keener 0.1.1 → 0.1.2
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/lib/keener/resource.rb +9 -1
 - data/lib/keener/version.rb +1 -1
 - data/spec/resource_spec.rb +17 -0
 - metadata +4 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 4fe08aec6f913985039b87b590ba3f55b62d679f
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: faf84f2f169e98b143d097f671d1f4e96c112814
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 54adaa62bbe419d4ec849f09169868ae08c5db8ea4f26e56340619d11875173444722770d24dcbacf720fcb34fc79a53023a73e17718035cdf351adb72eb87cf
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: cad04a3336966a507b07188876d5caf87272019cbab38a5639aa256e14550068970dc0b5b66e93febe79b7421c02f0954cb4add7cf17caff5f1bd961755aa67b
         
     | 
    
        data/lib/keener/resource.rb
    CHANGED
    
    | 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'json'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            module Keener
         
     | 
| 
       2 
4 
     | 
    
         
             
              # This class represents an API resource and supports methods for making calls on it
         
     | 
| 
       3 
5 
     | 
    
         
             
              class Resource
         
     | 
| 
         @@ -5,7 +7,13 @@ module Keener 
     | 
|
| 
       5 
7 
     | 
    
         | 
| 
       6 
8 
     | 
    
         
             
                def initialize(url = '', options = {})
         
     | 
| 
       7 
9 
     | 
    
         
             
                  @url = url
         
     | 
| 
       8 
     | 
    
         
            -
                  @options = options
         
     | 
| 
      
 10 
     | 
    
         
            +
                  @options = prepare_options(options)
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                # Converts an options hash into the proper format for sending
         
     | 
| 
      
 14 
     | 
    
         
            +
                def prepare_options(options)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  options[:filters] = JSON[options[:filters]] if options[:filters]
         
     | 
| 
      
 16 
     | 
    
         
            +
                  options
         
     | 
| 
       9 
17 
     | 
    
         
             
                end
         
     | 
| 
       10 
18 
     | 
    
         | 
| 
       11 
19 
     | 
    
         
             
                # Performs a get request on the given resource. A block passed will be used as an on_complete callback
         
     | 
    
        data/lib/keener/version.rb
    CHANGED
    
    
| 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Keener::Resource do
         
     | 
| 
      
 4 
     | 
    
         
            +
              subject :resource do
         
     | 
| 
      
 5 
     | 
    
         
            +
                Keener::Resource.new
         
     | 
| 
      
 6 
     | 
    
         
            +
              end
         
     | 
| 
      
 7 
     | 
    
         
            +
              
         
     | 
| 
      
 8 
     | 
    
         
            +
              describe '#prepare_options' do
         
     | 
| 
      
 9 
     | 
    
         
            +
                it "should convert a filter to a json string" do
         
     | 
| 
      
 10 
     | 
    
         
            +
                  input = {:filters=>[{:property_name=>"context.account_id", :operator=>"eq", :property_value=>4}], :group_by=>"context.site_id", :event_collection=>"download"}
         
     | 
| 
      
 11 
     | 
    
         
            +
                  output = {:filters=>'[{"property_name":"context.account_id","operator":"eq","property_value":4}]', :group_by => "context.site_id", :event_collection=>"download"}
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                  resource.prepare_options(input).should eq(output)
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: keener
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Mateo Murphy
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2013-05- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2013-05-09 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: faraday
         
     | 
| 
         @@ -210,6 +210,7 @@ files: 
     | 
|
| 
       210 
210 
     | 
    
         
             
            - spec/fixtures/vcr_cassettes/project.yml
         
     | 
| 
       211 
211 
     | 
    
         
             
            - spec/fixtures/vcr_cassettes/projects.yml
         
     | 
| 
       212 
212 
     | 
    
         
             
            - spec/integration/api_spec.rb
         
     | 
| 
      
 213 
     | 
    
         
            +
            - spec/resource_spec.rb
         
     | 
| 
       213 
214 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       214 
215 
     | 
    
         
             
            - spec/support/shared_examples.rb
         
     | 
| 
       215 
216 
     | 
    
         
             
            homepage: https://github.com/mateomurphy/keener
         
     | 
| 
         @@ -245,6 +246,7 @@ test_files: 
     | 
|
| 
       245 
246 
     | 
    
         
             
            - spec/fixtures/vcr_cassettes/project.yml
         
     | 
| 
       246 
247 
     | 
    
         
             
            - spec/fixtures/vcr_cassettes/projects.yml
         
     | 
| 
       247 
248 
     | 
    
         
             
            - spec/integration/api_spec.rb
         
     | 
| 
      
 249 
     | 
    
         
            +
            - spec/resource_spec.rb
         
     | 
| 
       248 
250 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       249 
251 
     | 
    
         
             
            - spec/support/shared_examples.rb
         
     | 
| 
       250 
252 
     | 
    
         
             
            has_rdoc: 
         
     |