Class: Troy::Cli
- Inherits:
-
Thor
- Object
- Thor
- Troy::Cli
- Defined in:
- lib/troy/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #export ⇒ Object
-
#initialize(args = [], options = {}, config = {}) ⇒ Cli
constructor
A new instance of Cli.
- #new(path) ⇒ Object
- #server ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(args = [], options = {}, config = {}) ⇒ Cli
Returns a new instance of Cli.
9 10 11 12 13 14 15 |
# File 'lib/troy/cli.rb', line 9 def initialize(args = [], = {}, config = {}) if (config[:current_task] || config[:current_command]).name == "new" && args.empty? raise Error, "The site path is required. For details run: troy help new" end super end |
Class Method Details
.exit_on_failure? ⇒ Boolean
5 6 7 |
# File 'lib/troy/cli.rb', line 5 def self.exit_on_failure? true end |
Instance Method Details
#export ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/troy/cli.rb', line 19 def export if [:assets] site.export_assets site.export_files end if [:file] [:file].each do |file| site.export_pages(file) end end if ![:assets] && ![:file] site.export end end |
#new(path) ⇒ Object
37 38 39 40 41 |
# File 'lib/troy/cli.rb', line 37 def new(path) generator = Generator.new generator.destination_root = path generator.invoke_all end |
#server ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/troy/cli.rb', line 52 def server begin handler = Rack::Handler::Thin Thin::Logging.level = Logger::DEBUG rescue Exception handler = Rack::Handler::WEBrick end handler.run Troy::Server.new(File.join(Dir.pwd, "public")), :Port => [:port], :Host => [:host] end |