Class: Siba::Scaffold

Inherits:
Object
  • Object
show all
Includes:
FilePlug, LoggerPlug
Defined in:
lib/siba/scaffold.rb

Constant Summary collapse

CATEGORY_REPLACE_TEXT =
"c6y"
NAME_REPLACE_TEXT =
"demo"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from LoggerPlug

close, create, logger, #logger, opened?

Methods included from FilePlug

#siba_file, siba_file, siba_file=

Constructor Details

#initialize(category, name) ⇒ Scaffold

Returns a new instance of Scaffold.

Raises:



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/siba/scaffold.rb', line 11

def initialize(category, name)
  @category = category
  unless Siba::Plugins.valid_category? category
    raise Siba::Error, "Invalid category '#{category}'. Available categories are: #{Siba::Plugins.categories_str}"
  end

  @name = Siba::StringHelper.str_to_alphnumeric name
  raise Siba::Error, "first character of gem name can not be number" if name =~ /^[0-9]/

  @name_camelized = StringHelper.camelize name
end

Instance Attribute Details

#categoryObject

Returns the value of attribute category.



7
8
9
# File 'lib/siba/scaffold.rb', line 7

def category
  @category
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/siba/scaffold.rb', line 7

def name
  @name
end

#name_camelizedObject

Returns the value of attribute name_camelized.



7
8
9
# File 'lib/siba/scaffold.rb', line 7

def name_camelized
  @name_camelized
end

Instance Method Details

#scaffold(dest_dir) ⇒ Object



23
24
25
26
27
# File 'lib/siba/scaffold.rb', line 23

def scaffold(dest_dir)
  run_scaffold dest_dir
ensure
  Siba.cleanup
end