Class: Workbench::Cli

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

Overview

CLI application for Workbench

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



10
11
12
# File 'lib/work_bench/cli.rb', line 10

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

Instance Method Details

#export(path = 'export') ⇒ Object



84
85
86
87
# File 'lib/work_bench/cli.rb', line 84

def export path = 'export'
		export = Workbench::Exporter.new File.expand_path('.'), File.join(File.expand_path('.'), path), options[:fix_urls]
	export.process
end

#init(path = '.') ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/work_bench/cli.rb', line 49

def init path = '.'
	puts 'Create empty project'.color(:green)

	self.destination_root = File.expand_path path

	empty_directory 'haml'
	empty_directory 'sass'
	empty_directory 'public/css'
	empty_directory 'public/js'
	empty_directory 'public/img'

	if options[:normalize]
		copy_file '_normalize.scss', 'sass/_normalize.scss'
	end

	if options[:js] && !options[:js].empty?
      js_libs = Workbench::JSLibs::LIST
      options[:js].each do |js|
        if js_libs[js]
          get js_libs[js], "public/js/#{File.basename(js_libs[js])}"
        end
      end
    end

	copy_file 'scripts.js', 'public/js/scripts.js'
	template 'style.sass', 'sass/style.sass'
	template 'index.haml', 'haml/index.haml'
	copy_file 'Gemfile', 'Gemfile'
end

#jsObject



95
96
97
98
# File 'lib/work_bench/cli.rb', line 95

def js
  puts 'Available JS frameworks'.color(:green)
  Workbench::JSLibs::LIST.each { |index, item| puts " * #{index.color(:blue)} => #{item}" }
end

#start(path = '.') ⇒ Object



28
29
30
31
32
33
# File 'lib/work_bench/cli.rb', line 28

def start path = '.'
    path = File.expand_path path
	puts 'Starting HTTP server...'.color(:green)
    app = Workbench::Application.new path
    app.start options[:port], options[:workers]
end

#versionObject



106
107
108
# File 'lib/work_bench/cli.rb', line 106

def version
	puts "Version: #{Workbench::VERSION.color(:blue)}"
end