Class: GGem::CLI::GenerateCommand

Inherits:
Object
  • Object
show all
Includes:
GitRepoCommand
Defined in:
lib/ggem/cli/commands.rb

Instance Method Summary collapse

Instance Method Details

#helpObject



148
149
150
151
152
153
# File 'lib/ggem/cli/commands.rb', line 148

def help
  "Usage: ggem generate [options] GEM-NAME\n\n" \
  "Options: #{@clirb}\n" \
  "Description:\n" \
  "  #{self.summary}"
end

#run(argv, *args) ⇒ Object



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/ggem/cli/commands.rb', line 127

def run(argv, *args)
  super

  begin
    require 'ggem/gem'
    path = GGem::Gem.new(Dir.pwd, @clirb.args.first).save!.path
    @stdout.puts "created gem in #{path}"
  rescue GGem::Gem::NoNameError => exception
    error = ArgumentError.new("GEM-NAME must be provided")
    error.set_backtrace(exception.backtrace)
    raise error
  end

  @repo = GGem::GitRepo.new(path)
  notify("initialized gem git repo"){ @repo.run_init_cmd }
end

#summaryObject



144
145
146
# File 'lib/ggem/cli/commands.rb', line 144

def summary
  "Create a gem given a GEM-NAME"
end