Commit graph

455 commits

Author SHA1 Message Date
John Wood a0d6204b42 Added some more doc for Collection, and cleaned up how provides_collection works. 2009-07-08 09:43:31 -07:00
John Wood a9a53b8729 Added more tests for Collection module, cleaned up the code as well. 2009-07-08 09:40:47 -07:00
John Wood 5963f1d4f8 Better integration with couchrest views. More tests, doc, and some cleanup still needed. 2009-07-08 09:39:30 -07:00
John Wood cf76466795 Added Collection mixin.
The Collection mixin adds support for executing a view, and passing
back the view results as an Array of the given ExtendedDocument instance.
It also supports will_paginate like pagination methods (paginate, paginated_each),
which will only fetch the given set of documents from CouchDB.
2009-07-08 09:38:26 -07:00
Seth Falcon 3e2b3ece46 Timeout::TimeoutError does not exist, use Timeout::Error instead
Also added a require for 'timeout' that contains this code.  Easy to get
confused as there is an alias TimeoutError:

irb(main):001:0> require 'timeout'
=> true
irb(main):002:0> TimeoutError
=> Timeout::Error
irb(main):003:0> Timeout::Error
=> Timeout::Error
irb(main):004:0> Timeout::TimeoutError
NameError: uninitialized constant Timeout::TimeoutError
        from (irb):4
2009-07-08 09:32:43 -07:00
Matt Aimonetti 9a89db44f1 fixed a commit that got reverted by accident 2009-07-08 09:28:15 -07:00
Rob Kaufman baabe40674 Fixed validates_is_numeric when dealing with an actual float 2009-07-08 09:17:07 -07:00
Matt Aimonetti 82090cb780 modified the timestamp parsing to run faster, making a big difference when loading huge datasets 2009-07-07 23:55:20 -07:00
Peter Gumeson ce02d05eac Merge commit 'mattetti/master' 2009-06-20 21:05:00 -07:00
wildchild f9d8f09ab9 Handle default values properly 2009-06-18 15:00:13 -07:00
Peter Gumeson f4f3946d86 Merged in more new callback stuff from rails 3 2009-06-13 22:41:16 -07:00
Peter Gumeson a47de6aaf5 Tidying up rails support 2009-06-13 14:51:15 -07:00
Peter Gumeson 62e8709df7 Fixed some casting issues for assigned properties 2009-06-12 12:22:58 -07:00
Peter Gumeson cdf998b185 Merge commit 'sethladd/master' 2009-06-12 12:17:15 -07:00
Peter Gumeson fc18b47800 Merge commit 'mattetti/master' 2009-06-11 21:18:37 -07:00
Seth Ladd 92d7fdb94d refactoring how casting works 2009-06-09 18:02:04 -10:00
Seth Ladd 209e36f61b cast values through setters to ensure validations are run after mass assignment, for example 2009-06-08 16:35:26 -10:00
Seth Ladd 130fdd16dd cosmetic cleanup 2009-06-08 16:34:52 -10:00
Seth Ladd ffceaec57d add silent settings for created_at and updated_at, allows for mass assignment with semantics that match rails 2009-06-08 16:34:21 -10:00
Seth Ladd 31180f6bc7 require the rails support 2009-06-08 11:52:02 -10:00
Seth Ladd 36f69ec332 check if Rails exists for the rails support 2009-06-08 11:48:15 -10:00
Seth Ladd 7246801f57 merged in sporkd 2009-06-08 10:10:59 -10:00
Matt Aimonetti c18567f8fc differentiated attachment's URI and URL 2009-06-07 18:51:31 -07:00
Peter Gumeson db7829e996 Callbacks now take multiple callback methods 2009-06-07 18:46:30 -07:00
Peter Gumeson ab362cb32c More convenient callback alias methods 2009-06-07 17:01:21 -07:00
Peter Gumeson 806a79a72a Enabled callback halting and added copyright notices 2009-06-07 14:52:23 -07:00
Peter Gumeson dc4787e905 Integrated Yehuda's new callback code from rails 2009-06-07 02:57:22 -07:00
Peter Gumeson 1c6e073b47 Added logger to rails support 2009-06-07 02:51:50 -07:00
Peter Gumeson 76b1563539 Renamed new_document? and new_model? to simply new? 2009-06-04 20:44:44 -07:00
Peter Gumeson b4e2250668 Added validation callbacks to extended documents and casted models 2009-06-04 19:49:10 -07:00
Peter Gumeson 91cd1d9c7b base_doc should be nil for unassociated casted models 2009-05-30 23:20:39 -07:00
Peter Gumeson d012380b67 Added helper for accessing the top level document. And more rails compatibility. 2009-05-28 22:42:30 -07:00
Peter Gumeson 936ce54449 Merge branch 'mattetti/master' 2009-05-28 22:31:20 -07:00
Matt Aimonetti f1b2315524 bumped the release because of github *sigh* 2009-05-28 19:43:55 -07:00
Matt Aimonetti 28df50daca minor text edit, trying to get github to build the gem 2009-05-28 19:41:30 -07:00
Peter Gumeson efeb654114 casted_by is now set on assignment to a document. 2009-05-28 17:56:42 -07:00
Peter Gumeson 3e4c90f104 Fixed a comment 2009-05-28 17:00:06 -07:00
Peter Gumeson 23341f3698 Added new_model? and new_record? alias to casted model for rails compatibility. 2009-05-28 16:09:53 -07:00
Peter Gumeson 9a026997dd valid? now recursively checks casted models. Added better validation spec coverage. 2009-05-28 12:18:23 -07:00
Peter Gumeson 4a4cae0d95 Merge branch 'mattetti/master' 2009-05-28 11:30:15 -07:00
Matt Aimonetti 5e0632c1d0 removed ObjectSpace usage 2009-05-28 10:36:25 -07:00
Matt Aimonetti 295c0f0511 fixed the design doc cache issue 2009-05-27 23:59:43 -07:00
Matt Aimonetti c35c35157a added an automated way to mark design docs as dirty after the db was reset 2009-05-27 18:16:50 -07:00
Peter Gumeson 704d0a09bd Added attributes= to casted model and extended doc 2009-05-27 13:24:25 -07:00
Matt Aimonetti e48a6c8866 fixed all the specs so we are back to green 2009-05-26 18:27:49 -07:00
Eric Watson a1087b48fe Enabled casting of CastedModel attributes 2009-05-26 15:55:10 -07:00
Eric Watson dff005f082 Modified CastedModel to apply defaults first
(so the defaults don't overwrite modified values)
Included failing (and now passing) specs
2009-05-26 15:51:30 -07:00
Eric Watson 0647307acd Enabled apply_defaults for CastedModel 2009-05-26 15:48:04 -07:00
Eric Watson 96f8d1aa96 Fixing CastedModel bug that modified casted objects
Also refactored code for skipping casting of nil-valued properties
Added and re-arranged specs
2009-05-26 15:47:12 -07:00
Eric Watson 101024aabc Changed CastedModel so it does not cast nil values 2009-05-26 15:45:42 -07:00
Will Leinweber eb160e3141 Add .count to extended documents to return how many there are.
Adds a reduce function to the default view so that an extra view doesn't have to be maintained just for the counting.
2009-05-26 15:43:27 -07:00
Matt Aimonetti e538a3881d strings respond to :each and the might break validation on casted arrays 2009-05-20 18:35:41 -07:00
Matt Aimonetti 8814ab531d bumped version number after fixing a potentially serious design doc bug 2009-05-20 16:33:19 -07:00
Matt Aimonetti b1ff1192e5 fixed the refresh design doc method to actually save the doc in the db 2009-05-20 11:44:44 -07:00
Matt Aimonetti 85079a54d9 bumped the version 2009-05-17 21:20:38 -07:00
Matt Aimonetti b89d327a61 cleaned up the design view names since we don't need to use md5 view names anymore. (we are using different revision numbers) 2009-05-17 19:34:02 -07:00
Eric Watson 406eaebfc9 Allowing save of default value for read-only property 2009-05-17 17:04:56 -07:00
Matt Aimonetti a4e6713aeb removed the json dependency so everything can work fine with ruby1.9/jruby/macruby etc.. version bumped 2009-05-13 23:20:05 -07:00
Matt Aimonetti 2596df1a3d added cascading validations for extended documents using casted models. Most code comes from nrstott's contribution 2009-05-13 22:50:29 -07:00
Matt Aimonetti 92b77a9649 fixed bulk_load/get_bulk and the specs 2009-05-13 20:44:57 -07:00
Matt Aimonetti 1b6ed9ce93 Merge branch 'master' of git://github.com/jchris/couchrest
* 'master' of git://github.com/jchris/couchrest:
  added bulk_load macro
  version support note
2009-05-13 12:59:42 -07:00
Chris Anderson 8363aa6298 added bulk_load macro 2009-05-08 19:00:39 -07:00
Matt Aimonetti 53df7369bc bumped the version due to many bug fixes being addressed lately 2009-04-27 20:53:02 -07:00
Mutwin Kraus f7bbee8243 Make "property :foo, :default => false" work
Before a default value of false was treated like a default of nil,
  which is not the same.

Signed-off-by: Matt Aimonetti <mattaimonetti@gmail.com>
2009-04-28 11:38:00 +08:00
Mutwin Kraus 75a5018b12 Improvements for ExtendedDocument initializer
* Tries to send arg= to the Document before setting the attribute

Signed-off-by: Matt Aimonetti <mattaimonetti@gmail.com>
2009-04-28 11:37:59 +08:00
YAMAMOTO Yohei 6fca60ebe4 fixed a bug with CastedModel constructer calling Hash#initialize(ifnone)
Signed-off-by: Matt Aimonetti <mattaimonetti@gmail.com>
2009-04-28 11:32:59 +08:00
Geoff Buesing ef3b0527c9 Hash#=== monkeypatch: don't add special behavior to subclasses, i.e. CouchRest documents 2009-04-01 14:16:10 -07:00
Geoff Buesing 5f5aa06409 Adding Rails-related monkeypatches file, which isn't required by default. Contains fixes for Rails routing and Rails form error compatibility. 2009-04-01 11:42:15 -07:00
Chris Anderson 09dcc9e5c2 Revert "Server URI can now include a prefix to the database name"
This reverts commit 14acd95444.
2009-03-31 12:24:04 -07:00
Brian Candler 55271490e8 Remove unnecessary design_doc_fresh test 2009-03-31 10:58:34 -07:00
Brian Candler d672d5f8d4 Move design_doc_* attributes into DesignDoc mixin 2009-03-31 10:58:05 -07:00
Brian Candler 159a761ad9 Tidy up initialisations of design_doc which are no longer needed 2009-03-31 10:57:33 -07:00
Matt Aimonetti abd19f7b68 bumped release to 0.23 (lots of fixes) 2009-03-27 11:27:44 -07:00
Matt Aimonetti 661daac473 fixed an inheritance problem with ExtendedDocument subclasses 2009-03-27 11:11:49 -07:00
Geoff Buesing 9c46546b39 Add call to super in CouchRest::Validation.inherited hook, so that ExtendedDocument.inherited isn't bypassed. This reveals a failing test: Subclassing an ExtendedDocument should inherit default property values 2009-03-27 10:39:23 -07:00
Geoff Buesing 5d112df1e8 Make design_doc non-inheritable. Fixes bug where views added to a child class were propagated to the parent and siblings. Child class "all" view map function now checks in guard clause for child class name instead of parent name 2009-03-27 10:35:18 -07:00
Geoff Buesing 1ee82b714c Don't make design_doc_slug_cache and design_doc_fresh inheritable, because these settings should be specific to the class 2009-03-27 10:35:05 -07:00
Brian Candler 14acd95444 Server URI can now include a prefix to the database name 2009-03-27 10:27:04 -07:00
Brian Candler 190bd13723 Escape slash in database name 2009-03-27 10:26:54 -07:00
Matt Aimonetti 4337e676ee Merge commit 'candlerb/candlerb/design-doc' into candlerb-merge
* commit 'candlerb/candlerb/design-doc':
  Update handler for old versions of couchdb
  ClassProxy provides class-level methods on a dynamically chosen database.
  Remove obsolete 'move' methods
  Tidying up spec, remove unnecessary assignments to local variable
  Multiple database support for ExtendedDocument.
  Typo in comment
  Move design_doc attributes to Mixins::DesignDoc
2009-03-27 10:21:56 -07:00
Brian Candler d71a33fc93 Update handler for old versions of couchdb 2009-03-27 14:00:28 +00:00
Brian Candler c4b49baecf ClassProxy provides class-level methods on a dynamically chosen database.
Examples:

  db = CouchRest::Database.new(...)
  articles = Article.on(db)

  articles.all { ... }
  articles.by_title { ... }

  u = articles.get("someid")

  u = articles.new(:title => "I like plankton")
  u.save    # saved on the correct database
2009-03-27 13:42:49 +00:00
Brian Candler af6ac7df89 Remove obsolete 'move' methods 2009-03-27 11:50:42 +00:00
Brian Candler ec7848b783 Multiple database support for ExtendedDocument.
New optional parameters are available to select the database:

Mixins::DocumentQueries
  * get <id>, <db>
  * all :database => <db>
  * first :database => <db>

Mixins::Views
  * view <name>, :database => <db>
  * all_design_doc_versions <db>
  * cleanup_design_docs! <db>

Mixins::DesignDoc
  * refresh_design_doc now only updates the design_doc _id and removes _rev
  * call save_design_doc to save and update the design_doc
  * call save_design_doc_on <db> to save the design doc on a given
    database without modifying the model's design_doc object

Design (core/design.rb)
  * new method view_on <db>, ...

Bug fixes:
  * design_doc_slug in mixins/design_doc.rb was using an empty document
    to calculate the slug each time
  * method_missing in core/extended_document.rb now passes a block through
2009-03-27 11:27:37 +00:00
Brian Candler f9278a4ca6 Typo in comment 2009-03-26 21:39:36 +00:00
Brian Candler ada5b1660f Move design_doc attributes to Mixins::DesignDoc 2009-03-26 21:21:20 +00:00
Geoff Buesing 125689cd34 ValidationErrors#on: allow String field_name 2009-03-24 23:57:28 -07:00
Geoff Buesing 49d19e2a29 Validation inheritance: do deeper dup so that child classes don't add to the parent's validations 2009-03-24 23:56:41 -07:00
Matt Aimonetti 115cb6a7ee fixed the subclassing of ExtendedDocument classes 2009-03-19 18:53:17 -07:00
Geoff Buesing bb119ae181 Move require of stdlib time from extended_document to properties 2009-03-19 16:59:58 -07:00
Geoff Buesing a1a4985149 Namespace Extlib versions of class_inheritable_accessor methods with extlib_prefix, as done in Wycats' Rails fork, so that their inclusion won't overwrite existing ActiveSupport implementations, if present. Check for existence of Class extensions on a per-method basis. 2009-03-19 16:59:22 -07:00
Geoff Buesing de0476b083 ExtendedDocument: don't require Extlib. Explicitly require Ruby stdlib time (which provides Time.parse), which was required by Extlib::Logger. 2009-03-19 16:38:47 -07:00
Geoff Buesing 1517622d53 Time#to_json monkeypatch: use Time#getutc instead of #utc, so that self is not modified 2009-03-19 16:38:20 -07:00
Geoff Buesing d9417f3915 Extract humanize method from Extlib::Inflection to CouchRest.humanize, so that Extlib::Inflection dependency can be removed 2009-03-19 16:37:45 -07:00
Matt Aimonetti ef8933432a Merge branch 'master' of git://github.com/jchris/couchrest
* 'master' of git://github.com/jchris/couchrest:
  Remove CouchRest.move, CouchRest::Database#move and #move_doc, because these methods are no longer supported by CouchDB
2009-03-19 16:35:31 -07:00
Geoff Buesing 4d8314124b Remove CouchRest.move, CouchRest::Database#move and #move_doc, because these methods are no longer supported by CouchDB
Ref: http://n2.nabble.com/Removing-MOVE-td2490780.html#a2490780
2009-03-18 11:22:49 -05:00
Matt Aimonetti aad6b8383d merged jchris/master 2009-03-16 14:57:29 -07:00
Chris Anderson 76ef427862 rev gem to version 0.17.0 2009-03-15 13:01:39 -07:00
Chris Anderson 36c8bea453 all specs pass against couchdb trunk 2009-03-15 13:00:47 -07:00
Chris Anderson 917157a0e7 rev version and new gemspec 2009-03-14 19:03:17 -07:00
Chris Anderson fbc21aacd9 updater is simpler now that I learned about open_revs=all 2009-03-14 19:00:26 -07:00
Chris Anderson 8964a9b282 created upgrade helper 2009-03-14 18:42:34 -07:00
Matt Aimonetti d2c461e7f0 bumped the version # since this version is only compatible with latest couchdb trunk 2009-03-11 15:15:08 -07:00
Chris Anderson b3a6a081fd fix for design doc url changes 2009-03-11 15:13:01 -07:00
Chris Anderson 7b03c7ba25 fix for design doc url changes 2009-03-09 13:12:28 -07:00
Matt Aimonetti bfff491202 bumped the version number 2009-03-06 16:31:07 -08:00
Matt Aimonetti 5607936540 updated the callback system using Yehuda's latest version and bumped the release to make the latest fixes available 2009-03-05 23:52:48 -08:00
Matthew Ford fdb0854859 Fix a bug where class extentions were conflicting with ActiveSupport 2009-03-05 21:19:27 -08:00
Matthew Ford d95b9de50d Fix net/http monkey patch, to prevent conflicts with other libraries.
Using the patch included in http://redmine.ruby-lang.org/issues/show/806
2009-03-05 21:19:13 -08:00
Matt Aimonetti 813f673d88 increased the bulk cache limit to 500, it can be manually increased up to 1000 safely 2009-03-05 15:06:56 -08:00
Matt Aimonetti 3e6dba7b66 fixed a bug with ExtendedDocument not declaring any views and trying to use #all or #first 2009-03-03 16:57:59 -08:00
Matt Aimonetti 98fb1d728d bumped to 0.2 now that I rebased with master 2009-03-02 22:40:29 -08:00
Matt Aimonetti 0250fea373 Merge branch 'master' of git://github.com/jchris/couchrest
* 'master' of git://github.com/jchris/couchrest:
  dcnstrct says Timeout::Error is the constant we probably mean
  fixed db spec
2009-03-02 22:37:36 -08:00
Matt Aimonetti 7455152f63 fixed a typo in the previous commit 2009-03-02 22:36:57 -08:00
Matt Aimonetti d383c5a7d4 fixed a typo added when I added more debugging info to the request processing 2009-03-02 21:26:18 -08:00
Matt Aimonetti b1999ac8b7 Merge branch 'casted-extendeddocument'
* casted-extendeddocument:
  fixed a bug where :include_docs on a view couldn't be overwritten
  spec'd casted extended document
2009-03-02 21:22:15 -08:00
Matt Aimonetti 5258a0ba52 fixed a bug where :include_docs on a view couldn't be overwritten 2009-03-02 21:21:59 -08:00
Matt Aimonetti 55ecda2c90 spec'd casted extended document 2009-03-02 21:15:02 -08:00
Chris Anderson 70d594ff5c dcnstrct says Timeout::Error is the constant we probably mean 2009-02-27 12:27:52 -08:00
Matt Aimonetti 4bfb69b3ce added a debugging statement on PUT failures 2009-02-26 19:53:01 -08:00
Matt Aimonetti bb93a5bb1f added rescue message to GET request 2009-02-26 18:44:39 -08:00
Matt Aimonetti 80317f31a5 fixed the uuid count for the latest version of couchdb
also avoided CONSTANTS warnings, cleaned up the attachment specs, added missing fixtures
2009-02-25 00:22:11 -08:00
Matt Aimonetti fe489f2d38 removed CouchRest::Model, added more specs and fixed a bug with casted CR::ExtendedDocument 2009-02-24 22:51:13 -08:00
Matt Aimonetti 72542dc876 fixed a bug with validation 2009-02-20 18:32:01 -08:00
Matt Aimonetti 2f8caa8740 added a new validator 2009-02-20 15:34:49 -08:00
Matt Aimonetti be469b2a86 bumped release to 0.14 after implementing the new features in a real life app.
* added extended attachments
* fixed a bug with default values
2009-02-17 17:59:31 -08:00
Matt Aimonetti c4cce18389 added database.bulk_delete as an alias for #bulk_save, added support for Model.by_view_name in ExtendedDoc and bumped the version to 0.13.3 2009-02-17 00:36:11 -08:00
Matt Aimonetti 3a57ed1414 fixed a bug with the RestClient optimization, added more callbacks on the ExtendedDocument and added support for casted arrays of objects. 2009-02-12 20:28:07 -08:00
Matt Aimonetti b79bb9a912 getting GH to build my gem, :emo:test #2 2009-02-10 18:06:25 -08:00
Matt Aimonetti e000c8b68c bumped release to 0.13 2009-02-10 16:20:33 -08:00
Matt Aimonetti c0abafd1e0 fixed a major bug with inheritance and the class database setup. (plus some validation bugs) 2009-02-10 16:10:35 -08:00
Matt Aimonetti e448112ff6 fixed some serious issues but left some for tomorrow (validations aren't working right) 2009-02-10 02:15:39 -08:00
Matt Aimonetti bc47e72ae0 fixed a bug with the casting of time objects 2009-02-09 15:12:22 -08:00
Matt Aimonetti e07e5b468f fixed a bug with a default value being a proc 2009-02-09 12:08:55 -08:00
Matt Aimonetti 621f5565e9 Started working on casted models, basic functionalities are now in.
property :casted_attribute, :cast_as => 'WithCastedModelMixin'

A casted attribute now knows about its parent. (#casted_by to retrieve the parent's object)
2009-02-09 11:20:23 -08:00
Matt Aimonetti fa7b176fce [extended-document] added support for property :name, :default => 'Matt" and default couchrest type 2009-02-05 18:57:11 -08:00
Matt Aimonetti 890b60cae4 added autovalidation (auto_validate! in your ExtendedDocument) and extracted some extlib stuff so we will soon be able to remove the dependency. 2009-02-05 17:06:12 -08:00
Matt Aimonetti e9930c5a86 extracted the response class to its own file 2009-02-05 16:56:48 -08:00
Matt Aimonetti 5d9e9fc53f simplified the validation callback method. 2009-02-03 18:23:30 -08:00
Matt Aimonetti fec21c3ff3 got rid of extlib hooking system in favor of the new Rails3 callback system. As well as fixed timestamps! in ExtendedDoc 2009-02-03 17:33:31 -08:00
Matt Aimonetti dfdcd79a58 Started added a validation mixin
Usage:
  class Invoice < CouchRest::ExtendedDocument
    include CouchRest::Validation

    property :client_name
    property :employee_name
    property :location

    # Validation
    validates_present :client_name, :employee_name
    validates_present :location, :message => "Hey stupid!, you forgot the location"

  end
2009-02-02 19:21:32 -08:00
Matt Aimonetti 475e970c26 renamed the ExtendedViews mixin 2009-02-02 16:16:14 -08:00
Matt Aimonetti 08c7f2107c moved stuff around and cleaned up some deprecation notices [save/save_doc] 2009-02-02 16:10:07 -08:00
Chris Anderson 60c577963d all specs pass; refined attachment api 2009-02-02 15:24:31 -08:00
Matt Aimonetti d64fa45cf0 Started on the ExtendedDocument class with features moved to mixins.
Properties got added, they define getters, setters and aliases.
They will also be the base of the new validation system.
2009-02-02 14:53:46 -08:00
Matt Aimonetti 83d7341553 Started on the ExtendedDocument class with features moved to mixins.
Properties got added, they define getters, setters and aliases.
They will also be the base of the new validation system.
2009-02-02 14:51:41 -08:00
Matt Aimonetti d9fe6ba374 Started the refactoring work on couchrest.
* A server can have multiple defined available databases set to be used by documents (think DM repos)
* A server can have a default database so documents can easily share the same db connection
* Let a document class have a default database to use
* Give access to a document uri
* extracted some of the document features to a mixin
2009-02-02 14:51:41 -08:00
Matt Aimonetti 427122c98a added some monkey patches to improve the http connection speed. (by keeping the http connection open) 2009-02-02 14:50:30 -08:00
Matt Aimonetti 84e2bf94e4 slight change of API, CR::Document now uses <action>_doc instead of <action>, also added #create! and #recreate! to Document instances 2009-02-02 14:50:30 -08:00
Matt Lyon a4a2b202ae Added attachment methods to CocuhRest::Document: #put_attachment, #fetch_attachment and #delete_attachment. Note you can overwrite exisitng attachments with #put_attachment. 2009-02-02 01:25:14 -08:00