ocean-rails 5.1.0 → 5.2.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.
- checksums.yaml +4 -4
- data/README.rdoc +35 -28
- data/config/initializers/_aws_config.rb +7 -4
- data/lib/ocean/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5c44b8c69112c22983de235e2f5132bd217ba76
|
4
|
+
data.tar.gz: bc171e271ad2b8e2a36edc9039d662da416d159c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64846dd878b0f1176007383dd028fac44570fa6c797e0e7f0519681709479c5e6f56127abdd6a2cef05e998e1836361fcaf13fcebda0b25c87e90bb190e8106c
|
7
|
+
data.tar.gz: faa9281445150744c0cf5d721d18def94e23e4c51d98f413df52bfeae67f2d9e8d21eebe71a99a89fbcb834f102609bc45c045b98859739d3b6e1925e94c79a0
|
data/README.rdoc
CHANGED
@@ -74,40 +74,25 @@ You can now proceed to tailor the new resource to your needs. You will want to a
|
|
74
74
|
|
75
75
|
=== Running the specs
|
76
76
|
|
77
|
-
To run the specs for the ocean-rails gem, you must first install
|
78
|
-
a
|
79
|
-
|
77
|
+
To run the specs for the +ocean-rails+ gem, you must first install DynamoDB Local.
|
78
|
+
It's a Java clone of Amazon DynamoDB which runs locally on your computer. We use
|
79
|
+
it for development and testing.
|
80
80
|
|
81
|
-
|
81
|
+
Download DynamoDB Local from the following location: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Tools.DynamoDBLocal.html
|
82
82
|
|
83
|
-
|
84
|
-
|
85
|
-
NB: +aws.yml+ is excluded from source control. This allows you to enter your AWS credentials
|
86
|
-
safely. Note that +aws.yml.example+ is under source control: don't edit it.
|
87
|
-
|
88
|
-
Make sure your have version 0.1.3 of the +fake_dynamo+ gem. It implements the +2011-12-05+ version
|
89
|
-
of the DynamoDB API. We're not yet using the +2012-08-10+ version, as the +aws-sdk+ ruby gem
|
90
|
-
doesn't fully support it. We'll make the change as soon as +aws-sdk+ is updated. Reportedly,
|
91
|
-
it's in the works.
|
92
|
-
|
93
|
-
Next, start +fake_dynamo+:
|
83
|
+
Next, copy the AWS configuration file from the template:
|
94
84
|
|
95
|
-
|
96
|
-
|
97
|
-
If this returns errors, make sure that <tt>/usr/local/var/fake_dynamo</tt> exists and
|
98
|
-
is writable:
|
85
|
+
cp spec/dummy/config/aws.yml.example spec/dummy/config/aws.yml
|
99
86
|
|
100
|
-
|
101
|
-
|
87
|
+
NB: +aws.yml+ should be excluded from source control. This allows you to enter your AWS
|
88
|
+
credentials safely. On the other hand, +aws.yml.example+ SHOULD be under source control.
|
89
|
+
Don't put sensitive information in it.
|
102
90
|
|
103
|
-
|
91
|
+
You're now ready to start DynamoDB Local:
|
104
92
|
|
105
|
-
|
93
|
+
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
|
106
94
|
|
107
|
-
|
108
|
-
+fake_dynamo+; we're just using it here as a test that the installation works. It will
|
109
|
-
be issued automatically as part of the test suite, so don't expect test data to survive
|
110
|
-
between runs.
|
95
|
+
Replace +-sharedDb+ with +-inMemory+ to run the DB in RAM.
|
111
96
|
|
112
97
|
Next, copy the +config.yml+ file from its template:
|
113
98
|
|
@@ -120,13 +105,35 @@ You must now generate the SQLite databases:
|
|
120
105
|
rake db:migrate
|
121
106
|
RAILS_ENV=test rake db:migrate
|
122
107
|
|
123
|
-
With
|
108
|
+
With DynamoDB Local running, you should now be able to do
|
124
109
|
|
125
110
|
rspec
|
126
111
|
|
127
112
|
All tests should pass.
|
128
113
|
|
129
114
|
|
115
|
+
=== Cleaning up the DB
|
116
|
+
|
117
|
+
You might want to add the following to your spec_helper.rb file, before the +RSpec.configure+
|
118
|
+
block:
|
119
|
+
|
120
|
+
# DynamoDB table cleaner
|
121
|
+
CHEF_ENV = "master" unless defined?(CHEF_ENV)
|
122
|
+
regexp = Regexp.new("^.+_#{CHEF_ENV}_[0-9]{1,3}-[0-9]{1,3}-[0-9]{1,3}-[0-9]{1,3}_test$")
|
123
|
+
cleaner = lambda {
|
124
|
+
c = Aws::DynamoDB::Client.new
|
125
|
+
c.list_tables.table_names.each { |t| c.delete_table({table_name: t}) if t =~ regexp }
|
126
|
+
}
|
127
|
+
|
128
|
+
Then, inside the +RSpec.configure+ block:
|
129
|
+
|
130
|
+
config.before(:suite) { cleaner.call }
|
131
|
+
config.after(:suite) { cleaner.call }
|
132
|
+
|
133
|
+
This will remove only those tables created by the specs on this particular machine and
|
134
|
+
environment. This is safe even on AWS and for parallel testing.
|
135
|
+
|
136
|
+
|
130
137
|
=== Rails console
|
131
138
|
|
132
139
|
The Rails console is available from the built-in dummy application:
|
@@ -2,8 +2,7 @@
|
|
2
2
|
if (ENV['AWS_ACCESS_KEY_ID'].present? &&
|
3
3
|
ENV['AWS_SECRET_ACCESS_KEY'].present? &&
|
4
4
|
ENV['AWS_REGION'].present?)
|
5
|
-
|
6
|
-
#Aws.config if defined? Aws
|
5
|
+
Aws.config if defined? Aws
|
7
6
|
else
|
8
7
|
|
9
8
|
# The is the example file
|
@@ -27,8 +26,12 @@ else
|
|
27
26
|
ENV['AWS_ACCESS_KEY_ID'] = options[:access_key_id] || options['access_key_id']
|
28
27
|
ENV['AWS_SECRET_ACCESS_KEY'] = options[:secret_access_key] || options['secret_access_key']
|
29
28
|
ENV['AWS_REGION'] = options[:region] || options['region']
|
30
|
-
|
31
|
-
|
29
|
+
Aws.config.update(
|
30
|
+
region: options["region"],
|
31
|
+
credentials: Aws::Credentials.new(options["access_key_id"], options["secret_access_key"]),
|
32
|
+
endpoint: options["endpoint"]
|
33
|
+
)
|
34
|
+
|
32
35
|
else
|
33
36
|
# Otherwise print an error message and abort.
|
34
37
|
puts
|
data/lib/ocean/version.rb
CHANGED