Class: Pushapp::Commands
- Inherits:
-
Object
- Object
- Pushapp::Commands
- Defined in:
- lib/pushapp/commands.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Class Method Summary collapse
Instance Method Summary collapse
- #init ⇒ Object
-
#initialize(options = {}) ⇒ Commands
constructor
A new instance of Commands.
- #list_remotes ⇒ Object
- #setup ⇒ Object
- #ssh ⇒ Object
- #tasks ⇒ Object
- #trigger ⇒ Object
- #update ⇒ Object
- #update_refs ⇒ Object
Constructor Details
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
5 6 7 |
# File 'lib/pushapp/commands.rb', line 5 def logger @logger end |
Class Method Details
.run(command, options = {}) ⇒ Object
7 8 9 |
# File 'lib/pushapp/commands.rb', line 7 def self.run(command, = {}) self.new(.merge({ command: command })).send(command) end |
Instance Method Details
#init ⇒ Object
16 17 18 19 20 21 |
# File 'lib/pushapp/commands.rb', line 16 def init logger.info "Creating an example config file in #{Pushapp::DEFAULT_CONFIG_LOCATION}" logger.info 'Customize it to your needs' create_config_directory write_config_file end |
#list_remotes ⇒ Object
28 29 30 31 32 33 |
# File 'lib/pushapp/commands.rb', line 28 def list_remotes logger.info 'Known remotes:' remotes_table = config.remotes.map {|r| [r.full_name, r.location, r.env]} remotes_table.unshift ['Full Name', 'Location', 'ENV'] logger.shell.print_table(remotes_table) end |
#setup ⇒ Object
35 36 37 38 39 |
# File 'lib/pushapp/commands.rb', line 35 def setup logger.info 'Setting up remotes' remotes.each { |r| r.setup! } update end |
#ssh ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/pushapp/commands.rb', line 75 def ssh if remote remote.ssh! else logger.error 'Remote not found' end end |
#tasks ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/pushapp/commands.rb', line 46 def tasks remotes_list = remotes.empty? ? config.remotes : remotes remotes_list.each do |r| puts "REMOTE: #{r.full_name}" r.tasks.keys.each do |event| puts " EVENT: #{event}" r.tasks[event].each do |task| puts " #{task.inspect}" end end end end |
#trigger ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/pushapp/commands.rb', line 59 def trigger event = @options[:event] local = @options[:local] if local logger.info "STARTING TASKS ON EVENT #{event}" remotes.each do |r| r.tasks_on(event).each do |t| logger.info "task: #{t.inspect}" Pushapp::Pipe.run(t) end end else remotes.each {|r| r.env_run "bundle exec pushapp trigger #{event} #{r.full_name} -l true"} end end |
#update ⇒ Object
41 42 43 44 |
# File 'lib/pushapp/commands.rb', line 41 def update logger.info 'Updating remotes' remotes.each { |r| r.update! } end |
#update_refs ⇒ Object
23 24 25 26 |
# File 'lib/pushapp/commands.rb', line 23 def update_refs logger.info 'Updating .git/config. Setting up refs to all remotes' Pushapp::Git.new.update_tracked_repos(config) end |