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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bda5470272ffd469565e7a0dcdc76080e14920ef
4
- data.tar.gz: cbf263a82ae23ad8afafdde321f585e2b6cba0f5
3
+ metadata.gz: 4fe08aec6f913985039b87b590ba3f55b62d679f
4
+ data.tar.gz: faf84f2f169e98b143d097f671d1f4e96c112814
5
5
  SHA512:
6
- metadata.gz: 79a79472075e094e68f544f65960e71982520dead251a0bd7d963f01292714d4c398a394798f88031eb665e8b86936a698fcc7094f72b88e635e38956592ef38
7
- data.tar.gz: 2010e7654b3eda977e8d94cfa7b1110f86a34c529a0df7bc286eae89ebe5f667212c0d513fcc58351abe21653128091dcac7a8416707834b635cb49abd7bfbfc
6
+ metadata.gz: 54adaa62bbe419d4ec849f09169868ae08c5db8ea4f26e56340619d11875173444722770d24dcbacf720fcb34fc79a53023a73e17718035cdf351adb72eb87cf
7
+ data.tar.gz: cad04a3336966a507b07188876d5caf87272019cbab38a5639aa256e14550068970dc0b5b66e93febe79b7421c02f0954cb4add7cf17caff5f1bd961755aa67b
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Keener
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -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.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-03 00:00:00.000000000 Z
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: