forked from kfaustino/rails-templater
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcore_extensions.rb
50 lines (38 loc) · 1.23 KB
/
core_extensions.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
module Rails
module Generators
module Actions
attr_accessor :stategies
attr_reader :template_options
def initialize_templater
@stategies = []
@template_options = {}
end
def execute_stategies
stategies.each {|stategy| stategy.call }
end
def load_options
@template_options[:design] = ask("Which design framework? [none(default), compass]: ").downcase
@template_options[:design] = "none" if @template_options[:design].nil?
@template_options[:orm] = options["skip_active_record"] ? "mongoid" : "active_record"
end
def recipe(name)
File.join File.dirname(__FILE__), 'recipes', "#{name}.rb"
end
# TODO: Refactor loading of files
def load_snippet(name, group)
path = File.expand_path name, snippet_path(group)
File.read path
end
def load_template(name, group)
path = File.expand_path name, template_path(group)
File.read path
end
def snippet_path(name)
File.join(File.dirname(__FILE__), 'snippets', name)
end
def template_path(name)
File.join(File.dirname(__FILE__), 'templates', name)
end
end
end
end