dm-adapter-simpledb 1.0.0 → 1.1.0
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.
- data/.gitignore +1 -0
- data/History.txt +21 -0
- data/README +21 -8
- data/Rakefile +35 -23
- data/VERSION +1 -1
- data/dm-adapter-simpledb.gemspec +44 -24
- data/lib/dm-adapter-simpledb.rb +17 -0
- data/lib/dm-adapter-simpledb/adapters/simpledb_adapter.rb +339 -0
- data/lib/dm-adapter-simpledb/chunked_string.rb +54 -0
- data/lib/dm-adapter-simpledb/migrations/simpledb_adapter.rb +45 -0
- data/lib/dm-adapter-simpledb/rake.rb +43 -0
- data/lib/dm-adapter-simpledb/record.rb +318 -0
- data/lib/{simpledb_adapter → dm-adapter-simpledb}/sdb_array.rb +0 -0
- data/lib/dm-adapter-simpledb/table.rb +40 -0
- data/lib/dm-adapter-simpledb/utils.rb +15 -0
- data/lib/simpledb_adapter.rb +2 -469
- data/scripts/simple_benchmark.rb +1 -1
- data/spec/{associations_spec.rb → integration/associations_spec.rb} +0 -0
- data/spec/{compliance_spec.rb → integration/compliance_spec.rb} +0 -0
- data/spec/{date_spec.rb → integration/date_spec.rb} +0 -0
- data/spec/{limit_and_order_spec.rb → integration/limit_and_order_spec.rb} +0 -0
- data/spec/{migrations_spec.rb → integration/migrations_spec.rb} +0 -0
- data/spec/{multiple_records_spec.rb → integration/multiple_records_spec.rb} +0 -0
- data/spec/{nils_spec.rb → integration/nils_spec.rb} +0 -0
- data/spec/{sdb_array_spec.rb → integration/sdb_array_spec.rb} +4 -5
- data/spec/{simpledb_adapter_spec.rb → integration/simpledb_adapter_spec.rb} +65 -0
- data/spec/{spec_helper.rb → integration/spec_helper.rb} +8 -3
- data/spec/unit/record_spec.rb +346 -0
- data/spec/unit/simpledb_adapter_spec.rb +80 -0
- data/spec/unit/unit_spec_helper.rb +26 -0
- metadata +58 -24
- data/tasks/devver.rake +0 -167
@@ -0,0 +1,80 @@
|
|
1
|
+
require File.expand_path('unit_spec_helper', File.dirname(__FILE__))
|
2
|
+
require 'simpledb_adapter'
|
3
|
+
|
4
|
+
describe DataMapper::Adapters::SimpleDBAdapter do
|
5
|
+
class Product
|
6
|
+
include DataMapper::Resource
|
7
|
+
|
8
|
+
property :id, Serial
|
9
|
+
property :name, String
|
10
|
+
property :stock, Integer
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "given a record" do
|
14
|
+
before :each do
|
15
|
+
@record = Product.new(:name => "War and Peace", :stock => 3)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should be able to save the record" do
|
19
|
+
@sdb.should_receive(:put_attributes).with(
|
20
|
+
anything,
|
21
|
+
anything,
|
22
|
+
hash_including(
|
23
|
+
'simpledb_type' => ["products"],
|
24
|
+
'stock' => ["3"],
|
25
|
+
'name' => ["War and Peace"]))
|
26
|
+
@record.save
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "given an existing record" do
|
31
|
+
before :each do
|
32
|
+
@sdb.stub(:select).
|
33
|
+
and_return(:items => [
|
34
|
+
{"HANDLE" => {
|
35
|
+
'id' => ['12345'],
|
36
|
+
'name' => ['War and Peace'],
|
37
|
+
'stock' => ['3']}}
|
38
|
+
])
|
39
|
+
@record = Product.first
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should be able to update the record" do
|
43
|
+
@record.stock = 5
|
44
|
+
@sdb.should_receive(:put_attributes).with(
|
45
|
+
anything,
|
46
|
+
anything,
|
47
|
+
hash_including('stock' => ["5"]),
|
48
|
+
:replace)
|
49
|
+
@record.save
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "given a record exists in the DB" do
|
54
|
+
before :each do
|
55
|
+
@sdb.stub(:select).
|
56
|
+
and_return(:items => [
|
57
|
+
{"HANDLE" => {
|
58
|
+
'id' => ['12345'],
|
59
|
+
'name' => ['War and Peace'],
|
60
|
+
'stock' => ['3'],
|
61
|
+
'__dm_metadata' => ['v01.01.00', 'foobar']}}
|
62
|
+
])
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should request metadata for the record" do
|
66
|
+
@sdb.should_receive(:select).
|
67
|
+
with(/select.*__dm_metadata.*from/i, anything).
|
68
|
+
and_return(:items => [
|
69
|
+
{"HANDLE" => {
|
70
|
+
'id' => ['12345'],
|
71
|
+
'name' => ['War and Peace'],
|
72
|
+
'stock' => ['3'],
|
73
|
+
'__dm_metadata' => ['v01.01.00', 'foobar']}}
|
74
|
+
])
|
75
|
+
@record = Product.first
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec'
|
2
|
+
ROOT = File.expand_path('../..', File.dirname(__FILE__))
|
3
|
+
$LOAD_PATH.unshift(File.join(ROOT,'lib'))
|
4
|
+
require 'simpledb_adapter'
|
5
|
+
|
6
|
+
Spec::Runner.configure do |config|
|
7
|
+
config.before :each do
|
8
|
+
@sdb = stub("RightAWS::SdbInterface").as_null_object
|
9
|
+
@log = stub("Log").as_null_object
|
10
|
+
|
11
|
+
# Using Abstract adapter as a null DB
|
12
|
+
DataMapper.setup(:default,
|
13
|
+
:adapter => 'simpledb',
|
14
|
+
:access_key => "ACCESS_KEY",
|
15
|
+
:secret_key => "SECRET_KEY",
|
16
|
+
:domain => "DOMAIN",
|
17
|
+
:logger => @log,
|
18
|
+
:sdb_interface => @sdb
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
config.after :each do
|
23
|
+
DataMapper::Repository.adapters.delete(:default)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-adapter-simpledb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Boles
|
@@ -13,7 +13,7 @@ autorequire:
|
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
15
|
|
16
|
-
date: 2009-11-
|
16
|
+
date: 2009-11-24 00:00:00 -05:00
|
17
17
|
default_executable:
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
@@ -36,6 +36,26 @@ dependencies:
|
|
36
36
|
- !ruby/object:Gem::Version
|
37
37
|
version: 0.10.0
|
38
38
|
version:
|
39
|
+
- !ruby/object:Gem::Dependency
|
40
|
+
name: dm-migrations
|
41
|
+
type: :runtime
|
42
|
+
version_requirement:
|
43
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.10.0
|
48
|
+
version:
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: dm-types
|
51
|
+
type: :runtime
|
52
|
+
version_requirement:
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ~>
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 0.10.0
|
58
|
+
version:
|
39
59
|
- !ruby/object:Gem::Dependency
|
40
60
|
name: uuidtools
|
41
61
|
type: :runtime
|
@@ -85,26 +105,37 @@ extra_rdoc_files:
|
|
85
105
|
files:
|
86
106
|
- .autotest
|
87
107
|
- .gitignore
|
108
|
+
- History.txt
|
88
109
|
- README
|
89
110
|
- Rakefile
|
90
111
|
- VERSION
|
91
112
|
- aws_config.sample
|
92
113
|
- dm-adapter-simpledb.gemspec
|
114
|
+
- lib/dm-adapter-simpledb.rb
|
115
|
+
- lib/dm-adapter-simpledb/adapters/simpledb_adapter.rb
|
116
|
+
- lib/dm-adapter-simpledb/chunked_string.rb
|
117
|
+
- lib/dm-adapter-simpledb/migrations/simpledb_adapter.rb
|
118
|
+
- lib/dm-adapter-simpledb/rake.rb
|
119
|
+
- lib/dm-adapter-simpledb/record.rb
|
120
|
+
- lib/dm-adapter-simpledb/sdb_array.rb
|
121
|
+
- lib/dm-adapter-simpledb/table.rb
|
122
|
+
- lib/dm-adapter-simpledb/utils.rb
|
93
123
|
- lib/simpledb_adapter.rb
|
94
|
-
- lib/simpledb_adapter/sdb_array.rb
|
95
124
|
- scripts/simple_benchmark.rb
|
96
|
-
- spec/associations_spec.rb
|
97
|
-
- spec/compliance_spec.rb
|
98
|
-
- spec/date_spec.rb
|
99
|
-
- spec/limit_and_order_spec.rb
|
100
|
-
- spec/migrations_spec.rb
|
101
|
-
- spec/multiple_records_spec.rb
|
102
|
-
- spec/nils_spec.rb
|
103
|
-
- spec/sdb_array_spec.rb
|
104
|
-
- spec/simpledb_adapter_spec.rb
|
125
|
+
- spec/integration/associations_spec.rb
|
126
|
+
- spec/integration/compliance_spec.rb
|
127
|
+
- spec/integration/date_spec.rb
|
128
|
+
- spec/integration/limit_and_order_spec.rb
|
129
|
+
- spec/integration/migrations_spec.rb
|
130
|
+
- spec/integration/multiple_records_spec.rb
|
131
|
+
- spec/integration/nils_spec.rb
|
132
|
+
- spec/integration/sdb_array_spec.rb
|
133
|
+
- spec/integration/simpledb_adapter_spec.rb
|
134
|
+
- spec/integration/spec_helper.rb
|
105
135
|
- spec/spec.opts
|
106
|
-
- spec/
|
107
|
-
-
|
136
|
+
- spec/unit/record_spec.rb
|
137
|
+
- spec/unit/simpledb_adapter_spec.rb
|
138
|
+
- spec/unit/unit_spec_helper.rb
|
108
139
|
has_rdoc: true
|
109
140
|
homepage: http://github.com/devver/dm-adapter-simpledb
|
110
141
|
licenses: []
|
@@ -134,13 +165,16 @@ signing_key:
|
|
134
165
|
specification_version: 3
|
135
166
|
summary: DataMapper adapter for Amazon SimpleDB
|
136
167
|
test_files:
|
137
|
-
- spec/nils_spec.rb
|
138
|
-
- spec/limit_and_order_spec.rb
|
139
|
-
- spec/compliance_spec.rb
|
140
|
-
- spec/simpledb_adapter_spec.rb
|
141
|
-
- spec/date_spec.rb
|
142
|
-
- spec/sdb_array_spec.rb
|
143
|
-
- spec/migrations_spec.rb
|
144
|
-
- spec/spec_helper.rb
|
145
|
-
- spec/multiple_records_spec.rb
|
146
|
-
- spec/associations_spec.rb
|
168
|
+
- spec/integration/nils_spec.rb
|
169
|
+
- spec/integration/limit_and_order_spec.rb
|
170
|
+
- spec/integration/compliance_spec.rb
|
171
|
+
- spec/integration/simpledb_adapter_spec.rb
|
172
|
+
- spec/integration/date_spec.rb
|
173
|
+
- spec/integration/sdb_array_spec.rb
|
174
|
+
- spec/integration/migrations_spec.rb
|
175
|
+
- spec/integration/spec_helper.rb
|
176
|
+
- spec/integration/multiple_records_spec.rb
|
177
|
+
- spec/integration/associations_spec.rb
|
178
|
+
- spec/unit/simpledb_adapter_spec.rb
|
179
|
+
- spec/unit/unit_spec_helper.rb
|
180
|
+
- spec/unit/record_spec.rb
|
data/tasks/devver.rake
DELETED
@@ -1,167 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
|
3
|
-
namespace :devver do
|
4
|
-
|
5
|
-
APP_CALL = 'devver'
|
6
|
-
# List any test files you do not want to run on Devver. This array can contain names and regular expressions.
|
7
|
-
EXCLUDED_TEST_FILES = []
|
8
|
-
|
9
|
-
desc "Runs all units functionals and integration tests on Devver"
|
10
|
-
task :test do
|
11
|
-
errors = %w(devver:test:units devver:test:functionals devver:test:integration).collect do |task|
|
12
|
-
begin
|
13
|
-
Rake::Task[task].invoke
|
14
|
-
nil
|
15
|
-
rescue => e
|
16
|
-
task
|
17
|
-
end
|
18
|
-
end.compact
|
19
|
-
abort "Errors running #{errors.join(", ").to_s}!" if errors.any?
|
20
|
-
end
|
21
|
-
|
22
|
-
desc "Forces Devver to rerun migration files"
|
23
|
-
task :migrate do
|
24
|
-
command = "#{APP_CALL} --db"
|
25
|
-
puts command
|
26
|
-
system(command)
|
27
|
-
end
|
28
|
-
|
29
|
-
desc "Forces Devver to sync all changed files"
|
30
|
-
task :sync do
|
31
|
-
command = "#{APP_CALL} --sync"
|
32
|
-
puts command
|
33
|
-
system(command)
|
34
|
-
end
|
35
|
-
|
36
|
-
desc "Delete the Devver project ID for this project. The next time you connect to Devver, you'll be assigned a new project ID"
|
37
|
-
task :reset do
|
38
|
-
command = "rm .devver/project_id"
|
39
|
-
system(command)
|
40
|
-
puts "Your project has been reset successfully"
|
41
|
-
end
|
42
|
-
|
43
|
-
desc "Delete all of the project files on the server and resync"
|
44
|
-
task :reload do
|
45
|
-
command = "#{APP_CALL} --reload"
|
46
|
-
puts command
|
47
|
-
system(command)
|
48
|
-
end
|
49
|
-
|
50
|
-
desc "Runs all specs on Devver"
|
51
|
-
task :spec do
|
52
|
-
devvertest('spec/**/*_spec.rb')
|
53
|
-
end
|
54
|
-
|
55
|
-
namespace :spec do
|
56
|
-
desc "Runs all model specs on Devver"
|
57
|
-
task :model do
|
58
|
-
devvertest('spec/models/**/*_spec.rb')
|
59
|
-
end
|
60
|
-
|
61
|
-
desc "Runs all request specs on Devver"
|
62
|
-
task :request do
|
63
|
-
devvertest('spec/requests/**/*_spec.rb')
|
64
|
-
end
|
65
|
-
|
66
|
-
desc "Runs all controller specs on Devver"
|
67
|
-
task :controller do
|
68
|
-
devvertest('spec/controllers/**/*_spec.rb')
|
69
|
-
end
|
70
|
-
|
71
|
-
desc "Runs all view specs on Devver"
|
72
|
-
task :view do
|
73
|
-
devvertest('spec/views/**/*_spec.rb')
|
74
|
-
end
|
75
|
-
|
76
|
-
desc "Runs all helper specs on Devver"
|
77
|
-
task :helper do
|
78
|
-
devvertest('spec/helpers/**/*_spec.rb')
|
79
|
-
end
|
80
|
-
|
81
|
-
desc "Runs all lib specs on Devver"
|
82
|
-
task :lib do
|
83
|
-
devvertest('spec/lib/**/*_spec.rb')
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
|
-
|
89
|
-
namespace :test do
|
90
|
-
desc "Runs all unit tests on Devver"
|
91
|
-
task :units do
|
92
|
-
devvertest('test/unit/**/*_test.rb')
|
93
|
-
end
|
94
|
-
|
95
|
-
desc "Runs all functional tests on Devver"
|
96
|
-
task :functionals do
|
97
|
-
devvertest('test/functional/**/*_test.rb')
|
98
|
-
end
|
99
|
-
|
100
|
-
desc "Runs all integration tests on Devver"
|
101
|
-
task :integration do
|
102
|
-
devvertest('test/integration/**/*_test.rb')
|
103
|
-
end
|
104
|
-
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
def remove_excluded_files(files)
|
109
|
-
removed_files = []
|
110
|
-
files.each do |file|
|
111
|
-
EXCLUDED_TEST_FILES.each do |exclude|
|
112
|
-
removed_files << file if exclude===file
|
113
|
-
end
|
114
|
-
end
|
115
|
-
removed_files = removed_files.flatten
|
116
|
-
files = files - removed_files
|
117
|
-
[files, removed_files]
|
118
|
-
end
|
119
|
-
|
120
|
-
def run_tests_locally(files)
|
121
|
-
puts "Running the excluded test files locally"
|
122
|
-
# Run RSpec files
|
123
|
-
if files.first=~/_spec.rb/
|
124
|
-
command ="spec "
|
125
|
-
else # Run Test::Unit files
|
126
|
-
command = 'ruby -e "ARGV.each{|f| load f unless f =~ /^-/}" '
|
127
|
-
end
|
128
|
-
command += files.join(" ")
|
129
|
-
puts command
|
130
|
-
results = system(command)
|
131
|
-
raise RuntimeError.new("Command failed with status (1)") unless results
|
132
|
-
end
|
133
|
-
|
134
|
-
def get_env_var(var_name)
|
135
|
-
ENV[var_name] || ENV[var_name.upcase]
|
136
|
-
end
|
137
|
-
|
138
|
-
def devvertest(pattern)
|
139
|
-
reload = get_env_var('reload')=='true' ? true : false
|
140
|
-
#default sync to true
|
141
|
-
sync = true
|
142
|
-
sync = false if get_env_var('sync')=='false'
|
143
|
-
cache = get_env_var('cache')=='true' ? true : false
|
144
|
-
db = get_env_var('db')=='true' ? true : false
|
145
|
-
run_excluded = get_env_var('run_excluded')
|
146
|
-
if run_excluded=='true' || run_excluded=='after'
|
147
|
-
run_excluded = 'after'
|
148
|
-
elsif run_excluded=='only'
|
149
|
-
run_excluded = 'only'
|
150
|
-
else
|
151
|
-
run_excluded = ''
|
152
|
-
end
|
153
|
-
|
154
|
-
files = FileList[pattern].to_a
|
155
|
-
files, removed_files = remove_excluded_files(files)
|
156
|
-
|
157
|
-
if run_excluded!='only'
|
158
|
-
command = "#{APP_CALL} #{'--reload' if reload} #{'--nosync' if !sync} #{'--db' if db} #{'--cache' if cache} #{files.join(' ')}"
|
159
|
-
puts command
|
160
|
-
results = system(command)
|
161
|
-
raise RuntimeError.new("Command failed with status (1)") unless results
|
162
|
-
end
|
163
|
-
|
164
|
-
if run_excluded=='only' || run_excluded=='after'
|
165
|
-
run_tests_locally(removed_files) if removed_files.length > 0
|
166
|
-
end
|
167
|
-
end
|