founders_toolkit 0.2.1 → 0.7.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
  SHA256:
3
- metadata.gz: '0045843eca13f85773f4d0fca27f2b3cb1bbe459a5076f3fdf3cc63cb5c36527'
4
- data.tar.gz: 71652d858715cd22ac97a797a2cbebcf2d2166834260cab568153986a79082e5
3
+ metadata.gz: ae135b54293ce448139bed2319a121ed257658a4990833e00c4fbd305ec8becb
4
+ data.tar.gz: e6844d386364f6d415bf1ca249e31dfef25f6e8daeeb8670e5d551f2bfcb3ee3
5
5
  SHA512:
6
- metadata.gz: ce28ceea9df56fb1340eaba37bca06ac8b2dbb604f14832f65df2b8b49c7e68634ffa0776e24e3d38055233f0224f16700d3e81bdd43764c0fbc03e747181e2d
7
- data.tar.gz: 137cdb98140961052d81f0ab4a1182f360ee2ca6bda200819b472330f8c017c7032bbf3f0b4e7e26c0cb31ffa7d6adef2750b18ccfb71d1762ce6d6116b7a6e6
6
+ metadata.gz: faddfdd5c8bf3590a73ac3bf042db3cbfb020534e506dc7c4314ba812f08f24c367ee63a6c096d655c5573cb9699b7427dae6db808a82c69bc275cbbc92afc3d
7
+ data.tar.gz: bd330a825d36a26da406cec52de4bbdaaaa0d041bfcd7b97056af26ca15b4e4614893253a7fb9cae9c9a988e1171c0b4873242a7bbec89e583dfed5e7b44f6ee
data/.rubocop.yml CHANGED
@@ -1,392 +1,12 @@
1
+ inherit_from:
2
+ - https://raw.githubusercontent.com/trobrock/style-guides/master/ruby-style.yml
3
+
1
4
  AllCops:
2
- Exclude:
3
- - "vendor/**/*"
4
- - "db/**/*"
5
- UseCache: false
6
- SuggestExtensions: false
5
+ NewCops: enable
6
+ TargetRubyVersion: 3.0.1
7
+ Style/ClassAndModuleChildren:
8
+ EnforcedStyle: compact
7
9
  Metrics/BlockLength:
8
- IgnoredMethods: [
9
- 'class_methods',
10
- 'context',
11
- 'define',
12
- 'describe',
13
- 'it',
14
- 'let',
15
- 'namespace',
16
- 'task'
17
- ]
18
- Style/CollectionMethods:
19
- Description: Preferred collection methods.
20
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
21
- Enabled: true
22
- PreferredMethods:
23
- collect: map
24
- collect!: map!
25
- find_all: select
26
- reduce:
27
- inject: reduce
28
- find:
29
- detect: find
30
- Style/GuardClause:
31
- Description: Check for conditionals that can be replaced with guard clauses
32
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
33
- Enabled: true
34
- MinBodyLength: 1
35
- Style/IfUnlessModifier:
36
- Description: Favor modifier if/unless usage when you have a single-line body.
37
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
38
- Enabled: true
39
- Style/OptionHash:
40
- Description: Don't use option hashes when you can use keyword arguments.
41
- Enabled: true
42
- Style/PercentLiteralDelimiters:
43
- Description: Use `%`-literal delimiters consistently
44
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
45
- Enabled: true
46
- PreferredDelimiters:
47
- "%": "()"
48
- "%i": "()"
49
- "%q": "()"
50
- "%Q": "()"
51
- "%r": "{}"
52
- "%s": "()"
53
- "%w": "()"
54
- "%W": "()"
55
- "%x": "()"
56
- Style/RaiseArgs:
57
- Description: Checks the arguments passed to raise/fail.
58
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
59
- Enabled: true
60
- EnforcedStyle: exploded
61
- SupportedStyles:
62
- - compact
63
- - exploded
64
- Style/SignalException:
65
- Description: Checks for proper usage of fail and raise.
66
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
67
- Enabled: true
68
- EnforcedStyle: semantic
69
- SupportedStyles:
70
- - only_raise
71
- - only_fail
72
- - semantic
73
- Style/SingleLineBlockParams:
74
- Description: Enforces the names of some block params.
75
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#reduce-blocks
76
- Enabled: true
77
- Methods:
78
- - reduce:
79
- - a
80
- - e
81
- - inject:
82
- - a
83
- - e
84
- Style/SingleLineMethods:
85
- Description: Avoid single-line methods.
86
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
87
- Enabled: true
88
- AllowIfMethodIsEmpty: true
89
- Style/StringLiterals:
90
- Description: Checks if uses of quotes match the configured preference.
91
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
92
- Enabled: true
93
- Style/StringLiteralsInInterpolation:
94
- Description: Checks if uses of quotes inside expressions in interpolated strings
95
- match the configured preference.
96
- Enabled: true
97
- EnforcedStyle: single_quotes
98
- SupportedStyles:
99
- - single_quotes
100
- - double_quotes
101
- Style/TrailingCommaInArguments:
102
- EnforcedStyleForMultiline: no_comma
103
- Style/TrailingCommaInArrayLiteral:
104
- EnforcedStyleForMultiline: no_comma
105
- Metrics/AbcSize:
106
- Description: A calculated magnitude based on number of assignments, branches, and
107
- conditions.
108
- Enabled: false
109
- Max: 15
110
- Metrics/ClassLength:
111
- Description: Avoid classes longer than 100 lines of code.
112
- Enabled: false
113
- CountComments: false
114
- Max: 100
115
- Metrics/ModuleLength:
116
- CountComments: false
117
- Max: 100
118
- Description: Avoid modules longer than 100 lines of code.
119
- Enabled: false
120
- Metrics/CyclomaticComplexity:
121
- Description: A complexity metric that is strongly correlated to the number of test
122
- cases needed to validate a method.
123
- Enabled: true
124
- Max: 6
125
- Metrics/MethodLength:
126
- Description: Avoid methods longer than 10 lines of code.
127
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
128
- Enabled: false
129
- CountComments: false
130
- Max: 10
131
- Metrics/ParameterLists:
132
- Description: Avoid parameter lists longer than three or four parameters.
133
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
134
- Enabled: false
135
- Max: 5
136
- CountKeywordArgs: true
137
- Metrics/PerceivedComplexity:
138
- Description: A complexity metric geared towards measuring complexity for a human
139
- reader.
140
- Enabled: false
141
- Max: 7
142
- Layout/LineLength:
143
- Max: 100
144
- # To make it possible to copy or click on URIs in the code, we allow lines
145
- # contaning a URI to be longer than Max.
146
- AllowURI: true
147
- URISchemes:
148
- - http
149
- - https
150
- Lint/AssignmentInCondition:
151
- Description: Don't use assignment in conditions.
152
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
153
- Enabled: true
154
- AllowSafeAssignment: true
155
- Style/InlineComment:
156
- Description: Avoid inline comments.
157
10
  Enabled: false
158
- Style/Alias:
159
- Description: Use alias_method instead of alias.
160
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
161
- Enabled: true
162
- Style/Documentation:
163
- Description: Document classes and non-namespace modules.
11
+ Lint/MissingSuper:
164
12
  Enabled: false
165
- Style/DoubleNegation:
166
- Description: Checks for uses of double negation (!!).
167
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
168
- Enabled: true
169
- Style/EachWithObject:
170
- Description: Prefer `each_with_object` over `inject` or `reduce`.
171
- Enabled: false
172
- Style/EmptyLiteral:
173
- Description: Prefer literals to Array.new/Hash.new/String.new.
174
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
175
- Enabled: true
176
- Style/ModuleFunction:
177
- Description: Checks for usage of `extend self` in modules.
178
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
179
- Enabled: true
180
- Style/OneLineConditional:
181
- Description: Favor the ternary operator(?:) over if/then/else/end constructs.
182
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
183
- Enabled: true
184
- Style/PerlBackrefs:
185
- Description: Avoid Perl-style regex back references.
186
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
187
- Enabled: true
188
- Style/Send:
189
- Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send`
190
- may overlap with existing methods.
191
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send
192
- Enabled: true
193
- Style/SpecialGlobalVars:
194
- Description: Avoid Perl-style global variables.
195
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
196
- Enabled: true
197
- Style/VariableInterpolation:
198
- Description: Don't interpolate global, instance and class variables directly in
199
- strings.
200
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
201
- Enabled: false
202
- Style/WhenThen:
203
- Description: Use when x then ... for one-line cases.
204
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
205
- Enabled: true
206
- Lint/EachWithObjectArgument:
207
- Description: Check for immutable argument given to each_with_object.
208
- Enabled: true
209
- Lint/SuppressedException:
210
- Description: Don't suppress exception.
211
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
212
- Enabled: false
213
- Lint/LiteralAsCondition:
214
- Description: Checks of literals used in conditions.
215
- Enabled: true
216
- Lint/LiteralInInterpolation:
217
- Description: Checks for literals used in interpolation.
218
- Enabled: true
219
- Layout/DotPosition:
220
- Description: Checks the position of the dot in multi-line method calls.
221
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
222
- Enabled: true
223
- EnforcedStyle: leading
224
- SupportedStyles:
225
- - leading
226
- - trailing
227
- Layout/MultilineOperationIndentation:
228
- EnforcedStyle: indented
229
- SupportedStyles:
230
- - aligned
231
- - indented
232
- Layout/MultilineMethodCallIndentation:
233
- EnforcedStyle: indented
234
- SupportedStyles:
235
- - aligned
236
- - indented
237
- Layout/SpaceInsidePercentLiteralDelimiters:
238
- Description: 'No unnecessary spaces inside delimiters of %i/%w/%x literals.'
239
- Enabled: false
240
- Layout/SpaceInLambdaLiteral:
241
- Description: 'Checks for spaces in lambda literals.'
242
- Enabled: false
243
- Naming/FileName:
244
- Description: Use snake_case for source file names.
245
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
246
- Enabled: true
247
- Exclude: []
248
- Naming/PredicateName:
249
- Description: Check the names of predicate methods.
250
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
251
- Enabled: true
252
- NamePrefix:
253
- - is_
254
- - has_
255
- - have_
256
- ForbiddenPrefixes:
257
- - is_
258
- Exclude:
259
- - spec/**/*
260
- Naming/AccessorMethodName:
261
- Description: Check the naming of accessor methods for get_/set_.
262
- Enabled: false
263
- Layout/EmptyLinesAroundAttributeAccessor:
264
- Description: "Keep blank lines around attribute accessors."
265
- Enabled: true
266
- AllowAliasSyntax: true
267
- AllowedMethods:
268
- - alias_method
269
- - public
270
- - protected
271
- - private
272
- Layout/SpaceAroundMethodCallOperator:
273
- Description: 'Checks method call operators to not have spaces around them.'
274
- Enabled: true
275
- Lint/DeprecatedOpenSSLConstant:
276
- Description: "Don't use algorithm constants for `OpenSSL::Cipher` and `OpenSSL::Digest`."
277
- Enabled: true
278
- Lint/MixedRegexpCaptureTypes:
279
- Description: 'Do not mix named captures and numbered captures in a Regexp literal.'
280
- Enabled: true
281
- Lint/RaiseException:
282
- Description: Checks for `raise` or `fail` statements which are raising `Exception` class.
283
- Enabled: true
284
- Safe: false
285
- AllowedImplicitNamespaces:
286
- - 'Gem'
287
- Lint/StructNewOverride:
288
- Description: 'Disallow overriding the `Struct` built-in methods via `Struct.new`.'
289
- Enabled: true
290
- Style/ExponentialNotation:
291
- Description: 'When using exponential notation, favor a mantissa between 1 (inclusive) and 10 (exclusive).'
292
- Enabled: true
293
- EnforcedStyle: scientific
294
- SupportedStyles:
295
- - scientific
296
- - engineering
297
- - integral
298
- Style/HashEachMethods:
299
- Description: 'Use Hash#each_key and Hash#each_value.'
300
- Enabled: true
301
- Safe: false
302
- Style/HashTransformKeys:
303
- Description: 'Prefer `transform_keys` over `each_with_object` and `map`.'
304
- Enabled: true
305
- Safe: false
306
- Style/HashTransformValues:
307
- Description: 'Prefer `transform_values` over `each_with_object` and `map`.'
308
- Enabled: true
309
- Safe: false
310
- Style/RedundantFetchBlock:
311
- Description: >-
312
- Use `fetch(key, value)` instead of `fetch(key) { value }`
313
- when value has Numeric, Rational, Complex, Symbol or String type, `false`, `true`, `nil` or is a constant.
314
- Enabled: true
315
- Safe: false
316
- SafeForConstants: false
317
- Style/RedundantRegexpCharacterClass:
318
- Description: 'Checks for unnecessary single-element Regexp character classes.'
319
- Enabled: true
320
- Style/RedundantRegexpEscape:
321
- Description: 'Checks for redundant escapes in Regexps.'
322
- Enabled: true
323
- Style/SlicingWithRange:
324
- Description: 'Checks array slicing is done with endless ranges when suitable.'
325
- Enabled: true
326
- Safe: false
327
- Style/AccessorGrouping:
328
- Enabled: true
329
- Style/BisectedAttrAccessor:
330
- Enabled: true
331
- Style/RedundantAssignment:
332
- Enabled: true
333
- Style/FrozenStringLiteralComment:
334
- Enabled: true
335
- Style/ClassAndModuleChildren:
336
- EnforcedStyle: compact
337
- Lint/DuplicateElsifCondition:
338
- Enabled: true
339
- Style/ArrayCoercion:
340
- Enabled: true
341
- Style/CaseLikeIf:
342
- Enabled: true
343
- Style/HashAsLastArrayItem:
344
- Enabled: true
345
- Style/HashLikeCase:
346
- Enabled: true
347
- Style/RedundantFileExtensionInRequire:
348
- Enabled: true
349
- Lint/DuplicateRegexpCharacterClassElement:
350
- Enabled: true
351
- Lint/EmptyBlock:
352
- Enabled: true
353
- Lint/ToEnumArguments:
354
- Enabled: true
355
- Lint/UnmodifiedReduceAccumulator:
356
- Enabled: true
357
- Style/ArgumentsForwarding:
358
- Enabled: true
359
- Style/DocumentDynamicEvalDefinition:
360
- Enabled: true
361
- Style/SwapValues:
362
- Enabled: true
363
- Layout/SpaceBeforeBrackets:
364
- Enabled: true
365
- Lint/AmbiguousAssignment:
366
- Enabled: true
367
- Lint/DuplicateBranch:
368
- Enabled: true
369
- Lint/EmptyClass:
370
- Enabled: true
371
- Lint/NoReturnInBeginEndBlocks:
372
- Enabled: true
373
- Lint/UnexpectedBlockArity:
374
- Enabled: true
375
- Style/CollectionCompact:
376
- Enabled: true
377
- Style/HashExcept:
378
- Enabled: true
379
- Style/NegatedIfElseCondition:
380
- Enabled: true
381
- Style/NilLambda:
382
- Enabled: true
383
- Style/RedundantArgument:
384
- Enabled: true
385
- Lint/DeprecatedConstants:
386
- Enabled: true
387
- Lint/LambdaWithoutLiteralBlock:
388
- Enabled: true
389
- Lint/RedundantDirGlobSort:
390
- Enabled: true
391
- Style/EndlessMethod:
392
- Enabled: true
data/CHANGELOG.md CHANGED
@@ -6,6 +6,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.6.0] - 2021-03-29
10
+ - Fix for rate limiter
11
+
12
+ ## [0.5.0] - 2021-03-29
13
+
14
+ - Added install rake task.
15
+ - Remove email as a protected attribute by default.
16
+
17
+ ## [0.4.0] - 2021-03-29
18
+ - Add tracking to limitable
19
+
20
+ ## [0.3.0] - 2021-03-29
21
+ - Added TrackedJob for simple statsd active job monitoring
22
+
9
23
  ## [0.2.1] - 2021-03-25
10
24
  ### Fixed
11
25
  - Fixed the protected attributes validator when updating the password.
data/Gemfile.lock CHANGED
@@ -1,16 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- founders_toolkit (0.2.0)
4
+ founders_toolkit (0.7.0)
5
5
  activemodel (~> 6.1)
6
6
  activesupport (~> 6.1)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activemodel (6.1.3)
12
- activesupport (= 6.1.3)
13
- activesupport (6.1.3)
11
+ activemodel (6.1.3.2)
12
+ activesupport (= 6.1.3.2)
13
+ activesupport (6.1.3.2)
14
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
15
15
  i18n (>= 1.6, < 2)
16
16
  minitest (>= 5.1)
@@ -19,7 +19,7 @@ GEM
19
19
  ast (2.4.2)
20
20
  concurrent-ruby (1.1.8)
21
21
  diff-lcs (1.4.4)
22
- i18n (1.8.9)
22
+ i18n (1.8.10)
23
23
  concurrent-ruby (~> 1.0)
24
24
  minitest (5.14.4)
25
25
  parallel (1.20.1)
@@ -61,6 +61,7 @@ GEM
61
61
 
62
62
  PLATFORMS
63
63
  x86_64-darwin-19
64
+ x86_64-darwin-20
64
65
 
65
66
  DEPENDENCIES
66
67
  founders_toolkit!
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = 'Founders Toolkit for Rails'
13
13
  spec.homepage = 'https://github.com/trobrock/founders-toolkit'
14
14
  spec.license = 'MIT'
15
- spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 3.0.1')
16
16
 
17
17
  spec.metadata['homepage_uri'] = spec.homepage
18
18
  spec.metadata['source_code_uri'] = 'https://github.com/trobrock/founders-toolkit.git'
@@ -6,4 +6,8 @@ module FoundersToolkit::Auth::Securable::CurrentAttributes
6
6
  included do
7
7
  attribute :user
8
8
  end
9
+
10
+ def user
11
+ super || ::Guest.new
12
+ end
9
13
  end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class FoundersToolkit::Auth::Securable::Guest
4
+ def guest? = true
5
+ end
@@ -7,7 +7,6 @@ module FoundersToolkit::Auth::Securable::Model
7
7
  include FoundersToolkit::Auth::Emailable::Model
8
8
  extend FoundersToolkit::Auth::Securable::Validations::ProtectedValidator::HelperMethods
9
9
 
10
- validates_protected_attributes :email
11
10
  validates_protected_attributes :password, secure: true
12
11
 
13
12
  has_secure_password
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FoundersToolkit::Jobs
4
+ module TrackedJob
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ include FoundersToolkit::Monitoring::Statsdable
9
+
10
+ around_perform :update_stats
11
+ end
12
+
13
+ private
14
+
15
+ def update_stats(&block)
16
+ statsd.increment("active_job.#{self.class.queue_name}.#{self.class.name}.started")
17
+ statsd.time("active_job.#{self.class.queue_name}.#{self.class.name}", &block)
18
+ statsd.increment("active_job.#{self.class.queue_name}.#{self.class.name}.finished")
19
+ update_queue_size_stats
20
+ end
21
+
22
+ def update_queue_size_stats
23
+ Resque.queues.each do |name|
24
+ statsd.gauge("active_job.queue_size.#{name}", Resque.size(name))
25
+ end
26
+ end
27
+ end
28
+ end
@@ -14,8 +14,6 @@ rescue LoadError
14
14
  raise
15
15
  end
16
16
 
17
- require_relative '../monitoring/statsdable'
18
-
19
17
  module FoundersToolkit::Util
20
18
  module RateLimitable
21
19
  extend ActiveSupport::Concern
@@ -31,13 +29,16 @@ module FoundersToolkit::Util
31
29
  limiter = instance_variable_get("@#{limiter_name}".to_sym)
32
30
  limiter ||= instance_variable_set("@#{limiter_name}".to_sym, Ratelimit.new(name))
33
31
 
34
- limiter.exec_within_threshold(__send__(key), threshold: threshold, interval: interval) do
35
- result = statsd.time(['retryable', limiter_name].join('.')) do
36
- Retryable.retryable(tries: 3, on: retry_from) { block.call }
37
- end
38
- limiter.add __send__(key)
39
- result
32
+ while limiter.exceeded?(__send__(key), threshold: threshold, interval: interval)
33
+ statsd.increment ['thottled', limiter_name].join('.')
34
+ sleep 5
35
+ end
36
+
37
+ result = statsd.time(['retryable', limiter_name].join('.')) do
38
+ Retryable.retryable(tries: 3, on: retry_from) { block.call }
40
39
  end
40
+ limiter.add __send__(key)
41
+ result
41
42
  end
42
43
  end
43
44
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FoundersToolkit
4
- VERSION = '0.2.1'
4
+ VERSION = '0.7.0'
5
5
  end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ source_paths << File.expand_path('templates', __dir__)
4
+
5
+ say 'Copy the files'
6
+ %w(
7
+ .rubocop.yml
8
+ Procfile
9
+ app/controllers/sessions_controller.rb
10
+ app/controllers/users_controller.rb
11
+ app/models/current.rb
12
+ app/models/guest.rb
13
+ app/models/user.rb
14
+ app/views/sessions/new.html.erb
15
+ ).each do |file|
16
+ copy_file(file)
17
+ end
18
+
19
+ say 'Adding routes'
20
+ route 'resource :session'
21
+ route 'resource :user'
22
+
23
+ say 'Brew the things'
24
+ copy_file 'Brewfile'
25
+ run 'brew bundle'
26
+
27
+ say 'Add gems'
28
+ gem 'hotwire-rails'
29
+ gem 'tailwindcss-rails'
30
+ gem 'resque'
31
+ gem 'resque-scheduler'
32
+ gem_group :development do
33
+ gem 'foreman'
34
+ gem 'rubocop'
35
+ end
36
+ run 'bin/bundle install'
37
+
38
+ say 'Install Tailwind CSS'
39
+ rails_command 'tailwindcss:install'
40
+
41
+ say 'Install Hotwire'
42
+ rails_command 'hotwire:install'
43
+
44
+ say 'Add Standard'
45
+ run 'yarn add --dev standardjs @babel/eslint-parser'
46
+
47
+ package_json = JSON.parse(File.read('package.json'))
48
+ package_json['standard'] = {
49
+ globals: %w(
50
+ fetch
51
+ FormData
52
+ CustomEvent
53
+ IntersectionObserver
54
+ ),
55
+ parser: '@babel/eslint-parser'
56
+ }
57
+ package_json['babel'] = {
58
+ presets: [
59
+ './node_modules/@rails/webpacker/package/babel/preset.js'
60
+ ]
61
+ }
62
+ File.open('package.json', 'w') do |file|
63
+ file.write(JSON.pretty_generate(package_json))
64
+ end
@@ -0,0 +1,2 @@
1
+ inherit_from:
2
+ - https://raw.githubusercontent.com/trobrock/style-guides/master/ruby-style.yml
@@ -0,0 +1,6 @@
1
+ brew "rbenv"
2
+ brew "openssl"
3
+ brew "mysql", start_service: true
4
+ brew "redis", start_service: true
5
+ brew "yarn"
6
+ brew "mailhog"
@@ -0,0 +1,5 @@
1
+ web: bundle exec rails s
2
+ queue: QUEUE=* bundle exec rake resque:work
3
+ scheduler: bundle exec rake resque:scheduler
4
+ webpack: ./bin/webpack-dev-server
5
+ mail: mailhog
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SessionsController < FoundersToolkit::Auth::Securable::SessionsController
4
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ class UsersController < ApplicationController
4
+ skip_before_action :redirect_if_set, only: %i(new create)
5
+ skip_before_action :authenticate, only: %i(new create)
6
+
7
+ def new
8
+ @user = User.new
9
+ end
10
+
11
+ def create
12
+ @user = User.new(user_params)
13
+
14
+ if @user.save
15
+ sign_in(@user)
16
+ redirect_to :root
17
+ else
18
+ render :new, status: :unprocessable_entity
19
+ end
20
+ end
21
+
22
+ def edit; end
23
+
24
+ def update
25
+ if Current.user.update(user_params)
26
+ redirect_to [:edit, Current.user], notice: 'Successfully updated your profile.'
27
+ else
28
+ render :edit, status: :unprocessable_entity
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def user_params
35
+ params.require(:user).permit(:email, :password, :password_confirmation, :current_password)
36
+ end
37
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Current < ActiveSupport::CurrentAttributes
4
+ include FoundersToolkit::Auth::Securable::CurrentAttributes
5
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Guest < FoundersToolkit::Auth::Securable::Guest
4
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ class User < ApplicationRecord
4
+ include FoundersToolkit::Auth::Securable::Model
5
+ include FoundersToolkit::Auth::Recoverable::Model
6
+ end
@@ -0,0 +1,33 @@
1
+ <div class="flex flex-col space-y-4 justify-center items-center h-screen">
2
+ <% if @user.errors.present? %>
3
+ <div class="py-2 px-4 bg-red-500 rounded">
4
+ Could not create your account because of the following errors:
5
+ <ul class="list-disc ml-6">
6
+ <% @user.errors.full_messages.each do |message| %>
7
+ <li><%= message %></li>
8
+ <% end %>
9
+ </ul>
10
+ </div>
11
+ <% end %>
12
+ <% form_with model: @user, class: 'flex-col space-y-2' do |f| %>
13
+ <div class="flex justify-between space-x-2 items-center">
14
+ <%= f.label :email %>
15
+ <%= f.text_field :email, class: 'rounded-sm px-4 py-2 border border-gray-700 bg-gray-800' %>
16
+ </div>
17
+
18
+ <div class="flex justify-between space-x-2 items-center">
19
+ <%= f.label :password %>
20
+ <%= f.password_field :password, class: 'rounded-sm px-4 py-2 border border-gray-700 bg-gray-800' %>
21
+ </div>
22
+
23
+ <div class="flex justify-between space-x-2 items-center">
24
+ <%= f.label :password_confirmation %>
25
+ <%= f.password_field :password_confirmation, class: 'rounded-sm px-4 py-2 border border-gray-700 bg-gray-800' %>
26
+ </div>
27
+
28
+ <div class="flex justify-between items-end">
29
+ <%= link_to 'or Login', new_session_path, class: 'text-blue-500 text-underline font-sans text-lg' %>
30
+ <%= f.submit 'Sign Up', class: 'rounded bg-blue-600 py-2 px-4' %>
31
+ </div>
32
+ <% end %>
33
+ </div>
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ def run_founders_install_template(path)
4
+ system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path(
5
+ "../install/#{path}.rb", __dir__
6
+ )}"
7
+ end
8
+
9
+ namespace :founders_toolkit do
10
+ desc 'Install Founders Toolkit'
11
+ task :install do
12
+ run_founders_install_template 'install'
13
+ end
14
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: founders_toolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trae Robrock
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-03-25 00:00:00.000000000 Z
12
+ date: 2021-05-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
@@ -71,17 +71,30 @@ files:
71
71
  - lib/founders_toolkit/auth/securable.rb
72
72
  - lib/founders_toolkit/auth/securable/controller.rb
73
73
  - lib/founders_toolkit/auth/securable/current_attributes.rb
74
+ - lib/founders_toolkit/auth/securable/guest.rb
74
75
  - lib/founders_toolkit/auth/securable/model.rb
75
76
  - lib/founders_toolkit/auth/securable/sessions_controller.rb
76
77
  - lib/founders_toolkit/auth/securable/validations/protected_validator.rb
77
78
  - lib/founders_toolkit/engine.rb
78
79
  - lib/founders_toolkit/jobs/locked_job.rb
80
+ - lib/founders_toolkit/jobs/tracked_job.rb
79
81
  - lib/founders_toolkit/monitoring/statsdable.rb
80
82
  - lib/founders_toolkit/util.rb
81
83
  - lib/founders_toolkit/util/cacheable.rb
82
84
  - lib/founders_toolkit/util/lockable.rb
83
85
  - lib/founders_toolkit/util/rate_limitable.rb
84
86
  - lib/founders_toolkit/version.rb
87
+ - lib/install/install.rb
88
+ - lib/install/templates/.rubocop.yml
89
+ - lib/install/templates/Brewfile
90
+ - lib/install/templates/Procfile
91
+ - lib/install/templates/app/controllers/sessions_controller.rb
92
+ - lib/install/templates/app/controllers/users_controller.rb
93
+ - lib/install/templates/app/models/current.rb
94
+ - lib/install/templates/app/models/guest.rb
95
+ - lib/install/templates/app/models/user.rb
96
+ - lib/install/templates/app/views/sessions/new.html.erb
97
+ - lib/tasks/install.rake
85
98
  homepage: https://github.com/trobrock/founders-toolkit
86
99
  licenses:
87
100
  - MIT
@@ -96,14 +109,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
96
109
  requirements:
97
110
  - - ">="
98
111
  - !ruby/object:Gem::Version
99
- version: 2.4.0
112
+ version: 3.0.1
100
113
  required_rubygems_version: !ruby/object:Gem::Requirement
101
114
  requirements:
102
115
  - - ">="
103
116
  - !ruby/object:Gem::Version
104
117
  version: '0'
105
118
  requirements: []
106
- rubygems_version: 3.2.3
119
+ rubygems_version: 3.2.15
107
120
  signing_key:
108
121
  specification_version: 4
109
122
  summary: Founders Toolkit for Rails