Class: Tweezer::CLI

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

Instance Method Summary collapse

Constructor Details

#initializeCLI

Returns a new instance of CLI.



6
7
8
9
10
11
12
13
14
15
# File 'lib/tweezer/cli.rb', line 6

def initialize(*)
  super

  custom_gemfile = options[:gemfile] || Bundler.settings[:gemfile]
  if custom_gemfile && !custom_gemfile.empty?
    ENV['BUNDLE_GEMFILE'] = File.expand_path(custom_gemfile)
  end

  @gemfile = Tweezer::Gemfile.load
end

Instance Method Details

#add(name, version = nil) ⇒ Object



21
22
23
24
25
# File 'lib/tweezer/cli.rb', line 21

def add(name, version = nil)
  groups = options[:groups].map(&:to_sym) if options[:groups]
  @gemfile.add_gem(name, version, groups: groups || [])
  @gemfile.save!
end