plucky 0.5.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/.bundle/config +4 -0
  2. data/.gitignore +3 -1
  3. data/.travis.yml +2 -2
  4. data/Gemfile +13 -3
  5. data/Guardfile +13 -0
  6. data/README.md +1 -1
  7. data/Rakefile +3 -17
  8. data/examples/query.rb +1 -1
  9. data/lib/plucky.rb +13 -0
  10. data/lib/plucky/criteria_hash.rb +85 -56
  11. data/lib/plucky/normalizers/criteria_hash_key.rb +17 -0
  12. data/lib/plucky/normalizers/criteria_hash_value.rb +83 -0
  13. data/lib/plucky/normalizers/fields_value.rb +26 -0
  14. data/lib/plucky/normalizers/integer.rb +19 -0
  15. data/lib/plucky/normalizers/options_hash_key.rb +23 -0
  16. data/lib/plucky/normalizers/options_hash_value.rb +85 -0
  17. data/lib/plucky/normalizers/sort_value.rb +55 -0
  18. data/lib/plucky/options_hash.rb +56 -85
  19. data/lib/plucky/pagination/decorator.rb +3 -2
  20. data/lib/plucky/pagination/paginator.rb +15 -6
  21. data/lib/plucky/query.rb +93 -51
  22. data/lib/plucky/version.rb +1 -1
  23. data/script/criteria_hash.rb +21 -0
  24. data/{test → spec}/helper.rb +12 -8
  25. data/spec/plucky/criteria_hash_spec.rb +166 -0
  26. data/spec/plucky/normalizers/criteria_hash_key_spec.rb +37 -0
  27. data/spec/plucky/normalizers/criteria_hash_value_spec.rb +193 -0
  28. data/spec/plucky/normalizers/fields_value_spec.rb +45 -0
  29. data/spec/plucky/normalizers/integer_spec.rb +24 -0
  30. data/spec/plucky/normalizers/options_hash_key_spec.rb +23 -0
  31. data/spec/plucky/normalizers/options_hash_value_spec.rb +99 -0
  32. data/spec/plucky/normalizers/sort_value_spec.rb +94 -0
  33. data/spec/plucky/options_hash_spec.rb +64 -0
  34. data/{test/plucky/pagination/test_decorator.rb → spec/plucky/pagination/decorator_spec.rb} +8 -10
  35. data/spec/plucky/pagination/paginator_spec.rb +118 -0
  36. data/spec/plucky/query_spec.rb +839 -0
  37. data/spec/plucky_spec.rb +68 -0
  38. data/{test/test_symbol_operator.rb → spec/symbol_operator_spec.rb} +14 -16
  39. data/spec/symbol_spec.rb +9 -0
  40. metadata +58 -23
  41. data/test/plucky/pagination/test_paginator.rb +0 -120
  42. data/test/plucky/test_criteria_hash.rb +0 -359
  43. data/test/plucky/test_options_hash.rb +0 -302
  44. data/test/plucky/test_query.rb +0 -843
  45. data/test/test_plucky.rb +0 -48
  46. data/test/test_symbol.rb +0 -11
@@ -1,48 +0,0 @@
1
- require 'helper'
2
-
3
- class PluckyTest < Test::Unit::TestCase
4
- context "Plucky" do
5
- context ".to_object_id" do
6
- setup do
7
- @id = BSON::ObjectId.new
8
- end
9
-
10
- should "convert nil to nil" do
11
- Plucky.to_object_id(nil).should be_nil
12
- end
13
-
14
- should "convert blank to nil" do
15
- Plucky.to_object_id('').should be_nil
16
- end
17
-
18
- should "leave object id alone" do
19
- Plucky.to_object_id(@id).should equal(@id)
20
- end
21
-
22
- should "convert string to object id" do
23
- Plucky.to_object_id(@id.to_s).should == @id
24
- end
25
-
26
- should "not convert string that is not legal object id" do
27
- Plucky.to_object_id('foo').should == 'foo'
28
- Plucky.to_object_id(1).should == 1
29
- end
30
- end
31
-
32
- context "::Methods" do
33
- should "return array of methods" do
34
- Plucky::Methods.should == [
35
- :where, :filter,
36
- :sort, :order, :reverse,
37
- :paginate, :per_page, :limit, :skip, :offset,
38
- :fields, :ignore, :only,
39
- :each, :find_each, :find_one, :find,
40
- :count, :size, :distinct,
41
- :last, :first, :all, :to_a,
42
- :exists?, :exist?, :empty?,
43
- :remove,
44
- ].sort_by(&:to_s)
45
- end
46
- end
47
- end
48
- end
@@ -1,11 +0,0 @@
1
- require 'helper'
2
-
3
- class SymbolTest < Test::Unit::TestCase
4
- context "Symbol" do
5
- SymbolOperators.each do |operator|
6
- should "respond to #{operator}" do
7
- :foo.send(operator).should be_instance_of(SymbolOperator)
8
- end
9
- end
10
- end
11
- end