dynamini 2.8.0 → 2.8.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e236f8c8534a981275e1f4e6f92fea37fbdad844
4
- data.tar.gz: 1e72cb755d72e27ae30834db85a2e0f2d00e2141
3
+ metadata.gz: 8dc1f7436267794e86bd3ba925c347fe0dbf8536
4
+ data.tar.gz: 202c5d8166d5dbcd95b57a3474533e38f869e9c6
5
5
  SHA512:
6
- metadata.gz: b1f37058d062d3ddc4b7ead58a23c0335cbeda994db926ca3abb2178139b7eefcbcf1a4125bce7c893575ec67197aa30f62dd32a5788afe6f8ff8194eda8ddc0
7
- data.tar.gz: a1aeae7aaa42a1a62c5c966e5141aa9804026541613094d4f5fb6f6a05e9f6bc808c796623763ec7c9eda81a4f5ee6e57caaeb556e1f19a6956c98c0d19e8e8f
6
+ metadata.gz: 028d80338df534f3560290e18108c1cafecbd97cc64f7b99e5920c5c05754334e2008efe8be13488d44b48e9eca5f63777136a5c9092a28ca5828a90d0647eda
7
+ data.tar.gz: 8b0fe74c4f36d33adf2ae8940407e357443b7d5f81c17f3c3a45f89ae10afd19a9aa696ce6037c621819d9e383a9cec428145b2bf84d44faa64aece87ada7702
data/Gemfile.lock CHANGED
@@ -1,29 +1,29 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dynamini (2.7.8)
4
+ dynamini (2.8.1)
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.8)
12
- activesupport (= 4.2.8)
11
+ activemodel (4.2.9)
12
+ activesupport (= 4.2.9)
13
13
  builder (~> 3.1)
14
- activesupport (4.2.8)
14
+ activesupport (4.2.9)
15
15
  i18n (~> 0.7)
16
16
  minitest (~> 5.1)
17
17
  thread_safe (~> 0.3, >= 0.3.4)
18
18
  tzinfo (~> 1.1)
19
- aws-sdk (2.7.15)
20
- aws-sdk-resources (= 2.7.15)
21
- aws-sdk-core (2.7.15)
19
+ aws-sdk (2.10.42)
20
+ aws-sdk-resources (= 2.10.42)
21
+ aws-sdk-core (2.10.42)
22
22
  aws-sigv4 (~> 1.0)
23
23
  jmespath (~> 1.0)
24
- aws-sdk-resources (2.7.15)
25
- aws-sdk-core (= 2.7.15)
26
- aws-sigv4 (1.0.0)
24
+ aws-sdk-resources (2.10.42)
25
+ aws-sdk-core (= 2.10.42)
26
+ aws-sigv4 (1.0.2)
27
27
  builder (3.2.3)
28
28
  coderay (1.1.0)
29
29
  diff-lcs (1.2.5)
@@ -49,14 +49,14 @@ GEM
49
49
  guard-shell (0.7.1)
50
50
  guard (>= 2.0.0)
51
51
  guard-compat (~> 1.0)
52
- i18n (0.8.1)
52
+ i18n (0.8.6)
53
53
  jmespath (1.3.1)
54
54
  listen (3.0.3)
55
55
  rb-fsevent (>= 0.9.3)
56
56
  rb-inotify (>= 0.9)
57
57
  lumberjack (1.0.9)
58
58
  method_source (0.8.2)
59
- minitest (5.10.1)
59
+ minitest (5.10.3)
60
60
  nenv (0.2.0)
61
61
  notiffany (0.0.8)
62
62
  nenv (~> 0.1)
@@ -86,7 +86,7 @@ GEM
86
86
  slop (3.6.0)
87
87
  thor (0.19.1)
88
88
  thread_safe (0.3.6)
89
- tzinfo (1.2.2)
89
+ tzinfo (1.2.3)
90
90
  thread_safe (~> 0.1)
91
91
 
92
92
  PLATFORMS
@@ -101,4 +101,4 @@ DEPENDENCIES
101
101
  rspec (~> 3)
102
102
 
103
103
  BUNDLED WITH
104
- 1.14.5
104
+ 1.16.0.pre.2
data/README.md CHANGED
@@ -52,7 +52,7 @@ In application.rb, or in initializers/dynamini.rb, include your AWS settings lik
52
52
 
53
53
  ```ruby
54
54
  Dynamini.configure do |config|
55
- config.aws_region = '[AWS region containing your DynamoDB instance]'
55
+ config.region = '[AWS region containing your DynamoDB instance]'
56
56
  config.access_key_id = '[access_key_id for your AWS account]'
57
57
  config.secret_access_key = '[secret_access_key for your AWS account]'
58
58
  end
data/dynamini.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'dynamini'
3
- s.version = '2.8.0'
3
+ s.version = '2.8.1'
4
4
  s.summary = 'DynamoDB interface'
5
5
  s.description = 'Lightweight DynamoDB interface gem designed as
6
6
  a drop-in replacement for ActiveRecord.
@@ -1,29 +1,39 @@
1
+ require 'date'
2
+
1
3
  module Dynamini
2
4
  module TypeHandler
3
5
 
4
6
  GETTER_PROCS = {
5
- integer: proc { |v| v.to_i },
6
- date: proc { |v| v.is_a?(Date) ? v : Time.at(v).to_date },
7
- time: proc { |v| Time.at(v.to_f) },
8
- float: proc { |v| v.to_f },
9
- symbol: proc { |v| v.to_sym },
10
- string: proc { |v| v.to_s },
11
- boolean: proc { |v| v },
12
- array: proc { |v| v.is_a?(Enumerable) ? v.to_a : [v] },
13
- set: proc { |v| v.is_a?(Enumerable) ? Set.new(v) : Set.new([v]) }
14
- }
7
+ integer: proc { |v| v.to_i },
8
+ date: proc do |v|
9
+ if v.is_a?(Date)
10
+ v
11
+ else
12
+ Time.methods.include?(:zone) ? Time.zone.at(v).to_date : Time.at(v).to_date
13
+ end
14
+ end,
15
+ time: proc do |v|
16
+ Time.methods.include?(:zone) ? Time.zone.at(v.to_f) : Time.at(v.to_f)
17
+ end,
18
+ float: proc { |v| v.to_f },
19
+ symbol: proc { |v| v.to_sym },
20
+ string: proc { |v| v.to_s },
21
+ boolean: proc { |v| v },
22
+ array: proc { |v| v.is_a?(Enumerable) ? v.to_a : [v] },
23
+ set: proc { |v| v.is_a?(Enumerable) ? Set.new(v) : Set.new([v]) }
24
+ }.freeze
15
25
 
16
26
  SETTER_PROCS = {
17
- integer: proc { |v| v.to_i },
18
- time: proc { |v| (v.is_a?(Date) ? v.to_time : v).to_f },
19
- float: proc { |v| v.to_f },
20
- symbol: proc { |v| v.to_s },
21
- string: proc { |v| v.to_s },
22
- boolean: proc { |v| v },
23
- date: proc { |v| v.to_time.to_f },
24
- array: proc { |v| v.is_a?(Enumerable) ? v.to_a : [v] },
25
- set: proc { |v| v.is_a?(Enumerable) ? Set.new(v) : Set.new([v]) }
26
- }
27
+ integer: proc { |v| v.to_i },
28
+ time: proc { |v| (v.is_a?(Date) ? v.to_time : v).to_f },
29
+ float: proc { |v| v.to_f },
30
+ symbol: proc { |v| v.to_s },
31
+ string: proc { |v| v.to_s },
32
+ boolean: proc { |v| v },
33
+ date: proc { |v| v.to_time.to_f },
34
+ array: proc { |v| v.is_a?(Enumerable) ? v.to_a : [v] },
35
+ set: proc { |v| v.is_a?(Enumerable) ? Set.new(v) : Set.new([v]) }
36
+ }.freeze
27
37
 
28
38
  def handle(column, format_class, options = {})
29
39
  validate_handle(format_class, options)
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Dynamini::TypeHandler do
4
4
  describe '.handle' do
5
5
 
6
- class HandledClass < Dynamini::Base;
6
+ class HandledClass < Dynamini::Base
7
7
  end
8
8
 
9
9
  context 'when reading the handled attirubte' do
@@ -67,6 +67,33 @@ describe Dynamini::TypeHandler do
67
67
  expect(handle_model.start_date).to be_a(Time)
68
68
  end
69
69
 
70
+ context 'Time.zone is not available' do
71
+ it 'should retrieve stored times using Time.at' do
72
+ handle_model.start_date = Time.now
73
+ expect(Time).to receive(:at)
74
+ handle_model.start_date
75
+ end
76
+ end
77
+
78
+ context 'Time.zone is available (e.g. ActiveSupport is present)' do
79
+ before do
80
+ Time.instance_eval do
81
+ def zone
82
+ Time
83
+ end
84
+ end
85
+ end
86
+
87
+ after do
88
+ Time.instance_eval {undef :zone}
89
+ end
90
+ it 'should retrieve stored times using Time.zone.at' do
91
+ handle_model.start_date = Time.now
92
+ expect(Time).to receive(:zone).and_call_original
93
+ handle_model.start_date
94
+ end
95
+ end
96
+
70
97
  it 'should reject bad data' do
71
98
  expect { handle_model.int_list = {a: 1} }.to raise_error NoMethodError
72
99
  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: 2.8.0
4
+ version: 2.8.1
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: 2017-08-10 00:00:00.000000000 Z
18
+ date: 2017-09-11 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activemodel
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
184
  version: '0'
185
185
  requirements: []
186
186
  rubyforge_project:
187
- rubygems_version: 2.6.12
187
+ rubygems_version: 2.5.1
188
188
  signing_key:
189
189
  specification_version: 4
190
190
  summary: DynamoDB interface