Class: Bundler::Geminabox::CLI::Gem

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/geminabox/cli/gem.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, gem_name, thor) ⇒ Gem

Returns a new instance of Gem.



5
6
7
8
9
# File 'lib/bundler/geminabox/cli/gem.rb', line 5

def initialize(options, gem_name, thor)
  @options = options
  @gem_name = gem_name
  @thor = thor
end

Instance Attribute Details

#gem_nameObject (readonly)

Returns the value of attribute gem_name.



4
5
6
# File 'lib/bundler/geminabox/cli/gem.rb', line 4

def gem_name
  @gem_name
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/bundler/geminabox/cli/gem.rb', line 4

def options
  @options
end

#thorObject (readonly)

Returns the value of attribute thor.



4
5
6
# File 'lib/bundler/geminabox/cli/gem.rb', line 4

def thor
  @thor
end

Instance Method Details

#runObject



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

def run
  name = gem_name.chomp("/") # remove trailing slash if present
  target = File.join(Dir.pwd, name)
  underscored_name = name.tr('-', '_')
  opts = {
    :geminabox        => ENV['GEMINABOX'] || 'https://your.rubygems.org',
    :gem_tasks        => ENV['CUSTOM_GEM_TASKS'] || 'bundler/geminabox/gem_tasks',
    :name             => name,
    :underscored_name => underscored_name,
    :test             => options[:test],
    :ext              => options[:ext]
  }
  opts[:force] = true
  thor.template(File.join("newgem/Gemfile.tt"), File.join(target, "Gemfile"), opts)
  thor.template(File.join("newgem/Rakefile.tt"), File.join(target, "Rakefile"), opts)
end