Class: WpFire::Generator
- Inherits:
-
Object
- Object
- WpFire::Generator
- Defined in:
- lib/wp_fire/generator.rb
Instance Method Summary collapse
- #copy_functions ⇒ Object
- #copy_javascript ⇒ Object
- #copy_stylesheets ⇒ Object
- #copy_templates ⇒ Object
- #create_structure ⇒ Object
-
#initialize(project_name, task, configuration) ⇒ Generator
constructor
A new instance of Generator.
- #layout_path ⇒ Object
- #theme_id ⇒ Object
- #write_config ⇒ Object
- #write_template(source, target) ⇒ Object
Constructor Details
#initialize(project_name, task, configuration) ⇒ Generator
Returns a new instance of Generator.
4 5 6 7 8 9 10 11 12 |
# File 'lib/wp_fire/generator.rb', line 4 def initialize(project_name, task, configuration) @project_name = project_name @task = task @configuration = configuration @source_path = File.join(project_name,"source") @config_file = File.join(project_name,"config.rb") @assets_path = File.join(project_name,"source","assets") end |
Instance Method Details
#copy_functions ⇒ Object
71 72 73 74 75 76 |
# File 'lib/wp_fire/generator.rb', line 71 def copy_functions source = File.(File.join(self.layout_path, 'functions', 'functions.php.erb')) target = File.(File.join(@source_path, 'functions', 'functions.php')) write_template(source, target) end |
#copy_javascript ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/wp_fire/generator.rb', line 40 def copy_javascript source = File.(File.join(self.layout_path, 'javascripts')) target = File.(File.join(@assets_path, 'javascripts')) render_directory(source, target) self end |
#copy_stylesheets ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/wp_fire/generator.rb', line 49 def copy_stylesheets source = File.(File.join(self.layout_path, 'stylesheets')) target = File.(File.join(@assets_path, 'stylesheets')) render_directory(source, target) self end |
#copy_templates ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/wp_fire/generator.rb', line 58 def copy_templates if @configuration[:template].nil? or !File.directory?(File.join(@configuration[:template_path],@configuration[:template],"children_files")) source = File.(File.join(self.layout_path, 'templates')) else source = File.(File.join(@configuration[:template_path],@configuration[:template],"children_files")) end target = File.(File.join(@source_path, 'templates')) render_directory(source, target) self end |
#create_structure ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/wp_fire/generator.rb', line 14 def create_structure source_paths = [ ['assets', 'fonts'], ['assets', 'images'], ['assets', 'javascripts'], ['assets', 'stylesheets'], ['functions'], ['templates'] ] source_paths.each do |path| @task.empty_directory File.join(@source_path, path) end self end |
#layout_path ⇒ Object
31 32 33 |
# File 'lib/wp_fire/generator.rb', line 31 def layout_path @layout_path ||= File.join(WpFire::ROOT, 'generators', 'wp_fire') end |
#theme_id ⇒ Object
88 89 90 |
# File 'lib/wp_fire/generator.rb', line 88 def theme_id @project_name end |
#write_config ⇒ Object
35 36 37 38 |
# File 'lib/wp_fire/generator.rb', line 35 def write_config write_template(['generators', 'wp_fire', 'config', 'config.tt'], @config_file) self end |
#write_template(source, target) ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/wp_fire/generator.rb', line 78 def write_template(source, target) source = File.join(source) template = File.(@task.find_in_source_paths((source))) target = File.(File.join(target)) @task.create_file target do parse_erb(template) end end |