Class: BundlerExt::Runtime
- Inherits:
-
Object
- Object
- BundlerExt::Runtime
- Defined in:
- lib/bundler_ext/runtime.rb
Class Method Summary collapse
-
.namespaced_file(file) ⇒ Object
Helper to generate, taken from bundler_ext.
Instance Method Summary collapse
- #add_spec(spec) ⇒ Object
- #bundler ⇒ Object
- #clear ⇒ Object
- #gemfile(new_val = nil) ⇒ Object
- #root ⇒ Object
- #rubygems ⇒ Object
- #setup_env ⇒ Object
- #system_require(files) ⇒ Object
Class Method Details
.namespaced_file(file) ⇒ Object
Helper to generate, taken from bundler_ext
31 32 33 34 |
# File 'lib/bundler_ext/runtime.rb', line 31 def self.namespaced_file(file) return nil unless file.to_s.include?('-') file.respond_to?(:name) ? file.name.gsub('-', '/') : file.to_s.gsub('-', '/') end |
Instance Method Details
#add_spec(spec) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/bundler_ext/runtime.rb', line 62 def add_spec(spec) # copied from Bundler::Runtime#setup rubygems.mark_loaded spec load_paths = spec.load_paths.reject {|path| $LOAD_PATH.include?(path)} $LOAD_PATH.unshift(*load_paths) end |
#bundler ⇒ Object
15 16 17 |
# File 'lib/bundler_ext/runtime.rb', line 15 def bundler @bundler_runtime ||= Bundler::Runtime.new(root, gemfile) end |
#clear ⇒ Object
58 59 60 |
# File 'lib/bundler_ext/runtime.rb', line 58 def clear bundler.send :clean_load_path end |
#gemfile(new_val = nil) ⇒ Object
5 6 7 8 9 |
# File 'lib/bundler_ext/runtime.rb', line 5 def gemfile(new_val = nil) @bext_gemfile ||= Bundler.default_gemfile @bext_gemfile = new_val unless new_val.nil? @bext_gemfile end |
#root ⇒ Object
11 12 13 |
# File 'lib/bundler_ext/runtime.rb', line 11 def root gemfile.dirname. end |
#rubygems ⇒ Object
19 20 21 |
# File 'lib/bundler_ext/runtime.rb', line 19 def rubygems @bundler_rubygems ||= Bundler::RubygemsIntegration.new end |
#setup_env ⇒ Object
24 25 26 27 28 |
# File 'lib/bundler_ext/runtime.rb', line 24 def setup_env # some rubygems do not play well with daemonized processes ($HOME is empty) ENV['HOME'] = ENV['BEXT_HOME'] if ENV['BEXT_HOME'] ENV['HOME'] = ENV['BUNDLER_EXT_HOME'] if ENV['BUNDLER_EXT_HOME'] end |
#system_require(files) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/bundler_ext/runtime.rb', line 36 def system_require(files) files.each do |dep| # this part also take from lib/bundler/runtime.rb (github/master) begin Output.verbose_msg "Attempting to require #{dep}" require dep rescue LoadError => err_regular begin namespaced_file = self.class.namespaced_file(dep) if namespaced_file.nil? Output.strict_err "Gem loading error: #{err_regular.}" else Output.verbose_msg "Attempting to require #{namespaced_file}" require namespaced_file end rescue LoadError => err_namespaced Output.strict_err "Gem loading error: #{err_namespaced.}" end end end end |