Sha256: bf4f7d1d6a4dd4131568156327bd74a8d72f4d20ae312d1a7b2d1acd71136ea3

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

module Dugway
  module Cli
    class Create < Thor::Group
      include Thor::Actions

      argument :name

      class_option 'skip-source',
        :type    => :boolean,
        :default => false,
        :desc    => "Don't create a starter theme"

      class_option 'skip-git',
        :type    => :boolean,
        :default => false,
        :desc    => "Don't create a .gitignore file"

      def self.source_root
        File.join(File.dirname(__FILE__), 'templates')
      end

      def core
        template('config.tt', "#{ theme_dir }/config.ru")
        template('source/settings.json', "#{ source_dir }/settings.json")
      end

      def source
        unless options['skip-source']
          Dir.glob("#{ self.class.source_root }/source/**/*.{html,jpg,png,js,coffee,css,sass}") do |file|
            file_name = file.gsub("#{ self.class.source_root }/source/", '')
            copy_file "source/#{ file_name }", "#{ source_dir }/#{ file_name }"
          end
        end
      end

      def git
        unless options['skip-git']
          copy_file('gitignore.tt', "#{ theme_dir }/.gitignore")
        end
      end

      def done
        say("#{ name } is ready!", :blue)
      end

      private

      def theme_dir
        name.parameterize
      end

      def source_dir
        "#{ theme_dir }/source"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dugway-0.5.6 lib/dugway/cli/create.rb