clusterpoint 0.2.2 → 0.2.3

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: 9341eb8053765e973c79fac55a79cf86e560d114
4
- data.tar.gz: 8e04fd53420b5cf8d395548ea1c2d0289d898d6b
3
+ metadata.gz: 13d4d1ff1b7c87171be7c76a357d8bf80a6a8f1f
4
+ data.tar.gz: ca9701eaf8731a1625582902340662db4aa4b845
5
5
  SHA512:
6
- metadata.gz: 832658e7085d3f7349efbb195967e00f0b56619d74811a1d27bc26bb8405e9eed58bcae161c7c6684580298092d4eba710c9ffc44ed0ad23b5284955f93e891c
7
- data.tar.gz: 4248a008564f749a5c78979013a27fe5daab6e8acc182c4a2d39691f35c0996eb8674c291a5191fab1c2b256b3e94da39da0e329c873fdf2f42502cb9f3c1d0b
6
+ metadata.gz: e77a0bcdc9c43e6e6a15aa0480dae90d2e915c3f867895adedc2b926f0af9d07c47edc12d85753afd270ed54534ae7198ade2a07da63f27fc751d940fd61c8f7
7
+ data.tar.gz: 739ff0c7de2f454b146fe9df85ae37d459b7b0c53e180415d7296637a205c59d2c97ebab0b93f93c8d121d68a1421cc2a78d23a71c44e35ec2256069aece8555
data/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # Overview
2
+
3
+ ## 0.2.3
4
+
5
+ ### New Features
6
+
7
+ * Exposed where method
8
+ * Added Clusterpoint order support (default order by ID ascending)
9
+ - `Item.where(query_hash, order_hash, record_count, start_offset)`
10
+ - `Item.where({code: "A*"}, {string: {code: :ascending}})`
11
+ - More about query syntax:
12
+ - http://docs.clusterpoint.com/wiki/Search_query_syntax
13
+ - http://docs.clusterpoint.com/wiki/Alphabetic_Ordering
14
+ * Moved HTTP request debug setting to configuration file
15
+ debug_output: $stdout
data/README.md CHANGED
@@ -28,38 +28,48 @@ Add railtie require to your application.rb file:
28
28
  ### Database connection
29
29
  Add cluster_point.yml file under config directory. Following format;
30
30
 
31
- development:
32
- url: https://api.clusterpoint.com
33
- account_id: [Clusterpoint cloud api account ID]
34
- database: [Database to use]
35
- username: [Clusterpoint cloud username]
36
- password: [Clusterpoint cloud password]
31
+ ```
32
+ development:
33
+ url: https://api.clusterpoint.com
34
+ account_id: [Clusterpoint cloud api account ID]
35
+ database: [Database to use]
36
+ username: [Clusterpoint cloud username]
37
+ password: [Clusterpoint cloud password]
38
+ [debug_output: $stdout]
39
+ ```
37
40
 
38
41
  ### Framework usage
39
42
  To make model as Clusterpoint document innerhit it from `ClusterPoint::Document`
40
43
 
41
44
  To define subdocuments you can use one of two options - `contains` (if contains single subdocument) or `contains_many` (if contains more than one subdocument):
42
45
 
43
- contains_many :translations
44
- contains :author
46
+ ```ruby
47
+ contains_many :translations
48
+ contains :author
49
+ ```
45
50
 
46
51
  Example:
47
52
 
48
- class Item < ClusterPoint::Document
49
- contains_many :translations
50
- contains_many :locations
51
- contains :author
52
- end
53
+ ```ruby
54
+ class Item < ClusterPoint::Document
55
+ contains_many :translations
56
+ contains_many :locations
57
+ contains :author
58
+ end
59
+ ```
53
60
 
54
61
  ### Basic operations
55
- * Item.all - retrieve all documents with type Item (models are divided with document attribute `type`)
56
- * Item.find(id) - retrieve document with ID = id
57
- * Item.new_from_hash(item_params.to_h) - create new document from hash
58
- * @item.save - save document
59
- * @item.update(item_params.to_h) - update document and save changes
60
- * @item.destroy - delete document
61
- * .where({type: "ITEM"}) - custom query - not yet exposed for easy use
62
-
62
+ * `Item.all` - retrieve all documents with type Item (models are divided with document attribute `type`)
63
+ * `Item.find(id)` - retrieve document with ID = id
64
+ * `Item.new_from_hash(item_params.to_h)` - create new document from hash
65
+ * `@item.save` - save document
66
+ * `@item.update(item_params.to_h)` - update document and save changes
67
+ * `@item.destroy `- delete document
68
+ * `Item.where(query_hash, order_hash, record_count, start_offset)` - custom query.
69
+ * `Item.where({code: "A*"}, {string: {code: :ascending}})`
70
+ - More about query syntax:
71
+ - http://docs.clusterpoint.com/wiki/Search_query_syntax
72
+ - http://docs.clusterpoint.com/wiki/Alphabetic_Ordering
63
73
 
64
74
  ## Development
65
75
 
@@ -5,7 +5,6 @@ module ClusterPoint
5
5
 
6
6
  class ClusterPointAdapter
7
7
  include HTTParty
8
- debug_output $stdout
9
8
  include ClusterPoint::Configuration
10
9
 
11
10
  def initialize
@@ -62,10 +61,12 @@ module ClusterPoint
62
61
  end
63
62
  end
64
63
 
65
- def where(hash={}, docs=20, offset=0)
66
- xml = hash.to_xml(skip_instruct: true, :indent => 1)
67
- options = { body: [{ query: xml.lines.to_a[1..-2].join,
68
- docs: docs,
64
+ def where(conditions={}, ordering={string: {id: :ascending}}, docs=20, offset=0)
65
+ query_xml = conditions.to_xml(skip_instruct: true, skip_types: true, indent: 1)
66
+ ordering_xml = ordering.to_xml(skip_instruct: true, skip_types: true, indent: 1)
67
+ options = { body: [{ query: query_xml.lines.to_a[1..-2].join,
68
+ ordering: ordering_xml.lines.to_a[1..-2].join,
69
+ docs: docs,
69
70
  offset: offset
70
71
  }].to_json,
71
72
  basic_auth: @auth,
@@ -19,6 +19,9 @@ module ClusterPoint
19
19
  @config = data[@env]
20
20
 
21
21
  self.class.base_uri get_base_uri(@config)
22
+ if @config["debug_output"]
23
+ self.class.debug_output $stdout
24
+ end
22
25
  end
23
26
 
24
27
  def get_base_uri(config)
@@ -2,8 +2,13 @@ require 'json'
2
2
  module ClusterPoint
3
3
  module FinderMethods
4
4
 
5
- def all()
6
- respToArray(JSON.parse(get_cp.where({type: self.to_s.upcase})))
5
+ def all(ordering={string: {id: :ascending}})
6
+ respToArray(JSON.parse(get_cp.where({type: self.to_s.upcase}, ordering)))
7
+ end
8
+
9
+ def where(conditions={}, ordering={string: {id: :ascending}}, docs=20, offset=0)
10
+ conditions.merge!({type: self.to_s.upcase})
11
+ respToArray(JSON.parse(get_cp.where(conditions, ordering, docs, offset)))
7
12
  end
8
13
 
9
14
  def find(*ids)
@@ -36,7 +41,7 @@ module ClusterPoint
36
41
  protected
37
42
 
38
43
  def get_some(ids)
39
- items = respToArray(JSON.parse(get_cp.where({type: self.to_s.upcase, id: "{" + ids.join(" ") + "}"}, ids.size, 0)))
44
+ items = respToArray(JSON.parse(get_cp.where({type: self.to_s.upcase, id: "{" + ids.join(" ") + "}"}, docs: ids.size)))
40
45
  if items.size != ids.size
41
46
  raise RecordNotFound
42
47
  end
@@ -1,3 +1,3 @@
1
1
  module ClusterPoint
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clusterpoint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janis Baiza
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-20 00:00:00.000000000 Z
11
+ date: 2015-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -147,6 +147,7 @@ files:
147
147
  - .gitignore
148
148
  - .rspec
149
149
  - .travis.yml
150
+ - CHANGELOG.md
150
151
  - Gemfile
151
152
  - LICENSE
152
153
  - README.md