thebigdb 1.2.1 → 1.2.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.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- thebigdb (1.2.1)
4
+ thebigdb (1.2.2)
5
5
  rack (~> 1.4)
6
6
 
7
7
  GEM
@@ -10,26 +10,27 @@ GEM
10
10
  addressable (2.3.3)
11
11
  coderay (1.0.9)
12
12
  crack (0.3.2)
13
- diff-lcs (1.2.1)
14
- ffi (1.4.0)
15
- guard (1.6.2)
13
+ diff-lcs (1.2.2)
14
+ ffi (1.6.0)
15
+ formatador (0.2.4)
16
+ guard (1.7.0)
17
+ formatador (>= 0.2.4)
16
18
  listen (>= 0.6.0)
17
19
  lumberjack (>= 1.0.2)
18
20
  pry (>= 0.9.10)
19
- terminal-table (>= 1.4.3)
20
21
  thor (>= 0.14.6)
21
- guard-rspec (2.5.0)
22
+ guard-rspec (2.5.1)
22
23
  guard (>= 1.1)
23
24
  rspec (~> 2.11)
24
25
  listen (0.7.3)
25
- lumberjack (1.0.2)
26
+ lumberjack (1.0.3)
26
27
  method_source (0.8.1)
27
28
  pry (0.9.12)
28
29
  coderay (~> 1.0.5)
29
30
  method_source (~> 0.8)
30
31
  slop (~> 3.4)
31
32
  rack (1.5.2)
32
- rake (10.0.3)
33
+ rake (10.0.4)
33
34
  rb-fchange (0.0.6)
34
35
  ffi
35
36
  rb-fsevent (0.9.3)
@@ -44,8 +45,7 @@ GEM
44
45
  diff-lcs (>= 1.1.3, < 2.0)
45
46
  rspec-mocks (2.13.0)
46
47
  slop (3.4.4)
47
- terminal-table (1.4.5)
48
- thor (0.17.0)
48
+ thor (0.18.1)
49
49
  webmock (1.11.0)
50
50
  addressable (>= 2.2.7)
51
51
  crack (>= 0.3.2)
@@ -1,10 +1,10 @@
1
1
  module TheBigDB
2
2
  module Helpers
3
3
 
4
- # serialize_query_params({house: "bricks", animals: ["cat", "dog"], computers: {cool: true, drives: ["hard", "flash"]}})
5
- # => house=bricks&animals%5B%5D=cat&animals%5B%5D=dog&computers%5Bcool%5D=true&computers%5Bdrives%5D%5B%5D=hard&computers%5Bdrives%5D%5B%5D=flash
4
+ # serialize_query_params({house: "brick and mortar", animals: ["cat", "dog"], computers: {cool: true, drives: ["hard", "flash"]}})
5
+ # => house=brick%20and%20mortar&animals%5B0%5D=cat&animals%5B1%5D=dog&computers%5Bcool%5D=true&computers%5Bdrives%5D%5B0%5D=hard&computers%5Bdrives%5D%5B1%5D=flash
6
6
  # which will be read by the server as:
7
- # => house=bricks&animals[]=cat&animals[]=dog&computers[cool]=true&computers[drives][]=hard&computers[drives][]=flash
7
+ # => house=brick%20and%20mortar&animals[]=cat&animals[]=dog&computers[cool]=true&computers[drives][]=hard&computers[drives][]=flash
8
8
  def self.serialize_query_params(params, prefix = nil)
9
9
  ret = []
10
10
  params.each_pair do |key, value|
@@ -19,14 +19,14 @@ module TheBigDB
19
19
  end
20
20
  ret << self.serialize_query_params(sub_hash, param_key.to_s)
21
21
  else
22
- ret << URI.encode_www_form_component(param_key.to_s) + "=" + URI.encode_www_form_component(value.to_s)
22
+ ret << URI.encode_www_form_component(param_key.to_s) + "=" + URI.encode_www_form_component(value.to_s).gsub("+", "%20")
23
23
  end
24
24
  end
25
25
  ret.join("&")
26
26
  end
27
27
 
28
- # flatten_params_keys({house: "bricks", animals: ["cat", "dog"], computers: {cool: true, drives: ["hard", "flash"]}})
29
- # => {"house" => "bricks", "animals[0]" => "cat", "animals[1]" => "dog", "computers[cool]" => "true", "computers[drives][0]" => "hard", "computers[drives][1]" => "flash"}
28
+ # flatten_params_keys({house: "brick and mortar", animals: ["cat", "dog"], computers: {cool: true, drives: ["hard", "flash"]}})
29
+ # => {"house" => "brick and mortar", "animals[0]" => "cat", "animals[1]" => "dog", "computers[cool]" => "true", "computers[drives][0]" => "hard", "computers[drives][1]" => "flash"}
30
30
  def self.flatten_params_keys(params)
31
31
  serialized_params = self.serialize_query_params(params)
32
32
  new_params = {}
@@ -2,7 +2,7 @@ module TheBigDB
2
2
  module VERSION
3
3
  MAJOR = 1
4
4
  MINOR = 2
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
8
8
  end
data/spec/helpers_spec.rb CHANGED
@@ -7,18 +7,20 @@ describe "Helpers" do
7
7
  end
8
8
 
9
9
  it "works with more complex imbricated params" do
10
+ same_expected_result = "house=brick%20and%20mortar&animals%5B0%5D=cat&animals%5B1%5D=dog&computers%5Bcool%5D=true&computers%5Bdrives%5D%5B0%5D=hard&computers%5Bdrives%5D%5B1%5D=flash"
11
+
10
12
  TheBigDB::Helpers::serialize_query_params({
11
- house: "bricks",
13
+ house: "brick and mortar",
12
14
  animals: ["cat", "dog"],
13
15
  computers: {cool: true, drives: ["hard", "flash"]}
14
- }).should == "house=bricks&animals%5B0%5D=cat&animals%5B1%5D=dog&computers%5Bcool%5D=true&computers%5Bdrives%5D%5B0%5D=hard&computers%5Bdrives%5D%5B1%5D=flash"
16
+ }).should == same_expected_result
15
17
 
16
18
  # and with a hash instead of an array
17
19
  TheBigDB::Helpers::serialize_query_params({
18
- house: "bricks",
20
+ house: "brick and mortar",
19
21
  animals: {"0" => "cat", "1" => "dog"},
20
22
  computers: {cool: true, drives: ["hard", "flash"]}
21
- }).should == "house=bricks&animals%5B0%5D=cat&animals%5B1%5D=dog&computers%5Bcool%5D=true&computers%5Bdrives%5D%5B0%5D=hard&computers%5Bdrives%5D%5B1%5D=flash"
23
+ }).should == same_expected_result
22
24
  end
23
25
  end
24
26
 
@@ -29,11 +31,11 @@ describe "Helpers" do
29
31
 
30
32
  it "works with more complex imbricated params" do
31
33
  TheBigDB::Helpers::flatten_params_keys({
32
- house: "bricks",
34
+ house: "brick and mortar",
33
35
  animals: ["cat", "dog"],
34
36
  computers: {cool: true, drives: ["hard", "flash"]}
35
37
  }).should == {
36
- "house" => "bricks",
38
+ "house" => "brick and mortar",
37
39
  "animals[0]" => "cat",
38
40
  "animals[1]" => "dog",
39
41
  "computers[cool]" => "true",
@@ -43,11 +45,11 @@ describe "Helpers" do
43
45
 
44
46
  # and with a hash instead of an array
45
47
  TheBigDB::Helpers::flatten_params_keys({
46
- house: "bricks",
48
+ house: "brick and mortar",
47
49
  animals: {"0" => "cat", "1" => "dog"},
48
50
  computers: {cool: true, drives: ["hard", "flash"]}
49
51
  }).should == {
50
- "house" => "bricks",
52
+ "house" => "brick and mortar",
51
53
  "animals[0]" => "cat",
52
54
  "animals[1]" => "dog",
53
55
  "computers[cool]" => "true",
@@ -5,7 +5,7 @@ describe "Statement" do
5
5
  before do
6
6
  stub_request(:get, @request_path.call("search")).to_return(:body => '{"server_says": "hello world"}')
7
7
 
8
- @request = TheBigDB::Statement(:search, nodes: ["a", "b"])
8
+ @request = TheBigDB::Statement(:search, nodes: ["a a", "b"])
9
9
  end
10
10
 
11
11
  it "sets the correct data_sent instance variable" do
@@ -15,7 +15,7 @@ describe "Statement" do
15
15
  "port" => TheBigDB.api_port,
16
16
  "path" => "/v#{TheBigDB.api_version}/statements/search",
17
17
  "method" => "GET",
18
- "params" => {"nodes" => {"0" => "a", "1" => "b"}}
18
+ "params" => {"nodes" => {"0" => "a a", "1" => "b"}}
19
19
  }
20
20
  end
21
21
 
@@ -33,9 +33,9 @@ describe "StatementRequest" do
33
33
  end
34
34
 
35
35
  it "makes normal requests" do
36
- @search = TheBigDB.search("a", "b", {match: "blue"})
36
+ @search = TheBigDB.search("a a", "b", {match: "blue"})
37
37
  @search.with(page: 2)
38
- @search.params.should == {"nodes" => ["a", "b", {match: "blue"}], "page" => 2}
38
+ @search.params.should == {"nodes" => ["a a", "b", {match: "blue"}], "page" => 2}
39
39
  end
40
40
 
41
41
  it "cache the response unless the params are modified, or asked to" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thebigdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-01 00:00:00.000000000 Z
12
+ date: 2013-04-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack