Class: Jeweler::Commands::CheckDependencies

Inherits:
Object
  • Object
show all
Defined in:
lib/jeweler/commands/check_dependencies.rb

Defined Under Namespace

Classes: MissingDependenciesError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#gemspecObject

Returns the value of attribute gemspec.



8
9
10
# File 'lib/jeweler/commands/check_dependencies.rb', line 8

def gemspec
  @gemspec
end

#typeObject

Returns the value of attribute type.



8
9
10
# File 'lib/jeweler/commands/check_dependencies.rb', line 8

def type
  @type
end

Class Method Details

.build_for(jeweler) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/jeweler/commands/check_dependencies.rb', line 41

def self.build_for(jeweler)
  command = new

  command.gemspec = jeweler.gemspec

  command
end

Instance Method Details

#dependenciesObject



32
33
34
35
36
37
38
39
# File 'lib/jeweler/commands/check_dependencies.rb', line 32

def dependencies
  case type
  when :runtime, :development
    gemspec.send("#{type}_dependencies")
  else
    gemspec.dependencies
  end
end

#runObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/jeweler/commands/check_dependencies.rb', line 10

def run
  missing_dependencies = dependencies.select do |dependency|
    begin
      Gem.activate dependency.name, *dependency.requirement.as_list
      false
    rescue LoadError => e
      true
    end
  end

  if missing_dependencies.empty?
    puts "#{type || 'All'} dependencies seem to be installed."
  else
    puts "Missing some dependencies. Install them with the following commands:"
    missing_dependencies.each do |dependency|
      puts %Q{\tgem install #{dependency.name} --version "#{dependency.requirement.to_s}"}
    end

    abort "Run the specified gem commands before trying to run this again: #{$0} #{ARGV.join(' ')}"
  end
end