Class: Delinquo::AuthenticatedConnection
- Inherits:
-
Object
- Object
- Delinquo::AuthenticatedConnection
- Includes:
- HTTParty
- Defined in:
- lib/delinquo/authenticated_connection.rb
Instance Method Summary collapse
- #add_run(project, runner, directory) ⇒ Object
-
#initialize(cert) ⇒ AuthenticatedConnection
constructor
A new instance of AuthenticatedConnection.
- #project(project) ⇒ Object
Constructor Details
#initialize(cert) ⇒ AuthenticatedConnection
Returns a new instance of AuthenticatedConnection.
18 19 20 |
# File 'lib/delinquo/authenticated_connection.rb', line 18 def initialize(cert) self.class.pem(File.read(cert)) end |
Instance Method Details
#add_run(project, runner, directory) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/delinquo/authenticated_connection.rb', line 26 def add_run(project, runner, directory) files = Dir["#{directory}/*.xml"] if files.empty? puts "No .xml files found in #{directory}" return end run_id = nil files.each do |file| current = File.read(file) url = "/project/#{project}/runner/#{runner}/run/#{run_id}" response = self.class.post(url, body: current, :headers => { "Content-Type" => "application/xml"}) run_id = response.body if response.code != 201 puts "Error: failed to post file #{file}".colorize(:red) else puts "Success: posted file #{file}".colorize(:green) end end end |
#project(project) ⇒ Object
22 23 24 |
# File 'lib/delinquo/authenticated_connection.rb', line 22 def project(project) self.class.get("/project/#{project}") end |