Sha256: f22e57df23aa135f89327df16857e87d5f7e4eea1dbffd36be616b86e57e4680

Contents?: true

Size: 1.95 KB

Versions: 1

Compression:

Stored size: 1.95 KB

Contents

module Bookshelf
  # The Bookshelf::Generator class will create a new book structure.
  #
  #   ebook = Bookshelf::Generator.new
  #   ebook.destination_root = "/some/path/book-name"
  #   ebook.invoke_all
  #
  class Generator < Thor::Group
    include Thor::Actions

    desc "Generate a new e-Book structure"

    def self.source_root
      File.dirname(__FILE__) + "/../../templates"
    end

    def copy_top_level
      copy_file "Gemfile", "Gemfile"
      copy_file "README.md", "README.md"
    end

    def copy_assets
      copy_file "epub.scss"    , "assets/styles/epub.scss"
      copy_file "html.scss"    , "assets/styles/html.scss"
      copy_file "html.scss"    , "assets/styles/_fonts.scss"
      empty_directory "assets/fonts"
      empty_directory "assets/images"
    end

    def copy_config_file
      template "config.erb", "config/config.yml"
    end

    def copy_helper_file
      copy_file "helper.rb", "config/helper.rb"
    end

    def copy_templates
      copy_file "layout.erb"  , "templates/html/layout.erb"
      copy_file "cover.erb"   , "templates/epub/cover.erb"
      copy_file "epub.erb"    , "templates/epub/page.erb"
    end

    def create_empty_directories
      empty_directory "output"
      empty_directory "output/assets"
      empty_directory "output/assets/fonts"
      empty_directory "output/assets/images"
      empty_directory "output/assets/styles"
      empty_directory "text"
    end

    def create_git_files
      create_file ".gitignore" do
        "output/*.{html,epub,pdf}\noutput/tmp"
      end
      create_file "assets/.gitkeep"
      create_file "assets/fonts/.gitkeep"
      create_file "assets/images/.gitkeep"
      create_file "assets/styles/.gitkeep"
      create_file "output/.gitkeep"
      create_file "output/assets/.gitkeep"
      create_file "output/assets/fonts/.gitkeep"
      create_file "output/assets/images/.gitkeep"
      create_file "output/assets/styles/.gitkeep"
      create_file "text/.gitkeep"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bookshelf-1.2.0 lib/bookshelf/generator.rb