plucky 0.6.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -3
  3. data/.rspec +1 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +7 -4
  6. data/Gemfile +6 -5
  7. data/Gemfile.lock +84 -0
  8. data/LICENSE +1 -1
  9. data/README.md +17 -75
  10. data/Rakefile +0 -3
  11. data/examples/query.rb +8 -7
  12. data/lib/plucky.rb +1 -0
  13. data/lib/plucky/criteria_hash.rb +78 -62
  14. data/lib/plucky/extensions/symbol.rb +8 -0
  15. data/lib/plucky/normalizers/criteria_hash_value.rb +3 -1
  16. data/lib/plucky/normalizers/fields_value.rb +3 -3
  17. data/lib/plucky/normalizers/hash_key.rb +19 -0
  18. data/lib/plucky/normalizers/options_hash_value.rb +5 -7
  19. data/lib/plucky/normalizers/sort_value.rb +8 -6
  20. data/lib/plucky/options_hash.rb +9 -3
  21. data/lib/plucky/pagination.rb +1 -1
  22. data/lib/plucky/pagination/{decorator.rb → collection.rb} +10 -1
  23. data/lib/plucky/query.rb +56 -21
  24. data/lib/plucky/transformer.rb +14 -0
  25. data/lib/plucky/version.rb +1 -1
  26. data/plucky.gemspec +4 -5
  27. data/script/bootstrap +21 -0
  28. data/script/release +42 -0
  29. data/script/test +20 -0
  30. data/spec/functional/options_hash_spec.rb +41 -0
  31. data/spec/helper.rb +12 -4
  32. data/spec/plucky/criteria_hash_spec.rb +68 -4
  33. data/spec/plucky/normalizers/criteria_hash_value_spec.rb +1 -1
  34. data/spec/plucky/normalizers/fields_value_spec.rb +5 -5
  35. data/spec/plucky/normalizers/hash_key_spec.rb +15 -0
  36. data/spec/plucky/normalizers/options_hash_value_spec.rb +2 -2
  37. data/spec/plucky/normalizers/sort_value_spec.rb +24 -20
  38. data/spec/plucky/options_hash_spec.rb +2 -2
  39. data/spec/plucky/pagination/{decorator_spec.rb → collection_spec.rb} +8 -5
  40. data/spec/plucky/query_spec.rb +92 -35
  41. data/spec/plucky_spec.rb +5 -5
  42. data/spec/symbol_operator_spec.rb +18 -1
  43. metadata +37 -36
  44. data/lib/plucky/normalizers/options_hash_key.rb +0 -23
  45. data/script/criteria_hash.rb +0 -21
  46. data/spec/plucky/normalizers/options_hash_key_spec.rb +0 -23
@@ -31,21 +31,21 @@ describe Plucky do
31
31
  describe ".modifier?" do
32
32
  context "with a string" do
33
33
  it "returns true if modifier" do
34
- Plucky.modifier?('$in').should be_true
34
+ Plucky.modifier?('$in').should == true
35
35
  end
36
36
 
37
37
  it "returns false if not modifier" do
38
- Plucky.modifier?('nope').should be_false
38
+ Plucky.modifier?('nope').should == false
39
39
  end
40
40
  end
41
41
 
42
42
  context "with a symbol" do
43
43
  it "returns true if modifier" do
44
- Plucky.modifier?(:$in).should be_true
44
+ Plucky.modifier?(:$in).should == true
45
45
  end
46
46
 
47
47
  it "returns false if not modifier" do
48
- Plucky.modifier?(:nope).should be_false
48
+ Plucky.modifier?(:nope).should == false
49
49
  end
50
50
  end
51
51
  end
@@ -56,7 +56,7 @@ describe Plucky do
56
56
  :where, :filter,
57
57
  :sort, :order, :reverse,
58
58
  :paginate, :per_page, :limit, :skip, :offset,
59
- :fields, :ignore, :only,
59
+ :fields, :projection, :ignore, :only,
60
60
  :each, :find_each, :find_one, :find,
61
61
  :count, :size, :distinct,
62
62
  :last, :first, :all, :to_a,
@@ -34,7 +34,24 @@ describe SymbolOperator do
34
34
  SymbolOperator.new(:foo, 'in').should_not == 'foo.in'
35
35
  end
36
36
  end
37
-
37
+
38
+ context "hash" do
39
+
40
+ it 'returns sum of operator and hash field' do
41
+ SymbolOperator.new(:foo, 'in').hash.should == :foo.hash + 'in'.hash
42
+ end
43
+
44
+ end
45
+
46
+ context 'eql?' do
47
+
48
+ it 'uses #== for equality comparison' do
49
+ subject.should_receive(:"==").with("dummy_value")
50
+ subject.eql?("dummy_value")
51
+ end
52
+
53
+ end
54
+
38
55
  context "<=>" do
39
56
  it "returns string comparison of operator for same field, different operator" do
40
57
  (SymbolOperator.new(:foo, 'in') <=> SymbolOperator.new(:foo, 'all')).should == 1
metadata CHANGED
@@ -1,42 +1,46 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plucky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
5
- prerelease:
4
+ version: 0.8.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - John Nunemaker
9
- autorequire:
8
+ - Chris Heald
9
+ - Scott Taylor
10
+ autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2013-03-14 00:00:00.000000000 Z
13
+ date: 2020-09-15 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: mongo
16
17
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
18
  requirements:
19
- - - ~>
19
+ - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: '1.5'
21
+ version: '2.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
25
  requirements:
27
- - - ~>
26
+ - - "~>"
28
27
  - !ruby/object:Gem::Version
29
- version: '1.5'
30
- description:
28
+ version: '2.0'
29
+ description:
31
30
  email:
32
31
  - nunemaker@gmail.com
32
+ - cheald@gmail.com
33
+ - scott@railsnewbie.com
33
34
  executables: []
34
35
  extensions: []
35
36
  extra_rdoc_files: []
36
37
  files:
37
- - .gitignore
38
- - .travis.yml
38
+ - ".gitignore"
39
+ - ".rspec"
40
+ - ".ruby-version"
41
+ - ".travis.yml"
39
42
  - Gemfile
43
+ - Gemfile.lock
40
44
  - Guardfile
41
45
  - LICENSE
42
46
  - README.md
@@ -52,78 +56,75 @@ files:
52
56
  - lib/plucky/normalizers/criteria_hash_key.rb
53
57
  - lib/plucky/normalizers/criteria_hash_value.rb
54
58
  - lib/plucky/normalizers/fields_value.rb
59
+ - lib/plucky/normalizers/hash_key.rb
55
60
  - lib/plucky/normalizers/integer.rb
56
- - lib/plucky/normalizers/options_hash_key.rb
57
61
  - lib/plucky/normalizers/options_hash_value.rb
58
62
  - lib/plucky/normalizers/sort_value.rb
59
63
  - lib/plucky/options_hash.rb
60
64
  - lib/plucky/pagination.rb
61
- - lib/plucky/pagination/decorator.rb
65
+ - lib/plucky/pagination/collection.rb
62
66
  - lib/plucky/pagination/paginator.rb
63
67
  - lib/plucky/query.rb
68
+ - lib/plucky/transformer.rb
64
69
  - lib/plucky/version.rb
65
70
  - plucky.gemspec
66
- - script/criteria_hash.rb
71
+ - script/bootstrap
72
+ - script/release
73
+ - script/test
74
+ - spec/functional/options_hash_spec.rb
67
75
  - spec/helper.rb
68
76
  - spec/plucky/criteria_hash_spec.rb
69
77
  - spec/plucky/normalizers/criteria_hash_key_spec.rb
70
78
  - spec/plucky/normalizers/criteria_hash_value_spec.rb
71
79
  - spec/plucky/normalizers/fields_value_spec.rb
80
+ - spec/plucky/normalizers/hash_key_spec.rb
72
81
  - spec/plucky/normalizers/integer_spec.rb
73
- - spec/plucky/normalizers/options_hash_key_spec.rb
74
82
  - spec/plucky/normalizers/options_hash_value_spec.rb
75
83
  - spec/plucky/normalizers/sort_value_spec.rb
76
84
  - spec/plucky/options_hash_spec.rb
77
- - spec/plucky/pagination/decorator_spec.rb
85
+ - spec/plucky/pagination/collection_spec.rb
78
86
  - spec/plucky/pagination/paginator_spec.rb
79
87
  - spec/plucky/query_spec.rb
80
88
  - spec/plucky_spec.rb
81
89
  - spec/symbol_operator_spec.rb
82
90
  - spec/symbol_spec.rb
83
91
  - specs.watchr
84
- homepage: http://jnunemaker.github.com/plucky/
92
+ homepage: http://github.com/mongomapper/plucky
85
93
  licenses: []
86
- post_install_message:
94
+ metadata: {}
95
+ post_install_message:
87
96
  rdoc_options: []
88
97
  require_paths:
89
98
  - lib
90
99
  required_ruby_version: !ruby/object:Gem::Requirement
91
- none: false
92
100
  requirements:
93
- - - ! '>='
101
+ - - ">="
94
102
  - !ruby/object:Gem::Version
95
103
  version: '0'
96
- segments:
97
- - 0
98
- hash: 2311334578269732837
99
104
  required_rubygems_version: !ruby/object:Gem::Requirement
100
- none: false
101
105
  requirements:
102
- - - ! '>='
106
+ - - ">="
103
107
  - !ruby/object:Gem::Version
104
108
  version: '0'
105
- segments:
106
- - 0
107
- hash: 2311334578269732837
108
109
  requirements: []
109
- rubyforge_project:
110
- rubygems_version: 1.8.23
111
- signing_key:
112
- specification_version: 3
110
+ rubygems_version: 3.1.4
111
+ signing_key:
112
+ specification_version: 4
113
113
  summary: Thin layer over the ruby driver that allows you to quickly grab hold of your
114
114
  data (pluck it!).
115
115
  test_files:
116
+ - spec/functional/options_hash_spec.rb
116
117
  - spec/helper.rb
117
118
  - spec/plucky/criteria_hash_spec.rb
118
119
  - spec/plucky/normalizers/criteria_hash_key_spec.rb
119
120
  - spec/plucky/normalizers/criteria_hash_value_spec.rb
120
121
  - spec/plucky/normalizers/fields_value_spec.rb
122
+ - spec/plucky/normalizers/hash_key_spec.rb
121
123
  - spec/plucky/normalizers/integer_spec.rb
122
- - spec/plucky/normalizers/options_hash_key_spec.rb
123
124
  - spec/plucky/normalizers/options_hash_value_spec.rb
124
125
  - spec/plucky/normalizers/sort_value_spec.rb
125
126
  - spec/plucky/options_hash_spec.rb
126
- - spec/plucky/pagination/decorator_spec.rb
127
+ - spec/plucky/pagination/collection_spec.rb
127
128
  - spec/plucky/pagination/paginator_spec.rb
128
129
  - spec/plucky/query_spec.rb
129
130
  - spec/plucky_spec.rb
@@ -1,23 +0,0 @@
1
- module Plucky
2
- module Normalizers
3
- class OptionsHashKey
4
-
5
- # Internal: Keys with values that they should normalize to
6
- NormalizedKeys = {
7
- :order => :sort,
8
- :select => :fields,
9
- :offset => :skip,
10
- :id => :_id,
11
- }
12
-
13
- # Public: Normalizes an options hash key
14
- #
15
- # key - The key to normalize
16
- #
17
- # Returns a Symbol.
18
- def call(key)
19
- NormalizedKeys.fetch key.to_sym, key
20
- end
21
- end
22
- end
23
- end
@@ -1,21 +0,0 @@
1
- require 'pp'
2
- require 'pathname'
3
- require 'benchmark'
4
- require 'rubygems'
5
- require 'bundler'
6
-
7
- Bundler.require :default, :performance
8
-
9
- root_path = Pathname(__FILE__).dirname.join('..').expand_path
10
- lib_path = root_path.join('lib')
11
- $:.unshift(lib_path)
12
- require 'plucky'
13
-
14
- criteria = Plucky::CriteriaHash.new(:foo => 'bar')
15
-
16
- PerfTools::CpuProfiler.start("/tmp/criteria_hash") do
17
- 1_000_000.times { criteria[:foo] = 'bar' }
18
- end
19
-
20
- puts system "pprof.rb --gif /tmp/criteria_hash > /tmp/criteria_hash.gif"
21
- puts system "open /tmp/criteria_hash.gif"
@@ -1,23 +0,0 @@
1
- require 'helper'
2
-
3
- describe Plucky::Normalizers::OptionsHashKey do
4
- subject {
5
- described_class.new
6
- }
7
-
8
- it "changes order to sort" do
9
- subject.call(:order).should eq(:sort)
10
- end
11
-
12
- it "changes select to fields" do
13
- subject.call(:select).should eq(:fields)
14
- end
15
-
16
- it "changes offset to skip" do
17
- subject.call(:offset).should eq(:skip)
18
- end
19
-
20
- it "changes id to _id" do
21
- subject.call(:id).should eq(:_id)
22
- end
23
- end