Sha256: 8d1629a937b66dc9dabc9541e59e6b44cf9be4bfed14e292a6466326d7d3e999

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

require File.expand_path('../command', File.dirname(__FILE__))

module Nesta
  module Commands
    module Theme
      class Create
        include Command

        def initialize(*args)
          name = args.shift
          options = args.shift || {}
          name.nil? && (raise UsageError.new('name not specified'))
          @name = name
          @theme_path = Nesta::Path.themes(@name)
          fail("#{@theme_path} already exists") if File.exist?(@theme_path)
        end

        def make_directories
          FileUtils.mkdir_p(File.join(@theme_path, 'public', @name))
          FileUtils.mkdir_p(File.join(@theme_path, 'views'))
        end

        def execute
          make_directories
          copy_templates(
            'themes/README.md' => "#{@theme_path}/README.md",
            'themes/app.rb' => "#{@theme_path}/app.rb",
            'themes/views/layout.haml' => "#{@theme_path}/views/layout.haml",
            'themes/views/page.haml' => "#{@theme_path}/views/page.haml",
            'themes/views/master.sass' => "#{@theme_path}/views/master.sass"
          )
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nesta-0.12.0 lib/nesta/commands/theme/create.rb
nesta-0.11.1 lib/nesta/commands/theme/create.rb
nesta-0.11.0 lib/nesta/commands/theme/create.rb