Sha256: 9728727635468333b9c190dc7c7d61cfa51e32a1d2d4aef9fb4787fa89aa566f

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

require 'rubygems'
require 'thor/group'

module Bookshop
  module Generators

    class AppGenerator < Thor::Group
      include Thor::Actions

      # Define arguments and options
      argument :app_path,                   :type => :string
                                        

      class_option :dtd,                :type => :string, :aliases => "-dtd",
                                        :desc => "DTD version [ 4.5, 5.0 ]", :default => "5.0"

      class_option :xsl,                :type => :string, :aliases => "-xsl",
                                        :desc => "DocBook-XSL version [ 1.75.2, 1.76.1 ]", :default => "1.76.1"
      
      # Define source root of application
      def self.source_root
        File.dirname(__FILE__)
      end

      # Create the project from templates
      def create_base_project
        directory "templates", "#{app_path}"
      end

      # Adds the dtd specified by user
      def add_dtd
        dtd = "#{options[:dtd]}"
        directory "tools/dtd/#{options[:dtd]}", "#{app_path}/tools/dtd"
      end

      # Adds the XSL/version specified by user
      def add_xsl
        directory "tools/xsl/#{options[:xsl]}", "#{app_path}/tools/xsl"
      end

      # Change the permissions so dbtoepub is executable 
      def chmod_dbtoepub
        chmod "#{app_path}/tools/xsl/epub/bin/dbtoepub", 0755
      end
      
      # Adds the Java jars and dependencies
      def add_java
        directory "tools/java/", "#{app_path}/tools/java"
      end
      
    protected

      def self.banner
        "bookshop new #{self.arguments.map(&:usage).join(' ')} [options]"
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bookshop-0.0.3 lib/bookshop/generators/bookshop/app/app_generator.rb