Class: Moka::Generators::MokaSiteGenerator
- Includes:
- SiteTree, Thor::Actions
- Defined in:
- lib/commands/site/site_generator.rb
Constant Summary
Constants included from SiteTree
Class Method Summary collapse
Instance Method Summary collapse
- #create_app_dir ⇒ Object
- #create_compiled_dir ⇒ Object
- #create_manifest_file ⇒ Object
- #create_project_dir ⇒ Object
- #create_script_dir ⇒ Object
- #set_permissions ⇒ Object
- #update_manifest_file ⇒ Object
- #update_variables ⇒ Object
Class Method Details
.source_root ⇒ Object
19 20 21 |
# File 'lib/commands/site/site_generator.rb', line 19 def self.source_root File.('template/', File.dirname(__FILE__)) end |
Instance Method Details
#create_app_dir ⇒ Object
23 24 25 |
# File 'lib/commands/site/site_generator.rb', line 23 def create_app_dir empty_directory(site_name) end |
#create_compiled_dir ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/commands/site/site_generator.rb', line 44 def create_compiled_dir unless [:template].nil? directory(File.join([:template], 'compiled'), "#{site_name}/compiled") else empty_directory("#{site_name}/compiled") empty_directory("#{site_name}/compiled/javascripts") empty_directory("#{site_name}/compiled/images") empty_directory("#{site_name}/compiled/stylesheets") end end |
#create_manifest_file ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/commands/site/site_generator.rb', line 55 def create_manifest_file unless [:template].nil? template(File.join([:template], 'manifest.yml'), File.join("#{site_name}", "manifest.yml")) else template('manifest.yml', File.join("#{site_name}", "manifest.yml")) end end |
#create_project_dir ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/commands/site/site_generator.rb', line 35 def create_project_dir unless [:template].nil? source_paths << "." directory(File.join([:template], 'project'), "#{site_name}/project") else directory('project', "#{site_name}/project") end end |
#create_script_dir ⇒ Object
27 28 29 |
# File 'lib/commands/site/site_generator.rb', line 27 def create_script_dir directory('script', "#{site_name}/script") end |
#set_permissions ⇒ Object
31 32 33 |
# File 'lib/commands/site/site_generator.rb', line 31 def chmod("#{site_name}/script/moka", 0755) end |
#update_manifest_file ⇒ Object
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/commands/site/site_generator.rb', line 80 def update_manifest_file unless [:template].nil? @manifest = YAML.load_file(File.join(site_name, "manifest.yml")) @manifest['site']['name'] = site_name f = File.open( File.join(site_name, "manifest.yml"), 'w' ) do |out| YAML.dump( @manifest, out ) end say_status "update", File.join(site_name, "manifest.yml"), :green end end |
#update_variables ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/commands/site/site_generator.rb', line 63 def update_variables unless [:vars].nil? [:vars].each do |var_name, var_value| if Moka::SiteTree::RESERVED_NAMES.include? var_name.to_s say_status "WARNING:", "variable '#{var_name}' is a reserved word, and will not be set as a variable", :yellow end end [:vars].delete_if {|var_name, var_value| Moka::SiteTree::RESERVED_NAMES.include? var_name.to_s } @variables = YAML.load_file(File.join(site_name, "project", "site", "variables.yml")) @variables.merge! [:vars] f = File.open( File.join(site_name, "project", "site", "variables.yml"), 'w' ) do |out| YAML.dump( @variables, out ) end say_status "update", File.join(site_name, "project", "site", "variables.yml"), :green end end |