/lib/middleman/vendor/gems/ruby/1.8/environment.rb

https://github.com/mecolin/middleman · Ruby · 177 lines · 162 code · 13 blank · 2 comment · 17 complexity · 9c9d6e13ba2ed17262a341f4f3acbf58 MD5 · raw file

  1. # DO NOT MODIFY THIS FILE
  2. module Bundler
  3. file = File.expand_path(__FILE__)
  4. dir = File.dirname(file)
  5. ENV["PATH"] = "#{dir}/../../../bin:#{ENV["PATH"]}"
  6. ENV["RUBYOPT"] = "-r#{file} #{ENV["RUBYOPT"]}"
  7. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/json_pure-1.2.0/bin")
  8. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/json_pure-1.2.0/lib")
  9. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/extlib-0.9.14/bin")
  10. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/extlib-0.9.14/lib")
  11. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/json-1.2.0/bin")
  12. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/json-1.2.0/ext/json/ext")
  13. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/json-1.2.0/ext")
  14. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/json-1.2.0/lib")
  15. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/yui-compressor-0.9.1/bin")
  16. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/yui-compressor-0.9.1/lib")
  17. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rack-1.1.0/bin")
  18. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rack-1.1.0/lib")
  19. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/shotgun-0.6/bin")
  20. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/shotgun-0.6/lib")
  21. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rack-test-0.5.3/bin")
  22. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rack-test-0.5.3/lib")
  23. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/haml-2.2.17/bin")
  24. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/haml-2.2.17/lib")
  25. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/sinatra-1.0.a/bin")
  26. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/sinatra-1.0.a/lib")
  27. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/sprockets-1.0.2/bin")
  28. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/sprockets-1.0.2/lib")
  29. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/diff-lcs-1.1.2/bin")
  30. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/diff-lcs-1.1.2/lib")
  31. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/highline-1.5.1/bin")
  32. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/highline-1.5.1/lib")
  33. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/templater-1.0.0/bin")
  34. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/templater-1.0.0/lib")
  35. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rake-0.8.7/bin")
  36. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rake-0.8.7/lib")
  37. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/httpclient-2.1.5.2/bin")
  38. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/httpclient-2.1.5.2/lib")
  39. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/sinatra-content-for-0.2/bin")
  40. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/sinatra-content-for-0.2/lib")
  41. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/compass-0.10.0.pre5/bin")
  42. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/compass-0.10.0.pre5/lib")
  43. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/compass-slickmap-0.2.3/bin")
  44. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/compass-slickmap-0.2.3/lib")
  45. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/smusher-0.4.2/bin")
  46. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/smusher-0.4.2/lib")
  47. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/compass-colors-0.3.1/bin")
  48. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/compass-colors-0.3.1/lib")
  49. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/fancy-buttons-0.3.9/bin")
  50. $LOAD_PATH.unshift File.expand_path("#{dir}/gems/fancy-buttons-0.3.9/lib")
  51. @gemfile = "#{dir}/../../../../../../Gemfile"
  52. require "rubygems" unless respond_to?(:gem) # 1.9 already has RubyGems loaded
  53. @bundled_specs = {}
  54. @bundled_specs["json_pure"] = eval(File.read("#{dir}/specifications/json_pure-1.2.0.gemspec"))
  55. @bundled_specs["json_pure"].loaded_from = "#{dir}/specifications/json_pure-1.2.0.gemspec"
  56. @bundled_specs["extlib"] = eval(File.read("#{dir}/specifications/extlib-0.9.14.gemspec"))
  57. @bundled_specs["extlib"].loaded_from = "#{dir}/specifications/extlib-0.9.14.gemspec"
  58. @bundled_specs["json"] = eval(File.read("#{dir}/specifications/json-1.2.0.gemspec"))
  59. @bundled_specs["json"].loaded_from = "#{dir}/specifications/json-1.2.0.gemspec"
  60. @bundled_specs["yui-compressor"] = eval(File.read("#{dir}/specifications/yui-compressor-0.9.1.gemspec"))
  61. @bundled_specs["yui-compressor"].loaded_from = "#{dir}/specifications/yui-compressor-0.9.1.gemspec"
  62. @bundled_specs["rack"] = eval(File.read("#{dir}/specifications/rack-1.1.0.gemspec"))
  63. @bundled_specs["rack"].loaded_from = "#{dir}/specifications/rack-1.1.0.gemspec"
  64. @bundled_specs["shotgun"] = eval(File.read("#{dir}/specifications/shotgun-0.6.gemspec"))
  65. @bundled_specs["shotgun"].loaded_from = "#{dir}/specifications/shotgun-0.6.gemspec"
  66. @bundled_specs["rack-test"] = eval(File.read("#{dir}/specifications/rack-test-0.5.3.gemspec"))
  67. @bundled_specs["rack-test"].loaded_from = "#{dir}/specifications/rack-test-0.5.3.gemspec"
  68. @bundled_specs["haml"] = eval(File.read("#{dir}/specifications/haml-2.2.17.gemspec"))
  69. @bundled_specs["haml"].loaded_from = "#{dir}/specifications/haml-2.2.17.gemspec"
  70. @bundled_specs["sinatra"] = eval(File.read("#{dir}/specifications/sinatra-1.0.a.gemspec"))
  71. @bundled_specs["sinatra"].loaded_from = "#{dir}/specifications/sinatra-1.0.a.gemspec"
  72. @bundled_specs["sprockets"] = eval(File.read("#{dir}/specifications/sprockets-1.0.2.gemspec"))
  73. @bundled_specs["sprockets"].loaded_from = "#{dir}/specifications/sprockets-1.0.2.gemspec"
  74. @bundled_specs["diff-lcs"] = eval(File.read("#{dir}/specifications/diff-lcs-1.1.2.gemspec"))
  75. @bundled_specs["diff-lcs"].loaded_from = "#{dir}/specifications/diff-lcs-1.1.2.gemspec"
  76. @bundled_specs["highline"] = eval(File.read("#{dir}/specifications/highline-1.5.1.gemspec"))
  77. @bundled_specs["highline"].loaded_from = "#{dir}/specifications/highline-1.5.1.gemspec"
  78. @bundled_specs["templater"] = eval(File.read("#{dir}/specifications/templater-1.0.0.gemspec"))
  79. @bundled_specs["templater"].loaded_from = "#{dir}/specifications/templater-1.0.0.gemspec"
  80. @bundled_specs["rake"] = eval(File.read("#{dir}/specifications/rake-0.8.7.gemspec"))
  81. @bundled_specs["rake"].loaded_from = "#{dir}/specifications/rake-0.8.7.gemspec"
  82. @bundled_specs["httpclient"] = eval(File.read("#{dir}/specifications/httpclient-2.1.5.2.gemspec"))
  83. @bundled_specs["httpclient"].loaded_from = "#{dir}/specifications/httpclient-2.1.5.2.gemspec"
  84. @bundled_specs["sinatra-content-for"] = eval(File.read("#{dir}/specifications/sinatra-content-for-0.2.gemspec"))
  85. @bundled_specs["sinatra-content-for"].loaded_from = "#{dir}/specifications/sinatra-content-for-0.2.gemspec"
  86. @bundled_specs["compass"] = eval(File.read("#{dir}/specifications/compass-0.10.0.pre5.gemspec"))
  87. @bundled_specs["compass"].loaded_from = "#{dir}/specifications/compass-0.10.0.pre5.gemspec"
  88. @bundled_specs["compass-slickmap"] = eval(File.read("#{dir}/specifications/compass-slickmap-0.2.3.gemspec"))
  89. @bundled_specs["compass-slickmap"].loaded_from = "#{dir}/specifications/compass-slickmap-0.2.3.gemspec"
  90. @bundled_specs["smusher"] = eval(File.read("#{dir}/specifications/smusher-0.4.2.gemspec"))
  91. @bundled_specs["smusher"].loaded_from = "#{dir}/specifications/smusher-0.4.2.gemspec"
  92. @bundled_specs["compass-colors"] = eval(File.read("#{dir}/specifications/compass-colors-0.3.1.gemspec"))
  93. @bundled_specs["compass-colors"].loaded_from = "#{dir}/specifications/compass-colors-0.3.1.gemspec"
  94. @bundled_specs["fancy-buttons"] = eval(File.read("#{dir}/specifications/fancy-buttons-0.3.9.gemspec"))
  95. @bundled_specs["fancy-buttons"].loaded_from = "#{dir}/specifications/fancy-buttons-0.3.9.gemspec"
  96. def self.add_specs_to_loaded_specs
  97. Gem.loaded_specs.merge! @bundled_specs
  98. end
  99. def self.add_specs_to_index
  100. @bundled_specs.each do |name, spec|
  101. Gem.source_index.add_spec spec
  102. end
  103. end
  104. add_specs_to_loaded_specs
  105. add_specs_to_index
  106. def self.require_env(env = nil)
  107. context = Class.new do
  108. def initialize(env) @env = env && env.to_s ; end
  109. def method_missing(*) ; yield if block_given? ; end
  110. def only(*env)
  111. old, @only = @only, _combine_only(env.flatten)
  112. yield
  113. @only = old
  114. end
  115. def except(*env)
  116. old, @except = @except, _combine_except(env.flatten)
  117. yield
  118. @except = old
  119. end
  120. def gem(name, *args)
  121. opt = args.last.is_a?(Hash) ? args.pop : {}
  122. only = _combine_only(opt[:only] || opt["only"])
  123. except = _combine_except(opt[:except] || opt["except"])
  124. files = opt[:require_as] || opt["require_as"] || name
  125. files = [files] unless files.respond_to?(:each)
  126. return unless !only || only.any? {|e| e == @env }
  127. return if except && except.any? {|e| e == @env }
  128. if files = opt[:require_as] || opt["require_as"]
  129. files = Array(files)
  130. files.each { |f| require f }
  131. else
  132. begin
  133. require name
  134. rescue LoadError
  135. # Do nothing
  136. end
  137. end
  138. yield if block_given?
  139. true
  140. end
  141. private
  142. def _combine_only(only)
  143. return @only unless only
  144. only = [only].flatten.compact.uniq.map { |o| o.to_s }
  145. only &= @only if @only
  146. only
  147. end
  148. def _combine_except(except)
  149. return @except unless except
  150. except = [except].flatten.compact.uniq.map { |o| o.to_s }
  151. except |= @except if @except
  152. except
  153. end
  154. end
  155. context.new(env && env.to_s).instance_eval(File.read(@gemfile), @gemfile, 1)
  156. end
  157. end
  158. module Gem
  159. @loaded_stacks = Hash.new { |h,k| h[k] = [] }
  160. def source_index.refresh!
  161. super
  162. Bundler.add_specs_to_index
  163. end
  164. end