Sha256: 808a201dc6957f96bad6a586876da51ede6e28d598184857a0ea4274cfcddf27

Contents?: true

Size: 1.14 KB

Versions: 6

Compression:

Stored size: 1.14 KB

Contents

module Nesta
  module Commands
    module Theme
      class Create
        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)
          if File.exist?(@theme_path)
            Nesta.fail_with("#{@theme_path} already exists")
          end
        end

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

        def execute(process)
          make_directories
          {
            '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"
          }.each do |src, dest|
            Nesta::Commands::Template.new(src).copy_to(dest, binding)
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
nesta-0.18.0 lib/nesta/commands/theme/create.rb
nesta-0.17.0 lib/nesta/commands/theme/create.rb
nesta-0.16.0 lib/nesta/commands/theme/create.rb
nesta-0.15.0 lib/nesta/commands/theme/create.rb
nesta-0.14.0 lib/nesta/commands/theme/create.rb
nesta-0.13.0 lib/nesta/commands/theme/create.rb