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:



13
14
15
16
# File 'lib/ggem/gem.rb', line 13

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.



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

def name
  @name
end

#root_pathObject (readonly)

Returns the value of attribute root_path.



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

def root_path
  @root_path
end

Instance Method Details

#module_nameObject



31
32
33
34
35
36
37
# File 'lib/ggem/gem.rb', line 31

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

#pathObject



23
24
25
# File 'lib/ggem/gem.rb', line 23

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

#ruby_nameObject



39
40
41
# File 'lib/ggem/gem.rb', line 39

def ruby_name
  @ruby_name ||= transform_name(&:downcase)
end

#save!Object



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

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