couchrest 0.38 → 1.0.0.beta

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.
Files changed (77) hide show
  1. data/README.md +8 -8
  2. data/Rakefile +3 -4
  3. data/couchrest.gemspec +25 -105
  4. data/history.txt +5 -4
  5. data/lib/couchrest.rb +31 -52
  6. data/lib/couchrest/{core/database.rb → database.rb} +6 -11
  7. data/lib/couchrest/{core/design.rb → design.rb} +2 -2
  8. data/lib/couchrest/{core/document.rb → document.rb} +1 -1
  9. data/lib/couchrest/helper/attachments.rb +29 -0
  10. data/lib/couchrest/middlewares/logger.rb +3 -3
  11. data/lib/couchrest/monkeypatches.rb +1 -71
  12. data/lib/couchrest/{core/response.rb → response.rb} +0 -0
  13. data/lib/couchrest/{core/rest_api.rb → rest_api.rb} +8 -12
  14. data/lib/couchrest/{core/server.rb → server.rb} +0 -2
  15. data/spec/couchrest/{core/couchrest_spec.rb → couchrest_spec.rb} +15 -9
  16. data/spec/couchrest/{core/database_spec.rb → database_spec.rb} +4 -4
  17. data/spec/couchrest/{core/design_spec.rb → design_spec.rb} +2 -2
  18. data/spec/couchrest/{core/document_spec.rb → document_spec.rb} +1 -1
  19. data/spec/couchrest/{core/server_spec.rb → server_spec.rb} +2 -2
  20. data/spec/spec.opts +0 -1
  21. data/spec/spec_helper.rb +0 -4
  22. metadata +32 -133
  23. data/examples/model/example.rb +0 -144
  24. data/lib/couchrest/core/adapters/restclient.rb +0 -35
  25. data/lib/couchrest/core/http_abstraction.rb +0 -48
  26. data/lib/couchrest/core/view.rb +0 -4
  27. data/lib/couchrest/mixins.rb +0 -4
  28. data/lib/couchrest/mixins/attachments.rb +0 -31
  29. data/lib/couchrest/mixins/attribute_protection.rb +0 -74
  30. data/lib/couchrest/mixins/callbacks.rb +0 -532
  31. data/lib/couchrest/mixins/class_proxy.rb +0 -124
  32. data/lib/couchrest/mixins/collection.rb +0 -260
  33. data/lib/couchrest/mixins/design_doc.rb +0 -103
  34. data/lib/couchrest/mixins/document_queries.rb +0 -80
  35. data/lib/couchrest/mixins/extended_attachments.rb +0 -70
  36. data/lib/couchrest/mixins/extended_document_mixins.rb +0 -9
  37. data/lib/couchrest/mixins/properties.rb +0 -158
  38. data/lib/couchrest/mixins/validation.rb +0 -246
  39. data/lib/couchrest/mixins/views.rb +0 -173
  40. data/lib/couchrest/more/casted_model.rb +0 -58
  41. data/lib/couchrest/more/extended_document.rb +0 -310
  42. data/lib/couchrest/more/property.rb +0 -58
  43. data/lib/couchrest/more/typecast.rb +0 -180
  44. data/lib/couchrest/support/blank.rb +0 -42
  45. data/lib/couchrest/support/rails.rb +0 -42
  46. data/lib/couchrest/validation/auto_validate.rb +0 -157
  47. data/lib/couchrest/validation/contextual_validators.rb +0 -78
  48. data/lib/couchrest/validation/validation_errors.rb +0 -125
  49. data/lib/couchrest/validation/validators/absent_field_validator.rb +0 -74
  50. data/lib/couchrest/validation/validators/confirmation_validator.rb +0 -107
  51. data/lib/couchrest/validation/validators/format_validator.rb +0 -122
  52. data/lib/couchrest/validation/validators/formats/email.rb +0 -66
  53. data/lib/couchrest/validation/validators/formats/url.rb +0 -43
  54. data/lib/couchrest/validation/validators/generic_validator.rb +0 -120
  55. data/lib/couchrest/validation/validators/length_validator.rb +0 -139
  56. data/lib/couchrest/validation/validators/method_validator.rb +0 -89
  57. data/lib/couchrest/validation/validators/numeric_validator.rb +0 -109
  58. data/lib/couchrest/validation/validators/required_field_validator.rb +0 -114
  59. data/spec/couchrest/more/attribute_protection_spec.rb +0 -150
  60. data/spec/couchrest/more/casted_extended_doc_spec.rb +0 -73
  61. data/spec/couchrest/more/casted_model_spec.rb +0 -406
  62. data/spec/couchrest/more/extended_doc_attachment_spec.rb +0 -135
  63. data/spec/couchrest/more/extended_doc_inherited_spec.rb +0 -40
  64. data/spec/couchrest/more/extended_doc_spec.rb +0 -807
  65. data/spec/couchrest/more/extended_doc_subclass_spec.rb +0 -98
  66. data/spec/couchrest/more/extended_doc_view_spec.rb +0 -456
  67. data/spec/couchrest/more/property_spec.rb +0 -628
  68. data/spec/fixtures/more/article.rb +0 -35
  69. data/spec/fixtures/more/card.rb +0 -22
  70. data/spec/fixtures/more/cat.rb +0 -20
  71. data/spec/fixtures/more/course.rb +0 -22
  72. data/spec/fixtures/more/event.rb +0 -8
  73. data/spec/fixtures/more/invoice.rb +0 -17
  74. data/spec/fixtures/more/person.rb +0 -9
  75. data/spec/fixtures/more/question.rb +0 -6
  76. data/spec/fixtures/more/service.rb +0 -12
  77. data/spec/fixtures/more/user.rb +0 -22
data/README.md CHANGED
@@ -14,12 +14,17 @@ CouchRest is designed to make a simple base for application and framework-specif
14
14
 
15
15
  $ sudo gem install couchrest
16
16
 
17
- ### Relax, it's RESTful
17
+ ## Relax, it's RESTful
18
18
 
19
19
  CouchRest rests on top of a HTTP abstraction layer using by default Heroku’s excellent REST Client Ruby HTTP wrapper.
20
- Other adapters can be added to support more http libraries.
21
20
 
22
- ### Running the Specs
21
+ ## Extended Document
22
+
23
+ As of May 2010 support for the popular CouchRest::ExtendedDocument mixin has been moved to its own gem: [couchrest_extended_document](http://github.com/couchrest/couchrest_extended_document).
24
+
25
+ Most people will probably want to use this library (or one of the alternatives) to make it slightly easier to access your documents.
26
+
27
+ ## Running the Specs
23
28
 
24
29
  The most complete documentation is the spec/ directory. To validate your
25
30
  CouchRest install, from the project root directory run `rake`, or `autotest`
@@ -38,9 +43,4 @@ Please post bugs, suggestions and patches to the bug tracker at [http://github.c
38
43
  Follow us on Twitter: [http://twitter.com/couchrest](http://twitter.com/couchrest)
39
44
 
40
45
  Also, check [http://twitter.com/#search?q=%23couchrest](http://twitter.com/#search?q=%23couchrest)
41
-
42
- ## Ruby on Rails
43
46
 
44
- CouchRest is compatible with rails and can even be used a Rails plugin.
45
- However, you might be interested in the CouchRest companion rails project:
46
- [http://github.com/hpoydar/couchrest-rails](http://github.com/hpoydar/couchrest-rails)
data/Rakefile CHANGED
@@ -24,11 +24,10 @@ begin
24
24
  gemspec.extra_rdoc_files = %w( README.md LICENSE THANKS.md )
25
25
  gemspec.files = %w( LICENSE README.md Rakefile THANKS.md history.txt couchrest.gemspec) + Dir["{examples,lib,spec,utils}/**/*"] - Dir["spec/tmp"]
26
26
  gemspec.has_rdoc = true
27
- gemspec.add_dependency("rest-client", ">= 0.5")
28
- gemspec.add_dependency("mime-types", ">= 1.15")
29
- gemspec.add_dependency("json", "1.2.4")
27
+ gemspec.add_dependency("rest-client", ">= 1.5.1")
28
+ # gemspec.add_dependency("couchrest_extended_document", ">= 1.0.0")
30
29
  gemspec.version = CouchRest::VERSION
31
- gemspec.date = Time.now.strftime("%Y-%m-%d")
30
+ gemspec.date = "2008-11-22"
32
31
  gemspec.require_path = "lib"
33
32
  end
34
33
  rescue LoadError
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{couchrest}
8
- s.version = "0.38"
8
+ s.version = "1.0.0.beta"
9
9
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["J. Chris Anderson", "Matt Aimonetti", "Marcos Tapajos", "Will Leinweber"]
12
- s.date = %q{2010-07-28}
12
+ s.date = %q{2010-06-15}
13
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
14
  s.email = %q{jchris@apache.org}
15
15
  s.extra_rdoc_files = [
@@ -23,7 +23,6 @@ Gem::Specification.new do |s|
23
23
  "Rakefile",
24
24
  "THANKS.md",
25
25
  "couchrest.gemspec",
26
- "examples/model/example.rb",
27
26
  "examples/word_count/markov",
28
27
  "examples/word_count/views/books/chunked-map.js",
29
28
  "examples/word_count/views/books/united-map.js",
@@ -38,82 +37,29 @@ Gem::Specification.new do |s|
38
37
  "lib/couchrest.rb",
39
38
  "lib/couchrest/commands/generate.rb",
40
39
  "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",
40
+ "lib/couchrest/database.rb",
41
+ "lib/couchrest/design.rb",
42
+ "lib/couchrest/document.rb",
43
+ "lib/couchrest/helper/attachments.rb",
50
44
  "lib/couchrest/helper/pager.rb",
51
45
  "lib/couchrest/helper/streamer.rb",
52
46
  "lib/couchrest/helper/upgrade.rb",
53
47
  "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
48
  "lib/couchrest/monkeypatches.rb",
68
- "lib/couchrest/more/casted_model.rb",
69
- "lib/couchrest/more/extended_document.rb",
70
- "lib/couchrest/more/property.rb",
71
- "lib/couchrest/more/typecast.rb",
72
- "lib/couchrest/support/blank.rb",
49
+ "lib/couchrest/response.rb",
50
+ "lib/couchrest/rest_api.rb",
51
+ "lib/couchrest/server.rb",
73
52
  "lib/couchrest/support/class.rb",
74
- "lib/couchrest/support/rails.rb",
75
- "lib/couchrest/validation/auto_validate.rb",
76
- "lib/couchrest/validation/contextual_validators.rb",
77
- "lib/couchrest/validation/validation_errors.rb",
78
- "lib/couchrest/validation/validators/absent_field_validator.rb",
79
- "lib/couchrest/validation/validators/confirmation_validator.rb",
80
- "lib/couchrest/validation/validators/format_validator.rb",
81
- "lib/couchrest/validation/validators/formats/email.rb",
82
- "lib/couchrest/validation/validators/formats/url.rb",
83
- "lib/couchrest/validation/validators/generic_validator.rb",
84
- "lib/couchrest/validation/validators/length_validator.rb",
85
- "lib/couchrest/validation/validators/method_validator.rb",
86
- "lib/couchrest/validation/validators/numeric_validator.rb",
87
- "lib/couchrest/validation/validators/required_field_validator.rb",
88
- "spec/couchrest/core/couchrest_spec.rb",
89
- "spec/couchrest/core/database_spec.rb",
90
- "spec/couchrest/core/design_spec.rb",
91
- "spec/couchrest/core/document_spec.rb",
92
- "spec/couchrest/core/server_spec.rb",
53
+ "spec/couchrest/couchrest_spec.rb",
54
+ "spec/couchrest/database_spec.rb",
55
+ "spec/couchrest/design_spec.rb",
56
+ "spec/couchrest/document_spec.rb",
93
57
  "spec/couchrest/helpers/pager_spec.rb",
94
58
  "spec/couchrest/helpers/streamer_spec.rb",
95
- "spec/couchrest/more/attribute_protection_spec.rb",
96
- "spec/couchrest/more/casted_extended_doc_spec.rb",
97
- "spec/couchrest/more/casted_model_spec.rb",
98
- "spec/couchrest/more/extended_doc_attachment_spec.rb",
99
- "spec/couchrest/more/extended_doc_inherited_spec.rb",
100
- "spec/couchrest/more/extended_doc_spec.rb",
101
- "spec/couchrest/more/extended_doc_subclass_spec.rb",
102
- "spec/couchrest/more/extended_doc_view_spec.rb",
103
- "spec/couchrest/more/property_spec.rb",
59
+ "spec/couchrest/server_spec.rb",
104
60
  "spec/fixtures/attachments/README",
105
61
  "spec/fixtures/attachments/couchdb.png",
106
62
  "spec/fixtures/attachments/test.html",
107
- "spec/fixtures/more/article.rb",
108
- "spec/fixtures/more/card.rb",
109
- "spec/fixtures/more/cat.rb",
110
- "spec/fixtures/more/course.rb",
111
- "spec/fixtures/more/event.rb",
112
- "spec/fixtures/more/invoice.rb",
113
- "spec/fixtures/more/person.rb",
114
- "spec/fixtures/more/question.rb",
115
- "spec/fixtures/more/service.rb",
116
- "spec/fixtures/more/user.rb",
117
63
  "spec/fixtures/views/lib.js",
118
64
  "spec/fixtures/views/test_view/lib.js",
119
65
  "spec/fixtures/views/test_view/only-map.js",
@@ -127,37 +73,17 @@ Gem::Specification.new do |s|
127
73
  s.homepage = %q{http://github.com/couchrest/couchrest}
128
74
  s.rdoc_options = ["--charset=UTF-8"]
129
75
  s.require_paths = ["lib"]
130
- s.rubygems_version = %q{1.3.7}
76
+ s.rubygems_version = %q{1.3.6}
131
77
  s.summary = %q{Lean and RESTful interface to CouchDB.}
132
78
  s.test_files = [
133
- "spec/couchrest/core/couchrest_spec.rb",
134
- "spec/couchrest/core/database_spec.rb",
135
- "spec/couchrest/core/design_spec.rb",
136
- "spec/couchrest/core/document_spec.rb",
137
- "spec/couchrest/core/server_spec.rb",
79
+ "spec/couchrest/couchrest_spec.rb",
80
+ "spec/couchrest/database_spec.rb",
81
+ "spec/couchrest/design_spec.rb",
82
+ "spec/couchrest/document_spec.rb",
138
83
  "spec/couchrest/helpers/pager_spec.rb",
139
84
  "spec/couchrest/helpers/streamer_spec.rb",
140
- "spec/couchrest/more/attribute_protection_spec.rb",
141
- "spec/couchrest/more/casted_extended_doc_spec.rb",
142
- "spec/couchrest/more/casted_model_spec.rb",
143
- "spec/couchrest/more/extended_doc_attachment_spec.rb",
144
- "spec/couchrest/more/extended_doc_inherited_spec.rb",
145
- "spec/couchrest/more/extended_doc_spec.rb",
146
- "spec/couchrest/more/extended_doc_subclass_spec.rb",
147
- "spec/couchrest/more/extended_doc_view_spec.rb",
148
- "spec/couchrest/more/property_spec.rb",
149
- "spec/fixtures/more/article.rb",
150
- "spec/fixtures/more/card.rb",
151
- "spec/fixtures/more/cat.rb",
152
- "spec/fixtures/more/course.rb",
153
- "spec/fixtures/more/event.rb",
154
- "spec/fixtures/more/invoice.rb",
155
- "spec/fixtures/more/person.rb",
156
- "spec/fixtures/more/question.rb",
157
- "spec/fixtures/more/service.rb",
158
- "spec/fixtures/more/user.rb",
85
+ "spec/couchrest/server_spec.rb",
159
86
  "spec/spec_helper.rb",
160
- "examples/model/example.rb",
161
87
  "examples/word_count/word_count.rb",
162
88
  "examples/word_count/word_count_query.rb",
163
89
  "examples/word_count/word_count_views.rb"
@@ -167,19 +93,13 @@ Gem::Specification.new do |s|
167
93
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
168
94
  s.specification_version = 3
169
95
 
170
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
171
- s.add_runtime_dependency(%q<rest-client>, [">= 0.5"])
172
- s.add_runtime_dependency(%q<mime-types>, [">= 1.15"])
173
- s.add_runtime_dependency(%q<json>, ["= 1.2.4"])
96
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
97
+ s.add_runtime_dependency(%q<rest-client>, [">= 1.5.1"])
174
98
  else
175
- s.add_dependency(%q<rest-client>, [">= 0.5"])
176
- s.add_dependency(%q<mime-types>, [">= 1.15"])
177
- s.add_dependency(%q<json>, ["= 1.2.4"])
99
+ s.add_dependency(%q<rest-client>, [">= 1.5.1"])
178
100
  end
179
101
  else
180
- s.add_dependency(%q<rest-client>, [">= 0.5"])
181
- s.add_dependency(%q<mime-types>, [">= 1.15"])
182
- s.add_dependency(%q<json>, ["= 1.2.4"])
102
+ s.add_dependency(%q<rest-client>, [">= 1.5.1"])
183
103
  end
184
104
  end
185
105
 
@@ -1,16 +1,17 @@
1
1
  == Next Version
2
2
 
3
3
  * Major enhancements
4
+ * Add create_target option to Database#replicate_to and #replicate_from. http://github.com/couchrest/couchrest/issues/#issue/26 (Alexander Uvarov)
4
5
 
5
6
  * Minor enhancements
6
7
 
7
- == 0.38
8
+ == 1.0.0.beta
8
9
 
9
10
  * Major enhancements
10
- * Add create_target option to Database#replicate_to and #replicate_from. http://github.com/couchrest/couchrest/issues/#issue/26 (Alexander Uvarov)
11
+ * Moved ExtendedDocument and friends into own library, couchrest_extended_document. (Sam Lown)
12
+ * Removed HttpAbstraction component for direct interface with RestClient. (Sam Lown)
13
+ * Changed version to more conventional format starting from 1.0.0 to avoid ambiguity issues with order. (Sam Lown)
11
14
 
12
- * Minor enhancements
13
- * Support for CouchDB 1.0
14
15
 
15
16
  == 0.37
16
17
 
@@ -16,40 +16,33 @@ require 'rubygems'
16
16
  begin
17
17
  require 'json'
18
18
  rescue LoadError
19
- raise "You need install and require your own json compatible library since couchrest rest couldn't load the json/json_pure gem" unless Kernel.const_defined?("JSON")
19
+ raise "No compatible json library found, install either json or json_pure gem" unless Kernel.const_defined?("JSON")
20
20
  end
21
21
  require 'rest_client'
22
22
 
23
+ # Not sure why this is required, so removed until a reason is found!
23
24
  $:.unshift File.dirname(__FILE__) unless
24
- $:.include?(File.dirname(__FILE__)) ||
25
- $:.include?(File.expand_path(File.dirname(__FILE__)))
25
+ $:.include?(File.dirname(__FILE__)) ||
26
+ $:.include?(File.expand_path(File.dirname(__FILE__)))
26
27
 
27
28
  require 'couchrest/monkeypatches'
29
+ require 'couchrest/rest_api'
28
30
 
29
31
  # = CouchDB, close to the metal
30
32
  module CouchRest
31
- VERSION = '0.38' unless self.const_defined?("VERSION")
33
+ VERSION = '1.0.0.beta'
32
34
 
33
- autoload :Server, 'couchrest/core/server'
34
- autoload :Database, 'couchrest/core/database'
35
- autoload :Response, 'couchrest/core/response'
36
- autoload :Document, 'couchrest/core/document'
37
- autoload :Design, 'couchrest/core/design'
38
- autoload :View, 'couchrest/core/view'
39
- autoload :Model, 'couchrest/core/model'
35
+ autoload :Server, 'couchrest/server'
36
+ autoload :Database, 'couchrest/database'
37
+ autoload :Response, 'couchrest/response'
38
+ autoload :Document, 'couchrest/document'
39
+ autoload :Design, 'couchrest/design'
40
+ autoload :Model, 'couchrest/model'
40
41
  autoload :Pager, 'couchrest/helper/pager'
41
- autoload :FileManager, 'couchrest/helper/file_manager'
42
42
  autoload :Streamer, 'couchrest/helper/streamer'
43
+ autoload :Attachments, 'couchrest/helper/attachments'
43
44
  autoload :Upgrade, 'couchrest/helper/upgrade'
44
-
45
- autoload :ExtendedDocument, 'couchrest/more/extended_document'
46
- autoload :CastedModel, 'couchrest/more/casted_model'
47
-
48
- require File.join(File.dirname(__FILE__), 'couchrest', 'core', 'rest_api')
49
- require File.join(File.dirname(__FILE__), 'couchrest', 'core', 'http_abstraction')
50
- require File.join(File.dirname(__FILE__), 'couchrest', 'mixins')
51
- require File.join(File.dirname(__FILE__), 'couchrest', 'support', 'rails') if defined?(Rails)
52
-
45
+
53
46
  # we extend CouchRest with the RestAPI module which gives us acess to
54
47
  # the get, post, put, delete and copy
55
48
  CouchRest.extend(::RestAPI)
@@ -59,35 +52,6 @@ module CouchRest
59
52
  # some helpers for tasks like instantiating a new Database or Server instance.
60
53
  class << self
61
54
 
62
- # extracted from Extlib
63
- #
64
- # Constantize tries to find a declared constant with the name specified
65
- # in the string. It raises a NameError when the name is not in CamelCase
66
- # or is not initialized.
67
- #
68
- # @example
69
- # "Module".constantize #=> Module
70
- # "Class".constantize #=> Class
71
- def constantize(camel_cased_word)
72
- unless /\A(?:::)?([A-Z]\w*(?:::[A-Z]\w*)*)\z/ =~ camel_cased_word
73
- raise NameError, "#{camel_cased_word.inspect} is not a valid constant name!"
74
- end
75
-
76
- Object.module_eval("::#{$1}", __FILE__, __LINE__)
77
- end
78
-
79
- # extracted from Extlib
80
- #
81
- # Capitalizes the first word and turns underscores into spaces and strips _id.
82
- # Like titleize, this is meant for creating pretty output.
83
- #
84
- # @example
85
- # "employee_salary" #=> "Employee salary"
86
- # "author_id" #=> "Author"
87
- def humanize(lower_case_and_underscored_word)
88
- lower_case_and_underscored_word.to_s.gsub(/_id$/, "").gsub(/_/, " ").capitalize
89
- end
90
-
91
55
  # todo, make this parse the url and instantiate a Server or Database instance
92
56
  # depending on the specificity.
93
57
  def new(*opts)
@@ -130,9 +94,9 @@ module CouchRest
130
94
 
131
95
  # set proxy to use
132
96
  def proxy url
133
- HttpAbstraction.proxy = url
97
+ RestClient.proxy = url
134
98
  end
135
-
99
+
136
100
  # ensure that a database exists
137
101
  # creates it if it isn't already there
138
102
  # returns it after it's been created
@@ -160,3 +124,18 @@ module CouchRest
160
124
  end
161
125
  end # class << self
162
126
  end
127
+
128
+ # For the sake of backwards compatability, generate a dummy ExtendedDocument class
129
+ # which should be replaced by real library: couchrest_extended_document.
130
+ #
131
+ # Added 2010-05-10 by Sam Lown. Please remove at some point in the future.
132
+ #
133
+ class CouchRest::ExtendedDocument < CouchRest::Document
134
+
135
+ def self.inherited(subclass)
136
+ raise "ExtendedDocument is no longer included in CouchRest base driver, see couchrest_extended_document gem"
137
+ end
138
+
139
+ end
140
+
141
+
@@ -65,7 +65,7 @@ module CouchRest
65
65
  keys = params.delete(:keys)
66
66
  funcs = funcs.merge({:keys => keys}) if keys
67
67
  url = CouchRest.paramify_url "#{@root}/_temp_view", params
68
- CouchRest.post(url, funcs)
68
+ JSON.parse(RestClient.post(url, funcs.to_json, {"Content-Type" => 'application/json'}))
69
69
  end
70
70
 
71
71
  # backwards compatibility is a plus
@@ -108,14 +108,14 @@ module CouchRest
108
108
  # GET an attachment directly from CouchDB
109
109
  def fetch_attachment(doc, name)
110
110
  uri = url_for_attachment(doc, name)
111
- HttpAbstraction.get uri
111
+ RestClient.get uri
112
112
  end
113
113
 
114
114
  # PUT an attachment directly to CouchDB
115
115
  def put_attachment(doc, name, file, options = {})
116
116
  docid = escape_docid(doc['_id'])
117
117
  uri = url_for_attachment(doc, name)
118
- JSON.parse(HttpAbstraction.put(uri, file, CouchRest.default_headers.update(options)))
118
+ JSON.parse(RestClient.put(uri, file, options))
119
119
  end
120
120
 
121
121
  # DELETE an attachment directly from CouchDB
@@ -123,13 +123,13 @@ module CouchRest
123
123
  uri = url_for_attachment(doc, name)
124
124
  # this needs a rev
125
125
  begin
126
- CouchRest.delete(uri)
126
+ JSON.parse(RestClient.delete(uri))
127
127
  rescue Exception => error
128
128
  if force
129
129
  # get over a 409
130
130
  doc = get(doc['_id'])
131
131
  uri = url_for_attachment(doc, name)
132
- CouchRest.delete(uri)
132
+ JSON.parse(RestClient.delete(uri))
133
133
  else
134
134
  error
135
135
  end
@@ -174,7 +174,7 @@ module CouchRest
174
174
  uri = "#{@root}/#{slug}"
175
175
  uri << "?batch=ok" if batch
176
176
  CouchRest.put uri, doc
177
- rescue HttpAbstraction::ResourceNotFound
177
+ rescue RestClient::ResourceNotFound
178
178
  p "resource not found when saving even tho an id was passed"
179
179
  slug = doc['_id'] = @server.next_uuid
180
180
  CouchRest.put "#{@root}/#{slug}", doc
@@ -316,7 +316,6 @@ module CouchRest
316
316
  # DELETE the database itself. This is not undoable and could be rather
317
317
  # catastrophic. Use with care!
318
318
  def delete!
319
- clear_extended_doc_fresh_cache
320
319
  CouchRest.delete @root
321
320
  end
322
321
 
@@ -334,10 +333,6 @@ module CouchRest
334
333
  payload[:continuous] = continuous
335
334
  CouchRest.post "#{@host}/_replicate", payload
336
335
  end
337
-
338
- def clear_extended_doc_fresh_cache
339
- ::CouchRest::ExtendedDocument.subclasses.each{|klass| klass.design_doc_fresh = false if klass.respond_to?(:design_doc_fresh=) }
340
- end
341
336
 
342
337
  def uri_for_attachment(doc, name)
343
338
  if doc.is_a?(String)
@@ -67,7 +67,7 @@ JAVASCRIPT
67
67
  def has_view?(view)
68
68
  view = view.to_s
69
69
  self['views'][view] &&
70
- (self['views'][view]["couchrest-defaults"]||{})
70
+ (self['views'][view]["couchrest-defaults"] || {})
71
71
  end
72
72
 
73
73
  def fetch_view view_name, opts, &block
@@ -76,4 +76,4 @@ JAVASCRIPT
76
76
 
77
77
  end
78
78
 
79
- end
79
+ end