Class: Skynet::CLI
- Inherits:
-
Thor
- Object
- Thor
- Skynet::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/skynet/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #build(project = nil, branch = nil) ⇒ Object
- #check ⇒ Object
- #config ⇒ Object
- #hook(project) ⇒ Object
- #install ⇒ Object
- #server ⇒ Object
- #version ⇒ Object
Class Method Details
.source_root ⇒ Object
10 11 12 |
# File 'lib/skynet/cli.rb', line 10 def self.source_root File.join File.dirname(__FILE__), 'templates' end |
Instance Method Details
#build(project = nil, branch = nil) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/skynet/cli.rb', line 51 def build(project=nil, branch=nil) all_apps = load_configuration [:file] if project.nil? all_apps.each do |app, config| begin Builder.build app, config rescue ArgumentError next end end else config = all_apps[project] if config.nil? Skynet.logger.error "Could not find configuration for #{project}" else Builder.build project, config, branch end end end |
#check ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/skynet/cli.rb', line 74 def check all_apps = load_configuration [:file] all_apps.each do |app, config| builder = Builder.for_app app, config if builder.valid? puts "#{app} configuration is valid" else puts "#{app} configuration errors: #{builder.errors..join '. '}" end end end |
#config ⇒ Object
95 96 97 98 |
# File 'lib/skynet/cli.rb', line 95 def config copy_file 'config.yml', [:file] unless File.exist? [:file] run_wizard [:file] end |
#hook(project) ⇒ Object
104 105 106 107 108 109 110 111 112 |
# File 'lib/skynet/cli.rb', line 104 def hook(project) if File.exist? [:output] Skynet.logger.fatal %{Output file "#{[:output]}" already exists} exit 1 end config = load_configuration([:file])[project] server = "#{[:server].chomp '/'}/#{project}" HookGenerator.new(config, server, [:output]).generate end |
#install ⇒ Object
88 89 90 91 |
# File 'lib/skynet/cli.rb', line 88 def install copy_file 'config.yml' run_wizard if [:wizard] end |
#server ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/skynet/cli.rb', line 24 def server Skynet.logger = Logger.new([:log], 'weekly') unless [:log].nil? unless File.exist? [:file] Skynet.logger.fatal "Configuration file #{[:file]} cannot be found" raise ArgumentError.new "Cannot find configuration file" end Skynet::App.configure do |app| app.set :config, load_configuration([:file]) end server = Thin::Server.new([:host], [:port]) do run Skynet::App end begin server.start! rescue => ex Skynet.logger.fatal ex. Skynet.logger.fatal ex.backtrace.join("\n") raise ex end end |