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 +4 -4
- data/CHANGELOG.md +1 -0
- data/lib/cb/models/api_call_model.rb +1 -1
- data/lib/cb/utils/api.rb +15 -6
- data/lib/cb/version.rb +1 -1
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: cc361451cedcf53facb26907387a0ac7ec5f8414
         | 
| 4 | 
            +
              data.tar.gz: 02ee8f06d35f76f97f31d6ac1610f8fdd1a123c1
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: f38f46f69986d146be3782e52406aac88d4871b07d6d1ce5b5e15d92c30686a2ab974acbec2e17118709ddf18763186fd90b0b430d4bcb7615e702971fce916d
         | 
| 7 | 
            +
              data.tar.gz: 2c72fa5e9facb62007da9124dc57ff3069a9b1ea5ac6d55bd52072a6d7ffc84a6d2e15d1d15ce533394c469a2ee919d94bb5d808b5569f2f9110eb10d7007f48
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -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
         | 
    
        data/lib/cb/utils/api.rb
    CHANGED
    
    | @@ -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)
         | 
    
        data/lib/cb/version.rb
    CHANGED