Class: Tmpgem::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/tmpgem/cli.rb

Defined Under Namespace

Classes: CommandExecutionError

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CLI

Returns a new instance of CLI.



5
6
7
8
# File 'lib/tmpgem/cli.rb', line 5

def initialize(argv)
  @argv = argv
  @debug = false
end

Instance Method Details

#runObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/tmpgem/cli.rb', line 10

def run
  parse_args

  gemspecs = Dir.glob('*.gemspec')
  unless gemspecs.size == 1
    $stderr.puts "gemspec must be one, but got #{gemspecs.join(', ')}."
    return 1
  end
  gemspec = gemspecs.first
  fname = build(gemspec)

  backup_original(fname) do
    install(fname)
    puts "#{fname} is installed temporary. Please CTRL-C when you do not need this gem."
    sleep
  end
  return 0
end