class Troy::Cli
Public Class Methods
exit_on_failure?()
click to toggle source
# File lib/troy/cli.rb, line 7 def self.exit_on_failure? true end
new(args = [], options = {}, config = {})
click to toggle source
Calls superclass method
# File lib/troy/cli.rb, line 11 def initialize(args = [], options = {}, 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
Public Instance Methods
export()
click to toggle source
# File lib/troy/cli.rb, line 23 def export runner = lambda do if options[:assets] site.export_assets site.export_files end options[:file]&.each do |file| site.export_pages(file) end site.export if !options[:assets] && !options[:file] end if options[:benchmark] require "benchmark" elapsed = Benchmark.realtime(&runner) puts "=> Finished in #{elapsed.round(2)}s" else runner.call end end
new(path)
click to toggle source
# File lib/troy/cli.rb, line 47 def new(path) generator = Generator.new generator.destination_root = path generator.invoke_all end
server()
click to toggle source
# File lib/troy/cli.rb, line 62 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: options[:port], Host: options[:host] end
site()
click to toggle source
# File lib/troy/cli.rb, line 74 def site @site ||= Troy::Site.new(Dir.pwd, options) end
version()
click to toggle source
# File lib/troy/cli.rb, line 55 def version say "Troy #{Troy::VERSION}" end