cb-api 17.1.0 → 17.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c80664abd59b880495e3a2458b5af977655840f
4
- data.tar.gz: 69ea0a53a191e570883c184c26a0a8aa35d15e64
3
+ metadata.gz: cc361451cedcf53facb26907387a0ac7ec5f8414
4
+ data.tar.gz: 02ee8f06d35f76f97f31d6ac1610f8fdd1a123c1
5
5
  SHA512:
6
- metadata.gz: 3e7ba492dfb8e688dd7d5a58e719ef829848a0ced9f73ce29883163f7c654dbfee574c19b30623d10204242f938eed27e197571697c3919fb831f09b978e69d2
7
- data.tar.gz: afafa2a22e3a20e363dca177296c2f4e8178d88c27681daa544d4af68aa14c438e87e885e3b9b335f167e085d9eee7883aed01d5a9c747bf773edf46617aa9c4
6
+ metadata.gz: f38f46f69986d146be3782e52406aac88d4871b07d6d1ce5b5e15d92c30686a2ab974acbec2e17118709ddf18763186fd90b0b430d4bcb7615e702971fce916d
7
+ data.tar.gz: 2c72fa5e9facb62007da9124dc57ff3069a9b1ea5ac6d55bd52072a6d7ffc84a6d2e15d1d15ce533394c469a2ee919d94bb5d808b5569f2f9110eb10d7007f48
@@ -3,6 +3,7 @@ Version History
3
3
  * All Version bumps are required to update this file as well!!
4
4
  ----
5
5
 
6
+ * 17.2.0 Give back more information about the API caller for timings
6
7
  * 17.1.0 Start sending timings to all observers for API calls
7
8
  * 17.0.2 making sure we explicitly ask for version 1 of the consumer APIs
8
9
  * 17.0.1 adding posted_time and company_did to job results
@@ -1,6 +1,6 @@
1
1
  module Cb
2
2
  module Models
3
- class ApiCall < Struct.new(:api_call_type, :path, :options, :response, :elapsed_time)
3
+ class ApiCall < Struct.new(:api_call_type, :path, :options, :api_caller, :response, :elapsed_time)
4
4
  end
5
5
  end
6
6
  end
@@ -46,10 +46,11 @@ module Cb
46
46
 
47
47
  def execute_http_request(http_method, uri, path, options={}, &block)
48
48
  self.class.base_uri(uri || Cb.configuration.base_uri)
49
+ api_caller = find_api_caller(caller)
49
50
  start_time = Time.now.to_f
50
- cb_event(:"cb_#{ http_method }_before", path, options, nil, 0.0, &block)
51
+ cb_event(:"cb_#{ http_method }_before", path, options, api_caller, nil, 0.0, &block)
51
52
  response = self.class.method(http_method).call(path, options)
52
- cb_event(:"cb_#{ http_method }_after", path, options, response, Time.now.to_f - start_time, &block)
53
+ cb_event(:"cb_#{ http_method }_after", path, options, api_caller, response, Time.now.to_f - start_time, &block)
53
54
  validate_response(response)
54
55
  end
55
56
 
@@ -101,18 +102,26 @@ module Cb
101
102
 
102
103
  private
103
104
 
105
+ def find_api_caller(call_list)
106
+ filename_regex = /.*\.rb/
107
+ linenum_regex = /:.*:in `/
108
+ filename, method_name = call_list.find { |l| l[filename_regex] != __FILE__ }[0..-2].split(linenum_regex)
109
+ simplified_filename = filename.include?('/lib/') ? filename[/\/lib\/.*/] : filename
110
+ { file: simplified_filename, method: method_name }
111
+ end
112
+
104
113
  def validate_response(response)
105
114
  validated_response = ResponseValidator.validate(response)
106
115
  set_api_error(validated_response)
107
116
  validated_response
108
117
  end
109
118
 
110
- def api_call_model(api_call_type, path, options, response, time_elapsed)
111
- Cb::Models::ApiCall.new(api_call_type, path, options, response, time_elapsed)
119
+ def api_call_model(api_call_type, path, options, api_caller, response, time_elapsed)
120
+ Cb::Models::ApiCall.new(api_call_type, path, options, api_caller, response, time_elapsed)
112
121
  end
113
122
 
114
- def cb_event(api_call_type, path, options, response, time_elapsed, &block)
115
- call_model = api_call_model(api_call_type, path, options, response, time_elapsed)
123
+ def cb_event(api_call_type, path, options, api_caller, response, time_elapsed, &block)
124
+ call_model = api_call_model(api_call_type, path, options, api_caller, response, time_elapsed)
116
125
  block.call(call_model) if block_given?
117
126
  changed(true)
118
127
  notify_observers(call_model)
@@ -1,3 +1,3 @@
1
1
  module Cb
2
- VERSION = '17.1.0'
2
+ VERSION = '17.2.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cb-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 17.1.0
4
+ version: 17.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The CareerBuilder.com Niche and Consumer Development teams