fake_dynamo 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -0
- data/bin/fake_dynamo +27 -0
- data/lib/fake_dynamo/attribute.rb +1 -1
- data/lib/fake_dynamo/db.rb +4 -0
- data/lib/fake_dynamo/server.rb +6 -0
- data/lib/fake_dynamo/storage.rb +7 -0
- data/lib/fake_dynamo/version.rb +1 -1
- data/spec/fake_dynamo/server_spec.rb +15 -0
- metadata +8 -8
data/README.md
CHANGED
data/bin/fake_dynamo
CHANGED
@@ -19,8 +19,35 @@ OptionParser.new do |opts|
|
|
19
19
|
opts.on("-c", "--compact", "Default: #{options[:compact]}") do |v|
|
20
20
|
options[:compact] = v
|
21
21
|
end
|
22
|
+
|
23
|
+
opts.on "-P", "--pid PIDFILE", "Where to write the pid" do |pid|
|
24
|
+
options[:pid] = pid
|
25
|
+
end
|
26
|
+
|
27
|
+
opts.on "-d", "--[no-]daemonize", "Detaches the process" do |daemonize|
|
28
|
+
options[:daemonize] = daemonize
|
29
|
+
end
|
30
|
+
|
22
31
|
end.parse!
|
23
32
|
|
33
|
+
if options[:daemonize]
|
34
|
+
Process.daemon(true, true)
|
35
|
+
end
|
36
|
+
|
37
|
+
if (pid = options[:pid])
|
38
|
+
if File.exist?(pid)
|
39
|
+
existing_pid = File.open(pid, 'r').read.chomp.to_i
|
40
|
+
running = Process.getpgid(existing_pid) rescue false
|
41
|
+
if running
|
42
|
+
warn "Error, Process #{existing_pid} already running"
|
43
|
+
exit 1
|
44
|
+
else
|
45
|
+
warn "Cleaning up stale pid at #{pid}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
File.open(pid, 'w') { |f| f.write(Process.pid) }
|
49
|
+
end
|
50
|
+
|
24
51
|
FakeDynamo::Storage.db_path = options[:db]
|
25
52
|
|
26
53
|
if options[:compact]
|
data/lib/fake_dynamo/db.rb
CHANGED
data/lib/fake_dynamo/server.rb
CHANGED
data/lib/fake_dynamo/storage.rb
CHANGED
data/lib/fake_dynamo/version.rb
CHANGED
@@ -34,5 +34,20 @@ module FakeDynamo
|
|
34
34
|
last_response.status.should eq(400)
|
35
35
|
end
|
36
36
|
|
37
|
+
it "should reset database" do
|
38
|
+
post '/', {}.to_json, 'HTTP_X_AMZ_TARGET' => 'DynamoDB_20111205.ListTables'
|
39
|
+
JSON.parse(last_response.body)["TableNames"].size.should == 1
|
40
|
+
|
41
|
+
delete '/'
|
42
|
+
last_response.should be_ok
|
43
|
+
|
44
|
+
post '/', {}.to_json, 'HTTP_X_AMZ_TARGET' => 'DynamoDB_20111205.ListTables'
|
45
|
+
JSON.parse(last_response.body)["TableNames"].size.should == 0
|
46
|
+
|
47
|
+
post '/', data.to_json, 'HTTP_X_AMZ_TARGET' => 'DynamoDB_20111205.CreateTable'
|
48
|
+
post '/', {}.to_json, 'HTTP_X_AMZ_TARGET' => 'DynamoDB_20111205.ListTables'
|
49
|
+
JSON.parse(last_response.body)["TableNames"].size.should == 1
|
50
|
+
end
|
51
|
+
|
37
52
|
end
|
38
53
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fake_dynamo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-03-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
16
|
-
requirement: &
|
16
|
+
requirement: &70338580048120 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70338580048120
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activesupport
|
27
|
-
requirement: &
|
27
|
+
requirement: &70338580047540 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70338580047540
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: json
|
38
|
-
requirement: &
|
38
|
+
requirement: &70338580046980 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70338580046980
|
47
47
|
description:
|
48
48
|
email:
|
49
49
|
- ananthakumaran@gmail.com
|