couchdb-client 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module CouchDB
2
2
  class Client
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.1"
4
4
  end
5
5
  end
@@ -60,7 +60,7 @@ module CouchDB
60
60
  #
61
61
  # This method can be used to create and update a document.
62
62
  def put(data)
63
- data = new_doc data
63
+ data = new_doc data unless data.is_a?(doc_class)
64
64
  raise InvalidObject.new(data) unless data.valid?
65
65
 
66
66
  resp =
@@ -64,7 +64,7 @@ module CouchDB
64
64
  h
65
65
  }
66
66
 
67
- super "#{json_object} is invalid."
67
+ super "#{json_object.inspect} is invalid."
68
68
  end
69
69
 
70
70
  def to_hash
@@ -136,13 +136,19 @@ module CouchDB
136
136
  errors.clear
137
137
 
138
138
  properties.each { |k, property|
139
- if property.required? and self[k].nil?
139
+ v = self[k]
140
+
141
+ if property.required? and v.nil?
140
142
  errors[k] = MissingProperty.new(k)
141
143
  next
142
144
  end
143
145
 
144
- if not property.valid_value?(self[k])
145
- errors[k] = InvalidValue.new(k, self[k])
146
+ if not property.valid_value?(v)
147
+ errors[k] = InvalidValue.new(k, v)
148
+ end
149
+
150
+ if v.is_a?(JSONObject) and not v.valid?
151
+ errors[k] = InvalidObject.new(v)
146
152
  end
147
153
  }
148
154
  end
data/lib/couchdb/model.rb CHANGED
@@ -93,6 +93,10 @@ module CouchDB
93
93
  freeze
94
94
  end
95
95
 
96
+ def errors
97
+ @doc.errors
98
+ end
99
+
96
100
  def to_hash
97
101
  @doc.to_hash
98
102
  end
metadata CHANGED
@@ -1,65 +1,55 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: couchdb-client
3
- version: !ruby/object:Gem::Version
4
- hash: 23
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 0
9
- - 0
10
- version: 1.0.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Gimi Liang
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-09-12 00:00:00 +08:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2012-09-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: json
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
18
+ requirements:
27
19
  - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 1
30
- segments:
31
- - 1
32
- - 7
33
- - 5
20
+ - !ruby/object:Gem::Version
34
21
  version: 1.7.5
35
22
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: httparty
39
23
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 1.7.5
30
+ - !ruby/object:Gem::Dependency
31
+ name: httparty
32
+ requirement: !ruby/object:Gem::Requirement
41
33
  none: false
42
- requirements:
34
+ requirements:
43
35
  - - ~>
44
- - !ruby/object:Gem::Version
45
- hash: 57
46
- segments:
47
- - 0
48
- - 8
49
- - 3
36
+ - !ruby/object:Gem::Version
50
37
  version: 0.8.3
51
38
  type: :runtime
52
- version_requirements: *id002
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.8.3
53
46
  description: A pure Ruby CouchDB client.
54
- email:
47
+ email:
55
48
  - liang.gimi@gmail.com
56
49
  executables: []
57
-
58
50
  extensions: []
59
-
60
51
  extra_rdoc_files: []
61
-
62
- files:
52
+ files:
63
53
  - .gitignore
64
54
  - Gemfile
65
55
  - LICENSE
@@ -81,41 +71,31 @@ files:
81
71
  - test/model_test.rb
82
72
  - test/test_all.rb
83
73
  - test/test_helper.rb
84
- has_rdoc: true
85
- homepage: ""
74
+ homepage: ''
86
75
  licenses: []
87
-
88
76
  post_install_message:
89
77
  rdoc_options: []
90
-
91
- require_paths:
78
+ require_paths:
92
79
  - lib
93
- required_ruby_version: !ruby/object:Gem::Requirement
80
+ required_ruby_version: !ruby/object:Gem::Requirement
94
81
  none: false
95
- requirements:
96
- - - ">="
97
- - !ruby/object:Gem::Version
98
- hash: 3
99
- segments:
100
- - 0
101
- version: "0"
102
- required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
87
  none: false
104
- requirements:
105
- - - ">="
106
- - !ruby/object:Gem::Version
107
- hash: 3
108
- segments:
109
- - 0
110
- version: "0"
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
111
92
  requirements: []
112
-
113
93
  rubyforge_project:
114
- rubygems_version: 1.3.9.5
94
+ rubygems_version: 1.8.24
115
95
  signing_key:
116
96
  specification_version: 3
117
97
  summary: A pure Ruby CouchDB client.
118
- test_files:
98
+ test_files:
119
99
  - test/client_test.rb
120
100
  - test/database_test.rb
121
101
  - test/json_object_test.rb