Class: ProjectTemplater

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

Instance Method Summary collapse

Constructor Details

#initialize(template) ⇒ ProjectTemplater

Returns a new instance of ProjectTemplater.



12
13
14
15
16
# File 'lib/project_templater.rb', line 12

def initialize(template)
  @template = template
  # load in the right generator
  puts "That generator doesn't exist." unless generator_exists?
end

Instance Method Details

#run(base_dir) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/project_templater.rb', line 22

def run(base_dir)
  base_dir = Dir.pwd + "/" + (base_dir ||= "")
  class_name = @template.camel_case
  instance = Object::const_get(class_name).new(base_dir)
  instance.pre_install
  instance.run
  instance.post_install
end

#valid?Boolean

Returns:

  • (Boolean)


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

def valid?
  generator_exists?
end