Sha256: fe4056a22e331a5051dac22be31494073f018c2d2c1ea3f41ca7787e991cd086

Contents?: true

Size: 1.7 KB

Versions: 1

Compression:

Stored size: 1.7 KB

Contents

module Bookmaker
  class Generator < Thor::Group
    include Thor::Actions
    def self.source_root
      File.dirname(__FILE__) + "/../../templates"
    end
    def build_config_file
      @title = File.basename(destination_root).gsub('-', ' ')
      @name = full_name
      @uid = Digest::MD5.hexdigest("#{Time.now}--#{rand}")
      @year = Date.today.year
      template "config.erb", "_bookmaker.yml"
    end
    def copy_templates
      copy_file "latex.erb",  "templates/pdf/layout.erb"
      copy_file "dp-logo.png",  "images/dp-logo.png"

      copy_file "html.erb",   "templates/html/layout.erb"
      copy_file "user.css",   "templates/html/user.css"
      copy_file "layout.css", "templates/html/layout.css"
      copy_file "syntax.css", "templates/html/syntax.css"

      copy_file "back.erb",   "templates/epub/back.erb"
      copy_file "copyright.erb",   "templates/epub/copyright.erb"
      copy_file "cover.erb", "templates/epub/cover.erb"
      copy_file "epub.erb",   "templates/epub/page.erb"
      copy_file "epub.css",   "templates/epub/user.css"
      copy_file "cover.jpg",  "images/cover.jpg"
      copy_file "rakefile.rb",  "Rakefile"
      copy_file "extras.tex",  "extras/characters.tex"
      copy_file "extras.tex",  "extras/dedicationls.tex"
    end
    def copy_sample_text
      copy_file "sample.tex"   , "text/01_First-Chapter/01-Welcome.tex"
    end
    def create_directories
      empty_directory "output"
      empty_directory "images"
    end
    private
      # 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`.chomp
        name.empty? ? "John Doe" : name.squish
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bookmaker-0.6.0 lib/bookmaker/generator.rb