Sha256: 5cb72747c6c95852939e17f4e2d7af1dad0e610c52e12413d1bdd0e559b95895
Contents?: true
Size: 1.62 KB
Versions: 5
Compression:
Stored size: 1.62 KB
Contents
# frozen_string_literal: true module Kitabu # 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 Generator < Thor::Group include Thor::Actions desc "Generate a new e-Book structure" def self.source_root "#{File.dirname(__FILE__)}/../../templates" end def copy_templates directory "templates", "templates" end def copy_sample_texts directory "text", "text" end def copy_images directory "images", "images" end 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 def copy_helper_file copy_file "helper.rb", "config/helper.rb" end def copy_gemfile copy_file "Gemfile" end def create_directories empty_directory "output" empty_directory "fonts" end def create_git_files create_file ".gitignore" do "/output" end create_file "fonts/.keep" end def copy_guardfile copy_file "Guardfile" end def bundle_install inside destination_root do run "bundle install" end end no_commands do # Retrieve user's name using finger. # Defaults to <tt>John Doe</tt>. # def full_name name = `finger $USER 2> /dev/null | grep Login | colrm 1 46 2> /dev/null` .chomp name.present? ? name.squish : "John Doe" end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
kitabu-3.1.0 | lib/kitabu/generator.rb |
kitabu-3.0.3 | lib/kitabu/generator.rb |
kitabu-3.0.2 | lib/kitabu/generator.rb |
kitabu-3.0.1 | lib/kitabu/generator.rb |
kitabu-3.0.0 | lib/kitabu/generator.rb |