Class: CourseGen::Templates
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- CourseGen::Templates
- Includes:
- Thor::Actions
- Defined in:
- lib/coursegen/templates.rb
Class Method Summary collapse
Instance Method Summary collapse
- #copy_template_dir(from, to) ⇒ Object
- #copy_template_file(from, to) ⇒ Object
- #create_empty_dir(to) ⇒ Object
- #delete_target_file(to) ⇒ Object
- #generate_all ⇒ Object
-
#initialize ⇒ Templates
constructor
invoke methods from Thor::Actions.
- #valid_cg_directory? ⇒ Boolean
Constructor Details
#initialize ⇒ Templates
invoke methods from Thor::Actions
42 43 44 45 |
# File 'lib/coursegen/templates.rb', line 42 def initialize super destination_root = Dir.getwd end |
Class Method Details
.source_root ⇒ Object
37 38 39 |
# File 'lib/coursegen/templates.rb', line 37 def self.source_root Pathname.new(File.dirname(__FILE__)).parent.parent.to_s end |
Instance Method Details
#copy_template_dir(from, to) ⇒ Object
51 52 53 |
# File 'lib/coursegen/templates.rb', line 51 def copy_template_dir from, to directory("templates/#{from}", "#{to}") end |
#copy_template_file(from, to) ⇒ Object
55 56 57 |
# File 'lib/coursegen/templates.rb', line 55 def copy_template_file from, to template("templates/#{from}", "#{to}") end |
#create_empty_dir(to) ⇒ Object
47 48 49 |
# File 'lib/coursegen/templates.rb', line 47 def create_empty_dir to empty_directory(to) end |
#delete_target_file(to) ⇒ Object
59 60 61 |
# File 'lib/coursegen/templates.rb', line 59 def delete_target_file(to) remove_file(to) end |
#generate_all ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/coursegen/templates.rb', line 7 def generate_all copy_template_dir("layouts", "layouts") copy_template_dir("content/bootstrap", "content/bootstrap") copy_template_dir("content/content", "content/content") delete_target_file("lib/default.rb") copy_template_dir("lib", "lib") delete_target_file("Rules") copy_template_file("Rules", "Rules") copy_template_file("Guardfile", "Guardfile") copy_template_file(".gitignore", ".gitignore") copy_template_file("cg_config.rb", "cg_config.rb") copy_template_file("cg_config.rb_sample", "cg_config.rb_sample") delete_target_file("content/stylesheet.css") delete_target_file("content/index.html") delete_target_file("layouts/default.html") create_empty_dir("content/images") end |
#valid_cg_directory? ⇒ Boolean
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/coursegen/templates.rb', line 25 def valid_cg_directory? valid = true list = ["Rules", "nanoc.yaml", "content", "lib"] list.each do |filename| if !File.exists?(filename) valid = false say("Required file not found: #{filename}") end end valid end |