Class: Kitabu::Generator
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Kitabu::Generator
- Includes:
- Thor::Actions
- Defined in:
- lib/kitabu/generator.rb
Overview
The Kitabu::Generator class will create a new book structure.
ebook = Kitabu::Generator.new
ebook.destination_root = "/some/path/book-name"
ebook.invoke_all
Class Method Summary collapse
Instance Method Summary collapse
- #bundle_install ⇒ Object
- #copy_config_file ⇒ Object
- #copy_gemfile ⇒ Object
- #copy_guardfile ⇒ Object
- #copy_helper_file ⇒ Object
- #copy_images ⇒ Object
- #copy_sample_texts ⇒ Object
- #copy_templates ⇒ Object
- #create_directories ⇒ Object
- #create_git_files ⇒ Object
Class Method Details
.source_root ⇒ Object
15 16 17 |
# File 'lib/kitabu/generator.rb', line 15 def self.source_root "#{File.dirname(__FILE__)}/../../templates" end |
Instance Method Details
#bundle_install ⇒ Object
63 64 65 66 67 |
# File 'lib/kitabu/generator.rb', line 63 def bundle_install inside destination_root do run "bundle install" end end |
#copy_config_file ⇒ Object
31 32 33 34 35 36 |
# File 'lib/kitabu/generator.rb', line 31 def copy_config_file @name = full_name @uid = Digest::MD5.hexdigest("#{Time.now}--#{rand}") @year = Date.today.year template "config.erb", "config/kitabu.yml" end |
#copy_gemfile ⇒ Object
42 43 44 |
# File 'lib/kitabu/generator.rb', line 42 def copy_gemfile copy_file "Gemfile" end |
#copy_guardfile ⇒ Object
59 60 61 |
# File 'lib/kitabu/generator.rb', line 59 def copy_guardfile copy_file "Guardfile" end |
#copy_helper_file ⇒ Object
38 39 40 |
# File 'lib/kitabu/generator.rb', line 38 def copy_helper_file copy_file "helper.rb", "config/helper.rb" end |
#copy_images ⇒ Object
27 28 29 |
# File 'lib/kitabu/generator.rb', line 27 def copy_images directory "images", "images" end |
#copy_sample_texts ⇒ Object
23 24 25 |
# File 'lib/kitabu/generator.rb', line 23 def copy_sample_texts directory "text", "text" end |
#copy_templates ⇒ Object
19 20 21 |
# File 'lib/kitabu/generator.rb', line 19 def copy_templates directory "templates", "templates" end |
#create_directories ⇒ Object
46 47 48 49 |
# File 'lib/kitabu/generator.rb', line 46 def create_directories empty_directory "output" empty_directory "fonts" end |
#create_git_files ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/kitabu/generator.rb', line 51 def create_git_files create_file ".gitignore" do "/output" end create_file "fonts/.keep" end |