founders_toolkit 0.2.0 → 0.6.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: f6dd057ec97f97ab59a9bcba36d014f994f6042ec8877ebe5ca696317b4b0706
4
- data.tar.gz: 4be1969f1f142fdd563ce0b3de48888ffc65491c32d28bc6ced7d0a41142d14f
3
+ metadata.gz: b5f9177014a99ce6c0ac2751cbc8dd34589a510e6412533c4c33a783a83cb5f5
4
+ data.tar.gz: 7143a519fdc2f6cd00f441331c24c601c1d2c70eaaa58f95cf1d9a6f2b1fdbe1
5
5
  SHA512:
6
- metadata.gz: cb12a632363369958f210b86504c074bae31fbe072843ece75471a1a26a5ef0a722c5ef8295196387e49558260406be031abaffce90f891cc381ab8f5623e4e5
7
- data.tar.gz: a39639f8bd9adb2164fa9f1db86f21714e4ed7fd5a858584f7e1254b1ff5b0f22cb88b45051882407408969576741fbc10a4a9b60ff7c22c21e937152d9f0094
6
+ metadata.gz: 3173aede632715cf33a530fc8d161baa667be9a887a8f0632c8bd7fa929ad972857b95d830720999d753e909202d7dc688deb7eca806a80e135d6ef22c1fe253
7
+ data.tar.gz: fc1bcda91214a46918cb7ca7f64e376a82517d01c15f10590df1d48074e26e7524fa83a8e3cb2933557f6810d4fe31043993535536d079f83e7d6794be481207
data/CHANGELOG.md CHANGED
@@ -6,6 +6,24 @@ 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
+
23
+ ## [0.2.1] - 2021-03-25
24
+ ### Fixed
25
+ - Fixed the protected attributes validator when updating the password.
26
+
9
27
  ## [0.1.0] - 2021-03-25
10
28
  - No real change, just CI
11
29
 
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.6.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.1)
12
+ activesupport (= 6.1.3.1)
13
+ activesupport (6.1.3.1)
14
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
15
15
  i18n (>= 1.6, < 2)
16
16
  minitest (>= 5.1)
@@ -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
@@ -31,7 +31,10 @@ module FoundersToolkit::Auth::Securable::Validations
31
31
  end
32
32
 
33
33
  def authenticate?(record)
34
- record.try(:reset_password_token?) || record.authenticate(record.current_password)
34
+ return true if record.try(:reset_password_token?)
35
+
36
+ fresh_record = record.class.find(record.id)
37
+ fresh_record.authenticate(record.current_password)
35
38
  end
36
39
 
37
40
  module HelperMethods
@@ -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.0'
4
+ VERSION = '0.6.0'
5
5
  end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source_paths << File.expand_path('templates', __dir__)
4
+
5
+ say 'Creating Current'
6
+ copy_file 'current.rb', 'app/models/current.rb'
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ say 'Add gems'
4
+ gem 'hotwire-rails'
5
+ gem 'tailwindcss-rails'
6
+ run 'bin/bundle install'
7
+
8
+ say 'Install Tailwind CSS'
9
+ rails_command 'tailwindcss:install'
10
+
11
+ say 'Install Hotwire'
12
+ rails_command 'hotwire:install'
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source_paths << File.expand_path('templates', __dir__)
4
+
5
+ say 'Add rubocop'
6
+ gem_group :development do
7
+ gem 'rubocop'
8
+ end
9
+ run 'bin/bundle install'
10
+ copy_file '.rubocop.yml', '.rubocop.yml'
@@ -0,0 +1,2 @@
1
+ inherit_from:
2
+ - https://raw.githubusercontent.com/trobrock/style-guides/master/ruby-style.yml
@@ -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,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ def run_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_install_template 'gems'
13
+ run_install_template 'current'
14
+ run_install_template 'linters'
15
+ end
16
+ 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.0
4
+ version: 0.6.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-03-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
@@ -76,12 +76,19 @@ files:
76
76
  - lib/founders_toolkit/auth/securable/validations/protected_validator.rb
77
77
  - lib/founders_toolkit/engine.rb
78
78
  - lib/founders_toolkit/jobs/locked_job.rb
79
+ - lib/founders_toolkit/jobs/tracked_job.rb
79
80
  - lib/founders_toolkit/monitoring/statsdable.rb
80
81
  - lib/founders_toolkit/util.rb
81
82
  - lib/founders_toolkit/util/cacheable.rb
82
83
  - lib/founders_toolkit/util/lockable.rb
83
84
  - lib/founders_toolkit/util/rate_limitable.rb
84
85
  - lib/founders_toolkit/version.rb
86
+ - lib/install/current.rb
87
+ - lib/install/gems.rb
88
+ - lib/install/linters.rb
89
+ - lib/install/templates/.rubocop.yml
90
+ - lib/install/templates/current.rb
91
+ - lib/tasks/install.rake
85
92
  homepage: https://github.com/trobrock/founders-toolkit
86
93
  licenses:
87
94
  - MIT