dynamoid 1.3.0 → 1.3.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.
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 4.2.0"
6
+ # Still tested against Ruby 2.0.0, which can't install nokogiri 1.7+
7
+ gem "nokogiri", "~> 1.6.8.1"
8
+
9
+ gemspec :path => "../"
@@ -0,0 +1,175 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ dynamoid (1.3.0)
5
+ activemodel (>= 4)
6
+ aws-sdk-resources (~> 2)
7
+ concurrent-ruby (>= 1.0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actionmailer (4.2.8)
13
+ actionpack (= 4.2.8)
14
+ actionview (= 4.2.8)
15
+ activejob (= 4.2.8)
16
+ mail (~> 2.5, >= 2.5.4)
17
+ rails-dom-testing (~> 1.0, >= 1.0.5)
18
+ actionpack (4.2.8)
19
+ actionview (= 4.2.8)
20
+ activesupport (= 4.2.8)
21
+ rack (~> 1.6)
22
+ rack-test (~> 0.6.2)
23
+ rails-dom-testing (~> 1.0, >= 1.0.5)
24
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
25
+ actionview (4.2.8)
26
+ activesupport (= 4.2.8)
27
+ builder (~> 3.1)
28
+ erubis (~> 2.7.0)
29
+ rails-dom-testing (~> 1.0, >= 1.0.5)
30
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
31
+ activejob (4.2.8)
32
+ activesupport (= 4.2.8)
33
+ globalid (>= 0.3.0)
34
+ activemodel (4.2.8)
35
+ activesupport (= 4.2.8)
36
+ builder (~> 3.1)
37
+ activerecord (4.2.8)
38
+ activemodel (= 4.2.8)
39
+ activesupport (= 4.2.8)
40
+ arel (~> 6.0)
41
+ activesupport (4.2.8)
42
+ i18n (~> 0.7)
43
+ minitest (~> 5.1)
44
+ thread_safe (~> 0.3, >= 0.3.4)
45
+ tzinfo (~> 1.1)
46
+ appraisal (2.1.0)
47
+ bundler
48
+ rake
49
+ thor (>= 0.14.0)
50
+ arel (6.0.4)
51
+ aws-sdk-core (2.8.11)
52
+ aws-sigv4 (~> 1.0)
53
+ jmespath (~> 1.0)
54
+ aws-sdk-resources (2.8.11)
55
+ aws-sdk-core (= 2.8.11)
56
+ aws-sigv4 (1.0.0)
57
+ builder (3.2.3)
58
+ coderay (1.1.1)
59
+ concurrent-ruby (1.0.5)
60
+ coveralls (0.8.19)
61
+ json (>= 1.8, < 3)
62
+ simplecov (~> 0.12.0)
63
+ term-ansicolor (~> 1.3)
64
+ thor (~> 0.19.1)
65
+ tins (~> 1.6)
66
+ diff-lcs (1.3)
67
+ docile (1.1.5)
68
+ erubis (2.7.0)
69
+ globalid (0.3.7)
70
+ activesupport (>= 4.1.0)
71
+ i18n (0.8.1)
72
+ jmespath (1.3.1)
73
+ json (2.0.3)
74
+ loofah (2.0.3)
75
+ nokogiri (>= 1.5.9)
76
+ mail (2.6.4)
77
+ mime-types (>= 1.16, < 4)
78
+ method_source (0.8.2)
79
+ mime-types (3.1)
80
+ mime-types-data (~> 3.2015)
81
+ mime-types-data (3.2016.0521)
82
+ mini_portile2 (2.1.0)
83
+ minitest (5.10.1)
84
+ nokogiri (1.6.8.1)
85
+ mini_portile2 (~> 2.1.0)
86
+ pry (0.10.4)
87
+ coderay (~> 1.1.0)
88
+ method_source (~> 0.8.1)
89
+ slop (~> 3.4)
90
+ rack (1.6.5)
91
+ rack-test (0.6.3)
92
+ rack (>= 1.0)
93
+ rails (4.2.8)
94
+ actionmailer (= 4.2.8)
95
+ actionpack (= 4.2.8)
96
+ actionview (= 4.2.8)
97
+ activejob (= 4.2.8)
98
+ activemodel (= 4.2.8)
99
+ activerecord (= 4.2.8)
100
+ activesupport (= 4.2.8)
101
+ bundler (>= 1.3.0, < 2.0)
102
+ railties (= 4.2.8)
103
+ sprockets-rails
104
+ rails-deprecated_sanitizer (1.0.3)
105
+ activesupport (>= 4.2.0.alpha)
106
+ rails-dom-testing (1.0.8)
107
+ activesupport (>= 4.2.0.beta, < 5.0)
108
+ nokogiri (~> 1.6)
109
+ rails-deprecated_sanitizer (>= 1.0.1)
110
+ rails-html-sanitizer (1.0.3)
111
+ loofah (~> 2.0)
112
+ railties (4.2.8)
113
+ actionpack (= 4.2.8)
114
+ activesupport (= 4.2.8)
115
+ rake (>= 0.8.7)
116
+ thor (>= 0.18.1, < 2.0)
117
+ rake (12.0.0)
118
+ rspec (3.5.0)
119
+ rspec-core (~> 3.5.0)
120
+ rspec-expectations (~> 3.5.0)
121
+ rspec-mocks (~> 3.5.0)
122
+ rspec-core (3.5.4)
123
+ rspec-support (~> 3.5.0)
124
+ rspec-expectations (3.5.0)
125
+ diff-lcs (>= 1.2.0, < 2.0)
126
+ rspec-support (~> 3.5.0)
127
+ rspec-mocks (3.5.0)
128
+ diff-lcs (>= 1.2.0, < 2.0)
129
+ rspec-support (~> 3.5.0)
130
+ rspec-retry (0.5.3)
131
+ rspec-core (> 3.3, < 3.6)
132
+ rspec-support (3.5.0)
133
+ simplecov (0.12.0)
134
+ docile (~> 1.1.0)
135
+ json (>= 1.8, < 3)
136
+ simplecov-html (~> 0.10.0)
137
+ simplecov-html (0.10.0)
138
+ slop (3.6.0)
139
+ sprockets (3.7.1)
140
+ concurrent-ruby (~> 1.0)
141
+ rack (> 1, < 3)
142
+ sprockets-rails (3.2.0)
143
+ actionpack (>= 4.0)
144
+ activesupport (>= 4.0)
145
+ sprockets (>= 3.0.0)
146
+ term-ansicolor (1.4.1)
147
+ tins (~> 1.0)
148
+ thor (0.19.4)
149
+ thread_safe (0.3.6)
150
+ tins (1.13.2)
151
+ tzinfo (1.2.3)
152
+ thread_safe (~> 0.1)
153
+ wwtd (1.3.0)
154
+ yard (0.9.8)
155
+
156
+ PLATFORMS
157
+ ruby
158
+
159
+ DEPENDENCIES
160
+ activesupport (>= 4)
161
+ appraisal (~> 2.1)
162
+ bundler (~> 1.14)
163
+ coveralls
164
+ dynamoid!
165
+ nokogiri (~> 1.6.8.1)
166
+ pry (~> 0.10)
167
+ rails (~> 4.2.0)
168
+ rake (~> 12.0)
169
+ rspec (~> 3.0)
170
+ rspec-retry
171
+ wwtd (~> 1.3)
172
+ yard
173
+
174
+ BUNDLED WITH
175
+ 1.14.6
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 5.0.0"
6
+
7
+ gemspec :path => "../"
@@ -0,0 +1,180 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ dynamoid (1.3.0)
5
+ activemodel (>= 4)
6
+ aws-sdk-resources (~> 2)
7
+ concurrent-ruby (>= 1.0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actioncable (5.0.2)
13
+ actionpack (= 5.0.2)
14
+ nio4r (>= 1.2, < 3.0)
15
+ websocket-driver (~> 0.6.1)
16
+ actionmailer (5.0.2)
17
+ actionpack (= 5.0.2)
18
+ actionview (= 5.0.2)
19
+ activejob (= 5.0.2)
20
+ mail (~> 2.5, >= 2.5.4)
21
+ rails-dom-testing (~> 2.0)
22
+ actionpack (5.0.2)
23
+ actionview (= 5.0.2)
24
+ activesupport (= 5.0.2)
25
+ rack (~> 2.0)
26
+ rack-test (~> 0.6.3)
27
+ rails-dom-testing (~> 2.0)
28
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
29
+ actionview (5.0.2)
30
+ activesupport (= 5.0.2)
31
+ builder (~> 3.1)
32
+ erubis (~> 2.7.0)
33
+ rails-dom-testing (~> 2.0)
34
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
35
+ activejob (5.0.2)
36
+ activesupport (= 5.0.2)
37
+ globalid (>= 0.3.6)
38
+ activemodel (5.0.2)
39
+ activesupport (= 5.0.2)
40
+ activerecord (5.0.2)
41
+ activemodel (= 5.0.2)
42
+ activesupport (= 5.0.2)
43
+ arel (~> 7.0)
44
+ activesupport (5.0.2)
45
+ concurrent-ruby (~> 1.0, >= 1.0.2)
46
+ i18n (~> 0.7)
47
+ minitest (~> 5.1)
48
+ tzinfo (~> 1.1)
49
+ appraisal (2.1.0)
50
+ bundler
51
+ rake
52
+ thor (>= 0.14.0)
53
+ arel (7.1.4)
54
+ aws-sdk-core (2.8.11)
55
+ aws-sigv4 (~> 1.0)
56
+ jmespath (~> 1.0)
57
+ aws-sdk-resources (2.8.11)
58
+ aws-sdk-core (= 2.8.11)
59
+ aws-sigv4 (1.0.0)
60
+ builder (3.2.3)
61
+ coderay (1.1.1)
62
+ concurrent-ruby (1.0.5)
63
+ coveralls (0.8.19)
64
+ json (>= 1.8, < 3)
65
+ simplecov (~> 0.12.0)
66
+ term-ansicolor (~> 1.3)
67
+ thor (~> 0.19.1)
68
+ tins (~> 1.6)
69
+ diff-lcs (1.3)
70
+ docile (1.1.5)
71
+ erubis (2.7.0)
72
+ globalid (0.3.7)
73
+ activesupport (>= 4.1.0)
74
+ i18n (0.8.1)
75
+ jmespath (1.3.1)
76
+ json (2.0.3)
77
+ loofah (2.0.3)
78
+ nokogiri (>= 1.5.9)
79
+ mail (2.6.4)
80
+ mime-types (>= 1.16, < 4)
81
+ method_source (0.8.2)
82
+ mime-types (3.1)
83
+ mime-types-data (~> 3.2015)
84
+ mime-types-data (3.2016.0521)
85
+ mini_portile2 (2.1.0)
86
+ minitest (5.10.1)
87
+ nio4r (2.0.0)
88
+ nokogiri (1.7.1)
89
+ mini_portile2 (~> 2.1.0)
90
+ pry (0.10.4)
91
+ coderay (~> 1.1.0)
92
+ method_source (~> 0.8.1)
93
+ slop (~> 3.4)
94
+ rack (2.0.1)
95
+ rack-test (0.6.3)
96
+ rack (>= 1.0)
97
+ rails (5.0.2)
98
+ actioncable (= 5.0.2)
99
+ actionmailer (= 5.0.2)
100
+ actionpack (= 5.0.2)
101
+ actionview (= 5.0.2)
102
+ activejob (= 5.0.2)
103
+ activemodel (= 5.0.2)
104
+ activerecord (= 5.0.2)
105
+ activesupport (= 5.0.2)
106
+ bundler (>= 1.3.0, < 2.0)
107
+ railties (= 5.0.2)
108
+ sprockets-rails (>= 2.0.0)
109
+ rails-dom-testing (2.0.2)
110
+ activesupport (>= 4.2.0, < 6.0)
111
+ nokogiri (~> 1.6)
112
+ rails-html-sanitizer (1.0.3)
113
+ loofah (~> 2.0)
114
+ railties (5.0.2)
115
+ actionpack (= 5.0.2)
116
+ activesupport (= 5.0.2)
117
+ method_source
118
+ rake (>= 0.8.7)
119
+ thor (>= 0.18.1, < 2.0)
120
+ rake (12.0.0)
121
+ rspec (3.5.0)
122
+ rspec-core (~> 3.5.0)
123
+ rspec-expectations (~> 3.5.0)
124
+ rspec-mocks (~> 3.5.0)
125
+ rspec-core (3.5.4)
126
+ rspec-support (~> 3.5.0)
127
+ rspec-expectations (3.5.0)
128
+ diff-lcs (>= 1.2.0, < 2.0)
129
+ rspec-support (~> 3.5.0)
130
+ rspec-mocks (3.5.0)
131
+ diff-lcs (>= 1.2.0, < 2.0)
132
+ rspec-support (~> 3.5.0)
133
+ rspec-retry (0.5.3)
134
+ rspec-core (> 3.3, < 3.6)
135
+ rspec-support (3.5.0)
136
+ simplecov (0.12.0)
137
+ docile (~> 1.1.0)
138
+ json (>= 1.8, < 3)
139
+ simplecov-html (~> 0.10.0)
140
+ simplecov-html (0.10.0)
141
+ slop (3.6.0)
142
+ sprockets (3.7.1)
143
+ concurrent-ruby (~> 1.0)
144
+ rack (> 1, < 3)
145
+ sprockets-rails (3.2.0)
146
+ actionpack (>= 4.0)
147
+ activesupport (>= 4.0)
148
+ sprockets (>= 3.0.0)
149
+ term-ansicolor (1.4.1)
150
+ tins (~> 1.0)
151
+ thor (0.19.4)
152
+ thread_safe (0.3.6)
153
+ tins (1.13.2)
154
+ tzinfo (1.2.3)
155
+ thread_safe (~> 0.1)
156
+ websocket-driver (0.6.5)
157
+ websocket-extensions (>= 0.1.0)
158
+ websocket-extensions (0.1.2)
159
+ wwtd (1.3.0)
160
+ yard (0.9.8)
161
+
162
+ PLATFORMS
163
+ ruby
164
+
165
+ DEPENDENCIES
166
+ activesupport (>= 4)
167
+ appraisal (~> 2.1)
168
+ bundler (~> 1.14)
169
+ coveralls
170
+ dynamoid!
171
+ pry (~> 0.10)
172
+ rails (~> 5.0.0)
173
+ rake (~> 12.0)
174
+ rspec (~> 3.0)
175
+ rspec-retry
176
+ wwtd (~> 1.3)
177
+ yard
178
+
179
+ BUNDLED WITH
180
+ 1.14.6
data/lib/dynamoid.rb CHANGED
@@ -25,8 +25,14 @@ require "dynamoid/components"
25
25
  require "dynamoid/document"
26
26
  require "dynamoid/adapter"
27
27
 
28
+ require "dynamoid/tasks/database"
29
+
28
30
  require "dynamoid/middleware/identity_map"
29
31
 
32
+ if defined?(Rails)
33
+ require "dynamoid/railtie"
34
+ end
35
+
30
36
  module Dynamoid
31
37
  extend self
32
38
 
@@ -17,7 +17,7 @@ module Dynamoid
17
17
 
18
18
  def tables
19
19
  if !@tables_.value
20
- @tables_.swap{|value, args| benchmark('Cache Tables') { list_tables } }
20
+ @tables_.swap{|value, args| benchmark('Cache Tables') { list_tables || [] } }
21
21
  end
22
22
  @tables_.value
23
23
  end
@@ -5,9 +5,10 @@ module Dynamoid #:nodoc:
5
5
  # The criteria chain is equivalent to an ActiveRecord relation (and realistically I should change the name from
6
6
  # chain to relation). It is a chainable object that builds up a query and eventually executes it by a Query or Scan.
7
7
  class Chain
8
+ # TODO: Should we transform any other types of query values?
9
+ TYPES_TO_DUMP_FOR_QUERY = [:string, :integer, :boolean]
8
10
  attr_accessor :query, :source, :values, :consistent_read
9
11
  include Enumerable
10
-
11
12
  # Create a new criteria chain.
12
13
  #
13
14
  # @param [Class] source the class upon which the ultimate query will be performed.
@@ -30,7 +31,14 @@ module Dynamoid #:nodoc:
30
31
  #
31
32
  # @since 0.2.0
32
33
  def where(args)
33
- args.each {|k, v| query[k.to_sym] = v}
34
+ args.each do |k, v|
35
+ sym = k.to_sym
36
+ query[sym] = if (field_options = source.attributes[sym]) && (type = field_options[:type]) && TYPES_TO_DUMP_FOR_QUERY.include?(type)
37
+ source.dump_field(v, field_options)
38
+ else
39
+ v
40
+ end
41
+ end
34
42
  self
35
43
  end
36
44
 
@@ -13,7 +13,7 @@ module Dynamoid #:nodoc:
13
13
  self.read_only_attributes = []
14
14
  self.base_class = self
15
15
 
16
- Dynamoid.included_models << self
16
+ Dynamoid.included_models << self unless Dynamoid.included_models.include? self
17
17
  end
18
18
 
19
19
  module ClassMethods
@@ -23,6 +23,15 @@ module Dynamoid
23
23
  end
24
24
  end
25
25
 
26
+ class RecordNotDestroyed < Error
27
+ attr_reader :record
28
+
29
+ def initialize(record)
30
+ super("Failed to destroy item")
31
+ @record = record
32
+ end
33
+ end
34
+
26
35
  # This class is intended to be private to Dynamoid.
27
36
  class ConditionalCheckFailedException < Error
28
37
  attr_reader :inner_exception