Class: Gem::Commands::CreateCommand::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/rubygems/commands/create_command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, params = {}) ⇒ Builder

Returns a new instance of Builder.



12
13
14
15
16
17
18
19
20
# File 'lib/rubygems/commands/create_command.rb', line 12

def initialize(name, params = {})
  @name = name.to_s

  params.each do |(key, value)|
    self.class.send(:define_method, key) do
      value.respond_to?(:gsub) ? value.gsub(IDENTIFIER, @name) : value
    end
  end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#gem_classObject

The class name of the gem in CamelCase.



28
29
30
# File 'lib/rubygems/commands/create_command.rb', line 28

def gem_class
  name.split('-').map { |seg| seg.gsub(/(?:^|_| )(.)/) { $1.upcase } }.join('::')
end

#get_bindingObject



32
33
34
# File 'lib/rubygems/commands/create_command.rb', line 32

def get_binding
  binding
end

#pathObject

The path of the gem.



23
24
25
# File 'lib/rubygems/commands/create_command.rb', line 23

def path
  name.gsub('-', '/')
end