Module: JumanjimanSpecHelper::Bundle
- Defined in:
- lib/jumanjiman_spec_helper/bundle.rb
Class Method Summary collapse
- .actual_bundle ⇒ Object
- .bundle_config ⇒ Object
- .desired_bundle ⇒ Object
- .print_bundle_error(e) ⇒ Object
-
.setup(envs = [:default], load_early = false) ⇒ Object
lock dependencies and setup load paths myronmars.to/n/dev-blog/2012/12/5-reasons-to-avoid-bundler-require anti-pattern.com/bundler-setup-vs-bundler-require.
Class Method Details
.actual_bundle ⇒ Object
47 48 49 50 51 52 |
# File 'lib/jumanjiman_spec_helper/bundle.rb', line 47 def self.actual_bundle path = YAML.load_file(bundle_config)['BUNDLE_PATH'] File.(path) # expand the tilde if necessary rescue '' end |
.bundle_config ⇒ Object
39 40 41 |
# File 'lib/jumanjiman_spec_helper/bundle.rb', line 39 def self.bundle_config File.join('.bundle', 'config') end |
.desired_bundle ⇒ Object
43 44 45 |
# File 'lib/jumanjiman_spec_helper/bundle.rb', line 43 def self.desired_bundle File.join(ENV['HOME'], '.bundle') end |
.print_bundle_error(e) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/jumanjiman_spec_helper/bundle.rb', line 54 def self.print_bundle_error(e) puts e. if File.exist?(bundle_config) puts 'Try running `bundle update`' else puts 'Try running `bundle install --path=%s`' % desired_bundle end end |
.setup(envs = [:default], load_early = false) ⇒ Object
lock dependencies and setup load paths myronmars.to/n/dev-blog/2012/12/5-reasons-to-avoid-bundler-require anti-pattern.com/bundler-setup-vs-bundler-require
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/jumanjiman_spec_helper/bundle.rb', line 18 def self.setup(envs = [:default], load_early = false) if load_early # load all gems at startup Bundler.require(envs) else # do not load until required Bundler.setup(envs) end rescue Bundler::GemfileNotFound, Bundler::GemNotFound, Bundler::VersionConflict => e # some of us are not ruby experts; we need a reminder print_bundle_error e exit rescue Exception => e puts e.class puts e. puts e.backtrace exit end |