Class: HotCocoa::Template

Inherits:
Object show all
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.

Returns:

  • (Array<String>)
[ 'lib', 'resources' ]
COPIED_FILES =

Project files which can be directly copied to a new project.

Returns:

  • (Array<String>)
[
 '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.

Returns:

  • (Array<String>)
[
 'Rakefile',
 '__APPLICATION_NAME__.appspec',
 'lib/application.rb',
]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir, name) ⇒ Template

Returns a new instance of Template.

Parameters:

  • dir (String)

    where to put the project

  • name (String)

    name for the project



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_directoryString

The path to the HotCocoa app template in the HotCocoa source files

Returns:

  • (String)


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.expand_path(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