Class: Tabby::Creator
- Inherits:
-
Object
- Object
- Tabby::Creator
- Defined in:
- lib/tabby/creator.rb
Constant Summary collapse
- TEMPLATE =
ROOT.join("templates/project.rb.erb")
Instance Attribute Summary collapse
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #create_project_directory ⇒ Object
- #create_project_file ⇒ Object
- #exist? ⇒ Boolean (also: #exists?)
-
#initialize(name) ⇒ Creator
constructor
A new instance of Creator.
- #klass ⇒ Object
- #project_path ⇒ Object
- #run! ⇒ Object
Constructor Details
Instance Attribute Details
#project ⇒ Object (readonly)
Returns the value of attribute project.
5 6 7 |
# File 'lib/tabby/creator.rb', line 5 def project @project end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
5 6 7 |
# File 'lib/tabby/creator.rb', line 5 def template @template end |
Instance Method Details
#create_project_directory ⇒ Object
28 29 30 |
# File 'lib/tabby/creator.rb', line 28 def create_project_directory FileUtils.mkdir_p(TABBYDIR) unless File.directory?(TABBYDIR) end |
#create_project_file ⇒ Object
32 33 34 |
# File 'lib/tabby/creator.rb', line 32 def create_project_file project_path.open("w") { |f| f << template.result(binding) } end |
#exist? ⇒ Boolean Also known as: exists?
23 24 25 |
# File 'lib/tabby/creator.rb', line 23 def exist? project_path.exist? end |
#klass ⇒ Object
40 41 42 |
# File 'lib/tabby/creator.rb', line 40 def klass project.gsub(/_|-/, " ").split.map { |w| w.capitalize }.join end |
#project_path ⇒ Object
36 37 38 |
# File 'lib/tabby/creator.rb', line 36 def project_path TABBYDIR.join("#{project}.rb"). end |