Class: Gem::Commands::ReadCommand

Inherits:
Gem::Command
  • Object
show all
Defined in:
lib/rubygems/commands/read_command.rb

Constant Summary collapse

VERSION =
"0.0.1"
FNAME =
"/.gemfile"

Instance Method Summary collapse

Constructor Details

#initializeReadCommand

Returns a new instance of ReadCommand.



9
10
11
12
# File 'lib/rubygems/commands/read_command.rb', line 9

def initialize
  super("read", "\"Reads\" all your gems from a ~/.gemfile",
        :version => Gem::Requirement.default)
end

Instance Method Details

#argumentsObject

:nodoc:



14
15
16
# File 'lib/rubygems/commands/read_command.rb', line 14

def arguments # :nodoc:
  'FILE reads from another file'
end

#defaults_strObject

:nodoc:



18
19
20
# File 'lib/rubygems/commands/read_command.rb', line 18

def defaults_str # :nodoc:
  "--version='>= 0'"
end

#executeObject



33
34
35
36
37
38
39
# File 'lib/rubygems/commands/read_command.rb', line 33

def execute
  file ||= ENV['HOME'] + FNAME
  unless file && File.exists?(file)
    puts "Gemfile not found.."; return
  end
  eval File.read(file)
end

#gem(name) ⇒ Object



26
27
28
29
30
31
# File 'lib/rubygems/commands/read_command.rb', line 26

def gem(name)
  unless Gem.available?(name)
    puts "Installing #{name}"
    `gem install #{name} --no-rdoc --no-ri`
  end
end

#usageObject

:nodoc:



22
23
24
# File 'lib/rubygems/commands/read_command.rb', line 22

def usage # :nodoc:
  "#{program_name} [FILE]"
end