Permalink
Browse files

Merge pull request #6 from tapajos/master

Remove files...
  • Loading branch information...
2 parents d403de5 + 973e00c commit 5dac015e585b33dd7c63233369fc7003eb4befe4 @tapajos tapajos committed Aug 31, 2011
Showing with 1 addition and 10,680 deletions.
  1. +0 −4 .gitignore
  2. +0 −176 LICENSE
  3. +1 −196 README.md
  4. +0 −75 Rakefile
  5. +0 −19 THANKS.md
  6. +0 −35 couchrest.gemspec
  7. +0 −144 examples/model/example.rb
  8. +0 −38 examples/word_count/markov
  9. +0 −3 examples/word_count/views/books/chunked-map.js
  10. +0 −1 examples/word_count/views/books/united-map.js
  11. +0 −6 examples/word_count/views/markov/chain-map.js
  12. +0 −7 examples/word_count/views/markov/chain-reduce.js
  13. +0 −6 examples/word_count/views/word_count/count-map.js
  14. +0 −3 examples/word_count/views/word_count/count-reduce.js
  15. +0 −46 examples/word_count/word_count.rb
  16. +0 −40 examples/word_count/word_count_query.rb
  17. +0 −26 examples/word_count/word_count_views.rb
  18. +0 −20 github_gemtest.rb
  19. +0 −63 history.txt
  20. +0 −1 init.rb
  21. +0 −159 lib/couchrest.rb
  22. +0 −71 lib/couchrest/commands/generate.rb
  23. +0 −103 lib/couchrest/commands/push.rb
  24. +0 −35 lib/couchrest/core/adapters/restclient.rb
  25. +0 −333 lib/couchrest/core/database.rb
  26. +0 −79 lib/couchrest/core/design.rb
  27. +0 −84 lib/couchrest/core/document.rb
  28. +0 −48 lib/couchrest/core/http_abstraction.rb
  29. +0 −16 lib/couchrest/core/response.rb
  30. +0 −49 lib/couchrest/core/rest_api.rb
  31. +0 −88 lib/couchrest/core/server.rb
  32. +0 −4 lib/couchrest/core/view.rb
  33. +0 −103 lib/couchrest/helper/pager.rb
  34. +0 −51 lib/couchrest/helper/streamer.rb
  35. +0 −51 lib/couchrest/helper/upgrade.rb
  36. +0 −263 lib/couchrest/middlewares/logger.rb
  37. +0 −4 lib/couchrest/mixins.rb
  38. +0 −31 lib/couchrest/mixins/attachments.rb
  39. +0 −74 lib/couchrest/mixins/attribute_protection.rb
  40. +0 −532 lib/couchrest/mixins/callbacks.rb
  41. +0 −116 lib/couchrest/mixins/class_proxy.rb
  42. +0 −224 lib/couchrest/mixins/collection.rb
  43. +0 −103 lib/couchrest/mixins/design_doc.rb
  44. +0 −80 lib/couchrest/mixins/document_queries.rb
  45. +0 −74 lib/couchrest/mixins/extended_attachments.rb
  46. +0 −9 lib/couchrest/mixins/extended_document_mixins.rb
  47. +0 −200 lib/couchrest/mixins/properties.rb
  48. +0 −246 lib/couchrest/mixins/validation.rb
  49. +0 −173 lib/couchrest/mixins/views.rb
  50. +0 −113 lib/couchrest/monkeypatches.rb
  51. +0 −58 lib/couchrest/more/casted_model.rb
  52. +0 −307 lib/couchrest/more/extended_document.rb
  53. +0 −59 lib/couchrest/more/property.rb
  54. +0 −42 lib/couchrest/support/blank.rb
  55. +0 −190 lib/couchrest/support/class.rb
  56. +0 −42 lib/couchrest/support/rails.rb
  57. +0 −157 lib/couchrest/validation/auto_validate.rb
  58. +0 −78 lib/couchrest/validation/contextual_validators.rb
  59. +0 −125 lib/couchrest/validation/validation_errors.rb
  60. +0 −74 lib/couchrest/validation/validators/absent_field_validator.rb
  61. +0 −107 lib/couchrest/validation/validators/confirmation_validator.rb
  62. +0 −122 lib/couchrest/validation/validators/format_validator.rb
  63. +0 −66 lib/couchrest/validation/validators/formats/email.rb
  64. +0 −43 lib/couchrest/validation/validators/formats/url.rb
  65. +0 −120 lib/couchrest/validation/validators/generic_validator.rb
  66. +0 −139 lib/couchrest/validation/validators/length_validator.rb
  67. +0 −89 lib/couchrest/validation/validators/method_validator.rb
  68. +0 −109 lib/couchrest/validation/validators/numeric_validator.rb
  69. +0 −114 lib/couchrest/validation/validators/required_field_validator.rb
  70. +0 −2 make-gemspec.sh
  71. +0 −1 spec/.gitignore
  72. +0 −247 spec/couchrest/core/couchrest_spec.rb
  73. +0 −721 spec/couchrest/core/database_spec.rb
  74. +0 −138 spec/couchrest/core/design_spec.rb
  75. +0 −267 spec/couchrest/core/document_spec.rb
  76. +0 −35 spec/couchrest/core/server_spec.rb
  77. +0 −122 spec/couchrest/helpers/pager_spec.rb
  78. +0 −52 spec/couchrest/helpers/streamer_spec.rb
  79. +0 −150 spec/couchrest/more/attribute_protection_spec.rb
  80. +0 −73 spec/couchrest/more/casted_extended_doc_spec.rb
  81. +0 −406 spec/couchrest/more/casted_model_spec.rb
  82. +0 −135 spec/couchrest/more/extended_doc_attachment_spec.rb
  83. +0 −746 spec/couchrest/more/extended_doc_spec.rb
  84. +0 −98 spec/couchrest/more/extended_doc_subclass_spec.rb
  85. +0 −437 spec/couchrest/more/extended_doc_view_spec.rb
  86. +0 −289 spec/couchrest/more/property_spec.rb
  87. +0 −3 spec/fixtures/attachments/README
  88. BIN spec/fixtures/attachments/couchdb.png
  89. +0 −11 spec/fixtures/attachments/test.html
  90. +0 −34 spec/fixtures/more/article.rb
  91. +0 −22 spec/fixtures/more/card.rb
  92. +0 −20 spec/fixtures/more/cat.rb
  93. +0 −14 spec/fixtures/more/course.rb
  94. +0 −9 spec/fixtures/more/event.rb
  95. +0 −17 spec/fixtures/more/invoice.rb
  96. +0 −9 spec/fixtures/more/person.rb
  97. +0 −6 spec/fixtures/more/question.rb
  98. +0 −12 spec/fixtures/more/service.rb
  99. +0 −22 spec/fixtures/more/user.rb
  100. +0 −3 spec/fixtures/views/lib.js
  101. +0 −3 spec/fixtures/views/test_view/lib.js
  102. +0 −4 spec/fixtures/views/test_view/only-map.js
  103. +0 −3 spec/fixtures/views/test_view/test-map.js
  104. +0 −3 spec/fixtures/views/test_view/test-reduce.js
  105. +0 −6 spec/spec.opts
  106. +0 −37 spec/spec_helper.rb
  107. +0 −27 utils/remap.rb
  108. +0 −30 utils/subset.rb
View
@@ -1,4 +0,0 @@
-.DS_Store
-html/*
-pkg
-*.swp
View
176 LICENSE
@@ -1,176 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
-2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
-3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
-4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
-5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
-6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
-8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
-9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
-END OF TERMS AND CONDITIONS
View
197 README.md
@@ -1,196 +1 @@
-# CouchRest: CouchDB, close to the metal
-
-CouchRest is based on [CouchDB's couch.js test
-library](http://svn.apache.org/repos/asf/couchdb/trunk/share/www/script/couch.js),
-which I find to be concise, clear, and well designed. CouchRest lightly wraps
-CouchDB's HTTP API, managing JSON serialization, and remembering the URI-paths
-to CouchDB's API endpoints so you don't have to.
-
-CouchRest is designed to make a simple base for application and framework-specific object oriented APIs. CouchRest is Object-Mapper agnostic, the parsed JSON it returns from CouchDB shows up as subclasses of Ruby's Hash. Naked JSON, just as it was mean to be.
-
-Note: CouchRest only support CouchDB 0.9.0 or newer.
-
-## Easy Install
-
- $ sudo gem install couchrest
-
-Alternatively, you can install from Github:
-
- $ gem sources -a http://gems.github.com (you only have to do this once)
- $ sudo gem install couchrest-couchrest
-
-### Relax, it's RESTful
-
-CouchRest rests on top of a HTTP abstraction layer using by default Heroku’s excellent REST Client Ruby HTTP wrapper.
-Other adapters can be added to support more http libraries.
-
-### Running the Specs
-
-The most complete documentation is the spec/ directory. To validate your
-CouchRest install, from the project root directory run `rake`, or `autotest`
-(requires RSpec and optionally ZenTest for autotest support).
-
-## Examples (CouchRest Core)
-
-Quick Start:
-
- # with !, it creates the database if it doesn't already exist
- @db = CouchRest.database!("http://127.0.0.1:5984/couchrest-test")
- response = @db.save_doc({:key => 'value', 'another key' => 'another value'})
- doc = @db.get(response['id'])
- puts doc.inspect
-
-Bulk Save:
-
- @db.bulk_save([
- {"wild" => "and random"},
- {"mild" => "yet local"},
- {"another" => ["set","of","keys"]}
- ])
- # returns ids and revs of the current docs
- puts @db.documents.inspect
-
-Creating and Querying Views:
-
- @db.save_doc({
- "_id" => "_design/first",
- :views => {
- :test => {
- :map => "function(doc){for(var w in doc){ if(!w.match(/^_/))emit(w,doc[w])}}"
- }
- }
- })
- puts @db.view('first/test')['rows'].inspect
-
-
-## CouchRest::ExtendedDocument
-
-CouchRest::ExtendedDocument is a DSL/ORM for CouchDB. Basically, ExtendedDocument seats on top of CouchRest Core to add the concept of Model.
-ExtendedDocument offers a lot of the usual ORM tools such as optional yet defined schema, validation, callbacks, pagination, casting and much more.
-
-### Model example
-
-Check spec/couchrest/more and spec/fixtures/more for more examples
-
- class Article < CouchRest::ExtendedDocument
- use_database DB
- unique_id :slug
-
- view_by :date, :descending => true
- view_by :user_id, :date
-
- view_by :tags,
- :map =>
- "function(doc) {
- if (doc['couchrest-type'] == 'Article' && doc.tags) {
- doc.tags.forEach(function(tag){
- emit(tag, 1);
- });
- }
- }",
- :reduce =>
- "function(keys, values, rereduce) {
- return sum(values);
- }"
-
- property :date
- property :slug, :read_only => true
- property :title
- property :tags, :cast_as => ['String']
-
- timestamps!
-
- save_callback :before, :generate_slug_from_title
-
- def generate_slug_from_title
- self['slug'] = title.downcase.gsub(/[^a-z0-9]/,'-').squeeze('-').gsub(/^\-|\-$/,'') if new?
- end
- end
-
-### Callbacks
-
-`CouchRest::ExtendedDocuments` instances have 4 callbacks already defined for you:
- `:validate`, `:create`, `:save`, `:update` and `:destroy`
-
-`CouchRest::CastedModel` instances have 1 callback already defined for you:
- `:validate`
-
-Define your callback as follows:
-
- set_callback :save, :before, :generate_slug_from_name
-
-CouchRest uses a mixin you can find in lib/mixins/callbacks which is extracted from Rails 3, here are some simple usage examples:
-
- set_callback :save, :before, :before_method
- set_callback :save, :after, :after_method, :if => :condition
- set_callback :save, :around {|r| stuff; yield; stuff }
-
- Or the aliased short version:
-
- before_save :before_method, :another_method
- after_save :after_method, :another_method, :if => :condition
- around_save {|r| stuff; yield; stuff }
-
-To halt the callback, simply return a :halt symbol in your callback method.
-
-Check the mixin or the ExtendedDocument class to see how to implement your own callbacks.
-
-### Properties
-
- property :last_name, :alias => :family_name
- property :read_only_value, :read_only => true
- property :name, :length => 4...20
- property :price, :type => Integer
-
-Attribute protection from mass assignment to CouchRest properties. There are two modes of protection:
-
-1) Declare accessible properties, assume all the rest are protected
- property :name, :accessible => true
- property :admin # this will be automatically protected
-
-2) Declare protected properties, assume all the rest are accessible
- property :name # this will not be protected
- property :admin, :protected => true
-
-Note: you cannot set both flags in a single class
-
-### Casting
-
-Often, you will want to store multiple objects within a document, to be able to retrieve your objects when you load the document,
-you can define some casting rules.
-
- property :casted_attribute, :cast_as => 'WithCastedModelMixin'
- property :keywords, :cast_as => ["String"]
- property :occurs_at, :cast_as => 'Time', :init_method => 'parse
- property :end_date, :cast_as => 'Date', :init_method => 'parse
-
-If you want to cast an array of instances from a specific Class, use the trick shown above ["ClassName"]
-
-### Pagination
-
-Pagination is available in any ExtendedDocument classes. Here are some usage examples:
-
-basic usage:
-
- Article.all.paginate(:page => 1, :per_page => 5)
-
-note: the above query will look like: `GET /db/_design/Article/_view/all?include_docs=true&skip=0&limit=5&reduce=false` and only fetch 5 documents.
-
-Slightly more advance usage:
-
- Article.by_name(:startkey => 'a', :endkey => {}).paginate(:page => 1, :per_page => 5)
-
-note: the above query will look like: `GET /db/_design/Article/_view/by_name?startkey=%22a%22&limit=5&skip=0&endkey=%7B%7D&include_docs=true`
-Basically, you can paginate through the articles starting by the letter a, 5 articles at a time.
-
-
-Low level usage:
-
- Article.paginate(:design_doc => 'Article', :view_name => 'by_date',
- :per_page => 3, :page => 2, :descending => true, :key => Date.today, :include_docs => true)
-
-## Ruby on Rails
-
-CouchRest is compatible with rails and can even be used a Rails plugin.
-However, you might be interested in the CouchRest companion rails project:
-[http://github.com/hpoydar/couchrest-rails](http://github.com/hpoydar/couchrest-rails)
+## Please use the copy of CouchRest found at [http://github.com/couchrest/couchrest](http://github.com/couchrest/couchrest)
Oops, something went wrong.

0 comments on commit 5dac015

Please sign in to comment.