surus 0.6.2 → 0.6.3
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/.rubocop.yml +7 -0
- data/.rubocop_todo.yml +339 -0
- data/.travis.yml +13 -3
- data/CHANGELOG.md +4 -0
- data/bench/benchmark_helper.rb +1 -1
- data/bench/hstore_find.rb +3 -3
- data/bench/synchronous_commit.rb +20 -20
- data/gemfiles/4.0.gemfile +1 -1
- data/gemfiles/4.1.gemfile +1 -1
- data/gemfiles/4.2.gemfile +1 -1
- data/gemfiles/5.0.gemfile +5 -0
- data/lib/surus.rb +1 -8
- data/lib/surus/hstore/scope.rb +3 -3
- data/lib/surus/json.rb +8 -0
- data/lib/surus/synchronous_commit/connection.rb +2 -2
- data/lib/surus/synchronous_commit/model.rb +1 -1
- data/lib/surus/version.rb +1 -1
- data/spec/array/scope_spec.rb +6 -6
- data/spec/hstore/scope_spec.rb +12 -12
- data/spec/hstore/serializer_spec.rb +11 -1
- data/spec/spec_helper.rb +0 -1
- data/spec/synchronous_commit/connection_spec.rb +1 -1
- data/surus.gemspec +2 -1
- metadata +24 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3979b782fd1e13d2e96ba994192cacf5433c53d7
|
|
4
|
+
data.tar.gz: 8f030cf17f9d8fb30dace66d08edb1b224a192bf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aab88cce49c5e6582b04c14b43e38da23e7463fec01e5772650537d241fa23cf6e1fdf06a40a57e6e3d5e2a4663dc8700d9b7e95a01914b9196b494c91a55b58
|
|
7
|
+
data.tar.gz: c3da04f7796d29af7a73d1ffff121ef2f206613921f8f1b6456e52257ee4e31bfc74bd32e0c9d3f123c1eb49c588b40e588d2c3517d2212a0baa74e57058fb44
|
data/.rubocop.yml
ADDED
data/.rubocop_todo.yml
ADDED
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
# This configuration was generated by
|
|
2
|
+
# `rubocop --auto-gen-config`
|
|
3
|
+
# on 2016-03-24 13:49:46 -0500 using RuboCop version 0.38.0.
|
|
4
|
+
# The point is for the user to remove these configuration records
|
|
5
|
+
# one by one as the offenses are removed from the code base.
|
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
|
8
|
+
|
|
9
|
+
# Offense count: 1
|
|
10
|
+
# Cop supports --auto-correct.
|
|
11
|
+
Lint/DeprecatedClassMethods:
|
|
12
|
+
Exclude:
|
|
13
|
+
- 'lib/generators/surus/hstore/templates/install_hstore.rb'
|
|
14
|
+
|
|
15
|
+
# Offense count: 5
|
|
16
|
+
# Cop supports --auto-correct.
|
|
17
|
+
# Configuration parameters: AlignWith, SupportedStyles, AutoCorrect.
|
|
18
|
+
# SupportedStyles: keyword, variable, start_of_line
|
|
19
|
+
Lint/EndAlignment:
|
|
20
|
+
Enabled: false
|
|
21
|
+
|
|
22
|
+
# Offense count: 1
|
|
23
|
+
Lint/ShadowingOuterLocalVariable:
|
|
24
|
+
Exclude:
|
|
25
|
+
- 'lib/surus/hstore/serializer.rb'
|
|
26
|
+
|
|
27
|
+
# Offense count: 1
|
|
28
|
+
Lint/UnderscorePrefixedVariableName:
|
|
29
|
+
Exclude:
|
|
30
|
+
- 'lib/surus/json/query.rb'
|
|
31
|
+
|
|
32
|
+
# Offense count: 1
|
|
33
|
+
# Cop supports --auto-correct.
|
|
34
|
+
# Configuration parameters: IgnoreEmptyBlocks.
|
|
35
|
+
Lint/UnusedBlockArgument:
|
|
36
|
+
Exclude:
|
|
37
|
+
- 'bench/hstore_find.rb'
|
|
38
|
+
|
|
39
|
+
# Offense count: 7
|
|
40
|
+
Lint/UselessAssignment:
|
|
41
|
+
Exclude:
|
|
42
|
+
- 'lib/generators/surus/hstore/templates/install_hstore.rb'
|
|
43
|
+
- 'spec/json/json_spec.rb'
|
|
44
|
+
|
|
45
|
+
# Offense count: 7
|
|
46
|
+
Metrics/AbcSize:
|
|
47
|
+
Max: 30
|
|
48
|
+
|
|
49
|
+
# Offense count: 1
|
|
50
|
+
# Configuration parameters: CountComments.
|
|
51
|
+
Metrics/ClassLength:
|
|
52
|
+
Max: 245
|
|
53
|
+
|
|
54
|
+
# Offense count: 4
|
|
55
|
+
Metrics/CyclomaticComplexity:
|
|
56
|
+
Max: 10
|
|
57
|
+
|
|
58
|
+
# Offense count: 76
|
|
59
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
|
|
60
|
+
# URISchemes: http, https
|
|
61
|
+
Metrics/LineLength:
|
|
62
|
+
Max: 151
|
|
63
|
+
|
|
64
|
+
# Offense count: 7
|
|
65
|
+
# Configuration parameters: CountComments.
|
|
66
|
+
Metrics/MethodLength:
|
|
67
|
+
Max: 220
|
|
68
|
+
|
|
69
|
+
# Offense count: 2
|
|
70
|
+
Metrics/PerceivedComplexity:
|
|
71
|
+
Max: 12
|
|
72
|
+
|
|
73
|
+
# Offense count: 1
|
|
74
|
+
Performance/TimesMap:
|
|
75
|
+
Exclude:
|
|
76
|
+
- 'bench/hstore_find.rb'
|
|
77
|
+
|
|
78
|
+
# Offense count: 1
|
|
79
|
+
# Cop supports --auto-correct.
|
|
80
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
|
|
81
|
+
# SupportedStyles: outdent, indent
|
|
82
|
+
Style/AccessModifierIndentation:
|
|
83
|
+
Enabled: false
|
|
84
|
+
|
|
85
|
+
# Offense count: 11
|
|
86
|
+
# Cop supports --auto-correct.
|
|
87
|
+
# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles.
|
|
88
|
+
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
|
|
89
|
+
Style/AlignHash:
|
|
90
|
+
Exclude:
|
|
91
|
+
- 'bench/synchronous_commit.rb'
|
|
92
|
+
|
|
93
|
+
# Offense count: 8
|
|
94
|
+
# Cop supports --auto-correct.
|
|
95
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
96
|
+
# SupportedStyles: with_first_parameter, with_fixed_indentation
|
|
97
|
+
Style/AlignParameters:
|
|
98
|
+
Exclude:
|
|
99
|
+
- 'spec/spec_helper.rb'
|
|
100
|
+
|
|
101
|
+
# Offense count: 2
|
|
102
|
+
# Cop supports --auto-correct.
|
|
103
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
104
|
+
# SupportedStyles: percent_q, bare_percent
|
|
105
|
+
Style/BarePercentLiterals:
|
|
106
|
+
Exclude:
|
|
107
|
+
- 'lib/surus/hstore/serializer.rb'
|
|
108
|
+
|
|
109
|
+
# Offense count: 4
|
|
110
|
+
# Cop supports --auto-correct.
|
|
111
|
+
# Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep, IndentationWidth.
|
|
112
|
+
# SupportedStyles: case, end
|
|
113
|
+
Style/CaseIndentation:
|
|
114
|
+
Enabled: false
|
|
115
|
+
|
|
116
|
+
# Offense count: 11
|
|
117
|
+
# Cop supports --auto-correct.
|
|
118
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
119
|
+
# SupportedStyles: is_a?, kind_of?
|
|
120
|
+
Style/ClassCheck:
|
|
121
|
+
Exclude:
|
|
122
|
+
- 'lib/surus/hstore/serializer.rb'
|
|
123
|
+
- 'lib/surus/json/query.rb'
|
|
124
|
+
|
|
125
|
+
# Offense count: 1
|
|
126
|
+
# Cop supports --auto-correct.
|
|
127
|
+
# Configuration parameters: SingleLineConditionsOnly.
|
|
128
|
+
Style/ConditionalAssignment:
|
|
129
|
+
Exclude:
|
|
130
|
+
- 'lib/generators/surus/hstore/templates/install_hstore.rb'
|
|
131
|
+
|
|
132
|
+
# Offense count: 22
|
|
133
|
+
Style/Documentation:
|
|
134
|
+
Exclude:
|
|
135
|
+
- 'spec/**/*'
|
|
136
|
+
- 'test/**/*'
|
|
137
|
+
- 'bench/benchmark_helper.rb'
|
|
138
|
+
- 'lib/generators/surus/hstore/install_generator.rb'
|
|
139
|
+
- 'lib/generators/surus/hstore/templates/install_hstore.rb'
|
|
140
|
+
- 'lib/surus/array/scope.rb'
|
|
141
|
+
- 'lib/surus/hstore/scope.rb'
|
|
142
|
+
- 'lib/surus/hstore/serializer.rb'
|
|
143
|
+
- 'lib/surus/json/array_agg_query.rb'
|
|
144
|
+
- 'lib/surus/json/association_scope_builder.rb'
|
|
145
|
+
- 'lib/surus/json/belongs_to_scope_builder.rb'
|
|
146
|
+
- 'lib/surus/json/has_and_belongs_to_many_scope_builder.rb'
|
|
147
|
+
- 'lib/surus/json/has_many_scope_builder.rb'
|
|
148
|
+
- 'lib/surus/json/model.rb'
|
|
149
|
+
- 'lib/surus/json/query.rb'
|
|
150
|
+
- 'lib/surus/json/row_query.rb'
|
|
151
|
+
- 'lib/surus/synchronous_commit/connection.rb'
|
|
152
|
+
|
|
153
|
+
# Offense count: 4
|
|
154
|
+
# Cop supports --auto-correct.
|
|
155
|
+
Style/ElseAlignment:
|
|
156
|
+
Exclude:
|
|
157
|
+
- 'lib/surus/hstore/serializer.rb'
|
|
158
|
+
- 'lib/surus/json/query.rb'
|
|
159
|
+
|
|
160
|
+
# Offense count: 2
|
|
161
|
+
# Cop supports --auto-correct.
|
|
162
|
+
Style/EmptyLines:
|
|
163
|
+
Exclude:
|
|
164
|
+
- 'bench/hstore_find.rb'
|
|
165
|
+
- 'lib/generators/surus/hstore/templates/install_hstore.rb'
|
|
166
|
+
|
|
167
|
+
# Offense count: 3
|
|
168
|
+
# Cop supports --auto-correct.
|
|
169
|
+
Style/EmptyLinesAroundAccessModifier:
|
|
170
|
+
Exclude:
|
|
171
|
+
- 'lib/generators/surus/hstore/templates/install_hstore.rb'
|
|
172
|
+
- 'lib/surus/array/scope.rb'
|
|
173
|
+
- 'lib/surus/json/query.rb'
|
|
174
|
+
|
|
175
|
+
# Offense count: 2
|
|
176
|
+
# Cop supports --auto-correct.
|
|
177
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
178
|
+
# SupportedStyles: empty_lines, no_empty_lines
|
|
179
|
+
Style/EmptyLinesAroundClassBody:
|
|
180
|
+
Exclude:
|
|
181
|
+
- 'lib/generators/surus/hstore/install_generator.rb'
|
|
182
|
+
- 'lib/surus/json/has_and_belongs_to_many_scope_builder.rb'
|
|
183
|
+
|
|
184
|
+
# Offense count: 1
|
|
185
|
+
# Cop supports --auto-correct.
|
|
186
|
+
Style/EmptyLinesAroundMethodBody:
|
|
187
|
+
Exclude:
|
|
188
|
+
- 'lib/generators/surus/hstore/templates/install_hstore.rb'
|
|
189
|
+
|
|
190
|
+
# Offense count: 1
|
|
191
|
+
# Cop supports --auto-correct.
|
|
192
|
+
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
|
|
193
|
+
Style/ExtraSpacing:
|
|
194
|
+
Exclude:
|
|
195
|
+
- 'spec/factories.rb'
|
|
196
|
+
|
|
197
|
+
# Offense count: 1
|
|
198
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
199
|
+
# SupportedStyles: format, sprintf, percent
|
|
200
|
+
Style/FormatString:
|
|
201
|
+
Exclude:
|
|
202
|
+
- 'lib/generators/surus/hstore/install_generator.rb'
|
|
203
|
+
|
|
204
|
+
# Offense count: 1
|
|
205
|
+
# Cop supports --auto-correct.
|
|
206
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
207
|
+
# SupportedStyles: normal, rails
|
|
208
|
+
Style/IndentationConsistency:
|
|
209
|
+
Exclude:
|
|
210
|
+
- 'lib/surus/json/query.rb'
|
|
211
|
+
|
|
212
|
+
# Offense count: 4
|
|
213
|
+
# Cop supports --auto-correct.
|
|
214
|
+
# Configuration parameters: Width.
|
|
215
|
+
Style/IndentationWidth:
|
|
216
|
+
Exclude:
|
|
217
|
+
- 'lib/surus/hstore/serializer.rb'
|
|
218
|
+
- 'lib/surus/json/query.rb'
|
|
219
|
+
|
|
220
|
+
# Offense count: 7
|
|
221
|
+
# Cop supports --auto-correct.
|
|
222
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
|
|
223
|
+
# SupportedStyles: aligned, indented
|
|
224
|
+
Style/MultilineMethodCallIndentation:
|
|
225
|
+
Enabled: false
|
|
226
|
+
|
|
227
|
+
# Offense count: 1
|
|
228
|
+
# Cop supports --auto-correct.
|
|
229
|
+
Style/MutableConstant:
|
|
230
|
+
Exclude:
|
|
231
|
+
- 'lib/surus/version.rb'
|
|
232
|
+
|
|
233
|
+
# Offense count: 1
|
|
234
|
+
# Cop supports --auto-correct.
|
|
235
|
+
Style/NilComparison:
|
|
236
|
+
Exclude:
|
|
237
|
+
- 'lib/surus/hstore/serializer.rb'
|
|
238
|
+
|
|
239
|
+
# Offense count: 2
|
|
240
|
+
# Cop supports --auto-correct.
|
|
241
|
+
Style/NumericLiterals:
|
|
242
|
+
MinDigits: 6
|
|
243
|
+
|
|
244
|
+
# Offense count: 6
|
|
245
|
+
# Cop supports --auto-correct.
|
|
246
|
+
# Configuration parameters: PreferredDelimiters.
|
|
247
|
+
Style/PercentLiteralDelimiters:
|
|
248
|
+
Exclude:
|
|
249
|
+
- 'spec/array/scope_spec.rb'
|
|
250
|
+
- 'spec/hstore/serializer_spec.rb'
|
|
251
|
+
|
|
252
|
+
# Offense count: 1
|
|
253
|
+
# Cop supports --auto-correct.
|
|
254
|
+
Style/RedundantParentheses:
|
|
255
|
+
Exclude:
|
|
256
|
+
- 'lib/generators/surus/hstore/templates/install_hstore.rb'
|
|
257
|
+
|
|
258
|
+
# Offense count: 5
|
|
259
|
+
# Cop supports --auto-correct.
|
|
260
|
+
Style/SpaceAfterComma:
|
|
261
|
+
Exclude:
|
|
262
|
+
- 'bench/benchmark_helper.rb'
|
|
263
|
+
- 'spec/hstore/serializer_spec.rb'
|
|
264
|
+
|
|
265
|
+
# Offense count: 4
|
|
266
|
+
# Cop supports --auto-correct.
|
|
267
|
+
# Configuration parameters: SupportedStyles.
|
|
268
|
+
# SupportedStyles: space, no_space
|
|
269
|
+
Style/SpaceAroundEqualsInParameterDefault:
|
|
270
|
+
EnforcedStyle: no_space
|
|
271
|
+
|
|
272
|
+
# Offense count: 1
|
|
273
|
+
# Cop supports --auto-correct.
|
|
274
|
+
Style/SpaceAroundKeyword:
|
|
275
|
+
Exclude:
|
|
276
|
+
- 'lib/generators/surus/hstore/templates/install_hstore.rb'
|
|
277
|
+
|
|
278
|
+
# Offense count: 2
|
|
279
|
+
# Cop supports --auto-correct.
|
|
280
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
281
|
+
# SupportedStyles: space, no_space
|
|
282
|
+
Style/SpaceBeforeBlockBraces:
|
|
283
|
+
Enabled: false
|
|
284
|
+
|
|
285
|
+
# Offense count: 4
|
|
286
|
+
# Cop supports --auto-correct.
|
|
287
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
|
|
288
|
+
# SupportedStyles: space, no_space
|
|
289
|
+
Style/SpaceInsideBlockBraces:
|
|
290
|
+
Enabled: false
|
|
291
|
+
|
|
292
|
+
# Offense count: 74
|
|
293
|
+
# Cop supports --auto-correct.
|
|
294
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
|
|
295
|
+
# SupportedStyles: space, no_space
|
|
296
|
+
Style/SpaceInsideHashLiteralBraces:
|
|
297
|
+
Enabled: false
|
|
298
|
+
|
|
299
|
+
# Offense count: 272
|
|
300
|
+
# Cop supports --auto-correct.
|
|
301
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
|
|
302
|
+
# SupportedStyles: single_quotes, double_quotes
|
|
303
|
+
Style/StringLiterals:
|
|
304
|
+
Enabled: false
|
|
305
|
+
|
|
306
|
+
# Offense count: 1
|
|
307
|
+
# Cop supports --auto-correct.
|
|
308
|
+
Style/Tab:
|
|
309
|
+
Exclude:
|
|
310
|
+
- 'lib/surus/json/query.rb'
|
|
311
|
+
|
|
312
|
+
# Offense count: 1
|
|
313
|
+
# Cop supports --auto-correct.
|
|
314
|
+
# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
|
|
315
|
+
# SupportedStyles: comma, consistent_comma, no_comma
|
|
316
|
+
Style/TrailingCommaInLiteral:
|
|
317
|
+
Exclude:
|
|
318
|
+
- 'spec/hstore/serializer_spec.rb'
|
|
319
|
+
|
|
320
|
+
# Offense count: 1
|
|
321
|
+
# Cop supports --auto-correct.
|
|
322
|
+
# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist.
|
|
323
|
+
# Whitelist: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym
|
|
324
|
+
Style/TrivialAccessors:
|
|
325
|
+
Exclude:
|
|
326
|
+
- 'bench/benchmark_helper.rb'
|
|
327
|
+
|
|
328
|
+
# Offense count: 1
|
|
329
|
+
# Cop supports --auto-correct.
|
|
330
|
+
Style/UnneededInterpolation:
|
|
331
|
+
Exclude:
|
|
332
|
+
- 'lib/surus/json/has_many_scope_builder.rb'
|
|
333
|
+
|
|
334
|
+
# Offense count: 4
|
|
335
|
+
# Cop supports --auto-correct.
|
|
336
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, MinSize, WordRegex.
|
|
337
|
+
# SupportedStyles: percent, brackets
|
|
338
|
+
Style/WordArray:
|
|
339
|
+
Enabled: false
|
data/.travis.yml
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
language: ruby
|
|
2
2
|
rvm:
|
|
3
|
-
- 2.
|
|
4
|
-
- 2.
|
|
5
|
-
- 2.
|
|
3
|
+
- 2.3.1
|
|
4
|
+
- 2.2.5
|
|
5
|
+
- 2.1.9
|
|
6
|
+
- rbx
|
|
6
7
|
gemfile:
|
|
7
8
|
- gemfiles/4.0.gemfile
|
|
8
9
|
- gemfiles/4.1.gemfile
|
|
9
10
|
- gemfiles/4.2.gemfile
|
|
11
|
+
- gemfiles/5.0.gemfile
|
|
12
|
+
|
|
13
|
+
matrix:
|
|
14
|
+
allow_failures:
|
|
15
|
+
- rvm: rbx
|
|
10
16
|
|
|
11
17
|
addons:
|
|
12
18
|
postgresql: "9.2"
|
|
@@ -15,3 +21,7 @@ before_script:
|
|
|
15
21
|
- cp spec/database.yml.travis spec/database.yml
|
|
16
22
|
- psql -U postgres -c 'create database surus_test;'
|
|
17
23
|
- psql -U postgres -f spec/database_structure.sql surus_test
|
|
24
|
+
|
|
25
|
+
script:
|
|
26
|
+
- bundle exec rake spec
|
|
27
|
+
- bundle exec rubocop
|
data/CHANGELOG.md
CHANGED
data/bench/benchmark_helper.rb
CHANGED
data/bench/hstore_find.rb
CHANGED
|
@@ -45,7 +45,7 @@ if eav
|
|
|
45
45
|
print "Creating EAV test data... "
|
|
46
46
|
EavMasterRecord.transaction do
|
|
47
47
|
num_records.times do |i|
|
|
48
|
-
EavMasterRecord.create! :
|
|
48
|
+
EavMasterRecord.create! properties: key_value_pairs[i]
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
puts "Done."
|
|
@@ -54,7 +54,7 @@ end
|
|
|
54
54
|
print "Creating Surus test data... "
|
|
55
55
|
SurusKeyValueRecord.transaction do
|
|
56
56
|
num_records.times do |i|
|
|
57
|
-
SurusKeyValueRecord.create! :
|
|
57
|
+
SurusKeyValueRecord.create! properties: key_value_pairs[i]
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
puts "Done."
|
|
@@ -63,7 +63,7 @@ if yaml
|
|
|
63
63
|
print "Creating YAML test data... "
|
|
64
64
|
YamlKeyValueRecord.transaction do
|
|
65
65
|
num_records.times do |i|
|
|
66
|
-
YamlKeyValueRecord.create! :
|
|
66
|
+
YamlKeyValueRecord.create! properties: key_value_pairs[i]
|
|
67
67
|
end
|
|
68
68
|
end
|
|
69
69
|
puts "Done."
|
data/bench/synchronous_commit.rb
CHANGED
|
@@ -20,22 +20,22 @@ puts "Done."
|
|
|
20
20
|
random_io = StringIO.new(random_string)
|
|
21
21
|
|
|
22
22
|
create_wide_record = lambda do
|
|
23
|
-
WideRecord.create! :
|
|
24
|
-
:
|
|
25
|
-
:
|
|
26
|
-
:
|
|
27
|
-
:
|
|
28
|
-
:
|
|
29
|
-
:
|
|
30
|
-
:
|
|
31
|
-
:
|
|
32
|
-
:
|
|
23
|
+
WideRecord.create! a: random_io.read(wide_field_width),
|
|
24
|
+
b: random_io.read(wide_field_width),
|
|
25
|
+
c: random_io.read(wide_field_width),
|
|
26
|
+
d: random_io.read(wide_field_width),
|
|
27
|
+
e: random_io.read(wide_field_width),
|
|
28
|
+
f: random_io.read(wide_field_width),
|
|
29
|
+
g: random_io.read(wide_field_width),
|
|
30
|
+
h: random_io.read(wide_field_width),
|
|
31
|
+
i: random_io.read(wide_field_width),
|
|
32
|
+
j: random_io.read(wide_field_width)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
create_narrow_record = lambda do
|
|
36
|
-
NarrowRecord.create! :
|
|
37
|
-
:
|
|
38
|
-
:
|
|
36
|
+
NarrowRecord.create! a: random_io.read(narrow_field_width),
|
|
37
|
+
b: random_io.read(narrow_field_width),
|
|
38
|
+
c: random_io.read(narrow_field_width)
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
{ "narrow" => create_narrow_record, "wide" => create_wide_record }.each do |text, create_record|
|
|
@@ -48,15 +48,15 @@ end
|
|
|
48
48
|
WideRecord.synchronous_commit true
|
|
49
49
|
x.report("enabled") do
|
|
50
50
|
num_records.times { create_record.call }
|
|
51
|
-
end
|
|
51
|
+
end
|
|
52
52
|
|
|
53
53
|
clean_database
|
|
54
54
|
random_io.rewind
|
|
55
55
|
WideRecord.synchronous_commit false
|
|
56
56
|
x.report("disabled") do
|
|
57
57
|
num_records.times { create_record.call }
|
|
58
|
-
end
|
|
59
|
-
|
|
58
|
+
end
|
|
59
|
+
|
|
60
60
|
clean_database
|
|
61
61
|
random_io.rewind
|
|
62
62
|
WideRecord.synchronous_commit true
|
|
@@ -68,7 +68,7 @@ end
|
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
|
-
|
|
71
|
+
|
|
72
72
|
clean_database
|
|
73
73
|
random_io.rewind
|
|
74
74
|
WideRecord.synchronous_commit true
|
|
@@ -76,8 +76,8 @@ end
|
|
|
76
76
|
WideRecord.transaction do
|
|
77
77
|
num_records.times { create_record.call }
|
|
78
78
|
end
|
|
79
|
-
end
|
|
80
|
-
|
|
79
|
+
end
|
|
80
|
+
|
|
81
81
|
clean_database
|
|
82
82
|
random_io.rewind
|
|
83
83
|
WideRecord.synchronous_commit false
|
|
@@ -85,6 +85,6 @@ end
|
|
|
85
85
|
WideRecord.transaction do
|
|
86
86
|
num_records.times { create_record.call }
|
|
87
87
|
end
|
|
88
|
-
end
|
|
88
|
+
end
|
|
89
89
|
end
|
|
90
90
|
end
|
data/gemfiles/4.0.gemfile
CHANGED
data/gemfiles/4.1.gemfile
CHANGED
data/gemfiles/4.2.gemfile
CHANGED
data/lib/surus.rb
CHANGED
|
@@ -5,11 +5,4 @@ require 'surus/hstore/scope'
|
|
|
5
5
|
require 'surus/array/scope'
|
|
6
6
|
require 'surus/synchronous_commit/connection'
|
|
7
7
|
require 'surus/synchronous_commit/model'
|
|
8
|
-
require 'surus/json
|
|
9
|
-
require 'surus/json/row_query'
|
|
10
|
-
require 'surus/json/array_agg_query'
|
|
11
|
-
require 'surus/json/model'
|
|
12
|
-
require 'surus/json/association_scope_builder'
|
|
13
|
-
require 'surus/json/belongs_to_scope_builder'
|
|
14
|
-
require 'surus/json/has_many_scope_builder'
|
|
15
|
-
require 'surus/json/has_and_belongs_to_many_scope_builder'
|
|
8
|
+
require 'surus/json'
|
data/lib/surus/hstore/scope.rb
CHANGED
|
@@ -14,7 +14,7 @@ module Surus
|
|
|
14
14
|
# Example:
|
|
15
15
|
# User.hstore_has_key(:properties, "favorite_color")
|
|
16
16
|
def hstore_has_key(column, key)
|
|
17
|
-
where("#{connection.quote_table_name(table_name)}.#{connection.quote_column_name(column)} ? :key", :
|
|
17
|
+
where("#{connection.quote_table_name(table_name)}.#{connection.quote_column_name(column)} ? :key", key: key)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
# Adds a where condition that requires column to contain all keys.
|
|
@@ -23,7 +23,7 @@ module Surus
|
|
|
23
23
|
# User.hstore_has_all_keys(:properties, "favorite_color", "favorite_song")
|
|
24
24
|
# User.hstore_has_all_keys(:properties, ["favorite_color", "favorite_song"])
|
|
25
25
|
def hstore_has_all_keys(column, *keys)
|
|
26
|
-
where("#{connection.quote_table_name(table_name)}.#{connection.quote_column_name(column)} ?& ARRAY[:keys]", :
|
|
26
|
+
where("#{connection.quote_table_name(table_name)}.#{connection.quote_column_name(column)} ?& ARRAY[:keys]", keys: keys.flatten)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
# Adds a where condition that requires column to contain any keys.
|
|
@@ -32,7 +32,7 @@ module Surus
|
|
|
32
32
|
# User.hstore_has_any_keys(:properties, "favorite_color", "favorite_song")
|
|
33
33
|
# User.hstore_has_any_keys(:properties, ["favorite_color", "favorite_song"])
|
|
34
34
|
def hstore_has_any_keys(column, *keys)
|
|
35
|
-
where("#{connection.quote_table_name(table_name)}.#{connection.quote_column_name(column)} ?| ARRAY[:keys]", :
|
|
35
|
+
where("#{connection.quote_table_name(table_name)}.#{connection.quote_column_name(column)} ?| ARRAY[:keys]", keys: keys.flatten)
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
end
|
data/lib/surus/json.rb
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
require 'surus/json/query'
|
|
2
|
+
require 'surus/json/row_query'
|
|
3
|
+
require 'surus/json/array_agg_query'
|
|
4
|
+
require 'surus/json/model'
|
|
5
|
+
require 'surus/json/association_scope_builder'
|
|
6
|
+
require 'surus/json/belongs_to_scope_builder'
|
|
7
|
+
require 'surus/json/has_many_scope_builder'
|
|
8
|
+
require 'surus/json/has_and_belongs_to_many_scope_builder'
|
|
@@ -12,14 +12,14 @@ module Surus
|
|
|
12
12
|
self.synchronous_commit = value
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
# Changes current synchronous_commit state. If a transaction is currently
|
|
17
17
|
# in progress the change will be reverted at the end of the transaction.
|
|
18
18
|
#
|
|
19
19
|
# Requires true or false to be passed exactly -- not merely truthy or falsy
|
|
20
20
|
def synchronous_commit=(value)
|
|
21
21
|
raise ArgumentError, "argument must be true or false" unless value == true || value == false
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
execute "SET #{'LOCAL' if open_transactions > 0} synchronous_commit TO #{value ? 'ON' : 'OFF'}"
|
|
24
24
|
end
|
|
25
25
|
end
|
|
@@ -3,7 +3,7 @@ module Surus
|
|
|
3
3
|
# synchronous_commit and synchronous_commit= are delegated to the underlying
|
|
4
4
|
# connection object
|
|
5
5
|
module Model
|
|
6
|
-
delegate :synchronous_commit, :synchronous_commit=, :
|
|
6
|
+
delegate :synchronous_commit, :synchronous_commit=, to: :connection
|
|
7
7
|
end
|
|
8
8
|
end
|
|
9
9
|
end
|
data/lib/surus/version.rb
CHANGED
data/spec/array/scope_spec.rb
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe Surus::Array::Scope do
|
|
4
|
-
let!(:empty) { TextArrayRecord.create! :
|
|
4
|
+
let!(:empty) { TextArrayRecord.create! texts: [] }
|
|
5
5
|
|
|
6
6
|
context "array_has" do
|
|
7
|
-
let!(:match) { TextArrayRecord.create! :
|
|
8
|
-
let!(:missing_element) { TextArrayRecord.create! :
|
|
7
|
+
let!(:match) { TextArrayRecord.create! texts: %w{a b} }
|
|
8
|
+
let!(:missing_element) { TextArrayRecord.create! texts: %w{a} }
|
|
9
9
|
|
|
10
10
|
def self.shared_examples
|
|
11
11
|
it { should include(match) }
|
|
@@ -30,8 +30,8 @@ describe Surus::Array::Scope do
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
context "array_has_any" do
|
|
33
|
-
let!(:match) { TextArrayRecord.create! :
|
|
34
|
-
let!(:missing_element) { TextArrayRecord.create! :
|
|
33
|
+
let!(:match) { TextArrayRecord.create! texts: %w{a b} }
|
|
34
|
+
let!(:missing_element) { TextArrayRecord.create! texts: %w{a} }
|
|
35
35
|
|
|
36
36
|
def self.shared_examples
|
|
37
37
|
it { should include(match) }
|
|
@@ -56,7 +56,7 @@ describe Surus::Array::Scope do
|
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
it "casts between varchar[] and text[]" do
|
|
59
|
-
record = VarcharArrayRecord.create! :
|
|
59
|
+
record = VarcharArrayRecord.create! varchars: %w{a b}
|
|
60
60
|
expect(VarcharArrayRecord.array_has_any(:varchars, "a")).to include(record)
|
|
61
61
|
expect(VarcharArrayRecord.array_has_any(:varchars, "c")).to_not include(record)
|
|
62
62
|
expect(VarcharArrayRecord.array_has_any(:varchars, "b", "c")).to include(record)
|
data/spec/hstore/scope_spec.rb
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe Surus::Hstore::Scope do
|
|
4
|
-
let!(:empty) { HstoreRecord.create! :
|
|
4
|
+
let!(:empty) { HstoreRecord.create! properties: {} }
|
|
5
5
|
|
|
6
6
|
context "hstore_has_pairs" do
|
|
7
|
-
let!(:match) { HstoreRecord.create! :
|
|
8
|
-
let!(:missing_key) { HstoreRecord.create! :
|
|
9
|
-
let!(:wrong_value) { HstoreRecord.create! :
|
|
7
|
+
let!(:match) { HstoreRecord.create! properties: { "a" => "1", "b" => "2", "c" => "3" } }
|
|
8
|
+
let!(:missing_key) { HstoreRecord.create! properties: { "a" => "1", "c" => "3" } }
|
|
9
|
+
let!(:wrong_value) { HstoreRecord.create! properties: { "a" => "1", "b" => "5" } }
|
|
10
10
|
|
|
11
11
|
subject { HstoreRecord.hstore_has_pairs(:properties, "a" => "1", "b" => "2") }
|
|
12
12
|
|
|
@@ -17,8 +17,8 @@ describe Surus::Hstore::Scope do
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
context "hstore_has_key" do
|
|
20
|
-
let!(:match) { HstoreRecord.create! :
|
|
21
|
-
let!(:missing_key) { HstoreRecord.create! :
|
|
20
|
+
let!(:match) { HstoreRecord.create! properties: { "a" => "1", "b" => "2" } }
|
|
21
|
+
let!(:missing_key) { HstoreRecord.create! properties: { "a" => "1", "c" => "3" } }
|
|
22
22
|
|
|
23
23
|
subject { HstoreRecord.hstore_has_key(:properties, "b") }
|
|
24
24
|
|
|
@@ -28,9 +28,9 @@ describe Surus::Hstore::Scope do
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
context "hstore_has_all_keys" do
|
|
31
|
-
let!(:match) { HstoreRecord.create! :
|
|
32
|
-
let!(:missing_one_key) { HstoreRecord.create! :
|
|
33
|
-
let!(:missing_all_keys) { HstoreRecord.create! :
|
|
31
|
+
let!(:match) { HstoreRecord.create! properties: { "a" => "1", "b" => "2", "c" => "3" } }
|
|
32
|
+
let!(:missing_one_key) { HstoreRecord.create! properties: { "b" => "2", "c" => "3" } }
|
|
33
|
+
let!(:missing_all_keys) { HstoreRecord.create! properties: { "f" => "1", "g" => "2" } }
|
|
34
34
|
|
|
35
35
|
def self.shared_examples
|
|
36
36
|
it { should include(match) }
|
|
@@ -51,9 +51,9 @@ describe Surus::Hstore::Scope do
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
context "hstore_has_any_key" do
|
|
54
|
-
let!(:match_1) { HstoreRecord.create! :
|
|
55
|
-
let!(:match_2) { HstoreRecord.create! :
|
|
56
|
-
let!(:missing_all_keys) { HstoreRecord.create! :
|
|
54
|
+
let!(:match_1) { HstoreRecord.create! properties: { "a" => "1", "c" => "3" } }
|
|
55
|
+
let!(:match_2) { HstoreRecord.create! properties: { "b" => "2", "d" => "4" } }
|
|
56
|
+
let!(:missing_all_keys) { HstoreRecord.create! properties: { "c" => "3", "d" => "4" } }
|
|
57
57
|
|
|
58
58
|
def self.shared_examples
|
|
59
59
|
it { should include(match_1) }
|
|
@@ -58,9 +58,19 @@ describe Surus::Hstore::Serializer do
|
|
|
58
58
|
|
|
59
59
|
round_trip_examples.each do |value, description|
|
|
60
60
|
it "round trips when #{description}" do
|
|
61
|
-
r = HstoreRecord.create! :
|
|
61
|
+
r = HstoreRecord.create! properties: value
|
|
62
62
|
r.reload
|
|
63
63
|
expect(r.properties).to eq(value)
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
|
+
|
|
67
|
+
context 'Stringify' do
|
|
68
|
+
it 'should store the values as UTC for Date' do
|
|
69
|
+
date = ::Time.find_zone!('Melbourne').now.to_datetime
|
|
70
|
+
serializer = Surus::Hstore::Serializer.new
|
|
71
|
+
result = serializer.stringify date
|
|
72
|
+
expect(result).to eq([date.to_s(:db), "Date"])
|
|
73
|
+
expect(result).to_not eq([date.to_s, "Date"])
|
|
74
|
+
end
|
|
75
|
+
end
|
|
66
76
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe Surus::SynchronousCommit::Connection, :
|
|
3
|
+
describe Surus::SynchronousCommit::Connection, disable_transactions: true do
|
|
4
4
|
let(:conn) { ActiveRecord::Base.connection }
|
|
5
5
|
before { conn.execute "SET synchronous_commit TO ON;" }
|
|
6
6
|
after { conn.execute "SET synchronous_commit TO ON;" }
|
data/surus.gemspec
CHANGED
|
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
|
|
|
24
24
|
s.require_paths = ["lib"]
|
|
25
25
|
|
|
26
26
|
# specify any dependencies here; for example:
|
|
27
|
-
s.add_dependency 'activerecord', "
|
|
27
|
+
s.add_dependency 'activerecord', "> 4.0"
|
|
28
28
|
|
|
29
29
|
s.add_development_dependency 'rspec', "~> 3.1.0"
|
|
30
30
|
s.add_development_dependency 'guard', ">= 0.10.0"
|
|
@@ -36,4 +36,5 @@ Gem::Specification.new do |s|
|
|
|
36
36
|
s.add_development_dependency 'factory_girl', '~> 4.2.0'
|
|
37
37
|
s.add_development_dependency 'faker', '~> 1.4.3'
|
|
38
38
|
s.add_development_dependency 'rake'
|
|
39
|
+
s.add_development_dependency 'rubocop'
|
|
39
40
|
end
|
metadata
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: surus
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jack Christensen
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2016-05-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: '4.0'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - "
|
|
24
|
+
- - ">"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '4.0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
@@ -164,6 +164,20 @@ dependencies:
|
|
|
164
164
|
- - ">="
|
|
165
165
|
- !ruby/object:Gem::Version
|
|
166
166
|
version: '0'
|
|
167
|
+
- !ruby/object:Gem::Dependency
|
|
168
|
+
name: rubocop
|
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
|
170
|
+
requirements:
|
|
171
|
+
- - ">="
|
|
172
|
+
- !ruby/object:Gem::Version
|
|
173
|
+
version: '0'
|
|
174
|
+
type: :development
|
|
175
|
+
prerelease: false
|
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
177
|
+
requirements:
|
|
178
|
+
- - ">="
|
|
179
|
+
- !ruby/object:Gem::Version
|
|
180
|
+
version: '0'
|
|
167
181
|
description: "Surus accelerates ActiveRecord with PostgreSQL specific types and\n
|
|
168
182
|
\ functionality. It enables indexed searching of serialized arrays
|
|
169
183
|
and hashes.\n It also can control PostgreSQL synchronous commit
|
|
@@ -177,6 +191,8 @@ extra_rdoc_files: []
|
|
|
177
191
|
files:
|
|
178
192
|
- ".gitignore"
|
|
179
193
|
- ".rspec"
|
|
194
|
+
- ".rubocop.yml"
|
|
195
|
+
- ".rubocop_todo.yml"
|
|
180
196
|
- ".travis.yml"
|
|
181
197
|
- CHANGELOG.md
|
|
182
198
|
- Gemfile
|
|
@@ -193,12 +209,14 @@ files:
|
|
|
193
209
|
- gemfiles/4.0.gemfile
|
|
194
210
|
- gemfiles/4.1.gemfile
|
|
195
211
|
- gemfiles/4.2.gemfile
|
|
212
|
+
- gemfiles/5.0.gemfile
|
|
196
213
|
- lib/generators/surus/hstore/install_generator.rb
|
|
197
214
|
- lib/generators/surus/hstore/templates/install_hstore.rb
|
|
198
215
|
- lib/surus.rb
|
|
199
216
|
- lib/surus/array/scope.rb
|
|
200
217
|
- lib/surus/hstore/scope.rb
|
|
201
218
|
- lib/surus/hstore/serializer.rb
|
|
219
|
+
- lib/surus/json.rb
|
|
202
220
|
- lib/surus/json/array_agg_query.rb
|
|
203
221
|
- lib/surus/json/association_scope_builder.rb
|
|
204
222
|
- lib/surus/json/belongs_to_scope_builder.rb
|
|
@@ -243,19 +261,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
243
261
|
version: '0'
|
|
244
262
|
requirements: []
|
|
245
263
|
rubyforge_project: ''
|
|
246
|
-
rubygems_version: 2.
|
|
264
|
+
rubygems_version: 2.5.1
|
|
247
265
|
signing_key:
|
|
248
266
|
specification_version: 4
|
|
249
267
|
summary: PostgreSQL Acceleration for ActiveRecord
|
|
250
|
-
test_files:
|
|
251
|
-
- spec/array/scope_spec.rb
|
|
252
|
-
- spec/database.yml
|
|
253
|
-
- spec/database.yml.travis
|
|
254
|
-
- spec/database_structure.sql
|
|
255
|
-
- spec/factories.rb
|
|
256
|
-
- spec/hstore/scope_spec.rb
|
|
257
|
-
- spec/hstore/serializer_spec.rb
|
|
258
|
-
- spec/json/json_spec.rb
|
|
259
|
-
- spec/spec_helper.rb
|
|
260
|
-
- spec/synchronous_commit/connection_spec.rb
|
|
261
|
-
- spec/synchronous_commit/model_spec.rb
|
|
268
|
+
test_files: []
|