riak_json 0.0.3 → 0.0.4
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/README.md +9 -5
- data/RELEASE_NOTES.md +19 -0
- data/lib/riak_json/client.rb +14 -0
- data/lib/riak_json/client_transport.rb +3 -1
- data/lib/riak_json/collection.rb +18 -0
- data/lib/riak_json/collection_schema.rb +11 -3
- data/lib/riak_json/query_result.rb +6 -0
- data/lib/riak_json/version.rb +1 -1
- data/test/integration/client_integration_test.rb +1 -0
- data/test/integration/collection_integration_test.rb +14 -12
- data/test/integration/geo_search_integration_test.rb +52 -0
- data/test/seeds/seeds.rb +25 -1
- data/test/seeds/us_capitals.json +302 -0
- data/test/unit/collection_schema_test.rb +18 -4
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c43742f2dcdd145c402e40cef17e434e0b5ef84
|
4
|
+
data.tar.gz: dafd71d453190ee709687c383c51b31b2eee5d06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57259662f3749b6c6a5bd60d6d53087c65881455c100d6e90100cbc4e7f23b930b7f5e38d58011c4422c55c3b9446cf8cdc94234fd44af0225cbd40eccf97185
|
7
|
+
data.tar.gz: f3ef1c3c668228610fe40571026721208224e0ddf34a8404723ff26372019cc570134d57b98e7ca8d926174c5b8de2620c9becc66ca5b7db6b3277fe22f44058
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@ For ActiveModel and Rails integration for RiakJson, see the [riagent](https://gi
|
|
5
5
|
|
6
6
|
For a sample Rails 4 application using RiakJson, see [Riak Threaded Forum](https://github.com/dmitrizagidulin/riak-threaded-forum)
|
7
7
|
|
8
|
-
See also [](RELEASE_NOTES.md) for a version/feature log.
|
8
|
+
See also [RELEASE_NOTES.md](https://github.com/basho-labs/riak_json_ruby_client/blob/master/RELEASE_NOTES.md) for a version/feature log.
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
To install from Ruby Gems:
|
@@ -83,14 +83,15 @@ collection = client.collection("cities")
|
|
83
83
|
# - text (spaces allowed)
|
84
84
|
# - multi_string (an array of strings, no spaces)
|
85
85
|
# - integer
|
86
|
-
# -
|
86
|
+
# - location (Solr 'location'/LatLonType type field)
|
87
|
+
# - location_rpt (Solr 'location_rpt'/SpatialRecursivePrefixTreeFieldType type field)
|
87
88
|
schema = RiakJson::CollectionSchema.new
|
88
89
|
schema.add_text_field(name='city', required=true)
|
89
90
|
schema.add_string_field('state', true)
|
90
91
|
schema.add_multi_string_field('zip_codes') # required: false
|
91
92
|
schema.add_integer_field('population', false)
|
92
93
|
schema.add_string_field('country', true)
|
93
|
-
schema.
|
94
|
+
schema.add_location_rpt_field('coordinates_rpt')
|
94
95
|
|
95
96
|
# Store the schema
|
96
97
|
collection.set_schema(schema)
|
@@ -117,8 +118,8 @@ schema_result = collection.get_schema()
|
|
117
118
|
# :type => "integer",
|
118
119
|
# :require => false
|
119
120
|
# }, {
|
120
|
-
# :name => "
|
121
|
-
# :type => "
|
121
|
+
# :name => "coordinates_rpt",
|
122
|
+
# :type => "location_rpt",
|
122
123
|
# :require => false
|
123
124
|
# }, {
|
124
125
|
# :name => "country",
|
@@ -168,6 +169,9 @@ collection.insert(doc)
|
|
168
169
|
# Read a document (load by key)
|
169
170
|
doc = collection.find_by_key("nyc")
|
170
171
|
doc['city'] # => 'New York'
|
172
|
+
|
173
|
+
# Retrieve all documents for a collection (paginated)
|
174
|
+
collection.all(docs_per_page=100)
|
171
175
|
```
|
172
176
|
|
173
177
|
### Querying RiakJson - find_one() and find_all()
|
data/RELEASE_NOTES.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# RiakJson Ruby Client Release Notes
|
2
|
+
|
3
|
+
## 0.0.4
|
4
|
+
Requires RiakJson >= v.0.0.3
|
5
|
+
|
6
|
+
* Adds support for [location](https://github.com/basho-labs/riak_json/issues/29) and
|
7
|
+
[location_rpt](https://github.com/basho-labs/riak_json/issues/28) field types.
|
8
|
+
* [#3](https://github.com/basho-labs/riak_json_ruby_client/issues/3) Implement ```client.all()``` (List all docs for a
|
9
|
+
collection (paginated))
|
10
|
+
* [#6](https://github.com/basho-labs/riak_json_ruby_client/issues/6) Implement ```collection.solr_query_raw(...)``` - perform
|
11
|
+
arbitrary Solr queries (used to test geospatial fields)
|
12
|
+
|
13
|
+
## 0.0.3
|
14
|
+
Requires RiakJson >= v.0.0.2
|
15
|
+
|
16
|
+
* [#5](https://github.com/basho-labs/riak_json_ruby_client/issues/5) Implement ```client.collections()``` List Collections call
|
17
|
+
|
18
|
+
## 0.0.2
|
19
|
+
Initial implementation
|
data/lib/riak_json/client.rb
CHANGED
@@ -61,6 +61,11 @@ module RiakJson
|
|
61
61
|
self.collection_cache[name] ||= RiakJson::Collection.new(name, self)
|
62
62
|
end
|
63
63
|
|
64
|
+
# Return the name of the Solr index (generated by RiakJson) for a collection
|
65
|
+
def collection_index_name(collection_name)
|
66
|
+
"#{collection_name}RJIndex"
|
67
|
+
end
|
68
|
+
|
64
69
|
# List all of the RiakJson collections on the riak cluster
|
65
70
|
# This is different from a Riak 'list buckets' command.
|
66
71
|
# Instead of iterating over all the keys on the cluster, 'list collections'
|
@@ -145,6 +150,15 @@ module RiakJson
|
|
145
150
|
self.transport.send_request("#{self.base_collection_url}/#{collection_name}/schema", :put, json)
|
146
151
|
end
|
147
152
|
|
153
|
+
# Perform an arbitrary raw Solr query to a collection's index
|
154
|
+
# @param [String] collection_name
|
155
|
+
# @param [String] query_params Arbitrary query parameters that will be passed to /solr/collectionRJIndex?... endpoint
|
156
|
+
# @return [String] JSON result from the query
|
157
|
+
def solr_query_raw(collection_name, query_params)
|
158
|
+
url = "#{self.base_riak_url}/search/#{self.collection_index_name(collection_name)}"
|
159
|
+
self.transport.send_request(url, :get, query_params)
|
160
|
+
end
|
161
|
+
|
148
162
|
def update_json_object(collection_name, key, json)
|
149
163
|
if key.nil? or key.empty?
|
150
164
|
raise Exception, "Error: cannot update document, key missing"
|
@@ -31,7 +31,7 @@ module RiakJson
|
|
31
31
|
begin
|
32
32
|
case http_method
|
33
33
|
when :get
|
34
|
-
response = RestClient.get url, {:content_type => :json}
|
34
|
+
response = RestClient.get url, {:content_type => :json, :params => data}
|
35
35
|
when :put
|
36
36
|
response = RestClient.put url, data, {:content_type => :json, :accept => :json}
|
37
37
|
when :post
|
@@ -41,6 +41,8 @@ module RiakJson
|
|
41
41
|
else
|
42
42
|
raise ArgumentError, "Invalid HTTP :method - #{http_method}"
|
43
43
|
end
|
44
|
+
# rescue Exception => e
|
45
|
+
# puts e.inspect
|
44
46
|
end
|
45
47
|
response
|
46
48
|
end
|
data/lib/riak_json/collection.rb
CHANGED
@@ -33,6 +33,16 @@ module RiakJson
|
|
33
33
|
@client = client
|
34
34
|
end
|
35
35
|
|
36
|
+
# Return all documents in the collection, paginated
|
37
|
+
# @param [Integer] results_limit Per-page results limit (defaults to 100)
|
38
|
+
def all(results_limit=100)
|
39
|
+
query = {
|
40
|
+
"*" => "*",
|
41
|
+
'$per_page' => results_limit
|
42
|
+
}.to_json
|
43
|
+
self.find_all(query)
|
44
|
+
end
|
45
|
+
|
36
46
|
def delete_raw_json(key)
|
37
47
|
self.client.delete_json_object(self.name, key)
|
38
48
|
end
|
@@ -96,6 +106,14 @@ module RiakJson
|
|
96
106
|
self.client.set_schema_json(self.name, schema)
|
97
107
|
end
|
98
108
|
|
109
|
+
# Perform an arbitrary raw Solr query to the collection's index
|
110
|
+
# See https://wiki.apache.org/solr/SpatialSearch
|
111
|
+
# @param [String] query_params Arbitrary query parameters that will be passed to /solr/collectionRJIndex?... endpoint
|
112
|
+
# @return [String] JSON result from the query
|
113
|
+
def solr_query_raw(query_params)
|
114
|
+
self.client.solr_query_raw(self.name, query_params)
|
115
|
+
end
|
116
|
+
|
99
117
|
def update(document)
|
100
118
|
self.update_raw_json(document.key, document.to_json)
|
101
119
|
end
|
@@ -34,8 +34,16 @@ module RiakJson
|
|
34
34
|
self.fields << { name: field_name.to_s, type: field_type.to_s, require: required }
|
35
35
|
end
|
36
36
|
|
37
|
-
|
38
|
-
|
37
|
+
# Add a 'location' type field (Solr class solr.LatLonType) to the schema
|
38
|
+
# See https://wiki.apache.org/solr/SpatialSearch
|
39
|
+
def add_location_field(field_name, required=false)
|
40
|
+
self.add_field(:location, field_name, required)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Add a 'location_rpt' type field (Solr class solr.SpatialRecursivePrefixTreeFieldType) to the schema
|
44
|
+
# See https://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4
|
45
|
+
def add_location_rpt_field(field_name, required=false)
|
46
|
+
self.add_field(:location_rpt, field_name, required)
|
39
47
|
end
|
40
48
|
|
41
49
|
def add_integer_field(field_name, required=false)
|
@@ -59,7 +67,7 @@ module RiakJson
|
|
59
67
|
end
|
60
68
|
|
61
69
|
def self.valid_field_types
|
62
|
-
[:text, :string, :multi_string, :integer, :
|
70
|
+
[:text, :string, :multi_string, :integer, :location, :location_rpt]
|
63
71
|
end
|
64
72
|
end
|
65
73
|
end
|
@@ -46,5 +46,11 @@ module RiakJson
|
|
46
46
|
documents = result_hash.fetch('data', [])
|
47
47
|
@documents = documents.map { | body | RiakJson::Document.new(body['_id'], body) }
|
48
48
|
end
|
49
|
+
|
50
|
+
# Return true if no results came back for a query
|
51
|
+
# @return [Boolean]
|
52
|
+
def empty?
|
53
|
+
self.total == 0
|
54
|
+
end
|
49
55
|
end
|
50
56
|
end
|
data/lib/riak_json/version.rb
CHANGED
@@ -50,6 +50,7 @@ describe "RiakJson Ruby Client" do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
it "can list all collections in the cluster" do
|
53
|
+
# these should be populated by 'rake db:seed'
|
53
54
|
result = rj_test_client.collections()
|
54
55
|
result.wont_be_empty
|
55
56
|
result.first.must_be_kind_of RiakJson::Collection
|
@@ -24,7 +24,7 @@ describe "a RiakJson Collection" do
|
|
24
24
|
context "uses a RiakJson client to perform CRUD on raw JSON objects" do
|
25
25
|
it "inserts a raw json object with a key" do
|
26
26
|
client = rj_test_client
|
27
|
-
collection_name = '
|
27
|
+
collection_name = '_rj-rb-client-test_collection'
|
28
28
|
collection = client.collection(collection_name) # create a new collection object
|
29
29
|
test_key = 'document-key-123'
|
30
30
|
json_obj = { 'field_one' => '123', 'field_two' => 'abc' }.to_json
|
@@ -34,7 +34,7 @@ describe "a RiakJson Collection" do
|
|
34
34
|
|
35
35
|
it "updates a raw json object" do
|
36
36
|
client = rj_test_client
|
37
|
-
collection_name = '
|
37
|
+
collection_name = '_rj-rb-client-test_collection'
|
38
38
|
collection = client.collection(collection_name) # create a new collection object
|
39
39
|
test_key = 'document-key-update'
|
40
40
|
# Insert an object first
|
@@ -48,7 +48,7 @@ describe "a RiakJson Collection" do
|
|
48
48
|
|
49
49
|
it "deletes a raw json object" do
|
50
50
|
client = rj_test_client
|
51
|
-
collection_name = '
|
51
|
+
collection_name = '_rj-rb-client-test_collection'
|
52
52
|
collection = client.collection(collection_name) # create a new collection object
|
53
53
|
test_key = 'document-key-delete'
|
54
54
|
# Insert an object first
|
@@ -66,7 +66,7 @@ describe "a RiakJson Collection" do
|
|
66
66
|
context "uses a RiakJson client to perform CRUD on RiakJson Documents" do
|
67
67
|
it "inserts a new document with a key" do
|
68
68
|
client = rj_test_client
|
69
|
-
collection_name = '
|
69
|
+
collection_name = '_rj-rb-client-test_collection'
|
70
70
|
collection = client.collection(collection_name)
|
71
71
|
|
72
72
|
test_key = 'key-123'
|
@@ -78,7 +78,7 @@ describe "a RiakJson Collection" do
|
|
78
78
|
|
79
79
|
it "inserts a new document with no key, receives key from RiakJson" do
|
80
80
|
client = rj_test_client
|
81
|
-
collection_name = '
|
81
|
+
collection_name = '_rj-rb-client-test_collection'
|
82
82
|
collection = client.collection(collection_name)
|
83
83
|
|
84
84
|
test_body = { 'field_one' => 'abc' }
|
@@ -94,7 +94,7 @@ describe "a RiakJson Collection" do
|
|
94
94
|
|
95
95
|
it "updates an existing document" do
|
96
96
|
client = rj_test_client
|
97
|
-
collection_name = '
|
97
|
+
collection_name = '_rj-rb-client-test_collection'
|
98
98
|
collection = client.collection(collection_name)
|
99
99
|
|
100
100
|
test_key = 'key-123'
|
@@ -105,7 +105,7 @@ describe "a RiakJson Collection" do
|
|
105
105
|
|
106
106
|
it "reads an existing document (loads it by key)" do
|
107
107
|
client = rj_test_client
|
108
|
-
collection_name = '
|
108
|
+
collection_name = '_rj-rb-client-test_collection'
|
109
109
|
collection = client.collection(collection_name)
|
110
110
|
|
111
111
|
# First, insert the document that's to be read
|
@@ -123,7 +123,7 @@ describe "a RiakJson Collection" do
|
|
123
123
|
context "can set, read and delete schemas" do
|
124
124
|
it "can use a raw JSON object to set schema" do
|
125
125
|
client = rj_test_client
|
126
|
-
collection = client.collection('cities')
|
126
|
+
collection = client.collection('_rj-rb-client-cities')
|
127
127
|
|
128
128
|
schema = [{
|
129
129
|
:name => "city",
|
@@ -153,7 +153,7 @@ describe "a RiakJson Collection" do
|
|
153
153
|
|
154
154
|
it "uses a CollectionSchema object to set schemas" do
|
155
155
|
client = rj_test_client
|
156
|
-
collection = client.collection('cities')
|
156
|
+
collection = client.collection('_rj-rb-client-cities')
|
157
157
|
|
158
158
|
schema = RiakJson::CollectionSchema.new
|
159
159
|
schema.add_text_field(name='city', required=true)
|
@@ -161,6 +161,8 @@ describe "a RiakJson Collection" do
|
|
161
161
|
schema.add_multi_string_field('zip_codes') # required: false
|
162
162
|
schema.add_integer_field('population', false)
|
163
163
|
schema.add_string_field('country', true)
|
164
|
+
schema.add_location_field('capital_coordinates', false)
|
165
|
+
schema.add_location_rpt_field('capital_coordinates_rpt', false)
|
164
166
|
|
165
167
|
response = collection.set_schema(schema)
|
166
168
|
response.code.must_equal 204
|
@@ -169,7 +171,7 @@ describe "a RiakJson Collection" do
|
|
169
171
|
it "can delete (unset) a schema for a collection" do
|
170
172
|
client = rj_test_client
|
171
173
|
# schema created via 'rake db:seed' (See test/seeds/seed.rb)
|
172
|
-
collection = client.collection('cities-delete-schema')
|
174
|
+
collection = client.collection('_rj-rb-client-cities-delete-schema')
|
173
175
|
|
174
176
|
# Delete the schema
|
175
177
|
response = collection.delete_schema
|
@@ -181,7 +183,7 @@ describe "a RiakJson Collection" do
|
|
181
183
|
context "performs queries" do
|
182
184
|
it "retrieves a single document with find_one()" do
|
183
185
|
client = rj_test_client
|
184
|
-
collection = client.collection('cities')
|
186
|
+
collection = client.collection('_rj-rb-client-cities')
|
185
187
|
key = "nyc"
|
186
188
|
body = { 'city' => "New York", 'state' => "NY", 'country' => "USA" }
|
187
189
|
doc = RiakJson::Document.new(key, body)
|
@@ -193,7 +195,7 @@ describe "a RiakJson Collection" do
|
|
193
195
|
|
194
196
|
it "retrieves many documents with find_all()" do
|
195
197
|
client = rj_test_client
|
196
|
-
collection = client.collection('cities')
|
198
|
+
collection = client.collection('_rj-rb-client-cities')
|
197
199
|
|
198
200
|
# Populate the cities collection with data
|
199
201
|
doc = RiakJson::Document.new(
|
@@ -0,0 +1,52 @@
|
|
1
|
+
## -------------------------------------------------------------------
|
2
|
+
##
|
3
|
+
## Copyright (c) "2014" Basho Technologies, Inc.
|
4
|
+
##
|
5
|
+
## This file is provided to you under the Apache License,
|
6
|
+
## Version 2.0 (the "License"); you may not use this file
|
7
|
+
## except in compliance with the License. You may obtain
|
8
|
+
## a copy of the License at
|
9
|
+
##
|
10
|
+
## http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
##
|
12
|
+
## Unless required by applicable law or agreed to in writing,
|
13
|
+
## software distributed under the License is distributed on an
|
14
|
+
## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
+
## KIND, either express or implied. See the License for the
|
16
|
+
## specific language governing permissions and limitations
|
17
|
+
## under the License.
|
18
|
+
##
|
19
|
+
## -------------------------------------------------------------------
|
20
|
+
|
21
|
+
require 'helper'
|
22
|
+
|
23
|
+
describe "RiakJson provides geospatial Solr search" do
|
24
|
+
# The '_rj-rb-client-us-capitals' docs were inserted in test/seeds/seeds.rb
|
25
|
+
|
26
|
+
it "ensure seeding of us capitals worked" do
|
27
|
+
client = rj_test_client
|
28
|
+
collection = client.collection('_rj-rb-client-us-capitals')
|
29
|
+
results = collection.all()
|
30
|
+
results.wont_be_empty
|
31
|
+
end
|
32
|
+
|
33
|
+
it "can perform arbitrary geo Solr queries" do
|
34
|
+
client = rj_test_client
|
35
|
+
collection = client.collection('_rj-rb-client-us-capitals')
|
36
|
+
spatial_field = 'capital_coords_rpt'
|
37
|
+
location = '41.82355,-71.422132' # Providence, RI
|
38
|
+
distance = '300' # kilometers
|
39
|
+
filter = true # exclude results that are outside of the distance?
|
40
|
+
query_params = {
|
41
|
+
:fl => '*,score', # field list
|
42
|
+
:sort => 'score asc',
|
43
|
+
:q => "{!geofilt score=distance filter=#{filter} sfield=#{spatial_field} pt=#{location} d=#{distance}}",
|
44
|
+
:wt => 'json'
|
45
|
+
}
|
46
|
+
# Get a raw Solr result in JSON format back
|
47
|
+
result = collection.solr_query_raw(query_params)
|
48
|
+
result = JSON.parse(result)
|
49
|
+
# puts JSON.pretty_generate(result)
|
50
|
+
result['response']['numFound'].must_equal 6 # There should be 6 state capitals within 300km of Providence RI
|
51
|
+
end
|
52
|
+
end
|
data/test/seeds/seeds.rb
CHANGED
@@ -26,7 +26,31 @@ port = ENV['RIAK_PORT'] ? ENV['RIAK_PORT'] : RiakJson::RIAK_TEST_PORT
|
|
26
26
|
client = RiakJson::Client.new(host, port)
|
27
27
|
|
28
28
|
# Ensure a collection has an existing schema for the Delete Schema test
|
29
|
-
collection = client.collection('cities-delete-schema')
|
29
|
+
collection = client.collection('_rj-rb-client-cities-delete-schema')
|
30
30
|
schema = RiakJson::CollectionSchema.new
|
31
31
|
schema.add_text_field(name='city', required=true)
|
32
32
|
collection.set_schema(schema)
|
33
|
+
|
34
|
+
# Set up the US States/Capitals collection, to test the geo search functionality
|
35
|
+
schema = RiakJson::CollectionSchema.new
|
36
|
+
schema.add_string_field('abbreviation', required=true)
|
37
|
+
schema.add_text_field('name', true)
|
38
|
+
schema.add_text_field('capital', true)
|
39
|
+
schema.add_location_rpt_field('capital_coords_rpt')
|
40
|
+
|
41
|
+
capitals = client.collection('_rj-rb-client-us-capitals')
|
42
|
+
capitals.set_schema(schema)
|
43
|
+
|
44
|
+
us_capitals_json = File.open('test/seeds/us_capitals.json', 'rb') { |file| file.read }
|
45
|
+
us_capitals = JSON.parse(us_capitals_json)
|
46
|
+
|
47
|
+
us_capitals.each do | abbrev, state_data |
|
48
|
+
state_json = {
|
49
|
+
:abbreviation => abbrev,
|
50
|
+
:name => state_data['name'],
|
51
|
+
:capital => state_data['capital'],
|
52
|
+
:capital_coords_rpt => "#{state_data['lat']},#{state_data['lon']}"
|
53
|
+
}
|
54
|
+
state_doc = RiakJson::Document.new(abbrev, state_json)
|
55
|
+
capitals.insert(state_doc)
|
56
|
+
end
|
@@ -0,0 +1,302 @@
|
|
1
|
+
{
|
2
|
+
"AL": {
|
3
|
+
"name": "Alabama",
|
4
|
+
"capital": "Montgomery",
|
5
|
+
"lat": "32.361538",
|
6
|
+
"long": "-86.279118"
|
7
|
+
},
|
8
|
+
"AK": {
|
9
|
+
"name": "Alaska",
|
10
|
+
"capital": "Juneau",
|
11
|
+
"lat": "58.301935",
|
12
|
+
"long": "-134.419740"
|
13
|
+
},
|
14
|
+
"AZ": {
|
15
|
+
"name": "Arizona",
|
16
|
+
"capital": "Phoenix",
|
17
|
+
"lat": "33.448457",
|
18
|
+
"long": "-112.073844"
|
19
|
+
},
|
20
|
+
"AR": {
|
21
|
+
"name": "Arkansas",
|
22
|
+
"capital": "Little Rock",
|
23
|
+
"lat": "34.736009",
|
24
|
+
"long": "-92.331122"
|
25
|
+
},
|
26
|
+
"CA": {
|
27
|
+
"name": "California",
|
28
|
+
"capital": "Sacramento",
|
29
|
+
"lat": "38.555605",
|
30
|
+
"long": "-121.468926"
|
31
|
+
},
|
32
|
+
"CO": {
|
33
|
+
"name": "Colorado",
|
34
|
+
"capital": "Denver",
|
35
|
+
"lat": "39.7391667",
|
36
|
+
"long": "-104.984167"
|
37
|
+
},
|
38
|
+
"CT": {
|
39
|
+
"name": "Connecticut",
|
40
|
+
"capital": "Hartford",
|
41
|
+
"lat": "41.767",
|
42
|
+
"long": "-72.677"
|
43
|
+
},
|
44
|
+
"DE": {
|
45
|
+
"name": "Delaware",
|
46
|
+
"capital": "Dover",
|
47
|
+
"lat": "39.161921",
|
48
|
+
"long": "-75.526755"
|
49
|
+
},
|
50
|
+
"FL": {
|
51
|
+
"name": "Florida",
|
52
|
+
"capital": "Tallahassee",
|
53
|
+
"lat": "30.4518",
|
54
|
+
"long": "-84.27277"
|
55
|
+
},
|
56
|
+
"GA": {
|
57
|
+
"name": "Georgia",
|
58
|
+
"capital": "Atlanta",
|
59
|
+
"lat": "33.76",
|
60
|
+
"long": "-84.39"
|
61
|
+
},
|
62
|
+
"HI": {
|
63
|
+
"name": "Hawaii",
|
64
|
+
"capital": "Honolulu",
|
65
|
+
"lat": "21.30895",
|
66
|
+
"long": "-157.826182"
|
67
|
+
},
|
68
|
+
"ID": {
|
69
|
+
"name": "Idaho",
|
70
|
+
"capital": "Boise",
|
71
|
+
"lat": "43.613739",
|
72
|
+
"long": "-116.237651"
|
73
|
+
},
|
74
|
+
"IL": {
|
75
|
+
"name": "Illinois",
|
76
|
+
"capital": "Springfield",
|
77
|
+
"lat": "39.783250",
|
78
|
+
"long": "-89.650373"
|
79
|
+
},
|
80
|
+
"IN": {
|
81
|
+
"name": "Indiana",
|
82
|
+
"capital": "Indianapolis",
|
83
|
+
"lat": "39.790942",
|
84
|
+
"long": "-86.147685"
|
85
|
+
},
|
86
|
+
"IA": {
|
87
|
+
"name": "Iowa",
|
88
|
+
"capital": "Des Moines",
|
89
|
+
"lat": "41.590939",
|
90
|
+
"long": "-93.620866"
|
91
|
+
},
|
92
|
+
"KS": {
|
93
|
+
"name": "Kansas",
|
94
|
+
"capital": "Topeka",
|
95
|
+
"lat": "39.04",
|
96
|
+
"long": "-95.69"
|
97
|
+
},
|
98
|
+
"KY": {
|
99
|
+
"name": "Kentucky",
|
100
|
+
"capital": "Frankfort",
|
101
|
+
"lat": "38.197274",
|
102
|
+
"long": "-84.86311"
|
103
|
+
},
|
104
|
+
"LA": {
|
105
|
+
"name": "Louisiana",
|
106
|
+
"capital": "Baton Rouge",
|
107
|
+
"lat": "30.45809",
|
108
|
+
"long": "-91.140229"
|
109
|
+
},
|
110
|
+
"ME": {
|
111
|
+
"name": "Maine",
|
112
|
+
"capital": "Augusta",
|
113
|
+
"lat": "44.323535",
|
114
|
+
"long": "-69.765261"
|
115
|
+
},
|
116
|
+
"MD": {
|
117
|
+
"name": "Maryland",
|
118
|
+
"capital": "Annapolis",
|
119
|
+
"lat": "38.972945",
|
120
|
+
"long": "-76.501157"
|
121
|
+
},
|
122
|
+
"MA": {
|
123
|
+
"name": "Massachusetts",
|
124
|
+
"capital": "Boston",
|
125
|
+
"lat": "42.2352",
|
126
|
+
"long": "-71.0275"
|
127
|
+
},
|
128
|
+
"MI": {
|
129
|
+
"name": "Michigan",
|
130
|
+
"capital": "Lansing",
|
131
|
+
"lat": "42.7335",
|
132
|
+
"long": "-84.5467"
|
133
|
+
},
|
134
|
+
"MN": {
|
135
|
+
"name": "Minnesota",
|
136
|
+
"capital": "Saint Paul",
|
137
|
+
"lat": "44.95",
|
138
|
+
"long": "-93.094"
|
139
|
+
},
|
140
|
+
"MS": {
|
141
|
+
"name": "Mississippi",
|
142
|
+
"capital": "Jackson",
|
143
|
+
"lat": "32.320",
|
144
|
+
"long": "-90.207"
|
145
|
+
},
|
146
|
+
"MO": {
|
147
|
+
"name": "Missouri",
|
148
|
+
"capital": "Jefferson City",
|
149
|
+
"lat": "38.572954",
|
150
|
+
"long": "-92.189283"
|
151
|
+
},
|
152
|
+
"MT": {
|
153
|
+
"name": "Montana",
|
154
|
+
"capital": "Helana",
|
155
|
+
"lat": "46.595805",
|
156
|
+
"long": "-112.027031"
|
157
|
+
},
|
158
|
+
"NE": {
|
159
|
+
"name": "Nebraska",
|
160
|
+
"capital": "Lincoln",
|
161
|
+
"lat": "40.809868",
|
162
|
+
"long": "-96.675345"
|
163
|
+
},
|
164
|
+
"NV": {
|
165
|
+
"name": "Nevada",
|
166
|
+
"capital": "Carson City",
|
167
|
+
"lat": "39.160949",
|
168
|
+
"long": "-119.753877"
|
169
|
+
},
|
170
|
+
"NH": {
|
171
|
+
"name": "New Hampshire",
|
172
|
+
"capital": "Concord",
|
173
|
+
"lat": "43.220093",
|
174
|
+
"long": "-71.549127"
|
175
|
+
},
|
176
|
+
"NJ": {
|
177
|
+
"name": "New Jersey",
|
178
|
+
"capital": "Trenton",
|
179
|
+
"lat": "40.221741",
|
180
|
+
"long": "-74.756138"
|
181
|
+
},
|
182
|
+
"NM": {
|
183
|
+
"name": "New Mexico",
|
184
|
+
"capital": "Santa Fe",
|
185
|
+
"lat": "35.667231",
|
186
|
+
"long": "-105.964575"
|
187
|
+
},
|
188
|
+
"NY": {
|
189
|
+
"name": "New York",
|
190
|
+
"capital": "Albany",
|
191
|
+
"lat": "42.659829",
|
192
|
+
"long": "-73.781339"
|
193
|
+
},
|
194
|
+
"NC": {
|
195
|
+
"name": "North Carolina",
|
196
|
+
"capital": "Raleigh",
|
197
|
+
"lat": "35.771",
|
198
|
+
"long": "-78.638"
|
199
|
+
},
|
200
|
+
"ND": {
|
201
|
+
"name": "North Dakota",
|
202
|
+
"capital": "Bismarck",
|
203
|
+
"lat": "48.813343",
|
204
|
+
"long": "-100.779004"
|
205
|
+
},
|
206
|
+
"OH": {
|
207
|
+
"name": "Ohio",
|
208
|
+
"capital": "Columbus",
|
209
|
+
"lat": "39.962245",
|
210
|
+
"long": "-83.000647"
|
211
|
+
},
|
212
|
+
"OK": {
|
213
|
+
"name": "Oklahoma",
|
214
|
+
"capital": "Oklahoma City",
|
215
|
+
"lat": "35.482309",
|
216
|
+
"long": "-97.534994"
|
217
|
+
},
|
218
|
+
"OR": {
|
219
|
+
"name": "Oregon",
|
220
|
+
"capital": "Salem",
|
221
|
+
"lat": "44.931109",
|
222
|
+
"long": "-123.029159"
|
223
|
+
},
|
224
|
+
"PA": {
|
225
|
+
"name": "Pennsylvania",
|
226
|
+
"capital": "Harrisburg",
|
227
|
+
"lat": "40.269789",
|
228
|
+
"long": "-76.875613"
|
229
|
+
},
|
230
|
+
"RI": {
|
231
|
+
"name": "Rhode Island",
|
232
|
+
"capital": "Providence",
|
233
|
+
"lat": "41.82355",
|
234
|
+
"long": "-71.422132"
|
235
|
+
},
|
236
|
+
"SC": {
|
237
|
+
"name": "South Carolina",
|
238
|
+
"capital": "Columbia",
|
239
|
+
"lat": "34.000",
|
240
|
+
"long": "-81.035"
|
241
|
+
},
|
242
|
+
"SD": {
|
243
|
+
"name": "South Dakota",
|
244
|
+
"capital": "Pierre",
|
245
|
+
"lat": "44.367966",
|
246
|
+
"long": "-100.336378"
|
247
|
+
},
|
248
|
+
"TN": {
|
249
|
+
"name": "Tennessee",
|
250
|
+
"capital": "Nashville",
|
251
|
+
"lat": "36.165",
|
252
|
+
"long": "-86.784"
|
253
|
+
},
|
254
|
+
"TX": {
|
255
|
+
"name": "Texas",
|
256
|
+
"capital": "Austin",
|
257
|
+
"lat": "30.266667",
|
258
|
+
"long": "-97.75"
|
259
|
+
},
|
260
|
+
"UT": {
|
261
|
+
"name": "Utah",
|
262
|
+
"capital": "Salt Lake City",
|
263
|
+
"lat": "40.7547",
|
264
|
+
"long": "-111.892622"
|
265
|
+
},
|
266
|
+
"VT": {
|
267
|
+
"name": "Vermont",
|
268
|
+
"capital": "Montpelier",
|
269
|
+
"lat": "44.26639",
|
270
|
+
"long": "-72.57194"
|
271
|
+
},
|
272
|
+
"VA": {
|
273
|
+
"name": "Virginia",
|
274
|
+
"capital": "Richmond",
|
275
|
+
"lat": "37.54",
|
276
|
+
"long": "-77.46"
|
277
|
+
},
|
278
|
+
"WA": {
|
279
|
+
"name": "Washington",
|
280
|
+
"capital": "Olympia",
|
281
|
+
"lat": "47.042418",
|
282
|
+
"long": "-122.893077"
|
283
|
+
},
|
284
|
+
"WV": {
|
285
|
+
"name": "West Virginia",
|
286
|
+
"capital": "Charleston",
|
287
|
+
"lat": "38.349497",
|
288
|
+
"long": "-81.633294"
|
289
|
+
},
|
290
|
+
"WI": {
|
291
|
+
"name": "Wisconsin",
|
292
|
+
"capital": "Madison",
|
293
|
+
"lat": "43.074722",
|
294
|
+
"long": "-89.384444"
|
295
|
+
},
|
296
|
+
"WY": {
|
297
|
+
"name": "Wyoming",
|
298
|
+
"capital": "Cheyenne",
|
299
|
+
"lat": "41.145548",
|
300
|
+
"long": "-104.802042"
|
301
|
+
}
|
302
|
+
}
|
@@ -95,17 +95,31 @@ describe "a RiakJson Collection Schema" do
|
|
95
95
|
schema.fields[0][:require].must_equal false
|
96
96
|
end
|
97
97
|
|
98
|
-
it "can add a
|
98
|
+
it "can add a location type field to the schema definition" do
|
99
99
|
# schema = [{
|
100
100
|
# :name => "coordinates",
|
101
|
-
# :type => "
|
101
|
+
# :type => "location",
|
102
102
|
# :require => false
|
103
103
|
# }]
|
104
104
|
schema = RiakJson::CollectionSchema.new
|
105
|
-
schema.
|
105
|
+
schema.add_location_field(name='coordinates', required=false)
|
106
106
|
schema.fields.count.must_equal 1
|
107
107
|
schema.fields[0][:name].must_equal 'coordinates'
|
108
|
-
schema.fields[0][:type].must_equal '
|
108
|
+
schema.fields[0][:type].must_equal 'location'
|
109
|
+
schema.fields[0][:require].must_equal false
|
110
|
+
end
|
111
|
+
|
112
|
+
it "can add a location_rpt type field to the schema definition" do
|
113
|
+
# schema = [{
|
114
|
+
# :name => "coordinates_rpt",
|
115
|
+
# :type => "location_rpt",
|
116
|
+
# :require => false
|
117
|
+
# }]
|
118
|
+
schema = RiakJson::CollectionSchema.new
|
119
|
+
schema.add_location_rpt_field(name='coordinates_rpt', required=false)
|
120
|
+
schema.fields.count.must_equal 1
|
121
|
+
schema.fields[0][:name].must_equal 'coordinates_rpt'
|
122
|
+
schema.fields[0][:type].must_equal 'location_rpt'
|
109
123
|
schema.fields[0][:require].must_equal false
|
110
124
|
end
|
111
125
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riak_json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitri Zagidulin
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-04-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -149,6 +149,7 @@ files:
|
|
149
149
|
- Gemfile
|
150
150
|
- LICENSE
|
151
151
|
- README.md
|
152
|
+
- RELEASE_NOTES.md
|
152
153
|
- Rakefile
|
153
154
|
- lib/riak_json.rb
|
154
155
|
- lib/riak_json/client.rb
|
@@ -165,7 +166,9 @@ files:
|
|
165
166
|
- test/helper.rb
|
166
167
|
- test/integration/client_integration_test.rb
|
167
168
|
- test/integration/collection_integration_test.rb
|
169
|
+
- test/integration/geo_search_integration_test.rb
|
168
170
|
- test/seeds/seeds.rb
|
171
|
+
- test/seeds/us_capitals.json
|
169
172
|
- test/unit/client_test.rb
|
170
173
|
- test/unit/client_transport_test.rb
|
171
174
|
- test/unit/collection_schema_test.rb
|
@@ -202,7 +205,9 @@ test_files:
|
|
202
205
|
- test/helper.rb
|
203
206
|
- test/integration/client_integration_test.rb
|
204
207
|
- test/integration/collection_integration_test.rb
|
208
|
+
- test/integration/geo_search_integration_test.rb
|
205
209
|
- test/seeds/seeds.rb
|
210
|
+
- test/seeds/us_capitals.json
|
206
211
|
- test/unit/client_test.rb
|
207
212
|
- test/unit/client_transport_test.rb
|
208
213
|
- test/unit/collection_schema_test.rb
|