dm-rest-adapter 1.1.0.rc2 → 1.1.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/VERSION +1 -1
- data/dm-rest-adapter.gemspec +9 -9
- data/lib/dm-rest-adapter/adapter.rb +6 -4
- data/lib/dm-rest-adapter/connection.rb +2 -10
- data/spec/semipublic/rest_adapter_spec.rb +8 -8
- data/spec/spec_helper.rb +1 -13
- metadata +5 -5
data/Gemfile
CHANGED
@@ -5,7 +5,7 @@ source 'http://rubygems.org'
|
|
5
5
|
SOURCE = ENV.fetch('SOURCE', :git).to_sym
|
6
6
|
REPO_POSTFIX = SOURCE == :path ? '' : '.git'
|
7
7
|
DATAMAPPER = SOURCE == :path ? Pathname(__FILE__).dirname.parent : 'http://github.com/datamapper'
|
8
|
-
DM_VERSION = '~> 1.1.0.
|
8
|
+
DM_VERSION = '~> 1.1.0.rc3'
|
9
9
|
|
10
10
|
gem 'dm-serializer', DM_VERSION, SOURCE => "#{DATAMAPPER}/dm-serializer#{REPO_POSTFIX}"
|
11
11
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.0.
|
1
|
+
1.1.0.rc3
|
data/dm-rest-adapter.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{dm-rest-adapter}
|
8
|
-
s.version = "1.1.0.
|
8
|
+
s.version = "1.1.0.rc3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Scott Burton @ Joyent Inc"]
|
12
|
-
s.date = %q{2011-03-
|
12
|
+
s.date = %q{2011-03-10}
|
13
13
|
s.description = %q{REST Adapter for DataMapper}
|
14
14
|
s.email = %q{scott.burton [a] joyent [d] com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -43,7 +43,7 @@ Gem::Specification.new do |s|
|
|
43
43
|
s.homepage = %q{http://github.com/datamapper/dm-rest-adapter}
|
44
44
|
s.require_paths = ["lib"]
|
45
45
|
s.rubyforge_project = %q{datamapper}
|
46
|
-
s.rubygems_version = %q{1.
|
46
|
+
s.rubygems_version = %q{1.6.2}
|
47
47
|
s.summary = %q{REST Adapter for DataMapper}
|
48
48
|
s.test_files = [
|
49
49
|
"spec/fixtures/book.rb",
|
@@ -57,23 +57,23 @@ Gem::Specification.new do |s|
|
|
57
57
|
s.specification_version = 3
|
58
58
|
|
59
59
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
60
|
-
s.add_runtime_dependency(%q<dm-serializer>, ["~> 1.1.0.
|
61
|
-
s.add_development_dependency(%q<dm-validations>, ["~> 1.1.0.
|
60
|
+
s.add_runtime_dependency(%q<dm-serializer>, ["~> 1.1.0.rc3"])
|
61
|
+
s.add_development_dependency(%q<dm-validations>, ["~> 1.1.0.rc3"])
|
62
62
|
s.add_development_dependency(%q<fakeweb>, ["~> 1.3"])
|
63
63
|
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
64
64
|
s.add_development_dependency(%q<rake>, ["~> 0.8.7"])
|
65
65
|
s.add_development_dependency(%q<rspec>, ["~> 1.3.1"])
|
66
66
|
else
|
67
|
-
s.add_dependency(%q<dm-serializer>, ["~> 1.1.0.
|
68
|
-
s.add_dependency(%q<dm-validations>, ["~> 1.1.0.
|
67
|
+
s.add_dependency(%q<dm-serializer>, ["~> 1.1.0.rc3"])
|
68
|
+
s.add_dependency(%q<dm-validations>, ["~> 1.1.0.rc3"])
|
69
69
|
s.add_dependency(%q<fakeweb>, ["~> 1.3"])
|
70
70
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
71
71
|
s.add_dependency(%q<rake>, ["~> 0.8.7"])
|
72
72
|
s.add_dependency(%q<rspec>, ["~> 1.3.1"])
|
73
73
|
end
|
74
74
|
else
|
75
|
-
s.add_dependency(%q<dm-serializer>, ["~> 1.1.0.
|
76
|
-
s.add_dependency(%q<dm-validations>, ["~> 1.1.0.
|
75
|
+
s.add_dependency(%q<dm-serializer>, ["~> 1.1.0.rc3"])
|
76
|
+
s.add_dependency(%q<dm-validations>, ["~> 1.1.0.rc3"])
|
77
77
|
s.add_dependency(%q<fakeweb>, ["~> 1.3"])
|
78
78
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
79
79
|
s.add_dependency(%q<rake>, ["~> 0.8.7"])
|
@@ -129,14 +129,16 @@ module DataMapperRest
|
|
129
129
|
raise "No root element matching #{element_name} in xml"
|
130
130
|
end
|
131
131
|
|
132
|
-
|
132
|
+
pairs = model.properties(name).map { |p| [ p.field, p ] }
|
133
|
+
field_to_property = DataMapper::Ext::Array.to_hash(pairs)
|
133
134
|
record_from_rexml(entity_element, field_to_property)
|
134
135
|
end
|
135
136
|
|
136
137
|
def parse_resources(xml, model)
|
137
138
|
doc = REXML::Document::new(xml)
|
138
139
|
|
139
|
-
|
140
|
+
pairs = model.properties(name).map { |p| [ p.field, p ] }
|
141
|
+
field_to_property = DataMapper::Ext::Array.to_hash(pairs)
|
140
142
|
element_name = element_name(model)
|
141
143
|
|
142
144
|
doc.elements.collect("/#{resource_name(model)}/#{element_name}") do |entity_element|
|
@@ -145,7 +147,7 @@ module DataMapperRest
|
|
145
147
|
end
|
146
148
|
|
147
149
|
def element_name(model)
|
148
|
-
model.storage_name(self.name)
|
150
|
+
DataMapper::Inflector.singularize(model.storage_name(self.name))
|
149
151
|
end
|
150
152
|
|
151
153
|
def resource_name(model)
|
@@ -153,7 +155,7 @@ module DataMapperRest
|
|
153
155
|
end
|
154
156
|
|
155
157
|
def update_with_response(resource, response)
|
156
|
-
return unless response.kind_of?(Net::HTTPSuccess) && !response.body
|
158
|
+
return unless response.kind_of?(Net::HTTPSuccess) && !DataMapper::Ext.blank?(response.body)
|
157
159
|
|
158
160
|
model = resource.model
|
159
161
|
properties = model.properties(name)
|
@@ -1,13 +1,5 @@
|
|
1
1
|
require 'net/http'
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'active_support/inflector'
|
5
|
-
rescue LoadError
|
6
|
-
require 'extlib/inflection'
|
7
|
-
module ActiveSupport
|
8
|
-
Inflector = Extlib::Inflection unless defined?(Inflector)
|
9
|
-
end
|
10
|
-
end
|
2
|
+
require 'dm-core/support/inflector'
|
11
3
|
|
12
4
|
module DataMapperRest
|
13
5
|
# Somewhat stolen from ActiveResource
|
@@ -40,7 +32,7 @@ module DataMapperRest
|
|
40
32
|
|
41
33
|
def run_verb(verb, data = nil)
|
42
34
|
request do |http|
|
43
|
-
klass =
|
35
|
+
klass = DataMapper::Ext::Module.find_const(Net::HTTP, DataMapper::Inflector.camelize(verb))
|
44
36
|
request = klass.new(@uri.to_s, @format.header)
|
45
37
|
request.basic_auth(@uri.user, @uri.password) if @uri.user && @uri.password
|
46
38
|
result = http.request(request, data)
|
@@ -12,7 +12,7 @@ describe DataMapper::Adapters::RestAdapter do
|
|
12
12
|
describe '#create' do
|
13
13
|
describe 'when provided a Resource' do
|
14
14
|
before :all do
|
15
|
-
body = <<-XML
|
15
|
+
body = DataMapper::Ext::String.compress_lines(<<-XML)
|
16
16
|
<book>
|
17
17
|
<id type='datamapper::types::serial'>1</id>
|
18
18
|
<created_at type='datetime'>2009-05-17T22:38:42-07:00</created_at>
|
@@ -46,7 +46,7 @@ describe DataMapper::Adapters::RestAdapter do
|
|
46
46
|
describe '#read' do
|
47
47
|
describe 'with unscoped query' do
|
48
48
|
before :all do
|
49
|
-
body = <<-XML
|
49
|
+
body = DataMapper::Ext::String.compress_lines(<<-XML)
|
50
50
|
<books>
|
51
51
|
<book>
|
52
52
|
<id type='datamapper::types::serial'>1</id>
|
@@ -82,7 +82,7 @@ describe DataMapper::Adapters::RestAdapter do
|
|
82
82
|
before :all do
|
83
83
|
@query = Book.all(:id => 1, :limit => 1).query
|
84
84
|
|
85
|
-
body = <<-XML
|
85
|
+
body = DataMapper::Ext::String.compress_lines(<<-XML)
|
86
86
|
<book>
|
87
87
|
<id type='datamapper::types::serial'>1</id>
|
88
88
|
<created_at type='datetime'>2009-05-17T22:38:42-07:00</created_at>
|
@@ -105,7 +105,7 @@ describe DataMapper::Adapters::RestAdapter do
|
|
105
105
|
|
106
106
|
describe 'with query scoped by a non-key' do
|
107
107
|
before :all do
|
108
|
-
body = <<-XML
|
108
|
+
body = DataMapper::Ext::String.compress_lines(<<-XML)
|
109
109
|
<books>
|
110
110
|
<book>
|
111
111
|
<id type='datamapper::types::serial'>1</id>
|
@@ -142,7 +142,7 @@ describe DataMapper::Adapters::RestAdapter do
|
|
142
142
|
|
143
143
|
describe 'with a non-standard model <=> storage_name relationship' do
|
144
144
|
before :all do
|
145
|
-
body = <<-XML
|
145
|
+
body = DataMapper::Ext::String.compress_lines(<<-XML)
|
146
146
|
<books>
|
147
147
|
<book>
|
148
148
|
<id type='datamapper::types::serial'>1</id>
|
@@ -172,7 +172,7 @@ describe DataMapper::Adapters::RestAdapter do
|
|
172
172
|
|
173
173
|
describe '#update' do
|
174
174
|
before :all do
|
175
|
-
body = <<-XML
|
175
|
+
body = DataMapper::Ext::String.compress_lines(<<-XML)
|
176
176
|
<books>
|
177
177
|
<book>
|
178
178
|
<id type='datamapper::types::serial'>1</id>
|
@@ -189,7 +189,7 @@ describe DataMapper::Adapters::RestAdapter do
|
|
189
189
|
end
|
190
190
|
|
191
191
|
before :all do
|
192
|
-
body = <<-XML
|
192
|
+
body = DataMapper::Ext::String.compress_lines(<<-XML)
|
193
193
|
<book>
|
194
194
|
<id type='datamapper::types::serial'>1</id>
|
195
195
|
<created_at type='datetime'>2009-05-17T22:38:42-07:00</created_at>
|
@@ -220,7 +220,7 @@ describe DataMapper::Adapters::RestAdapter do
|
|
220
220
|
|
221
221
|
describe '#delete' do
|
222
222
|
before :all do
|
223
|
-
body = <<-XML
|
223
|
+
body = DataMapper::Ext::String.compress_lines(<<-XML)
|
224
224
|
<books>
|
225
225
|
<book>
|
226
226
|
<id type='datamapper::types::serial'>1</id>
|
data/spec/spec_helper.rb
CHANGED
@@ -1,20 +1,8 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'pathname'
|
3
3
|
require 'fakeweb'
|
4
|
-
|
5
|
-
# use local dm-core if running from a typical dev checkout.
|
6
|
-
lib = File.join('..', '..', '..', 'dm-core', 'lib')
|
7
|
-
$LOAD_PATH.unshift(lib) if File.directory?(lib)
|
8
|
-
|
9
|
-
# use local dm-validations if running from a typical dev checkout.
|
10
|
-
lib = File.join('..', '..', 'dm-validations', 'lib')
|
11
|
-
$LOAD_PATH.unshift(lib) if File.directory?(lib)
|
12
4
|
require 'dm-validations'
|
13
5
|
|
14
|
-
# use local dm-serializer if running from a typical dev checkout.
|
15
|
-
lib = File.join('..', '..', 'dm-serializer', 'lib')
|
16
|
-
$LOAD_PATH.unshift(lib) if File.directory?(lib)
|
17
|
-
|
18
6
|
# Support running specs with 'rake spec' and 'spec'
|
19
7
|
$LOAD_PATH.unshift('lib') unless $LOAD_PATH.include?('lib')
|
20
8
|
|
@@ -24,6 +12,6 @@ ROOT = Pathname(__FILE__).dirname.parent
|
|
24
12
|
|
25
13
|
DataMapper.setup(:default, 'rest://admin:secret@localhost:4000/?format=xml')
|
26
14
|
|
27
|
-
|
15
|
+
Pathname.glob((ROOT + 'spec/fixtures/**/*.rb').to_s).each { |file| require file }
|
28
16
|
|
29
17
|
FakeWeb.allow_net_connect = false
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: dm-rest-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: 6
|
5
|
-
version: 1.1.0.
|
5
|
+
version: 1.1.0.rc3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Scott Burton @ Joyent Inc
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-03-
|
13
|
+
date: 2011-03-10 00:00:00 -08:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ~>
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 1.1.0.
|
23
|
+
version: 1.1.0.rc3
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: *id001
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - ~>
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 1.1.0.
|
34
|
+
version: 1.1.0.rc3
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: *id002
|
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
requirements: []
|
136
136
|
|
137
137
|
rubyforge_project: datamapper
|
138
|
-
rubygems_version: 1.
|
138
|
+
rubygems_version: 1.6.2
|
139
139
|
signing_key:
|
140
140
|
specification_version: 3
|
141
141
|
summary: REST Adapter for DataMapper
|