dynamini 1.11.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dab1531824d1cd003429a7abbae63ee2ca5f059f
4
- data.tar.gz: f9c99348fc0f13d9b5aa38f9ead4af354cb9dfcf
3
+ metadata.gz: 11da53293d155b8933c028bcf5d419878f71dc15
4
+ data.tar.gz: 190bb0c142388bd56c1385eec116adc1f99c445e
5
5
  SHA512:
6
- metadata.gz: 3f6f990e17451bf03705f5d15c1c0d2dd783430590b55b5de24ec1e731af8373d3c9e5d74d55db2fd5eac58c4a0313589fcbe0e14f000ba83af75b7c8b16be48
7
- data.tar.gz: d84f6c09af62a8b4d8ed8dd3a80b45222b86b29999e45fe44e9bfac3c8957bf558c37ff0ef2743a700435b03a3dfc522745a9b8307b655c5574e143dca9dbd8e
6
+ metadata.gz: f6b83322fee0328a7969a1b73e41920807e9fc5201921ea96a9c273891cf7b25b056925b4498786b628a9e1957e79ed8c1e984428c8ad902c8d07bbd9d71649f
7
+ data.tar.gz: bcafd1d511a9106e3c76858456295f78eebc9e0ce23df3a5efb47a42680419b6f34f6d075d7372371b4c6d2629848e86a89d7733799d209f63ede250e5e8fc5a
@@ -1,28 +1,28 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dynamini (1.11.0)
4
+ dynamini (2.0.0)
5
5
  activemodel (>= 3, < 5.0)
6
6
  aws-sdk (~> 2)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activemodel (4.2.4)
12
- activesupport (= 4.2.4)
11
+ activemodel (4.2.5.1)
12
+ activesupport (= 4.2.5.1)
13
13
  builder (~> 3.1)
14
- activesupport (4.2.4)
14
+ activesupport (4.2.5.1)
15
15
  i18n (~> 0.7)
16
16
  json (~> 1.7, >= 1.7.7)
17
17
  minitest (~> 5.1)
18
18
  thread_safe (~> 0.3, >= 0.3.4)
19
19
  tzinfo (~> 1.1)
20
- aws-sdk (2.2.9)
21
- aws-sdk-resources (= 2.2.9)
22
- aws-sdk-core (2.2.9)
20
+ aws-sdk (2.2.14)
21
+ aws-sdk-resources (= 2.2.14)
22
+ aws-sdk-core (2.2.14)
23
23
  jmespath (~> 1.0)
24
- aws-sdk-resources (2.2.9)
25
- aws-sdk-core (= 2.2.9)
24
+ aws-sdk-resources (2.2.14)
25
+ aws-sdk-core (= 2.2.14)
26
26
  builder (3.2.2)
27
27
  coderay (1.1.0)
28
28
  diff-lcs (1.2.5)
@@ -56,7 +56,7 @@ GEM
56
56
  rb-inotify (>= 0.9)
57
57
  lumberjack (1.0.9)
58
58
  method_source (0.8.2)
59
- minitest (5.8.2)
59
+ minitest (5.8.4)
60
60
  nenv (0.2.0)
61
61
  notiffany (0.0.8)
62
62
  nenv (~> 0.1)
data/README.md CHANGED
@@ -15,6 +15,8 @@ Class methods:
15
15
  * exists?(hash_key, range_key)
16
16
  * find_or_new(hash_key, range_key)
17
17
  * import(model_array)
18
+ * before_save
19
+ * after_save
18
20
 
19
21
  Note: The range_key arguments are only necessary if your DynamoDB table is configured with a range key.
20
22
 
@@ -175,9 +177,9 @@ Vehicle.find('H3LLO').stuff
175
177
  ## Testing
176
178
  There's a test client included with this gem, meaning you don't have to connect to a real Dynamo instance when testing.
177
179
  You could also use this in development if you dont have a real Dynamo instance yet, but the data saved to it won't persist through a server restart.
178
- To activate this feature, just call:
180
+ To activate this feature, just do:
179
181
  ```ruby
180
- Vehicle.in_memory = true
182
+ require 'dynamini/testing'
181
183
  ```
182
184
  After which any internal API calls will be replaced with calls to Dynamini::TestClient.
183
185
 
@@ -188,9 +190,8 @@ Vehicle.client.reset
188
190
 
189
191
  So, for instance, to get Rspec working with your test suite the way your ActiveRecord model behaved, add these lines to your spec_helper.rb:
190
192
  ```ruby
191
- config.before(:all) {
192
- Vehicle.in_memory = true
193
- }
193
+ require 'dynamini/testing'
194
+
194
195
  config.after(:each) {
195
196
  Vehicle.client.reset # Large test suites will be very slow and unpredictable otherwise!
196
197
  }
@@ -1,7 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'dynamini'
3
- s.version = '1.11.0'
4
- s.date = '2015-01-11'
3
+ s.version = '2.0.0'
5
4
  s.summary = 'DynamoDB interface'
6
5
  s.description = 'Lightweight DynamoDB interface gem designed as
7
6
  a drop-in replacement for ActiveRecord.
@@ -1,23 +1,12 @@
1
1
  module Dynamini
2
2
  module ClientInterface
3
3
  module ClassMethods
4
-
5
- attr_writer :in_memory
6
-
7
4
  def client
8
- if in_memory
9
- @client ||= Dynamini::TestClient.new(hash_key, range_key)
10
- else
11
5
  @client ||= Aws::DynamoDB::Client.new(
12
6
  region: Dynamini.configuration.region,
13
7
  access_key_id: Dynamini.configuration.access_key_id,
14
8
  secret_access_key: Dynamini.configuration.secret_access_key
15
9
  )
16
- end
17
- end
18
-
19
- def in_memory
20
- @in_memory || false
21
10
  end
22
11
  end
23
12
 
@@ -0,0 +1,9 @@
1
+ module Dynamini
2
+ module ClientInterface
3
+ module ClassMethods
4
+ def client
5
+ @client ||= Dynamini::TestClient.new(hash_key, range_key)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -15,12 +15,10 @@ describe Dynamini::Base do
15
15
  class TestClassWithRange < Dynamini::Base
16
16
  set_hash_key :foo
17
17
  set_range_key :bar
18
- self.in_memory = true
19
18
  handle :bar, :integer
20
19
  end
21
20
 
22
21
  class TestClassWithCallbacks < Dynamini::Base
23
- self.in_memory = true
24
22
  before_save :before_callback
25
23
  after_save :after_callback
26
24
  end
@@ -68,7 +66,6 @@ describe Dynamini::Base do
68
66
 
69
67
  context 'when creating a subclass' do
70
68
  class Foo < Dynamini::Base
71
- Foo.in_memory = true
72
69
  end
73
70
 
74
71
  it 'should return the object as an instance of the subclass' do
@@ -286,7 +283,6 @@ describe Dynamini::Base do
286
283
  class TestValidation < Dynamini::Base
287
284
  set_hash_key :bar
288
285
  validates_presence_of :foo
289
- self.in_memory = true
290
286
  end
291
287
 
292
288
  it 'should raise its failed validation errors' do
@@ -318,8 +314,6 @@ describe Dynamini::Base do
318
314
  set_range_key :abc
319
315
  end
320
316
 
321
- TestHashRangeTable.in_memory = true
322
-
323
317
  let(:time) { Time.now }
324
318
  before do
325
319
  allow(Time).to receive(:now).and_return(time)
@@ -473,7 +467,6 @@ describe Dynamini::Base do
473
467
  before do
474
468
  class TestClass < Dynamini::Base
475
469
  set_hash_key :foo
476
- self.in_memory = true
477
470
  end
478
471
  end
479
472
 
@@ -16,7 +16,6 @@ describe Dynamini::Querying do
16
16
  class TestClassWithRange < Dynamini::Base
17
17
  set_hash_key :foo
18
18
  set_range_key :bar
19
- self.in_memory = true
20
19
  handle :bar, :integer
21
20
  end
22
21
 
@@ -42,7 +41,6 @@ describe Dynamini::Querying do
42
41
 
43
42
  context 'when retrieving a subclass' do
44
43
  class Foo < Dynamini::Base
45
- self.in_memory = true
46
44
  end
47
45
 
48
46
  it 'should return the object as an instance of the subclass' do
@@ -94,7 +92,6 @@ describe Dynamini::Querying do
94
92
  context 'a non-numeric range field' do
95
93
  it 'should raise an error' do
96
94
  class TestClassWithStringRange < Dynamini::Base
97
- self.in_memory = true
98
95
  set_hash_key :group
99
96
  set_range_key :user_name
100
97
  end
@@ -5,11 +5,11 @@ require 'aws-sdk'
5
5
  require 'pry'
6
6
  require 'fuubar'
7
7
  require 'dynamini'
8
+ require 'dynamini/testing'
8
9
 
9
10
  RSpec.configure do |config|
10
11
  # For running just wanted tests in guard
11
12
  config.filter_run :focus => true
12
13
  config.run_all_when_everything_filtered = true
13
- config.before(:all) { Dynamini::Base.in_memory = true }
14
14
  config.after(:each) { Dynamini::Base.client.reset }
15
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamini
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Ward
@@ -15,7 +15,7 @@ authors:
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
- date: 2015-01-11 00:00:00.000000000 Z
18
+ date: 2016-02-08 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activemodel
@@ -150,10 +150,10 @@ files:
150
150
  - lib/dynamini/increment.rb
151
151
  - lib/dynamini/querying.rb
152
152
  - lib/dynamini/test_client.rb
153
+ - lib/dynamini/testing.rb
153
154
  - lib/dynamini/type_handler.rb
154
155
  - spec/dynamini/base_spec.rb
155
156
  - spec/dynamini/batch_operations_spec.rb
156
- - spec/dynamini/client_interface_spec.rb
157
157
  - spec/dynamini/dirty_spec.rb
158
158
  - spec/dynamini/increment_spec.rb
159
159
  - spec/dynamini/querying_spec.rb
@@ -187,7 +187,6 @@ summary: DynamoDB interface
187
187
  test_files:
188
188
  - spec/dynamini/base_spec.rb
189
189
  - spec/dynamini/batch_operations_spec.rb
190
- - spec/dynamini/client_interface_spec.rb
191
190
  - spec/dynamini/dirty_spec.rb
192
191
  - spec/dynamini/increment_spec.rb
193
192
  - spec/dynamini/querying_spec.rb
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Dynamini::ClientInterface do
4
- describe '.client' do
5
- it 'should not reinstantiate the client' do
6
- expect(Dynamini::TestClient).to_not receive(:new)
7
- Dynamini::Base.client
8
- end
9
- end
10
- end