Module: JumanjimanSpecHelper::Bundle

Defined in:
lib/jumanjiman_spec_helper/bundle.rb

Class Method Summary collapse

Class Method Details

.actual_bundleObject



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.expand_path(path) # expand the tilde if necessary
rescue
  ''
end

.bundle_configObject



39
40
41
# File 'lib/jumanjiman_spec_helper/bundle.rb', line 39

def self.bundle_config
  File.join('.bundle', 'config')
end

.desired_bundleObject



43
44
45
# File 'lib/jumanjiman_spec_helper/bundle.rb', line 43

def self.desired_bundle
  File.join(ENV['HOME'], '.bundle')
end


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.message
  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



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.message
  puts e.backtrace
  exit
end