samlown-couchrest 0.37.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/README.md +10 -4
  2. data/Rakefile +1 -1
  3. data/history.txt +8 -0
  4. data/lib/couchrest.rb +27 -49
  5. data/lib/couchrest/{core/database.rb → database.rb} +6 -11
  6. data/lib/couchrest/{core/design.rb → design.rb} +2 -2
  7. data/lib/couchrest/{core/document.rb → document.rb} +1 -1
  8. data/lib/couchrest/helper/attachments.rb +29 -0
  9. data/lib/couchrest/middlewares/logger.rb +3 -3
  10. data/lib/couchrest/monkeypatches.rb +1 -71
  11. data/lib/couchrest/{core/response.rb → response.rb} +0 -0
  12. data/lib/couchrest/{core/rest_api.rb → rest_api.rb} +9 -6
  13. data/lib/couchrest/{core/server.rb → server.rb} +0 -0
  14. data/spec/couchrest/{core/couchrest_spec.rb → couchrest_spec.rb} +16 -3
  15. data/spec/couchrest/{core/database_spec.rb → database_spec.rb} +2 -2
  16. data/spec/couchrest/{core/design_spec.rb → design_spec.rb} +2 -2
  17. data/spec/couchrest/{core/document_spec.rb → document_spec.rb} +1 -1
  18. data/spec/couchrest/{core/server_spec.rb → server_spec.rb} +2 -2
  19. data/spec/spec.opts +0 -1
  20. data/spec/spec_helper.rb +0 -4
  21. metadata +24 -113
  22. data/couchrest.gemspec +0 -183
  23. data/examples/model/example.rb +0 -144
  24. data/lib/couchrest/core/adapters/restclient.rb +0 -35
  25. data/lib/couchrest/core/http_abstraction.rb +0 -48
  26. data/lib/couchrest/core/view.rb +0 -4
  27. data/lib/couchrest/mixins.rb +0 -4
  28. data/lib/couchrest/mixins/attachments.rb +0 -31
  29. data/lib/couchrest/mixins/attribute_protection.rb +0 -74
  30. data/lib/couchrest/mixins/callbacks.rb +0 -532
  31. data/lib/couchrest/mixins/class_proxy.rb +0 -124
  32. data/lib/couchrest/mixins/collection.rb +0 -260
  33. data/lib/couchrest/mixins/design_doc.rb +0 -103
  34. data/lib/couchrest/mixins/document_queries.rb +0 -80
  35. data/lib/couchrest/mixins/extended_attachments.rb +0 -70
  36. data/lib/couchrest/mixins/extended_document_mixins.rb +0 -9
  37. data/lib/couchrest/mixins/properties.rb +0 -154
  38. data/lib/couchrest/mixins/validation.rb +0 -246
  39. data/lib/couchrest/mixins/views.rb +0 -173
  40. data/lib/couchrest/more/casted_array.rb +0 -25
  41. data/lib/couchrest/more/casted_model.rb +0 -58
  42. data/lib/couchrest/more/extended_document.rb +0 -310
  43. data/lib/couchrest/more/property.rb +0 -50
  44. data/lib/couchrest/more/typecast.rb +0 -175
  45. data/lib/couchrest/support/blank.rb +0 -42
  46. data/lib/couchrest/support/rails.rb +0 -42
  47. data/lib/couchrest/validation/auto_validate.rb +0 -157
  48. data/lib/couchrest/validation/contextual_validators.rb +0 -78
  49. data/lib/couchrest/validation/validation_errors.rb +0 -125
  50. data/lib/couchrest/validation/validators/absent_field_validator.rb +0 -74
  51. data/lib/couchrest/validation/validators/confirmation_validator.rb +0 -107
  52. data/lib/couchrest/validation/validators/format_validator.rb +0 -122
  53. data/lib/couchrest/validation/validators/formats/email.rb +0 -66
  54. data/lib/couchrest/validation/validators/formats/url.rb +0 -43
  55. data/lib/couchrest/validation/validators/generic_validator.rb +0 -120
  56. data/lib/couchrest/validation/validators/length_validator.rb +0 -139
  57. data/lib/couchrest/validation/validators/method_validator.rb +0 -89
  58. data/lib/couchrest/validation/validators/numeric_validator.rb +0 -109
  59. data/lib/couchrest/validation/validators/required_field_validator.rb +0 -114
  60. data/spec/couchrest/more/attribute_protection_spec.rb +0 -150
  61. data/spec/couchrest/more/casted_extended_doc_spec.rb +0 -79
  62. data/spec/couchrest/more/casted_model_spec.rb +0 -406
  63. data/spec/couchrest/more/extended_doc_attachment_spec.rb +0 -135
  64. data/spec/couchrest/more/extended_doc_inherited_spec.rb +0 -40
  65. data/spec/couchrest/more/extended_doc_spec.rb +0 -808
  66. data/spec/couchrest/more/extended_doc_subclass_spec.rb +0 -98
  67. data/spec/couchrest/more/extended_doc_view_spec.rb +0 -462
  68. data/spec/couchrest/more/property_spec.rb +0 -628
  69. data/spec/fixtures/more/article.rb +0 -35
  70. data/spec/fixtures/more/card.rb +0 -22
  71. data/spec/fixtures/more/cat.rb +0 -20
  72. data/spec/fixtures/more/course.rb +0 -22
  73. data/spec/fixtures/more/event.rb +0 -8
  74. data/spec/fixtures/more/invoice.rb +0 -17
  75. data/spec/fixtures/more/person.rb +0 -9
  76. data/spec/fixtures/more/question.rb +0 -6
  77. data/spec/fixtures/more/service.rb +0 -12
  78. data/spec/fixtures/more/user.rb +0 -22
@@ -1,35 +0,0 @@
1
- class Article < CouchRest::ExtendedDocument
2
- use_database DB
3
- unique_id :slug
4
-
5
- provides_collection :article_details, 'Article', 'by_date', :descending => true, :include_docs => true
6
- view_by :date, :descending => true
7
- view_by :user_id, :date
8
-
9
- view_by :tags,
10
- :map =>
11
- "function(doc) {
12
- if (doc['couchrest-type'] == 'Article' && doc.tags) {
13
- doc.tags.forEach(function(tag){
14
- emit(tag, 1);
15
- });
16
- }
17
- }",
18
- :reduce =>
19
- "function(keys, values, rereduce) {
20
- return sum(values);
21
- }"
22
-
23
- property :date, :type => 'Date'
24
- property :slug, :read_only => true
25
- property :title
26
- property :tags, :type => ['String']
27
-
28
- timestamps!
29
-
30
- before_save :generate_slug_from_title
31
-
32
- def generate_slug_from_title
33
- self['slug'] = title.downcase.gsub(/[^a-z0-9]/,'-').squeeze('-').gsub(/^\-|\-$/,'') if new?
34
- end
35
- end
@@ -1,22 +0,0 @@
1
- class Card < CouchRest::ExtendedDocument
2
- # Include the validation module to get access to the validation methods
3
- include CouchRest::Validation
4
- # set the auto_validation before defining the properties
5
- auto_validate!
6
-
7
- # Set the default database to use
8
- use_database DB
9
-
10
- # Official Schema
11
- property :first_name
12
- property :last_name, :alias => :family_name
13
- property :read_only_value, :read_only => true
14
- property :cast_alias, :cast_as => Person, :alias => :calias
15
-
16
-
17
- timestamps!
18
-
19
- # Validation
20
- validates_presence_of :first_name
21
-
22
- end
@@ -1,20 +0,0 @@
1
- class Cat < CouchRest::ExtendedDocument
2
- include ::CouchRest::Validation
3
-
4
- # Set the default database to use
5
- use_database DB
6
-
7
- property :name, :accessible => true
8
- property :toys, :cast_as => ['CatToy'], :default => [], :accessible => true
9
- property :favorite_toy, :cast_as => 'CatToy', :accessible => true
10
- property :number
11
- end
12
-
13
- class CatToy < Hash
14
- include ::CouchRest::CastedModel
15
- include ::CouchRest::Validation
16
-
17
- property :name
18
-
19
- validates_presence_of :name
20
- end
@@ -1,22 +0,0 @@
1
- require File.join(FIXTURE_PATH, 'more', 'question')
2
- require File.join(FIXTURE_PATH, 'more', 'person')
3
-
4
- class Course < CouchRest::ExtendedDocument
5
- use_database TEST_SERVER.default_database
6
-
7
- property :title, :cast_as => 'String'
8
- property :questions, :cast_as => ['Question']
9
- property :professor, :cast_as => 'Person'
10
- property :participants, :type => ['Object']
11
- property :ends_at, :type => 'Time'
12
- property :estimate, :type => 'Float'
13
- property :hours, :type => 'Integer'
14
- property :profit, :type => 'BigDecimal'
15
- property :started_on, :type => 'Date'
16
- property :updated_at, :type => 'DateTime'
17
- property :active, :type => 'Boolean'
18
- property :klass, :type => 'Class'
19
-
20
- view_by :title
21
- view_by :dept, :ducktype => true
22
- end
@@ -1,8 +0,0 @@
1
- class Event < CouchRest::ExtendedDocument
2
- use_database DB
3
-
4
- property :subject
5
- property :occurs_at, :cast_as => 'Time', :init_method => 'parse'
6
- property :end_date, :cast_as => 'Date', :init_method => 'parse'
7
-
8
- end
@@ -1,17 +0,0 @@
1
- class Invoice < CouchRest::ExtendedDocument
2
- # Include the validation module to get access to the validation methods
3
- include CouchRest::Validation
4
-
5
- # Set the default database to use
6
- use_database DB
7
-
8
- # Official Schema
9
- property :client_name
10
- property :employee_name
11
- property :location
12
-
13
- # Validation
14
- validates_presence_of :client_name, :employee_name
15
- validates_presence_of :location, :message => "Hey stupid!, you forgot the location"
16
-
17
- end
@@ -1,9 +0,0 @@
1
- class Person < Hash
2
- include ::CouchRest::CastedModel
3
- property :pet, :cast_as => 'Cat'
4
- property :name, :type => ['String']
5
-
6
- def last_name
7
- name.last
8
- end
9
- end
@@ -1,6 +0,0 @@
1
- class Question < Hash
2
- include ::CouchRest::CastedModel
3
-
4
- property :q
5
- property :a, :type => 'Object'
6
- end
@@ -1,12 +0,0 @@
1
- class Service < CouchRest::ExtendedDocument
2
- # Include the validation module to get access to the validation methods
3
- include CouchRest::Validation
4
- auto_validate!
5
- # Set the default database to use
6
- use_database DB
7
-
8
- # Official Schema
9
- property :name, :length => 4...20
10
- property :price, :type => 'Integer'
11
-
12
- end
@@ -1,22 +0,0 @@
1
- class User < CouchRest::ExtendedDocument
2
- # Set the default database to use
3
- use_database DB
4
- property :name, :accessible => true
5
- property :admin # this will be automatically protected
6
- end
7
-
8
- class SpecialUser < CouchRest::ExtendedDocument
9
- # Set the default database to use
10
- use_database DB
11
- property :name # this will not be protected
12
- property :admin, :protected => true
13
- end
14
-
15
- # There are two modes of protection
16
- # 1) Declare accessible poperties, assume all the rest are protected
17
- # property :name, :accessible => true
18
- # property :admin # this will be automatically protected
19
- #
20
- # 2) Declare protected properties, assume all the rest are accessible
21
- # property :name # this will not be protected
22
- # property :admin, :protected => true