Class: Niso::Dependency

Inherits:
Object
  • Object
show all
Defined in:
lib/niso/dependency.rb

Class Method Summary collapse

Class Method Details

.allObject



3
4
5
6
7
8
# File 'lib/niso/dependency.rb', line 3

def self.all
  {
    'highline' => { :require => 'highline', :version => '>= 1.7.8'},
    'droplet_kit' =>  { :require => 'droplet_kit',  :version => '>= 2.1.0' },
  }
end

.load(name) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/niso/dependency.rb', line 10

def self.load(name)
  begin
    gem(name, all[name][:version])
    require(all[name][:require])
  rescue LoadError
    if $!.to_s =~ /Gemfile/
      Logger.error <<-EOS
Dependency missing: #{name}
Add this line to your application's Gemfile.

gem '#{name}', '#{all[name][:version]}'

Please try again after running "bundle install".
      EOS
    else
      Logger.error <<-EOS
Dependency missing: #{name}
To install the gem, issue the following command:

gem install #{name} -v '#{all[name][:version]}'

Please try again after installing the missing dependency.
      EOS
    end
    abort
  end
end