Class: HotCocoa::Template
- Includes:
- FileUtils
- Defined in:
- lib/hotcocoa/template.rb
Overview
This class creates new projects given the directory to put them into and the name for the new project.
Constant Summary collapse
- DIRECTORIES =
Directories that need to be created for a new app project.
[ 'lib', 'resources' ]
- COPIED_FILES =
Project files which can be directly copied to a new project.
[ 'lib/menu.rb', 'resources/HotCocoa.icns' ]
- FILTERED_FILES =
Project files which contain tokens that need to be substituted before being copied to a new project.
[ 'Rakefile', '__APPLICATION_NAME__.appspec', 'lib/application.rb', ]
Class Method Summary collapse
-
.template_directory ⇒ String
The path to the HotCocoa app template in the HotCocoa source files.
Instance Method Summary collapse
-
#copy! ⇒ Object
Create the project!.
-
#initialize(dir, name) ⇒ Template
constructor
A new instance of Template.
Constructor Details
#initialize(dir, name) ⇒ Template
Returns a new instance of Template.
46 47 48 49 |
# File 'lib/hotcocoa/template.rb', line 46 def initialize dir, name @directory = dir @app_name = name end |
Class Method Details
.template_directory ⇒ String
The path to the HotCocoa app template in the HotCocoa source files
39 40 41 42 |
# File 'lib/hotcocoa/template.rb', line 39 def self.template_directory file = $LOADED_FEATURES.find { |file| file.match /hotcocoa\/template\.rbo?$/ } File.(File.join(File.dirname(file), '../../template')) end |
Instance Method Details
#copy! ⇒ Object
Create the project!
53 54 55 56 57 58 |
# File 'lib/hotcocoa/template.rb', line 53 def copy! @template = self.class.template_directory make_directories copy_resources copy_sources end |