synchronized_model 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +57 -0
- data/.gitignore +11 -0
- data/.hound-rubocop.yml +323 -0
- data/.hound.yml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +48 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +62 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +9 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/synchronized_model.rb +9 -0
- data/lib/synchronized_model/message.rb +28 -0
- data/lib/synchronized_model/publish_mixin.rb +17 -0
- data/lib/synchronized_model/support.rb +15 -0
- data/lib/synchronized_model/version.rb +5 -0
- data/synchronized_model.gemspec +33 -0
- metadata +148 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d0b98643d66e151e3926adb82abc79bab1588ff3
|
4
|
+
data.tar.gz: ec9bdcff4bfc1b7cb0973af623aa0e73e26d2f9a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aca3e9236dd0d7a8f5a9b0527785aeff842db114731b43e76f300f629cc5508cd908bf6578fd18b7fb7a143a65931a37f63f57f941af295660fd0af94dec849b
|
7
|
+
data.tar.gz: f27149ec51abf4eae3a5fd2deedc0cea463e3b833257c68daf81f6297e4975a8180392223e773e1d1091951e4daa8a1439d464812049d036ec134f90ba61add6
|
@@ -0,0 +1,57 @@
|
|
1
|
+
version: 2
|
2
|
+
|
3
|
+
jobs:
|
4
|
+
build:
|
5
|
+
docker:
|
6
|
+
# specify the version you desire here
|
7
|
+
- image: circleci/ruby:2.4.4
|
8
|
+
|
9
|
+
working_directory: ~/repo
|
10
|
+
|
11
|
+
steps:
|
12
|
+
- checkout
|
13
|
+
|
14
|
+
# Download and cache dependencies
|
15
|
+
- restore_cache:
|
16
|
+
keys:
|
17
|
+
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
18
|
+
# fallback to using the latest cache if no exact match is found
|
19
|
+
- v1-dependencies-
|
20
|
+
|
21
|
+
- run:
|
22
|
+
name: install dependencies
|
23
|
+
command: |
|
24
|
+
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
25
|
+
|
26
|
+
- run:
|
27
|
+
name: Setup Code Climate test-reporter
|
28
|
+
command: |
|
29
|
+
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
30
|
+
chmod +x ./cc-test-reporter
|
31
|
+
- save_cache:
|
32
|
+
paths:
|
33
|
+
- ./vendor/bundle
|
34
|
+
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
35
|
+
|
36
|
+
# run tests!
|
37
|
+
- run:
|
38
|
+
name: run tests
|
39
|
+
command: |
|
40
|
+
./cc-test-reporter before-build
|
41
|
+
mkdir /tmp/test-results
|
42
|
+
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
|
43
|
+
|
44
|
+
bundle exec rspec --format progress \
|
45
|
+
--format RspecJunitFormatter \
|
46
|
+
--out /tmp/test-results/rspec.xml \
|
47
|
+
--format progress \
|
48
|
+
-- \
|
49
|
+
$TEST_FILES
|
50
|
+
./cc-test-reporter after-build --coverage-input-type simplecov --exit-code $?
|
51
|
+
|
52
|
+
# collect reports
|
53
|
+
- store_test_results:
|
54
|
+
path: /tmp/test-results
|
55
|
+
- store_artifacts:
|
56
|
+
path: /tmp/test-results
|
57
|
+
destination: test-results
|
data/.gitignore
ADDED
data/.hound-rubocop.yml
ADDED
@@ -0,0 +1,323 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.2
|
3
|
+
Exclude:
|
4
|
+
- "vendor/**/*"
|
5
|
+
- "db/schema.rb"
|
6
|
+
UseCache: false
|
7
|
+
Layout/DotPosition:
|
8
|
+
Description: Checks the position of the dot in multi-line method calls.
|
9
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
|
10
|
+
Enabled: true
|
11
|
+
EnforcedStyle: trailing
|
12
|
+
SupportedStyles:
|
13
|
+
- leading
|
14
|
+
- trailing
|
15
|
+
Layout/EmptyLineAfterMagicComment:
|
16
|
+
Description: 'Add an empty line after magic comments to separate them from code.'
|
17
|
+
StyleGuide: '#separate-magic-comments-from-code'
|
18
|
+
Enabled: false
|
19
|
+
Lint/AmbiguousBlockAssociation:
|
20
|
+
Exclude:
|
21
|
+
- "spec/**/*"
|
22
|
+
Style/CollectionMethods:
|
23
|
+
Description: Preferred collection methods.
|
24
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
|
25
|
+
Enabled: true
|
26
|
+
PreferredMethods:
|
27
|
+
collect: map
|
28
|
+
collect!: map!
|
29
|
+
find: detect
|
30
|
+
find_all: select
|
31
|
+
reduce: inject
|
32
|
+
Naming/FileName:
|
33
|
+
Description: Use snake_case for source file names.
|
34
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
|
35
|
+
Enabled: false
|
36
|
+
Exclude: []
|
37
|
+
Style/GuardClause:
|
38
|
+
Description: Check for conditionals that can be replaced with guard clauses
|
39
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
|
40
|
+
Enabled: false
|
41
|
+
MinBodyLength: 1
|
42
|
+
Style/IfUnlessModifier:
|
43
|
+
Description: Favor modifier if/unless usage when you have a single-line body.
|
44
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
|
45
|
+
Enabled: false
|
46
|
+
Style/OptionHash:
|
47
|
+
Description: Don't use option hashes when you can use keyword arguments.
|
48
|
+
Enabled: false
|
49
|
+
Style/PercentLiteralDelimiters:
|
50
|
+
Description: Use `%`-literal delimiters consistently
|
51
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
|
52
|
+
Enabled: false
|
53
|
+
PreferredDelimiters:
|
54
|
+
"%": "()"
|
55
|
+
"%i": "()"
|
56
|
+
"%q": "()"
|
57
|
+
"%Q": "()"
|
58
|
+
"%r": "{}"
|
59
|
+
"%s": "()"
|
60
|
+
"%w": "()"
|
61
|
+
"%W": "()"
|
62
|
+
"%x": "()"
|
63
|
+
Naming/PredicateName:
|
64
|
+
Description: Check the names of predicate methods.
|
65
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
|
66
|
+
Enabled: true
|
67
|
+
NamePrefix:
|
68
|
+
- is_
|
69
|
+
- has_
|
70
|
+
- have_
|
71
|
+
NamePrefixBlacklist:
|
72
|
+
- is_
|
73
|
+
Exclude:
|
74
|
+
- spec/**/*
|
75
|
+
Style/RaiseArgs:
|
76
|
+
Description: Checks the arguments passed to raise/fail.
|
77
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
|
78
|
+
Enabled: false
|
79
|
+
EnforcedStyle: exploded
|
80
|
+
SupportedStyles:
|
81
|
+
- compact
|
82
|
+
- exploded
|
83
|
+
Style/SignalException:
|
84
|
+
Description: Checks for proper usage of fail and raise.
|
85
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
|
86
|
+
Enabled: true
|
87
|
+
EnforcedStyle: semantic
|
88
|
+
SupportedStyles:
|
89
|
+
- only_raise
|
90
|
+
- only_fail
|
91
|
+
- semantic
|
92
|
+
Style/SingleLineBlockParams:
|
93
|
+
Description: Enforces the names of some block params.
|
94
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#reduce-blocks
|
95
|
+
Enabled: false
|
96
|
+
Methods:
|
97
|
+
- reduce:
|
98
|
+
- a
|
99
|
+
- e
|
100
|
+
- inject:
|
101
|
+
- a
|
102
|
+
- e
|
103
|
+
Style/SingleLineMethods:
|
104
|
+
Description: Avoid single-line methods.
|
105
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
|
106
|
+
Enabled: false
|
107
|
+
AllowIfMethodIsEmpty: true
|
108
|
+
Style/StringLiterals:
|
109
|
+
Description: Checks if uses of quotes match the configured preference.
|
110
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
|
111
|
+
Enabled: true
|
112
|
+
EnforcedStyle: double_quotes
|
113
|
+
SupportedStyles:
|
114
|
+
- single_quotes
|
115
|
+
- double_quotes
|
116
|
+
Style/StringLiteralsInInterpolation:
|
117
|
+
Description: Checks if uses of quotes inside expressions in interpolated strings
|
118
|
+
match the configured preference.
|
119
|
+
Enabled: true
|
120
|
+
EnforcedStyle: single_quotes
|
121
|
+
SupportedStyles:
|
122
|
+
- single_quotes
|
123
|
+
- double_quotes
|
124
|
+
Style/TrailingCommaInArguments:
|
125
|
+
Description: 'Checks for trailing comma in argument lists.'
|
126
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
|
127
|
+
Enabled: true
|
128
|
+
EnforcedStyleForMultiline: no_comma
|
129
|
+
Style/TrailingCommaInArrayLiteral:
|
130
|
+
Description: 'Checks for trailing comma in array literals.'
|
131
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
|
132
|
+
Enabled: true
|
133
|
+
EnforcedStyleForMultiline: no_comma
|
134
|
+
Style/TrailingCommaInHashLiteral:
|
135
|
+
Description: 'Checks for trailing comma in hash literals.'
|
136
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
|
137
|
+
Enabled: true
|
138
|
+
EnforcedStyleForMultiline: no_comma
|
139
|
+
Metrics/AbcSize:
|
140
|
+
Description: A calculated magnitude based on number of assignments, branches, and
|
141
|
+
conditions.
|
142
|
+
Enabled: false
|
143
|
+
Max: 15
|
144
|
+
Metrics/ClassLength:
|
145
|
+
Description: Avoid classes longer than 100 lines of code.
|
146
|
+
Enabled: false
|
147
|
+
CountComments: false
|
148
|
+
Max: 100
|
149
|
+
Metrics/ModuleLength:
|
150
|
+
CountComments: false
|
151
|
+
Max: 100
|
152
|
+
Description: Avoid modules longer than 100 lines of code.
|
153
|
+
Enabled: false
|
154
|
+
Metrics/CyclomaticComplexity:
|
155
|
+
Description: A complexity metric that is strongly correlated to the number of test
|
156
|
+
cases needed to validate a method.
|
157
|
+
Enabled: false
|
158
|
+
Max: 6
|
159
|
+
Metrics/MethodLength:
|
160
|
+
Description: Avoid methods longer than 10 lines of code.
|
161
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
|
162
|
+
Enabled: false
|
163
|
+
CountComments: false
|
164
|
+
Max: 10
|
165
|
+
Metrics/ParameterLists:
|
166
|
+
Description: Avoid parameter lists longer than three or four parameters.
|
167
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
|
168
|
+
Enabled: false
|
169
|
+
Max: 5
|
170
|
+
CountKeywordArgs: true
|
171
|
+
Metrics/PerceivedComplexity:
|
172
|
+
Description: A complexity metric geared towards measuring complexity for a human
|
173
|
+
reader.
|
174
|
+
Enabled: false
|
175
|
+
Max: 7
|
176
|
+
Lint/AssignmentInCondition:
|
177
|
+
Description: Don't use assignment in conditions.
|
178
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
|
179
|
+
Enabled: false
|
180
|
+
AllowSafeAssignment: true
|
181
|
+
Style/InlineComment:
|
182
|
+
Description: Avoid inline comments.
|
183
|
+
Enabled: false
|
184
|
+
Naming/AccessorMethodName:
|
185
|
+
Description: Check the naming of accessor methods for get_/set_.
|
186
|
+
Enabled: false
|
187
|
+
Style/Alias:
|
188
|
+
Description: Use alias_method instead of alias.
|
189
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
|
190
|
+
Enabled: false
|
191
|
+
Style/Documentation:
|
192
|
+
Description: Document classes and non-namespace modules.
|
193
|
+
Enabled: false
|
194
|
+
Style/DoubleNegation:
|
195
|
+
Description: Checks for uses of double negation (!!).
|
196
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
|
197
|
+
Enabled: false
|
198
|
+
Style/EachWithObject:
|
199
|
+
Description: Prefer `each_with_object` over `inject` or `reduce`.
|
200
|
+
Enabled: false
|
201
|
+
Style/EmptyLiteral:
|
202
|
+
Description: Prefer literals to Array.new/Hash.new/String.new.
|
203
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
|
204
|
+
Enabled: false
|
205
|
+
Style/ModuleFunction:
|
206
|
+
Description: Checks for usage of `extend self` in modules.
|
207
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
|
208
|
+
Enabled: false
|
209
|
+
Style/OneLineConditional:
|
210
|
+
Description: Favor the ternary operator(?:) over if/then/else/end constructs.
|
211
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
|
212
|
+
Enabled: false
|
213
|
+
Style/PerlBackrefs:
|
214
|
+
Description: Avoid Perl-style regex back references.
|
215
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
|
216
|
+
Enabled: false
|
217
|
+
Style/Send:
|
218
|
+
Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send`
|
219
|
+
may overlap with existing methods.
|
220
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send
|
221
|
+
Enabled: false
|
222
|
+
Style/SpecialGlobalVars:
|
223
|
+
Description: Avoid Perl-style global variables.
|
224
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
|
225
|
+
Enabled: false
|
226
|
+
Style/VariableInterpolation:
|
227
|
+
Description: Don't interpolate global, instance and class variables directly in
|
228
|
+
strings.
|
229
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
|
230
|
+
Enabled: false
|
231
|
+
Style/WhenThen:
|
232
|
+
Description: Use when x then ... for one-line cases.
|
233
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
|
234
|
+
Enabled: false
|
235
|
+
Lint/EachWithObjectArgument:
|
236
|
+
Description: Check for immutable argument given to each_with_object.
|
237
|
+
Enabled: true
|
238
|
+
Lint/HandleExceptions:
|
239
|
+
Description: Don't suppress exception.
|
240
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
|
241
|
+
Enabled: false
|
242
|
+
Lint/LiteralAsCondition:
|
243
|
+
Description: Checks of literals used in conditions.
|
244
|
+
Enabled: false
|
245
|
+
Lint/LiteralInInterpolation:
|
246
|
+
Description: Checks for literals used in interpolation.
|
247
|
+
Enabled: false
|
248
|
+
|
249
|
+
##################### Rails ##################################
|
250
|
+
|
251
|
+
Rails/ActionFilter:
|
252
|
+
Description: 'Enforces consistent use of action filter methods.'
|
253
|
+
Enabled: true
|
254
|
+
Rails/Date:
|
255
|
+
Description: >-
|
256
|
+
Checks the correct usage of date aware methods,
|
257
|
+
such as Date.today, Date.current etc.
|
258
|
+
Enabled: true
|
259
|
+
Rails/Delegate:
|
260
|
+
Description: 'Prefer delegate method for delegations.'
|
261
|
+
Enabled: true
|
262
|
+
Rails/Exit:
|
263
|
+
Description: >-
|
264
|
+
Favor `fail`, `break`, `return`, etc. over `exit` in
|
265
|
+
application or library code outside of Rake files to avoid
|
266
|
+
exits during unit testing or running in production.
|
267
|
+
Enabled: true
|
268
|
+
Rails/FindBy:
|
269
|
+
Description: 'Prefer find_by over where.first.'
|
270
|
+
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#find_by'
|
271
|
+
Enabled: true
|
272
|
+
Rails/FindEach:
|
273
|
+
Description: 'Prefer all.find_each over all.find.'
|
274
|
+
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#find-each'
|
275
|
+
Enabled: true
|
276
|
+
Rails/HasAndBelongsToMany:
|
277
|
+
Description: 'Prefer has_many :through to has_and_belongs_to_many.'
|
278
|
+
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#has-many-through'
|
279
|
+
Enabled: true
|
280
|
+
Rails/HttpPositionalArguments:
|
281
|
+
Description: 'Rails 5 only, disabled to keep Hound quiet'
|
282
|
+
Enabled: false
|
283
|
+
Rails/NotNullColumn:
|
284
|
+
Description: 'Do not add a NOT NULL column without a default value'
|
285
|
+
Enabled: false
|
286
|
+
Rails/Output:
|
287
|
+
Description: 'Checks for calls to puts, print, etc.'
|
288
|
+
Enabled: true
|
289
|
+
Rails/OutputSafety:
|
290
|
+
Description: 'The use of `html_safe` or `raw` may be a security risk.'
|
291
|
+
Enabled: true
|
292
|
+
Rails/PluralizationGrammar:
|
293
|
+
Description: 'Checks for incorrect grammar when using methods like `3.day.ago`.'
|
294
|
+
Enabled: true
|
295
|
+
Rails/ReadWriteAttribute:
|
296
|
+
Description: >-
|
297
|
+
Checks for read_attribute(:attr) and
|
298
|
+
write_attribute(:attr, val).
|
299
|
+
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#read-attribute'
|
300
|
+
Enabled: true
|
301
|
+
Rails/RequestReferer:
|
302
|
+
Description: 'Use consistent syntax for request.referer.'
|
303
|
+
Enabled: true
|
304
|
+
Rails/SafeNavigation:
|
305
|
+
Description: "Use Ruby's safe navigation operator (`&.`) instead of `try!`"
|
306
|
+
Enabled: true
|
307
|
+
Rails/ScopeArgs:
|
308
|
+
Description: 'Checks the arguments of ActiveRecord scopes.'
|
309
|
+
Enabled: true
|
310
|
+
Rails/TimeZone:
|
311
|
+
Description: 'Checks the correct usage of time zone aware methods.'
|
312
|
+
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#time'
|
313
|
+
Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
|
314
|
+
Enabled: true
|
315
|
+
Rails/UniqBeforePluck:
|
316
|
+
Description: 'Prefer the use of uniq or distinct before pluck.'
|
317
|
+
Enabled: true
|
318
|
+
Rails/Validation:
|
319
|
+
Description: 'Use validates :attribute, hash of validations.'
|
320
|
+
Enabled: true
|
321
|
+
Security/JSONLoad:
|
322
|
+
Description : 'Prefer usage of JSON.parse'
|
323
|
+
Enabled: true
|
data/.hound.yml
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
inherit_from: .hound-rubocop.yml
|
2
|
+
|
3
|
+
Rails:
|
4
|
+
Enabled: true
|
5
|
+
AllCops:
|
6
|
+
TargetRubyVersion: 2.4
|
7
|
+
Exclude:
|
8
|
+
- "vendor/**/*"
|
9
|
+
- "db/schema.rb"
|
10
|
+
- "node_modules/**/*"
|
11
|
+
- bin/*
|
12
|
+
Layout/DotPosition:
|
13
|
+
Description: Checks the position of the dot in multi-line method calls.
|
14
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
|
15
|
+
Enabled: true
|
16
|
+
EnforcedStyle: leading
|
17
|
+
SupportedStyles:
|
18
|
+
- leading
|
19
|
+
- trailing
|
20
|
+
Metrics/BlockLength:
|
21
|
+
Enabled: false
|
22
|
+
Style/AndOr:
|
23
|
+
Description: Use &&/|| instead of and/or.
|
24
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-and-or-or
|
25
|
+
Enabled: true
|
26
|
+
EnforcedStyle: conditionals
|
27
|
+
SupportedStyles:
|
28
|
+
- always
|
29
|
+
- conditionals
|
30
|
+
Style/ClassAndModuleChildren:
|
31
|
+
Enabled: true
|
32
|
+
EnforcedStyle: nested
|
33
|
+
SupportedStyles:
|
34
|
+
- compact
|
35
|
+
- nested
|
36
|
+
Style/MultilineIfModifier:
|
37
|
+
Enabled: false
|
38
|
+
Style/StringLiterals:
|
39
|
+
Description: Checks if uses of quotes match the configured preference.
|
40
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
|
41
|
+
Enabled: true
|
42
|
+
EnforcedStyle: single_quotes
|
43
|
+
SupportedStyles:
|
44
|
+
- single_quotes
|
45
|
+
- double_quotes
|
46
|
+
Rails/DynamicFindBy:
|
47
|
+
Exclude:
|
48
|
+
- "spec/features/**/*"
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at cracell@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
synchronized_model (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.0)
|
10
|
+
diff-lcs (1.3)
|
11
|
+
docile (1.3.1)
|
12
|
+
json (2.1.0)
|
13
|
+
parallel (1.12.1)
|
14
|
+
parser (2.5.1.0)
|
15
|
+
ast (~> 2.4.0)
|
16
|
+
powerpack (0.1.2)
|
17
|
+
rainbow (3.0.0)
|
18
|
+
rake (10.5.0)
|
19
|
+
rspec (3.7.0)
|
20
|
+
rspec-core (~> 3.7.0)
|
21
|
+
rspec-expectations (~> 3.7.0)
|
22
|
+
rspec-mocks (~> 3.7.0)
|
23
|
+
rspec-core (3.7.1)
|
24
|
+
rspec-support (~> 3.7.0)
|
25
|
+
rspec-expectations (3.7.0)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.7.0)
|
28
|
+
rspec-mocks (3.7.0)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.7.0)
|
31
|
+
rspec-support (3.7.1)
|
32
|
+
rspec_junit_formatter (0.4.1)
|
33
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
34
|
+
rubocop (0.54.0)
|
35
|
+
parallel (~> 1.10)
|
36
|
+
parser (>= 2.5)
|
37
|
+
powerpack (~> 0.1)
|
38
|
+
rainbow (>= 2.2.2, < 4.0)
|
39
|
+
ruby-progressbar (~> 1.7)
|
40
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
41
|
+
ruby-progressbar (1.9.0)
|
42
|
+
simplecov (0.16.1)
|
43
|
+
docile (~> 1.1)
|
44
|
+
json (>= 1.8, < 3)
|
45
|
+
simplecov-html (~> 0.10.0)
|
46
|
+
simplecov-html (0.10.2)
|
47
|
+
unicode-display_width (1.4.0)
|
48
|
+
|
49
|
+
PLATFORMS
|
50
|
+
ruby
|
51
|
+
|
52
|
+
DEPENDENCIES
|
53
|
+
bundler (~> 1.16)
|
54
|
+
rake (~> 10.0)
|
55
|
+
rspec (~> 3.0)
|
56
|
+
rspec_junit_formatter
|
57
|
+
rubocop (~> 0.54.0)
|
58
|
+
simplecov
|
59
|
+
synchronized_model!
|
60
|
+
|
61
|
+
BUNDLED WITH
|
62
|
+
1.16.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Eric Cranston
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# SynchronizedModel
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/synchronized_model`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'synchronized_model'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install synchronized_model
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/synchronized_model. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the SynchronizedModel project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/synchronized_model/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#!/usr/bin/env ruby
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'synchronized_model'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require 'pry'
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'synchronized_model/version'
|
4
|
+
|
5
|
+
module SynchronizedModel
|
6
|
+
autoload :Message, 'synchronized_model/message'
|
7
|
+
autoload :PublishMixin, 'synchronized_model/publish_mixin'
|
8
|
+
autoload :Support, 'synchronized_model/support'
|
9
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'securerandom'
|
4
|
+
|
5
|
+
module SynchronizedModel
|
6
|
+
class Message
|
7
|
+
include Support
|
8
|
+
attr_reader :model
|
9
|
+
|
10
|
+
def initialize(model)
|
11
|
+
@model = model
|
12
|
+
end
|
13
|
+
|
14
|
+
def call
|
15
|
+
message
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def message
|
21
|
+
{
|
22
|
+
id: SecureRandom.uuid,
|
23
|
+
payload: model.to_message_payload,
|
24
|
+
resource: underscore(model.class.name)
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SynchronizedModel
|
4
|
+
module PublishMixin
|
5
|
+
def to_message_payload
|
6
|
+
attributes.merge(additional_message_attributes)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
# This method can be overriden in the model to attach additional
|
12
|
+
# attributes to the message
|
13
|
+
def additional_message_attributes
|
14
|
+
{}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module SynchronizedModel
|
3
|
+
module Support
|
4
|
+
# Taken from ActiveSupport:Inflector.underscore
|
5
|
+
def underscore(camel_cased_word)
|
6
|
+
return camel_cased_word unless /[A-Z-]|::/.match?(camel_cased_word)
|
7
|
+
word = camel_cased_word.to_s.gsub('::', '/')
|
8
|
+
word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
|
9
|
+
word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
|
10
|
+
word.tr!('-', '_')
|
11
|
+
word.downcase!
|
12
|
+
word
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'synchronized_model/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'synchronized_model'
|
9
|
+
spec.version = SynchronizedModel::VERSION
|
10
|
+
spec.authors = ['Eric Cranston']
|
11
|
+
spec.email = ['ecranston@westernmilling.com']
|
12
|
+
|
13
|
+
spec.summary = 'Helper library for synchronizing model data using ' \
|
14
|
+
'messages'
|
15
|
+
spec.description = 'Helper library for synchronizing model data using ' \
|
16
|
+
'messages'
|
17
|
+
spec.homepage = 'https://github.com/westernmilling/synchronized_model'
|
18
|
+
spec.license = 'MIT'
|
19
|
+
|
20
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
21
|
+
f.match(%r{^(test|spec|features)/})
|
22
|
+
end
|
23
|
+
spec.bindir = 'exe'
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ['lib']
|
26
|
+
|
27
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
28
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
29
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
30
|
+
spec.add_development_dependency 'rspec_junit_formatter'
|
31
|
+
spec.add_development_dependency 'rubocop', '~> 0.54.0'
|
32
|
+
spec.add_development_dependency 'simplecov'
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: synchronized_model
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eric Cranston
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-06-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec_junit_formatter
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.54.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.54.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Helper library for synchronizing model data using messages
|
98
|
+
email:
|
99
|
+
- ecranston@westernmilling.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".circleci/config.yml"
|
105
|
+
- ".gitignore"
|
106
|
+
- ".hound-rubocop.yml"
|
107
|
+
- ".hound.yml"
|
108
|
+
- ".rspec"
|
109
|
+
- ".rubocop.yml"
|
110
|
+
- CODE_OF_CONDUCT.md
|
111
|
+
- Gemfile
|
112
|
+
- Gemfile.lock
|
113
|
+
- LICENSE.txt
|
114
|
+
- README.md
|
115
|
+
- Rakefile
|
116
|
+
- bin/console
|
117
|
+
- bin/setup
|
118
|
+
- lib/synchronized_model.rb
|
119
|
+
- lib/synchronized_model/message.rb
|
120
|
+
- lib/synchronized_model/publish_mixin.rb
|
121
|
+
- lib/synchronized_model/support.rb
|
122
|
+
- lib/synchronized_model/version.rb
|
123
|
+
- synchronized_model.gemspec
|
124
|
+
homepage: https://github.com/westernmilling/synchronized_model
|
125
|
+
licenses:
|
126
|
+
- MIT
|
127
|
+
metadata: {}
|
128
|
+
post_install_message:
|
129
|
+
rdoc_options: []
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
requirements: []
|
143
|
+
rubyforge_project:
|
144
|
+
rubygems_version: 2.6.14
|
145
|
+
signing_key:
|
146
|
+
specification_version: 4
|
147
|
+
summary: Helper library for synchronizing model data using messages
|
148
|
+
test_files: []
|