Class: Flatrack::CLI

Inherits:
Thor
  • Object
show all
Includes:
FileUtils, Thor::Actions
Defined in:
lib/flatrack/cli.rb

Overview

The command line interface for flatrack

Constant Summary collapse

SRC_ROOT =
File.join Flatrack.gem_root, 'flatrack/cli/templates'
KEEP_DIRS =
[
  'assets/stylesheets',
  'assets/javascripts',
  'assets/images',
  'pages',
  'layouts',
  'partials'
]
FILES =
{
  '.gitignore'           => '.gitignore',
  'boot.rb'              => 'boot.rb',
  'Rakefile'             => 'Rakefile',
  'Gemfile.erb'          => 'Gemfile',
  'config.ru'            => 'config.ru',
  'layout.html.erb'      => 'layouts/layout.html.erb',
  'page.html.erb'        => 'pages/index.html.erb',
  'stylesheet.css.scss'  => 'assets/stylesheets/main.css.scss',
  'javascript.js.coffee' => 'assets/javascripts/main.js.coffee'
}
BIN_COPY_FILES =
{
  'logo.png' => 'assets/images/logo.png'
}

Instance Method Summary collapse

Instance Method Details

#__default__Object

Info about flatrack



77
78
79
80
81
82
# File 'lib/flatrack/cli.rb', line 77

def __default__
  if options[:version]
    puts 'Flatrack ' + Flatrack::VERSION
    return
  end
end

#new(path) ⇒ Object

Create a new app

Parameters:

  • path (String)


49
50
51
52
53
54
55
56
57
# File 'lib/flatrack/cli.rb', line 49

def new(path)
  mkdir_p path
  full_path             = File.expand_path path
  @name                 = File.basename(full_path).titleize
  self.destination_root = full_path
  write_keeps
  write_files
  bundle!
end

#startObject

Start the app



64
65
66
67
68
69
70
71
72
# File 'lib/flatrack/cli.rb', line 64

def start
  require './boot'
  run_opts             = {}
  run_opts[:app]       = Flatrack::Site
  run_opts[:Port]      = options[:port]
  run_opts[:Logger]    = Logger.new('/dev/null') unless options[:verbose]
  run_opts[:AccessLog] = Logger.new('/dev/null') unless options[:verbose]
  Rack::Server.start run_opts
end