slipcover 0.2.66 → 0.2.67

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: c30eb78e5ec3f19a657da3119d879a03be089de2
4
- data.tar.gz: 48307fb9bd6423823cf6b00cf11a1b105dafff83
3
+ metadata.gz: 417ec7939c7ef5d78b6c8ef1d0a1847e3045705e
4
+ data.tar.gz: 09f2b87cb89c7f9726a857beaf1632c9b3e4e4f5
5
5
  SHA512:
6
- metadata.gz: e9813aea3e0f1cb40c222a551f0890a5b42b28a927a9da0a69a1f41388f2f26e39e143572fe19027f1b793c28ba04e84985aa80115138054fbb1e92b0ae210a9
7
- data.tar.gz: 0ab91d8b3d9e7a38596eb2fd2be4026f7fab8355607a8735e70f9651f545e65b4ab3ba6c9f229b523c1d551c317dd0ba0819b5b7d64a540ef083ac7c7e4fcf5f
6
+ metadata.gz: 5bd92b0951ef316fe3328fa91f23a3da98f711ef8c748dd0947ef6b719d2b30883ea9715a8d05e501f8cbb5db279c47286d77b9ba4ea0b4c55deef5b4da60535
7
+ data.tar.gz: 76247d31077baa3f46c0a6fae8e2c30681811e8ea2f1b2f9eddf5b7937591b8a71d753e994fd9c6b9122b6c627ecb326df7a386bb92b543cefdc125fd8022f13
@@ -12,10 +12,7 @@ module Slipcover
12
12
  end
13
13
 
14
14
  def all(opts={})
15
- opts_params, body_params = url_params_and_body(opts)
16
- url_with_qs = add_qs_to_url(url, repackage(opts_params))
17
-
18
- http_adapter.post(url_with_qs, body_params)[:rows].map do |row|
15
+ do_http_request(opts)[:rows].map do |row|
19
16
  doc_data = opts[:include_docs] ? row["doc"] : row
20
17
  Document.new(database.name, doc_data.symbolize_keys)
21
18
  end
@@ -27,16 +24,27 @@ module Slipcover
27
24
 
28
25
  private
29
26
 
27
+ # This is here because Cloudant doesn't support POST without supplying
28
+ # `keys`.
29
+ def do_http_request(opts)
30
+ if opts.include?(:keys)
31
+ opts_params, body_params = url_params_and_body(opts)
32
+ url_with_qs = add_qs_to_url(url, repackage(opts_params))
33
+ http_adapter.post(url_with_qs, body_params)
34
+ else
35
+ url_with_qs = add_qs_to_url(url, repackage(opts))
36
+ http_adapter.get(url_with_qs)
37
+ end
38
+ end
39
+
30
40
  def url_params_and_body(opts)
31
41
  keys_for_body = [:keys]
32
42
  [opts.except(*keys_for_body), opts.slice(*keys_for_body)]
33
43
  end
34
44
 
35
45
  def repackage(opts)
36
- opts = opts.dup
37
-
38
- opts.each do |key, value|
39
- opts[key] = jsonify_param(value) if jsonify_key?(key)
46
+ opts.each_with_object({}) do |(key, value), result|
47
+ result[key] = jsonify_key?(key) ? jsonify_param(value) : value
40
48
  end
41
49
  end
42
50
 
@@ -1,3 +1,3 @@
1
1
  module Slipcover
2
- VERSION = "0.2.66"
2
+ VERSION = "0.2.67"
3
3
  end
@@ -71,6 +71,20 @@ describe Slipcover::Query do
71
71
  results.first[:name].should == "blah&"
72
72
  end
73
73
  end
74
+
75
+ # These tests are here because Cloudant doesn't support POST without
76
+ # supplying `keys`.
77
+ it "performs a GET request when keys is not supplied" do
78
+ Slipcover::HttpAdapter.any_instance.should_receive(:get).
79
+ and_call_original
80
+ query.all
81
+ end
82
+
83
+ it "performs a POST request when keys is supplied" do
84
+ Slipcover::HttpAdapter.any_instance.should_receive(:post).
85
+ and_call_original
86
+ query.all(keys: ["Fito"])
87
+ end
74
88
  end
75
89
  end
76
90
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slipcover
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.66
4
+ version: 0.2.67
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kane Baccigalupi