Class: GGem::Gem

Inherits:
Object
  • Object
show all
Defined in:
lib/ggem/gem.rb

Constant Summary collapse

NoNameError =
Class.new(ArgumentError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, name) ⇒ Gem

Returns a new instance of Gem.

Raises:



10
11
12
13
# File 'lib/ggem/gem.rb', line 10

def initialize(path, name)
  raise NoNameError if name.to_s.empty?
  @root_path, self.name = path, name
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/ggem/gem.rb', line 8

def name
  @name
end

#root_pathObject (readonly)

Returns the value of attribute root_path.



8
9
10
# File 'lib/ggem/gem.rb', line 8

def root_path
  @root_path
end

Instance Method Details

#module_nameObject



28
29
30
31
32
33
34
# File 'lib/ggem/gem.rb', line 28

def module_name
  transforms = {
    "_" => "",
    "-" => ""
  }
  @module_name ||= transform_name(transforms){ |part| part.capitalize }
end

#pathObject



20
21
22
# File 'lib/ggem/gem.rb', line 20

def path
  File.join(@root_path, @name)
end

#ruby_nameObject



36
37
38
# File 'lib/ggem/gem.rb', line 36

def ruby_name
  @ruby_name ||= transform_name{ |part| part.downcase }
end

#save!Object



15
16
17
18
# File 'lib/ggem/gem.rb', line 15

def save!
  GGem::Template.new(self).save
  self
end