hyperion-riak 0.1.1 → 0.1.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.
@@ -0,0 +1,3 @@
1
+ function(values) {
2
+ return [values.length];
3
+ }
@@ -0,0 +1,33 @@
1
+ function(riak_record) {
2
+ var data = Riak.mapValuesJson(riak_record)[0];
3
+ <% filters.each do |filter| %>
4
+ var value = <%= filter.value.to_json %>
5
+ var fieldValue = data[<%= filter.field.to_json %>];
6
+ <% operator = filter.operator %>
7
+ <% if operator == "contains?" %>
8
+ var found = false;
9
+ <% filter.value.each do |item| %>
10
+ if (fieldValue == <%= item.to_json %>) {
11
+ found = true;
12
+ }
13
+ <% end %>
14
+ if (!found) {
15
+ return [];
16
+ }
17
+ <% elsif operator == "=" %>
18
+ if (fieldValue !== value) {
19
+ return [];
20
+ }
21
+ <% elsif operator == "!=" %>
22
+ if (fieldValue == value) {
23
+ return [];
24
+ }
25
+ <% else %>
26
+ if (!(fieldValue <%= operator %> value)) {
27
+ return [];
28
+ }
29
+ <% end %>
30
+ <% end %>
31
+ data.riak_key = riak_record.key;
32
+ return [data];
33
+ }
@@ -0,0 +1,3 @@
1
+ function(values) {
2
+ return values.slice(0, <%= limit.to_json %>);
3
+ }
@@ -0,0 +1,3 @@
1
+ function(values) {
2
+ return values.slice(<%= offset.to_json %>, values.length);
3
+ }
@@ -0,0 +1,3 @@
1
+ function(values) {
2
+ return values;
3
+ }
@@ -0,0 +1,28 @@
1
+ function(values) {
2
+ return values.sort(function(record1, record2) {
3
+ var field1, field2;
4
+ <% sorts.each do |sort| %>
5
+ <% field_json = sort.field.to_json %>
6
+ field1 = record1[<%= field_json %>];
7
+ field2 = record2[<%= field_json %>];
8
+ if (field1 !== field2) {
9
+ <% if sort.ascending? %>
10
+ if (field1 < field2) {
11
+ return -1;
12
+ } else {
13
+ return 1;
14
+ }
15
+ <% elsif sort.descending? %>
16
+ if (field1 > field2) {
17
+ return -1;
18
+ } else {
19
+ return 1;
20
+ }
21
+ <% else %>
22
+ return 1;
23
+ <% end %>
24
+ }
25
+ <% end %>
26
+ return 0;
27
+ });
28
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hyperion-riak
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
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: 2012-10-26 00:00:00.000000000 Z
12
+ date: 2012-11-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - '='
36
36
  - !ruby/object:Gem::Version
37
- version: 0.1.1
37
+ version: 0.1.3
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - '='
44
44
  - !ruby/object:Gem::Version
45
- version: 0.1.1
45
+ version: 0.1.3
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: riak-client
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -66,15 +66,21 @@ executables: []
66
66
  extensions: []
67
67
  extra_rdoc_files: []
68
68
  files:
69
- - lib/hyperion/riak.rb
70
- - lib/hyperion/riak/map_reduce_js.rb
71
- - lib/hyperion/riak/optimized_filter_order.rb
72
- - lib/hyperion/riak/optimized_range_filters.rb
73
69
  - lib/hyperion/riak/spec_helper.rb
74
70
  - lib/hyperion/riak/datastore.rb
75
- - spec/hyperion/riak_spec.rb
71
+ - lib/hyperion/riak/optimized_range_filters.rb
72
+ - lib/hyperion/riak/map_reduce_js.rb
73
+ - lib/hyperion/riak/optimized_filter_order.rb
74
+ - lib/hyperion/riak.rb
76
75
  - spec/hyperion/riak/optimized_filter_order_spec.rb
77
76
  - spec/hyperion/riak/optimized_range_filters_spec.rb
77
+ - spec/hyperion/riak_spec.rb
78
+ - lib/hyperion/riak/map_reduce/pass_thru.js.erb
79
+ - lib/hyperion/riak/map_reduce/sort.js.erb
80
+ - lib/hyperion/riak/map_reduce/offset.js.erb
81
+ - lib/hyperion/riak/map_reduce/limit.js.erb
82
+ - lib/hyperion/riak/map_reduce/filter.js.erb
83
+ - lib/hyperion/riak/map_reduce/count.js.erb
78
84
  homepage: https://github.com/mylesmegyesi/hyperion-ruby
79
85
  licenses:
80
86
  - Eclipse Public License
@@ -101,6 +107,6 @@ signing_key:
101
107
  specification_version: 3
102
108
  summary: Riak datastore for Hypeiron
103
109
  test_files:
104
- - spec/hyperion/riak_spec.rb
105
110
  - spec/hyperion/riak/optimized_filter_order_spec.rb
106
111
  - spec/hyperion/riak/optimized_range_filters_spec.rb
112
+ - spec/hyperion/riak_spec.rb