samlown-couchrest 0.37.2 → 1.0.0
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.
- data/README.md +10 -4
 - data/Rakefile +1 -1
 - data/history.txt +8 -0
 - data/lib/couchrest.rb +27 -49
 - data/lib/couchrest/{core/database.rb → database.rb} +6 -11
 - data/lib/couchrest/{core/design.rb → design.rb} +2 -2
 - data/lib/couchrest/{core/document.rb → document.rb} +1 -1
 - data/lib/couchrest/helper/attachments.rb +29 -0
 - data/lib/couchrest/middlewares/logger.rb +3 -3
 - data/lib/couchrest/monkeypatches.rb +1 -71
 - data/lib/couchrest/{core/response.rb → response.rb} +0 -0
 - data/lib/couchrest/{core/rest_api.rb → rest_api.rb} +9 -6
 - data/lib/couchrest/{core/server.rb → server.rb} +0 -0
 - data/spec/couchrest/{core/couchrest_spec.rb → couchrest_spec.rb} +16 -3
 - data/spec/couchrest/{core/database_spec.rb → database_spec.rb} +2 -2
 - data/spec/couchrest/{core/design_spec.rb → design_spec.rb} +2 -2
 - data/spec/couchrest/{core/document_spec.rb → document_spec.rb} +1 -1
 - data/spec/couchrest/{core/server_spec.rb → server_spec.rb} +2 -2
 - data/spec/spec.opts +0 -1
 - data/spec/spec_helper.rb +0 -4
 - metadata +24 -113
 - data/couchrest.gemspec +0 -183
 - data/examples/model/example.rb +0 -144
 - data/lib/couchrest/core/adapters/restclient.rb +0 -35
 - data/lib/couchrest/core/http_abstraction.rb +0 -48
 - data/lib/couchrest/core/view.rb +0 -4
 - data/lib/couchrest/mixins.rb +0 -4
 - data/lib/couchrest/mixins/attachments.rb +0 -31
 - data/lib/couchrest/mixins/attribute_protection.rb +0 -74
 - data/lib/couchrest/mixins/callbacks.rb +0 -532
 - data/lib/couchrest/mixins/class_proxy.rb +0 -124
 - data/lib/couchrest/mixins/collection.rb +0 -260
 - data/lib/couchrest/mixins/design_doc.rb +0 -103
 - data/lib/couchrest/mixins/document_queries.rb +0 -80
 - data/lib/couchrest/mixins/extended_attachments.rb +0 -70
 - data/lib/couchrest/mixins/extended_document_mixins.rb +0 -9
 - data/lib/couchrest/mixins/properties.rb +0 -154
 - data/lib/couchrest/mixins/validation.rb +0 -246
 - data/lib/couchrest/mixins/views.rb +0 -173
 - data/lib/couchrest/more/casted_array.rb +0 -25
 - data/lib/couchrest/more/casted_model.rb +0 -58
 - data/lib/couchrest/more/extended_document.rb +0 -310
 - data/lib/couchrest/more/property.rb +0 -50
 - data/lib/couchrest/more/typecast.rb +0 -175
 - data/lib/couchrest/support/blank.rb +0 -42
 - data/lib/couchrest/support/rails.rb +0 -42
 - data/lib/couchrest/validation/auto_validate.rb +0 -157
 - data/lib/couchrest/validation/contextual_validators.rb +0 -78
 - data/lib/couchrest/validation/validation_errors.rb +0 -125
 - data/lib/couchrest/validation/validators/absent_field_validator.rb +0 -74
 - data/lib/couchrest/validation/validators/confirmation_validator.rb +0 -107
 - data/lib/couchrest/validation/validators/format_validator.rb +0 -122
 - data/lib/couchrest/validation/validators/formats/email.rb +0 -66
 - data/lib/couchrest/validation/validators/formats/url.rb +0 -43
 - data/lib/couchrest/validation/validators/generic_validator.rb +0 -120
 - data/lib/couchrest/validation/validators/length_validator.rb +0 -139
 - data/lib/couchrest/validation/validators/method_validator.rb +0 -89
 - data/lib/couchrest/validation/validators/numeric_validator.rb +0 -109
 - data/lib/couchrest/validation/validators/required_field_validator.rb +0 -114
 - data/spec/couchrest/more/attribute_protection_spec.rb +0 -150
 - data/spec/couchrest/more/casted_extended_doc_spec.rb +0 -79
 - data/spec/couchrest/more/casted_model_spec.rb +0 -406
 - data/spec/couchrest/more/extended_doc_attachment_spec.rb +0 -135
 - data/spec/couchrest/more/extended_doc_inherited_spec.rb +0 -40
 - data/spec/couchrest/more/extended_doc_spec.rb +0 -808
 - data/spec/couchrest/more/extended_doc_subclass_spec.rb +0 -98
 - data/spec/couchrest/more/extended_doc_view_spec.rb +0 -462
 - data/spec/couchrest/more/property_spec.rb +0 -628
 - data/spec/fixtures/more/article.rb +0 -35
 - data/spec/fixtures/more/card.rb +0 -22
 - data/spec/fixtures/more/cat.rb +0 -20
 - data/spec/fixtures/more/course.rb +0 -22
 - data/spec/fixtures/more/event.rb +0 -8
 - data/spec/fixtures/more/invoice.rb +0 -17
 - data/spec/fixtures/more/person.rb +0 -9
 - data/spec/fixtures/more/question.rb +0 -6
 - data/spec/fixtures/more/service.rb +0 -12
 - data/spec/fixtures/more/user.rb +0 -22
 
| 
         @@ -1,4 +1,4 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require File.expand_path(" 
     | 
| 
      
 1 
     | 
    
         
            +
            require File.expand_path("../../spec_helper", __FILE__)
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            describe CouchRest::Database do
         
     | 
| 
       4 
4 
     | 
    
         
             
              before(:each) do
         
     | 
| 
         @@ -391,7 +391,7 @@ describe CouchRest::Database do 
     | 
|
| 
       391 
391 
     | 
    
         | 
| 
       392 
392 
     | 
    
         
             
                it "should force a delete even if we get a 409" do
         
     | 
| 
       393 
393 
     | 
    
         
             
                  @doc['new_attribute'] = 'something new'
         
     | 
| 
       394 
     | 
    
         
            -
                  @db.put_attachment(@doc, 'test', File.open(File.join( 
     | 
| 
      
 394 
     | 
    
         
            +
                  @db.put_attachment(@doc, 'test', File.open(File.join(FIXTURE_PATH, 'attachments', 'test.html')).read)
         
     | 
| 
       395 
395 
     | 
    
         
             
                  # at this point the revision number changed, if we try to save doc one more time
         
     | 
| 
       396 
396 
     | 
    
         
             
                  # we would get a 409.
         
     | 
| 
       397 
397 
     | 
    
         
             
                  lambda{ @db.save_doc(@doc) }.should raise_error
         
     | 
    
        data/spec/spec.opts
    CHANGED
    
    
    
        data/spec/spec_helper.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -3,10 +3,10 @@ name: samlown-couchrest 
     | 
|
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
4 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       5 
5 
     | 
    
         
             
              segments: 
         
     | 
| 
      
 6 
     | 
    
         
            +
              - 1
         
     | 
| 
       6 
7 
     | 
    
         
             
              - 0
         
     | 
| 
       7 
     | 
    
         
            -
              -  
     | 
| 
       8 
     | 
    
         
            -
               
     | 
| 
       9 
     | 
    
         
            -
              version: 0.37.2
         
     | 
| 
      
 8 
     | 
    
         
            +
              - 0
         
     | 
| 
      
 9 
     | 
    
         
            +
              version: 1.0.0
         
     | 
| 
       10 
10 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       11 
11 
     | 
    
         
             
            authors: 
         
     | 
| 
       12 
12 
     | 
    
         
             
            - J. Chris Anderson
         
     | 
| 
         @@ -17,7 +17,7 @@ autorequire: 
     | 
|
| 
       17 
17 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       18 
18 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
            date: 2010- 
     | 
| 
      
 20 
     | 
    
         
            +
            date: 2010-05-10 00:00:00 +02:00
         
     | 
| 
       21 
21 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       22 
22 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       23 
23 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
         @@ -33,19 +33,6 @@ dependencies: 
     | 
|
| 
       33 
33 
     | 
    
         
             
                    version: "0.5"
         
     | 
| 
       34 
34 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       35 
35 
     | 
    
         
             
              version_requirements: *id001
         
     | 
| 
       36 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       37 
     | 
    
         
            -
              name: mime-types
         
     | 
| 
       38 
     | 
    
         
            -
              prerelease: false
         
     | 
| 
       39 
     | 
    
         
            -
              requirement: &id002 !ruby/object:Gem::Requirement 
         
     | 
| 
       40 
     | 
    
         
            -
                requirements: 
         
     | 
| 
       41 
     | 
    
         
            -
                - - ">="
         
     | 
| 
       42 
     | 
    
         
            -
                  - !ruby/object:Gem::Version 
         
     | 
| 
       43 
     | 
    
         
            -
                    segments: 
         
     | 
| 
       44 
     | 
    
         
            -
                    - 1
         
     | 
| 
       45 
     | 
    
         
            -
                    - 15
         
     | 
| 
       46 
     | 
    
         
            -
                    version: "1.15"
         
     | 
| 
       47 
     | 
    
         
            -
              type: :runtime
         
     | 
| 
       48 
     | 
    
         
            -
              version_requirements: *id002
         
     | 
| 
       49 
36 
     | 
    
         
             
            description: CouchRest provides a simple interface on top of CouchDB's RESTful HTTP API, as well as including some utility scripts for managing views and attachments.
         
     | 
| 
       50 
37 
     | 
    
         
             
            email: jchris@apache.org
         
     | 
| 
       51 
38 
     | 
    
         
             
            executables: []
         
     | 
| 
         @@ -61,8 +48,6 @@ files: 
     | 
|
| 
       61 
48 
     | 
    
         
             
            - README.md
         
     | 
| 
       62 
49 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       63 
50 
     | 
    
         
             
            - THANKS.md
         
     | 
| 
       64 
     | 
    
         
            -
            - couchrest.gemspec
         
     | 
| 
       65 
     | 
    
         
            -
            - examples/model/example.rb
         
     | 
| 
       66 
51 
     | 
    
         
             
            - examples/word_count/markov
         
     | 
| 
       67 
52 
     | 
    
         
             
            - examples/word_count/views/books/chunked-map.js
         
     | 
| 
       68 
53 
     | 
    
         
             
            - examples/word_count/views/books/united-map.js
         
     | 
| 
         @@ -77,83 +62,29 @@ files: 
     | 
|
| 
       77 
62 
     | 
    
         
             
            - lib/couchrest.rb
         
     | 
| 
       78 
63 
     | 
    
         
             
            - lib/couchrest/commands/generate.rb
         
     | 
| 
       79 
64 
     | 
    
         
             
            - lib/couchrest/commands/push.rb
         
     | 
| 
       80 
     | 
    
         
            -
            - lib/couchrest/ 
     | 
| 
       81 
     | 
    
         
            -
            - lib/couchrest/ 
     | 
| 
       82 
     | 
    
         
            -
            - lib/couchrest/ 
     | 
| 
       83 
     | 
    
         
            -
            - lib/couchrest/ 
     | 
| 
       84 
     | 
    
         
            -
            - lib/couchrest/core/http_abstraction.rb
         
     | 
| 
       85 
     | 
    
         
            -
            - lib/couchrest/core/response.rb
         
     | 
| 
       86 
     | 
    
         
            -
            - lib/couchrest/core/rest_api.rb
         
     | 
| 
       87 
     | 
    
         
            -
            - lib/couchrest/core/server.rb
         
     | 
| 
       88 
     | 
    
         
            -
            - lib/couchrest/core/view.rb
         
     | 
| 
      
 65 
     | 
    
         
            +
            - lib/couchrest/database.rb
         
     | 
| 
      
 66 
     | 
    
         
            +
            - lib/couchrest/design.rb
         
     | 
| 
      
 67 
     | 
    
         
            +
            - lib/couchrest/document.rb
         
     | 
| 
      
 68 
     | 
    
         
            +
            - lib/couchrest/helper/attachments.rb
         
     | 
| 
       89 
69 
     | 
    
         
             
            - lib/couchrest/helper/pager.rb
         
     | 
| 
       90 
70 
     | 
    
         
             
            - lib/couchrest/helper/streamer.rb
         
     | 
| 
       91 
71 
     | 
    
         
             
            - lib/couchrest/helper/upgrade.rb
         
     | 
| 
       92 
72 
     | 
    
         
             
            - lib/couchrest/middlewares/logger.rb
         
     | 
| 
       93 
     | 
    
         
            -
            - lib/couchrest/mixins.rb
         
     | 
| 
       94 
     | 
    
         
            -
            - lib/couchrest/mixins/attachments.rb
         
     | 
| 
       95 
     | 
    
         
            -
            - lib/couchrest/mixins/attribute_protection.rb
         
     | 
| 
       96 
     | 
    
         
            -
            - lib/couchrest/mixins/callbacks.rb
         
     | 
| 
       97 
     | 
    
         
            -
            - lib/couchrest/mixins/class_proxy.rb
         
     | 
| 
       98 
     | 
    
         
            -
            - lib/couchrest/mixins/collection.rb
         
     | 
| 
       99 
     | 
    
         
            -
            - lib/couchrest/mixins/design_doc.rb
         
     | 
| 
       100 
     | 
    
         
            -
            - lib/couchrest/mixins/document_queries.rb
         
     | 
| 
       101 
     | 
    
         
            -
            - lib/couchrest/mixins/extended_attachments.rb
         
     | 
| 
       102 
     | 
    
         
            -
            - lib/couchrest/mixins/extended_document_mixins.rb
         
     | 
| 
       103 
     | 
    
         
            -
            - lib/couchrest/mixins/properties.rb
         
     | 
| 
       104 
     | 
    
         
            -
            - lib/couchrest/mixins/validation.rb
         
     | 
| 
       105 
     | 
    
         
            -
            - lib/couchrest/mixins/views.rb
         
     | 
| 
       106 
73 
     | 
    
         
             
            - lib/couchrest/monkeypatches.rb
         
     | 
| 
       107 
     | 
    
         
            -
            - lib/couchrest/ 
     | 
| 
       108 
     | 
    
         
            -
            - lib/couchrest/ 
     | 
| 
       109 
     | 
    
         
            -
            - lib/couchrest/ 
     | 
| 
       110 
     | 
    
         
            -
            - lib/couchrest/more/property.rb
         
     | 
| 
       111 
     | 
    
         
            -
            - lib/couchrest/more/typecast.rb
         
     | 
| 
       112 
     | 
    
         
            -
            - lib/couchrest/support/blank.rb
         
     | 
| 
      
 74 
     | 
    
         
            +
            - lib/couchrest/response.rb
         
     | 
| 
      
 75 
     | 
    
         
            +
            - lib/couchrest/rest_api.rb
         
     | 
| 
      
 76 
     | 
    
         
            +
            - lib/couchrest/server.rb
         
     | 
| 
       113 
77 
     | 
    
         
             
            - lib/couchrest/support/class.rb
         
     | 
| 
       114 
     | 
    
         
            -
            -  
     | 
| 
       115 
     | 
    
         
            -
            -  
     | 
| 
       116 
     | 
    
         
            -
            -  
     | 
| 
       117 
     | 
    
         
            -
            -  
     | 
| 
       118 
     | 
    
         
            -
            - lib/couchrest/validation/validators/absent_field_validator.rb
         
     | 
| 
       119 
     | 
    
         
            -
            - lib/couchrest/validation/validators/confirmation_validator.rb
         
     | 
| 
       120 
     | 
    
         
            -
            - lib/couchrest/validation/validators/format_validator.rb
         
     | 
| 
       121 
     | 
    
         
            -
            - lib/couchrest/validation/validators/formats/email.rb
         
     | 
| 
       122 
     | 
    
         
            -
            - lib/couchrest/validation/validators/formats/url.rb
         
     | 
| 
       123 
     | 
    
         
            -
            - lib/couchrest/validation/validators/generic_validator.rb
         
     | 
| 
       124 
     | 
    
         
            -
            - lib/couchrest/validation/validators/length_validator.rb
         
     | 
| 
       125 
     | 
    
         
            -
            - lib/couchrest/validation/validators/method_validator.rb
         
     | 
| 
       126 
     | 
    
         
            -
            - lib/couchrest/validation/validators/numeric_validator.rb
         
     | 
| 
       127 
     | 
    
         
            -
            - lib/couchrest/validation/validators/required_field_validator.rb
         
     | 
| 
       128 
     | 
    
         
            -
            - spec/couchrest/core/couchrest_spec.rb
         
     | 
| 
       129 
     | 
    
         
            -
            - spec/couchrest/core/database_spec.rb
         
     | 
| 
       130 
     | 
    
         
            -
            - spec/couchrest/core/design_spec.rb
         
     | 
| 
       131 
     | 
    
         
            -
            - spec/couchrest/core/document_spec.rb
         
     | 
| 
       132 
     | 
    
         
            -
            - spec/couchrest/core/server_spec.rb
         
     | 
| 
      
 78 
     | 
    
         
            +
            - spec/couchrest/couchrest_spec.rb
         
     | 
| 
      
 79 
     | 
    
         
            +
            - spec/couchrest/database_spec.rb
         
     | 
| 
      
 80 
     | 
    
         
            +
            - spec/couchrest/design_spec.rb
         
     | 
| 
      
 81 
     | 
    
         
            +
            - spec/couchrest/document_spec.rb
         
     | 
| 
       133 
82 
     | 
    
         
             
            - spec/couchrest/helpers/pager_spec.rb
         
     | 
| 
       134 
83 
     | 
    
         
             
            - spec/couchrest/helpers/streamer_spec.rb
         
     | 
| 
       135 
     | 
    
         
            -
            - spec/couchrest/ 
     | 
| 
       136 
     | 
    
         
            -
            - spec/couchrest/more/casted_extended_doc_spec.rb
         
     | 
| 
       137 
     | 
    
         
            -
            - spec/couchrest/more/casted_model_spec.rb
         
     | 
| 
       138 
     | 
    
         
            -
            - spec/couchrest/more/extended_doc_attachment_spec.rb
         
     | 
| 
       139 
     | 
    
         
            -
            - spec/couchrest/more/extended_doc_inherited_spec.rb
         
     | 
| 
       140 
     | 
    
         
            -
            - spec/couchrest/more/extended_doc_spec.rb
         
     | 
| 
       141 
     | 
    
         
            -
            - spec/couchrest/more/extended_doc_subclass_spec.rb
         
     | 
| 
       142 
     | 
    
         
            -
            - spec/couchrest/more/extended_doc_view_spec.rb
         
     | 
| 
       143 
     | 
    
         
            -
            - spec/couchrest/more/property_spec.rb
         
     | 
| 
      
 84 
     | 
    
         
            +
            - spec/couchrest/server_spec.rb
         
     | 
| 
       144 
85 
     | 
    
         
             
            - spec/fixtures/attachments/README
         
     | 
| 
       145 
86 
     | 
    
         
             
            - spec/fixtures/attachments/couchdb.png
         
     | 
| 
       146 
87 
     | 
    
         
             
            - spec/fixtures/attachments/test.html
         
     | 
| 
       147 
     | 
    
         
            -
            - spec/fixtures/more/article.rb
         
     | 
| 
       148 
     | 
    
         
            -
            - spec/fixtures/more/card.rb
         
     | 
| 
       149 
     | 
    
         
            -
            - spec/fixtures/more/cat.rb
         
     | 
| 
       150 
     | 
    
         
            -
            - spec/fixtures/more/course.rb
         
     | 
| 
       151 
     | 
    
         
            -
            - spec/fixtures/more/event.rb
         
     | 
| 
       152 
     | 
    
         
            -
            - spec/fixtures/more/invoice.rb
         
     | 
| 
       153 
     | 
    
         
            -
            - spec/fixtures/more/person.rb
         
     | 
| 
       154 
     | 
    
         
            -
            - spec/fixtures/more/question.rb
         
     | 
| 
       155 
     | 
    
         
            -
            - spec/fixtures/more/service.rb
         
     | 
| 
       156 
     | 
    
         
            -
            - spec/fixtures/more/user.rb
         
     | 
| 
       157 
88 
     | 
    
         
             
            - spec/fixtures/views/lib.js
         
     | 
| 
       158 
89 
     | 
    
         
             
            - spec/fixtures/views/test_view/lib.js
         
     | 
| 
       159 
90 
     | 
    
         
             
            - spec/fixtures/views/test_view/only-map.js
         
     | 
| 
         @@ -194,34 +125,14 @@ signing_key: 
     | 
|
| 
       194 
125 
     | 
    
         
             
            specification_version: 3
         
     | 
| 
       195 
126 
     | 
    
         
             
            summary: Lean and RESTful interface to CouchDB.
         
     | 
| 
       196 
127 
     | 
    
         
             
            test_files: 
         
     | 
| 
       197 
     | 
    
         
            -
            - spec/couchrest/more/extended_doc_attachment_spec.rb
         
     | 
| 
       198 
     | 
    
         
            -
            - spec/couchrest/more/casted_extended_doc_spec.rb
         
     | 
| 
       199 
     | 
    
         
            -
            - spec/couchrest/more/extended_doc_inherited_spec.rb
         
     | 
| 
       200 
     | 
    
         
            -
            - spec/couchrest/more/casted_model_spec.rb
         
     | 
| 
       201 
     | 
    
         
            -
            - spec/couchrest/more/extended_doc_view_spec.rb
         
     | 
| 
       202 
     | 
    
         
            -
            - spec/couchrest/more/extended_doc_spec.rb
         
     | 
| 
       203 
     | 
    
         
            -
            - spec/couchrest/more/property_spec.rb
         
     | 
| 
       204 
     | 
    
         
            -
            - spec/couchrest/more/attribute_protection_spec.rb
         
     | 
| 
       205 
     | 
    
         
            -
            - spec/couchrest/more/extended_doc_subclass_spec.rb
         
     | 
| 
       206 
     | 
    
         
            -
            - spec/couchrest/helpers/streamer_spec.rb
         
     | 
| 
       207 
     | 
    
         
            -
            - spec/couchrest/helpers/pager_spec.rb
         
     | 
| 
       208 
     | 
    
         
            -
            - spec/couchrest/core/design_spec.rb
         
     | 
| 
       209 
     | 
    
         
            -
            - spec/couchrest/core/server_spec.rb
         
     | 
| 
       210 
     | 
    
         
            -
            - spec/couchrest/core/couchrest_spec.rb
         
     | 
| 
       211 
     | 
    
         
            -
            - spec/couchrest/core/database_spec.rb
         
     | 
| 
       212 
     | 
    
         
            -
            - spec/couchrest/core/document_spec.rb
         
     | 
| 
       213 
     | 
    
         
            -
            - spec/fixtures/more/person.rb
         
     | 
| 
       214 
     | 
    
         
            -
            - spec/fixtures/more/cat.rb
         
     | 
| 
       215 
     | 
    
         
            -
            - spec/fixtures/more/card.rb
         
     | 
| 
       216 
     | 
    
         
            -
            - spec/fixtures/more/course.rb
         
     | 
| 
       217 
     | 
    
         
            -
            - spec/fixtures/more/service.rb
         
     | 
| 
       218 
     | 
    
         
            -
            - spec/fixtures/more/article.rb
         
     | 
| 
       219 
     | 
    
         
            -
            - spec/fixtures/more/invoice.rb
         
     | 
| 
       220 
     | 
    
         
            -
            - spec/fixtures/more/user.rb
         
     | 
| 
       221 
     | 
    
         
            -
            - spec/fixtures/more/event.rb
         
     | 
| 
       222 
     | 
    
         
            -
            - spec/fixtures/more/question.rb
         
     | 
| 
       223 
128 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       224 
     | 
    
         
            -
            -  
     | 
| 
      
 129 
     | 
    
         
            +
            - spec/couchrest/server_spec.rb
         
     | 
| 
      
 130 
     | 
    
         
            +
            - spec/couchrest/helpers/pager_spec.rb
         
     | 
| 
      
 131 
     | 
    
         
            +
            - spec/couchrest/helpers/streamer_spec.rb
         
     | 
| 
      
 132 
     | 
    
         
            +
            - spec/couchrest/document_spec.rb
         
     | 
| 
      
 133 
     | 
    
         
            +
            - spec/couchrest/couchrest_spec.rb
         
     | 
| 
      
 134 
     | 
    
         
            +
            - spec/couchrest/design_spec.rb
         
     | 
| 
      
 135 
     | 
    
         
            +
            - spec/couchrest/database_spec.rb
         
     | 
| 
       225 
136 
     | 
    
         
             
            - examples/word_count/word_count.rb
         
     | 
| 
      
 137 
     | 
    
         
            +
            - examples/word_count/word_count_views.rb
         
     | 
| 
       226 
138 
     | 
    
         
             
            - examples/word_count/word_count_query.rb
         
     | 
| 
       227 
     | 
    
         
            -
            - examples/model/example.rb
         
     | 
    
        data/couchrest.gemspec
    DELETED
    
    | 
         @@ -1,183 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # Generated by jeweler
         
     | 
| 
       2 
     | 
    
         
            -
            # DO NOT EDIT THIS FILE DIRECTLY
         
     | 
| 
       3 
     | 
    
         
            -
            # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
         
     | 
| 
       4 
     | 
    
         
            -
            # -*- encoding: utf-8 -*-
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            Gem::Specification.new do |s|
         
     | 
| 
       7 
     | 
    
         
            -
              s.name = %q{couchrest}
         
     | 
| 
       8 
     | 
    
         
            -
              s.version = "0.37"
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         
     | 
| 
       11 
     | 
    
         
            -
              s.authors = ["J. Chris Anderson", "Matt Aimonetti", "Marcos Tapajos", "Will Leinweber"]
         
     | 
| 
       12 
     | 
    
         
            -
              s.date = %q{2010-04-05}
         
     | 
| 
       13 
     | 
    
         
            -
              s.description = %q{CouchRest provides a simple interface on top of CouchDB's RESTful HTTP API, as well as including some utility scripts for managing views and attachments.}
         
     | 
| 
       14 
     | 
    
         
            -
              s.email = %q{jchris@apache.org}
         
     | 
| 
       15 
     | 
    
         
            -
              s.extra_rdoc_files = [
         
     | 
| 
       16 
     | 
    
         
            -
                "LICENSE",
         
     | 
| 
       17 
     | 
    
         
            -
                 "README.md",
         
     | 
| 
       18 
     | 
    
         
            -
                 "THANKS.md"
         
     | 
| 
       19 
     | 
    
         
            -
              ]
         
     | 
| 
       20 
     | 
    
         
            -
              s.files = [
         
     | 
| 
       21 
     | 
    
         
            -
                "LICENSE",
         
     | 
| 
       22 
     | 
    
         
            -
                 "README.md",
         
     | 
| 
       23 
     | 
    
         
            -
                 "Rakefile",
         
     | 
| 
       24 
     | 
    
         
            -
                 "THANKS.md",
         
     | 
| 
       25 
     | 
    
         
            -
                 "couchrest.gemspec",
         
     | 
| 
       26 
     | 
    
         
            -
                 "examples/model/example.rb",
         
     | 
| 
       27 
     | 
    
         
            -
                 "examples/word_count/markov",
         
     | 
| 
       28 
     | 
    
         
            -
                 "examples/word_count/views/books/chunked-map.js",
         
     | 
| 
       29 
     | 
    
         
            -
                 "examples/word_count/views/books/united-map.js",
         
     | 
| 
       30 
     | 
    
         
            -
                 "examples/word_count/views/markov/chain-map.js",
         
     | 
| 
       31 
     | 
    
         
            -
                 "examples/word_count/views/markov/chain-reduce.js",
         
     | 
| 
       32 
     | 
    
         
            -
                 "examples/word_count/views/word_count/count-map.js",
         
     | 
| 
       33 
     | 
    
         
            -
                 "examples/word_count/views/word_count/count-reduce.js",
         
     | 
| 
       34 
     | 
    
         
            -
                 "examples/word_count/word_count.rb",
         
     | 
| 
       35 
     | 
    
         
            -
                 "examples/word_count/word_count_query.rb",
         
     | 
| 
       36 
     | 
    
         
            -
                 "examples/word_count/word_count_views.rb",
         
     | 
| 
       37 
     | 
    
         
            -
                 "history.txt",
         
     | 
| 
       38 
     | 
    
         
            -
                 "lib/couchrest.rb",
         
     | 
| 
       39 
     | 
    
         
            -
                 "lib/couchrest/commands/generate.rb",
         
     | 
| 
       40 
     | 
    
         
            -
                 "lib/couchrest/commands/push.rb",
         
     | 
| 
       41 
     | 
    
         
            -
                 "lib/couchrest/core/adapters/restclient.rb",
         
     | 
| 
       42 
     | 
    
         
            -
                 "lib/couchrest/core/database.rb",
         
     | 
| 
       43 
     | 
    
         
            -
                 "lib/couchrest/core/design.rb",
         
     | 
| 
       44 
     | 
    
         
            -
                 "lib/couchrest/core/document.rb",
         
     | 
| 
       45 
     | 
    
         
            -
                 "lib/couchrest/core/http_abstraction.rb",
         
     | 
| 
       46 
     | 
    
         
            -
                 "lib/couchrest/core/response.rb",
         
     | 
| 
       47 
     | 
    
         
            -
                 "lib/couchrest/core/rest_api.rb",
         
     | 
| 
       48 
     | 
    
         
            -
                 "lib/couchrest/core/server.rb",
         
     | 
| 
       49 
     | 
    
         
            -
                 "lib/couchrest/core/view.rb",
         
     | 
| 
       50 
     | 
    
         
            -
                 "lib/couchrest/helper/pager.rb",
         
     | 
| 
       51 
     | 
    
         
            -
                 "lib/couchrest/helper/streamer.rb",
         
     | 
| 
       52 
     | 
    
         
            -
                 "lib/couchrest/helper/upgrade.rb",
         
     | 
| 
       53 
     | 
    
         
            -
                 "lib/couchrest/middlewares/logger.rb",
         
     | 
| 
       54 
     | 
    
         
            -
                 "lib/couchrest/mixins.rb",
         
     | 
| 
       55 
     | 
    
         
            -
                 "lib/couchrest/mixins/attachments.rb",
         
     | 
| 
       56 
     | 
    
         
            -
                 "lib/couchrest/mixins/attribute_protection.rb",
         
     | 
| 
       57 
     | 
    
         
            -
                 "lib/couchrest/mixins/callbacks.rb",
         
     | 
| 
       58 
     | 
    
         
            -
                 "lib/couchrest/mixins/class_proxy.rb",
         
     | 
| 
       59 
     | 
    
         
            -
                 "lib/couchrest/mixins/collection.rb",
         
     | 
| 
       60 
     | 
    
         
            -
                 "lib/couchrest/mixins/design_doc.rb",
         
     | 
| 
       61 
     | 
    
         
            -
                 "lib/couchrest/mixins/document_queries.rb",
         
     | 
| 
       62 
     | 
    
         
            -
                 "lib/couchrest/mixins/extended_attachments.rb",
         
     | 
| 
       63 
     | 
    
         
            -
                 "lib/couchrest/mixins/extended_document_mixins.rb",
         
     | 
| 
       64 
     | 
    
         
            -
                 "lib/couchrest/mixins/properties.rb",
         
     | 
| 
       65 
     | 
    
         
            -
                 "lib/couchrest/mixins/validation.rb",
         
     | 
| 
       66 
     | 
    
         
            -
                 "lib/couchrest/mixins/views.rb",
         
     | 
| 
       67 
     | 
    
         
            -
                 "lib/couchrest/monkeypatches.rb",
         
     | 
| 
       68 
     | 
    
         
            -
                 "lib/couchrest/more/casted_array.rb",
         
     | 
| 
       69 
     | 
    
         
            -
                 "lib/couchrest/more/casted_model.rb",
         
     | 
| 
       70 
     | 
    
         
            -
                 "lib/couchrest/more/extended_document.rb",
         
     | 
| 
       71 
     | 
    
         
            -
                 "lib/couchrest/more/property.rb",
         
     | 
| 
       72 
     | 
    
         
            -
                 "lib/couchrest/more/typecast.rb",
         
     | 
| 
       73 
     | 
    
         
            -
                 "lib/couchrest/support/blank.rb",
         
     | 
| 
       74 
     | 
    
         
            -
                 "lib/couchrest/support/class.rb",
         
     | 
| 
       75 
     | 
    
         
            -
                 "lib/couchrest/support/rails.rb",
         
     | 
| 
       76 
     | 
    
         
            -
                 "lib/couchrest/validation/auto_validate.rb",
         
     | 
| 
       77 
     | 
    
         
            -
                 "lib/couchrest/validation/contextual_validators.rb",
         
     | 
| 
       78 
     | 
    
         
            -
                 "lib/couchrest/validation/validation_errors.rb",
         
     | 
| 
       79 
     | 
    
         
            -
                 "lib/couchrest/validation/validators/absent_field_validator.rb",
         
     | 
| 
       80 
     | 
    
         
            -
                 "lib/couchrest/validation/validators/confirmation_validator.rb",
         
     | 
| 
       81 
     | 
    
         
            -
                 "lib/couchrest/validation/validators/format_validator.rb",
         
     | 
| 
       82 
     | 
    
         
            -
                 "lib/couchrest/validation/validators/formats/email.rb",
         
     | 
| 
       83 
     | 
    
         
            -
                 "lib/couchrest/validation/validators/formats/url.rb",
         
     | 
| 
       84 
     | 
    
         
            -
                 "lib/couchrest/validation/validators/generic_validator.rb",
         
     | 
| 
       85 
     | 
    
         
            -
                 "lib/couchrest/validation/validators/length_validator.rb",
         
     | 
| 
       86 
     | 
    
         
            -
                 "lib/couchrest/validation/validators/method_validator.rb",
         
     | 
| 
       87 
     | 
    
         
            -
                 "lib/couchrest/validation/validators/numeric_validator.rb",
         
     | 
| 
       88 
     | 
    
         
            -
                 "lib/couchrest/validation/validators/required_field_validator.rb",
         
     | 
| 
       89 
     | 
    
         
            -
                 "spec/couchrest/core/couchrest_spec.rb",
         
     | 
| 
       90 
     | 
    
         
            -
                 "spec/couchrest/core/database_spec.rb",
         
     | 
| 
       91 
     | 
    
         
            -
                 "spec/couchrest/core/design_spec.rb",
         
     | 
| 
       92 
     | 
    
         
            -
                 "spec/couchrest/core/document_spec.rb",
         
     | 
| 
       93 
     | 
    
         
            -
                 "spec/couchrest/core/server_spec.rb",
         
     | 
| 
       94 
     | 
    
         
            -
                 "spec/couchrest/helpers/pager_spec.rb",
         
     | 
| 
       95 
     | 
    
         
            -
                 "spec/couchrest/helpers/streamer_spec.rb",
         
     | 
| 
       96 
     | 
    
         
            -
                 "spec/couchrest/more/attribute_protection_spec.rb",
         
     | 
| 
       97 
     | 
    
         
            -
                 "spec/couchrest/more/casted_extended_doc_spec.rb",
         
     | 
| 
       98 
     | 
    
         
            -
                 "spec/couchrest/more/casted_model_spec.rb",
         
     | 
| 
       99 
     | 
    
         
            -
                 "spec/couchrest/more/extended_doc_attachment_spec.rb",
         
     | 
| 
       100 
     | 
    
         
            -
                 "spec/couchrest/more/extended_doc_inherited_spec.rb",
         
     | 
| 
       101 
     | 
    
         
            -
                 "spec/couchrest/more/extended_doc_spec.rb",
         
     | 
| 
       102 
     | 
    
         
            -
                 "spec/couchrest/more/extended_doc_subclass_spec.rb",
         
     | 
| 
       103 
     | 
    
         
            -
                 "spec/couchrest/more/extended_doc_view_spec.rb",
         
     | 
| 
       104 
     | 
    
         
            -
                 "spec/couchrest/more/property_spec.rb",
         
     | 
| 
       105 
     | 
    
         
            -
                 "spec/fixtures/attachments/README",
         
     | 
| 
       106 
     | 
    
         
            -
                 "spec/fixtures/attachments/couchdb.png",
         
     | 
| 
       107 
     | 
    
         
            -
                 "spec/fixtures/attachments/test.html",
         
     | 
| 
       108 
     | 
    
         
            -
                 "spec/fixtures/more/article.rb",
         
     | 
| 
       109 
     | 
    
         
            -
                 "spec/fixtures/more/card.rb",
         
     | 
| 
       110 
     | 
    
         
            -
                 "spec/fixtures/more/cat.rb",
         
     | 
| 
       111 
     | 
    
         
            -
                 "spec/fixtures/more/course.rb",
         
     | 
| 
       112 
     | 
    
         
            -
                 "spec/fixtures/more/event.rb",
         
     | 
| 
       113 
     | 
    
         
            -
                 "spec/fixtures/more/invoice.rb",
         
     | 
| 
       114 
     | 
    
         
            -
                 "spec/fixtures/more/person.rb",
         
     | 
| 
       115 
     | 
    
         
            -
                 "spec/fixtures/more/question.rb",
         
     | 
| 
       116 
     | 
    
         
            -
                 "spec/fixtures/more/service.rb",
         
     | 
| 
       117 
     | 
    
         
            -
                 "spec/fixtures/more/user.rb",
         
     | 
| 
       118 
     | 
    
         
            -
                 "spec/fixtures/views/lib.js",
         
     | 
| 
       119 
     | 
    
         
            -
                 "spec/fixtures/views/test_view/lib.js",
         
     | 
| 
       120 
     | 
    
         
            -
                 "spec/fixtures/views/test_view/only-map.js",
         
     | 
| 
       121 
     | 
    
         
            -
                 "spec/fixtures/views/test_view/test-map.js",
         
     | 
| 
       122 
     | 
    
         
            -
                 "spec/fixtures/views/test_view/test-reduce.js",
         
     | 
| 
       123 
     | 
    
         
            -
                 "spec/spec.opts",
         
     | 
| 
       124 
     | 
    
         
            -
                 "spec/spec_helper.rb",
         
     | 
| 
       125 
     | 
    
         
            -
                 "utils/remap.rb",
         
     | 
| 
       126 
     | 
    
         
            -
                 "utils/subset.rb"
         
     | 
| 
       127 
     | 
    
         
            -
              ]
         
     | 
| 
       128 
     | 
    
         
            -
              s.homepage = %q{http://github.com/couchrest/couchrest}
         
     | 
| 
       129 
     | 
    
         
            -
              s.rdoc_options = ["--charset=UTF-8"]
         
     | 
| 
       130 
     | 
    
         
            -
              s.require_paths = ["lib"]
         
     | 
| 
       131 
     | 
    
         
            -
              s.rubygems_version = %q{1.3.6}
         
     | 
| 
       132 
     | 
    
         
            -
              s.summary = %q{Lean and RESTful interface to CouchDB.}
         
     | 
| 
       133 
     | 
    
         
            -
              s.test_files = [
         
     | 
| 
       134 
     | 
    
         
            -
                "spec/couchrest/more/extended_doc_attachment_spec.rb",
         
     | 
| 
       135 
     | 
    
         
            -
                 "spec/couchrest/more/casted_extended_doc_spec.rb",
         
     | 
| 
       136 
     | 
    
         
            -
                 "spec/couchrest/more/extended_doc_inherited_spec.rb",
         
     | 
| 
       137 
     | 
    
         
            -
                 "spec/couchrest/more/casted_model_spec.rb",
         
     | 
| 
       138 
     | 
    
         
            -
                 "spec/couchrest/more/extended_doc_view_spec.rb",
         
     | 
| 
       139 
     | 
    
         
            -
                 "spec/couchrest/more/extended_doc_spec.rb",
         
     | 
| 
       140 
     | 
    
         
            -
                 "spec/couchrest/more/property_spec.rb",
         
     | 
| 
       141 
     | 
    
         
            -
                 "spec/couchrest/more/attribute_protection_spec.rb",
         
     | 
| 
       142 
     | 
    
         
            -
                 "spec/couchrest/more/extended_doc_subclass_spec.rb",
         
     | 
| 
       143 
     | 
    
         
            -
                 "spec/couchrest/helpers/streamer_spec.rb",
         
     | 
| 
       144 
     | 
    
         
            -
                 "spec/couchrest/helpers/pager_spec.rb",
         
     | 
| 
       145 
     | 
    
         
            -
                 "spec/couchrest/core/design_spec.rb",
         
     | 
| 
       146 
     | 
    
         
            -
                 "spec/couchrest/core/server_spec.rb",
         
     | 
| 
       147 
     | 
    
         
            -
                 "spec/couchrest/core/couchrest_spec.rb",
         
     | 
| 
       148 
     | 
    
         
            -
                 "spec/couchrest/core/database_spec.rb",
         
     | 
| 
       149 
     | 
    
         
            -
                 "spec/couchrest/core/document_spec.rb",
         
     | 
| 
       150 
     | 
    
         
            -
                 "spec/fixtures/more/person.rb",
         
     | 
| 
       151 
     | 
    
         
            -
                 "spec/fixtures/more/cat.rb",
         
     | 
| 
       152 
     | 
    
         
            -
                 "spec/fixtures/more/card.rb",
         
     | 
| 
       153 
     | 
    
         
            -
                 "spec/fixtures/more/course.rb",
         
     | 
| 
       154 
     | 
    
         
            -
                 "spec/fixtures/more/service.rb",
         
     | 
| 
       155 
     | 
    
         
            -
                 "spec/fixtures/more/article.rb",
         
     | 
| 
       156 
     | 
    
         
            -
                 "spec/fixtures/more/invoice.rb",
         
     | 
| 
       157 
     | 
    
         
            -
                 "spec/fixtures/more/user.rb",
         
     | 
| 
       158 
     | 
    
         
            -
                 "spec/fixtures/more/event.rb",
         
     | 
| 
       159 
     | 
    
         
            -
                 "spec/fixtures/more/question.rb",
         
     | 
| 
       160 
     | 
    
         
            -
                 "spec/spec_helper.rb",
         
     | 
| 
       161 
     | 
    
         
            -
                 "examples/word_count/word_count_views.rb",
         
     | 
| 
       162 
     | 
    
         
            -
                 "examples/word_count/word_count.rb",
         
     | 
| 
       163 
     | 
    
         
            -
                 "examples/word_count/word_count_query.rb",
         
     | 
| 
       164 
     | 
    
         
            -
                 "examples/model/example.rb"
         
     | 
| 
       165 
     | 
    
         
            -
              ]
         
     | 
| 
       166 
     | 
    
         
            -
             
     | 
| 
       167 
     | 
    
         
            -
              if s.respond_to? :specification_version then
         
     | 
| 
       168 
     | 
    
         
            -
                current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
         
     | 
| 
       169 
     | 
    
         
            -
                s.specification_version = 3
         
     | 
| 
       170 
     | 
    
         
            -
             
     | 
| 
       171 
     | 
    
         
            -
                if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
         
     | 
| 
       172 
     | 
    
         
            -
                  s.add_runtime_dependency(%q<rest-client>, [">= 0.5"])
         
     | 
| 
       173 
     | 
    
         
            -
                  s.add_runtime_dependency(%q<mime-types>, [">= 1.15"])
         
     | 
| 
       174 
     | 
    
         
            -
                else
         
     | 
| 
       175 
     | 
    
         
            -
                  s.add_dependency(%q<rest-client>, [">= 0.5"])
         
     | 
| 
       176 
     | 
    
         
            -
                  s.add_dependency(%q<mime-types>, [">= 1.15"])
         
     | 
| 
       177 
     | 
    
         
            -
                end
         
     | 
| 
       178 
     | 
    
         
            -
              else
         
     | 
| 
       179 
     | 
    
         
            -
                s.add_dependency(%q<rest-client>, [">= 0.5"])
         
     | 
| 
       180 
     | 
    
         
            -
                s.add_dependency(%q<mime-types>, [">= 1.15"])
         
     | 
| 
       181 
     | 
    
         
            -
              end
         
     | 
| 
       182 
     | 
    
         
            -
            end
         
     | 
| 
       183 
     | 
    
         
            -
             
     | 
    
        data/examples/model/example.rb
    DELETED
    
    | 
         @@ -1,144 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'couchrest')
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            def show obj
         
     | 
| 
       4 
     | 
    
         
            -
              puts obj.inspect
         
     | 
| 
       5 
     | 
    
         
            -
              puts
         
     | 
| 
       6 
     | 
    
         
            -
            end
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            SERVER = CouchRest.new
         
     | 
| 
       9 
     | 
    
         
            -
            SERVER.default_database = 'couchrest-extendeddoc-example'
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            class Author < CouchRest::ExtendedDocument
         
     | 
| 
       12 
     | 
    
         
            -
              use_database SERVER.default_database
         
     | 
| 
       13 
     | 
    
         
            -
              property :name
         
     | 
| 
       14 
     | 
    
         
            -
              
         
     | 
| 
       15 
     | 
    
         
            -
              def drink_scotch
         
     | 
| 
       16 
     | 
    
         
            -
                puts "... glug type glug ... I'm #{name} ... type glug glug ..."
         
     | 
| 
       17 
     | 
    
         
            -
              end
         
     | 
| 
       18 
     | 
    
         
            -
            end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
            class Post < CouchRest::ExtendedDocument
         
     | 
| 
       21 
     | 
    
         
            -
              use_database SERVER.default_database
         
     | 
| 
       22 
     | 
    
         
            -
              
         
     | 
| 
       23 
     | 
    
         
            -
              property :title
         
     | 
| 
       24 
     | 
    
         
            -
              property :body
         
     | 
| 
       25 
     | 
    
         
            -
              property :author, :cast_as => 'Author'
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
              timestamps!
         
     | 
| 
       28 
     | 
    
         
            -
            end
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
            class Comment < CouchRest::ExtendedDocument
         
     | 
| 
       31 
     | 
    
         
            -
              use_database SERVER.default_database
         
     | 
| 
       32 
     | 
    
         
            -
              
         
     | 
| 
       33 
     | 
    
         
            -
              property :commenter, :cast_as => 'Author'
         
     | 
| 
       34 
     | 
    
         
            -
              timestamps!
         
     | 
| 
       35 
     | 
    
         
            -
              
         
     | 
| 
       36 
     | 
    
         
            -
              def post= post
         
     | 
| 
       37 
     | 
    
         
            -
                self["post_id"] = post.id
         
     | 
| 
       38 
     | 
    
         
            -
              end
         
     | 
| 
       39 
     | 
    
         
            -
              def post
         
     | 
| 
       40 
     | 
    
         
            -
                Post.get(self['post_id']) if self['post_id']
         
     | 
| 
       41 
     | 
    
         
            -
              end
         
     | 
| 
       42 
     | 
    
         
            -
              
         
     | 
| 
       43 
     | 
    
         
            -
            end
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
            puts "Act I: CRUD"
         
     | 
| 
       46 
     | 
    
         
            -
            puts
         
     | 
| 
       47 
     | 
    
         
            -
            puts "(pause for dramatic effect)"
         
     | 
| 
       48 
     | 
    
         
            -
            puts
         
     | 
| 
       49 
     | 
    
         
            -
            sleep 2
         
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
            puts "Create an author."
         
     | 
| 
       52 
     | 
    
         
            -
            quentin = Author.new("name" => "Quentin Hazel")
         
     | 
| 
       53 
     | 
    
         
            -
            show quentin
         
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
            puts "Create a new post."
         
     | 
| 
       56 
     | 
    
         
            -
            post = Post.new(:title => "First Post", :body => "Lorem ipsum dolor sit amet, consectetur adipisicing elit...")
         
     | 
| 
       57 
     | 
    
         
            -
            show post
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
            puts "Add the author to the post."
         
     | 
| 
       60 
     | 
    
         
            -
            post.author = quentin
         
     | 
| 
       61 
     | 
    
         
            -
            show post
         
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
            puts "Save the post."
         
     | 
| 
       64 
     | 
    
         
            -
            post.save
         
     | 
| 
       65 
     | 
    
         
            -
            show post
         
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
            puts "Load the post."
         
     | 
| 
       68 
     | 
    
         
            -
            reloaded = Post.get(post.id)
         
     | 
| 
       69 
     | 
    
         
            -
            show reloaded
         
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
            puts "The author of the post is an instance of Author."
         
     | 
| 
       72 
     | 
    
         
            -
            reloaded.author.drink_scotch
         
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
            puts "\nAdd some comments to the post."
         
     | 
| 
       75 
     | 
    
         
            -
            comment_one = Comment.new :text => "Blah blah blah", :commenter => {:name => "Joe Sixpack"}
         
     | 
| 
       76 
     | 
    
         
            -
            comment_two = Comment.new :text => "Yeah yeah yeah", :commenter => {:name => "Jane Doe"}
         
     | 
| 
       77 
     | 
    
         
            -
            comment_three = Comment.new :text => "Whatever...", :commenter => {:name => "John Stewart"}
         
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
            # TODO - maybe add some magic here?
         
     | 
| 
       80 
     | 
    
         
            -
            comment_one.post = post
         
     | 
| 
       81 
     | 
    
         
            -
            comment_two.post = post
         
     | 
| 
       82 
     | 
    
         
            -
            comment_three.post = post
         
     | 
| 
       83 
     | 
    
         
            -
            comment_one.save
         
     | 
| 
       84 
     | 
    
         
            -
            comment_two.save
         
     | 
| 
       85 
     | 
    
         
            -
            comment_three.save
         
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
            show comment_one
         
     | 
| 
       88 
     | 
    
         
            -
            show comment_two
         
     | 
| 
       89 
     | 
    
         
            -
            show comment_three
         
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
            puts "We can load a post through its comment (no magic here)."
         
     | 
| 
       92 
     | 
    
         
            -
            show post = comment_one.post
         
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
            puts "Commenters are also authors."
         
     | 
| 
       95 
     | 
    
         
            -
            comment_two['commenter'].drink_scotch
         
     | 
| 
       96 
     | 
    
         
            -
            comment_one['commenter'].drink_scotch
         
     | 
| 
       97 
     | 
    
         
            -
            comment_three['commenter'].drink_scotch
         
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
            puts "\nLet's save an author to her own document."
         
     | 
| 
       100 
     | 
    
         
            -
            jane = comment_two['commenter']
         
     | 
| 
       101 
     | 
    
         
            -
            jane.save
         
     | 
| 
       102 
     | 
    
         
            -
            show jane
         
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
            puts "Oh, that's neat! Because Ruby passes hash valuee by reference, Jane's new id has been added to the comment she left."
         
     | 
| 
       105 
     | 
    
         
            -
            show comment_two
         
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
            puts "Of course, we'd better remember to save it."
         
     | 
| 
       108 
     | 
    
         
            -
            comment_two.save
         
     | 
| 
       109 
     | 
    
         
            -
            show comment_two
         
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
       111 
     | 
    
         
            -
            puts "Oooh, denormalized... feel the burn!"
         
     | 
| 
       112 
     | 
    
         
            -
            puts
         
     | 
| 
       113 
     | 
    
         
            -
            puts
         
     | 
| 
       114 
     | 
    
         
            -
            puts
         
     | 
| 
       115 
     | 
    
         
            -
            puts "Act II: Views"
         
     | 
| 
       116 
     | 
    
         
            -
            puts
         
     | 
| 
       117 
     | 
    
         
            -
            puts
         
     | 
| 
       118 
     | 
    
         
            -
            sleep 2
         
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
       120 
     | 
    
         
            -
            puts "Let's find all the comments that go with our post."
         
     | 
| 
       121 
     | 
    
         
            -
            puts "Our post has id #{post.id}, so lets find all the comments with that post_id."
         
     | 
| 
       122 
     | 
    
         
            -
            puts
         
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
       124 
     | 
    
         
            -
            class Comment
         
     | 
| 
       125 
     | 
    
         
            -
              view_by :post_id
         
     | 
| 
       126 
     | 
    
         
            -
            end
         
     | 
| 
       127 
     | 
    
         
            -
             
     | 
| 
       128 
     | 
    
         
            -
            comments = Comment.by_post_id :key => post.id
         
     | 
| 
       129 
     | 
    
         
            -
            show comments
         
     | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
       131 
     | 
    
         
            -
            puts "That was too easy."
         
     | 
| 
       132 
     | 
    
         
            -
            puts "We can even wrap it up in a finder on the Post class."
         
     | 
| 
       133 
     | 
    
         
            -
            puts
         
     | 
| 
       134 
     | 
    
         
            -
             
     | 
| 
       135 
     | 
    
         
            -
            class Post
         
     | 
| 
       136 
     | 
    
         
            -
              def comments
         
     | 
| 
       137 
     | 
    
         
            -
                Comment.by_post_id :key => id
         
     | 
| 
       138 
     | 
    
         
            -
              end
         
     | 
| 
       139 
     | 
    
         
            -
            end
         
     | 
| 
       140 
     | 
    
         
            -
             
     | 
| 
       141 
     | 
    
         
            -
            show post.comments
         
     | 
| 
       142 
     | 
    
         
            -
            puts "Gimme 5 minutes and I'll roll this into the framework. ;)"
         
     | 
| 
       143 
     | 
    
         
            -
            puts
         
     | 
| 
       144 
     | 
    
         
            -
            puts "There is a lot more that can be done with views, but a lot of the interesting stuff is joins, which of course range across types. We'll pick up where we left off, next time."
         
     |