Class: CookieCutter::Recipe

Inherits:
Object
  • Object
show all
Defined in:
lib/cookie_cutter/recipe.rb

Overview

Reads config file information and builds a cookie from the selected template

Constant Summary collapse

DEFAULT_CONFIG_FILENAME =
'config.yml'
CONFIG_PATH =
'config_path'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_file_path = nil) ⇒ Recipe

Returns a new instance of Recipe.



11
12
13
14
15
16
# File 'lib/cookie_cutter/recipe.rb', line 11

def initialize(config_file_path = nil)
  throw ArgumentError if config_file_path.nil?

  @config_file_path = config_file_path
  @_config = Recipe.read_config_file(config_file_path)
end

Instance Attribute Details

#config_file_pathObject

Returns the value of attribute config_file_path.



7
8
9
# File 'lib/cookie_cutter/recipe.rb', line 7

def config_file_path
  @config_file_path
end

Returns the value of attribute cookie.



7
8
9
# File 'lib/cookie_cutter/recipe.rb', line 7

def cookie
  @cookie
end

Instance Method Details



27
28
29
30
# File 'lib/cookie_cutter/recipe.rb', line 27

def build_cookie(cookie_name, which_template)
  @_template = self.config[which_template]
  @cookie = Cookie.new(cookie_name, self.template)
end

#configObject



18
19
20
# File 'lib/cookie_cutter/recipe.rb', line 18

def config
  @_config
end

#templateObject



22
23
24
25
# File 'lib/cookie_cutter/recipe.rb', line 22

def template
  @_template[Recipe::CONFIG_PATH] = @config_file_path
  @_template
end