Class: Dploy::Client
- Inherits:
-
Object
- Object
- Dploy::Client
- Defined in:
- lib/dploy/client.rb
Instance Method Summary collapse
- #deploy ⇒ Object
- #get_deploy_logs(deploy_id) ⇒ Object
-
#initialize(server, project, environment, version) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(server, project, environment, version) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 |
# File 'lib/dploy/client.rb', line 8 def initialize(server, project, environment, version) @server = server @project = project @environment = environment @version = version end |
Instance Method Details
#deploy ⇒ Object
15 16 17 18 |
# File 'lib/dploy/client.rb', line 15 def deploy deploy_data = JSON.parse((RestClient.post "http://#{@server}/deploy", { :project => @project, :environment => @environment, :version => @version }.to_json, :content_type => :json, :accept => :json)) get_deploy_logs(deploy_data['id']) end |
#get_deploy_logs(deploy_id) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/dploy/client.rb', line 20 def get_deploy_logs(deploy_id) finished = false start_id = "000000000000000000000000" while not finished logs = JSON.parse(RestClient.get( "http://#{@server}/logs/#{deploy_id}/?start_id=#{start_id}", :accept => :json), :symbolize_keys => true) logs.each do |row| puts "!!!!!!!!!!!!!!!!!!!SOME LOGS!!!!!!!!!!!!!!!!!!1" puts "#{row[:log_type]} #{row[:message]}" STDOUT.flush finished = true if row[:log_type] == "completion" end sleep 1 end end |