Class: LimitedRed::Client
- Inherits:
-
Object
- Object
- LimitedRed::Client
- Defined in:
- lib/limited_red/client.rb
Instance Method Summary collapse
- #find_failing_features ⇒ Object
-
#initialize(config, out = STDOUT, adapter = nil, thread_pool = ThreadPool) ⇒ Client
constructor
A new instance of Client.
- #log_build(build_id, data) ⇒ Object
- #log_fail_result(build_id, data) ⇒ Object
- #log_pass_result(build_id, data) ⇒ Object
- #log_result(build_id, data) ⇒ Object
Constructor Details
#initialize(config, out = STDOUT, adapter = nil, thread_pool = ThreadPool) ⇒ Client
Returns a new instance of Client.
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/limited_red/client.rb', line 3 def initialize(config, out = STDOUT, adapter = nil, thread_pool = ThreadPool) @config ||= config @out = out @username = @config['username'] @api_key = @config['api key'] @project_id = "#{@username}/#{@config['project name']}" @adapter = adapter || LimitedRed::Adapter::HttParty.new(@config) @thread_pool = thread_pool end |
Instance Method Details
#find_failing_features ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/limited_red/client.rb', line 50 def find_failing_features raise "No project name was found in params: #{@config.inspect}" if @project_id.nil? begin response = nil without_fakeweb do response = @adapter.get("/#{@project_id}/features/fails") end rescue puts "[Limited Red] Unable to reach www.limited-red.com. No tests will be recorded." return [] end if response.nil? || response.empty? || error?(response) return [] else response.body.split(" ") end end |
#log_build(build_id, data) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/limited_red/client.rb', line 36 def log_build(build_id, data) data[:build_id] = build_id data = data.merge({:user => @username, :version => LimitedRed::Version::STRING, :build_id => build_id, :token => token_for(data)}) @thread_pool.with_a_thread_run do without_fakeweb do response = @adapter.post("/#{@project_id}/builds", :body => data) log(response) if response && error?(response) end end end |
#log_fail_result(build_id, data) ⇒ Object
14 15 16 |
# File 'lib/limited_red/client.rb', line 14 def log_fail_result(build_id, data) log_result(build_id, data.merge(:pass => 'false')) end |
#log_pass_result(build_id, data) ⇒ Object
18 19 20 |
# File 'lib/limited_red/client.rb', line 18 def log_pass_result(build_id, data) log_result(build_id, data.merge(:pass => 'true')) end |
#log_result(build_id, data) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/limited_red/client.rb', line 22 def log_result(build_id, data) data[:result] = @adapter.encode_and_compress(data[:result]) data = data.merge({:user => @username, :version => LimitedRed::Version::STRING, :token => token_for(data.merge(:build_id => build_id))}) @thread_pool.with_a_thread_run do without_fakeweb do response = @adapter.post("/#{@project_id}/builds/#{build_id}/results", :body => data) log(response) if error?(response) end end end |