couch_potato 0.6.0 → 0.7.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/.gitignore +0 -1
  2. data/.travis.yml +9 -1
  3. data/CHANGES.md +12 -0
  4. data/Gemfile.lock +29 -23
  5. data/MIT-LICENSE.txt +1 -1
  6. data/README.md +68 -38
  7. data/Rakefile +19 -60
  8. data/active_support_3_0.lock +4 -0
  9. data/active_support_3_1.lock +4 -0
  10. data/active_support_3_2 +4 -0
  11. data/active_support_3_2.lock +55 -0
  12. data/couch_potato.gemspec +1 -0
  13. data/lib/couch_potato/database.rb +55 -27
  14. data/lib/couch_potato/persistence/active_model_compliance.rb +6 -2
  15. data/lib/couch_potato/persistence/callbacks.rb +0 -1
  16. data/lib/couch_potato/persistence/dirty_attributes.rb +8 -17
  17. data/lib/couch_potato/persistence/json.rb +3 -2
  18. data/lib/couch_potato/persistence/properties.rb +19 -8
  19. data/lib/couch_potato/persistence/simple_property.rb +1 -3
  20. data/lib/couch_potato/persistence/type_caster.rb +7 -2
  21. data/lib/couch_potato/persistence.rb +27 -13
  22. data/lib/couch_potato/railtie.rb +1 -1
  23. data/lib/couch_potato/rspec/matchers/list_as_matcher.rb +12 -12
  24. data/lib/couch_potato/rspec/matchers/map_to_matcher.rb +8 -8
  25. data/lib/couch_potato/rspec/matchers/reduce_to_matcher.rb +10 -10
  26. data/lib/couch_potato/rspec/matchers.rb +8 -7
  27. data/lib/couch_potato/validation.rb +15 -11
  28. data/lib/couch_potato/version.rb +1 -1
  29. data/lib/couch_potato/view/base_view_spec.rb +14 -12
  30. data/lib/couch_potato/view/model_view_spec.rb +134 -39
  31. data/lib/couch_potato/view/properties_view_spec.rb +11 -7
  32. data/lib/couch_potato/view/view_query.rb +10 -9
  33. data/lib/couch_potato.rb +25 -10
  34. data/spec/callbacks_spec.rb +88 -0
  35. data/spec/create_spec.rb +22 -4
  36. data/spec/default_property_spec.rb +6 -0
  37. data/spec/property_spec.rb +81 -44
  38. data/spec/railtie_spec.rb +20 -18
  39. data/spec/spec_helper.rb +19 -1
  40. data/spec/unit/active_model_compliance_spec.rb +17 -11
  41. data/spec/unit/attributes_spec.rb +33 -10
  42. data/spec/unit/base_view_spec_spec.rb +19 -5
  43. data/spec/unit/couch_potato_spec.rb +1 -20
  44. data/spec/unit/create_spec.rb +2 -2
  45. data/spec/unit/database_spec.rb +113 -47
  46. data/spec/unit/dirty_attributes_spec.rb +19 -19
  47. data/spec/unit/model_view_spec_spec.rb +78 -1
  48. data/spec/unit/properties_view_spec_spec.rb +18 -5
  49. data/spec/unit/validation_spec.rb +1 -55
  50. data/spec/unit/view_query_spec.rb +48 -26
  51. data/spec/{custom_view_spec.rb → views_spec.rb} +59 -17
  52. metadata +88 -90
  53. data/.rvmrc +0 -1
  54. data/lib/core_ext/object.rb +0 -5
  55. data/lib/core_ext/string.rb +0 -12
  56. data/lib/core_ext/symbol.rb +0 -15
  57. data/lib/couch_potato/validation/with_active_model.rb +0 -27
  58. data/lib/couch_potato/validation/with_validatable.rb +0 -41
@@ -1,27 +0,0 @@
1
- module CouchPotato
2
- module Validation
3
- module WithActiveModel
4
- def self.included(base)
5
- require 'active_model'
6
- require 'active_model/translation'
7
- base.send :include, ::ActiveModel::Validations
8
- base.instance_eval do
9
- def before_validation(*names)
10
- names.each do |name|
11
- validate name
12
- end
13
- end
14
- end
15
- end
16
- end
17
- end
18
- end
19
-
20
- # provide same interface to errors object as in Validatable
21
- module ::ActiveModel
22
- class Errors
23
- def errors
24
- self
25
- end
26
- end
27
- end
@@ -1,41 +0,0 @@
1
- module CouchPotato
2
- module Validation
3
- module WithValidatable
4
- def self.included(base)
5
- begin
6
- require 'validatable'
7
- rescue LoadError
8
- puts "Please install the gem validatable using 'gem install validatable'"
9
- raise
10
- end
11
- base.send :include, ::Validatable
12
- base.class_eval do
13
- # Override the validate method to first run before_validation callback
14
- def valid_with_before_validation_callback?
15
- errors.clear
16
- run_callbacks :validation do
17
- before_validation_errors = errors.errors.dup
18
- valid_without_before_validation_callback?
19
- before_validation_errors.each do |k, v|
20
- v.each {|message| errors.add(k, message)}
21
- end
22
- end
23
- errors.empty?
24
- end
25
-
26
- alias_method :valid_without_before_validation_callback?, :valid?
27
- alias_method :valid?, :valid_with_before_validation_callback?
28
- end
29
- end
30
- end
31
- end
32
- end
33
-
34
- # add [] method to Validatable's implementation of the Errors class
35
- module Validatable
36
- class Errors
37
- def [](attribute)
38
- [on(attribute)].flatten.compact
39
- end
40
- end
41
- end