roqua-support 0.3.4 → 0.4.2
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/.gitlab-ci.yml +11 -27
- data/Appraisals +6 -7
- data/CHANGELOG.md +19 -0
- data/Gemfile +4 -3
- data/Gemfile.lock +36 -30
- data/README.md +23 -0
- data/gemfiles/rails52.gemfile +3 -3
- data/gemfiles/rails60.gemfile +2 -3
- data/gemfiles/{rails51.gemfile → rails61.gemfile} +4 -4
- data/lib/roqua/core_ext/active_interaction/filters/date_time_as_unix_extension.rb +4 -4
- data/lib/roqua/core_ext/enumerable/sort_by_alphanum.rb +34 -18
- data/lib/roqua/logging/roqua_logging_railtie.rb +2 -0
- data/lib/roqua/scheduling/scheduler.rb +6 -1
- data/lib/roqua/support/errors.rb +4 -1
- data/lib/roqua/type/stripped_string.rb +34 -0
- data/lib/roqua/type.rb +7 -0
- data/lib/roqua/validators/subset_validator.rb +1 -1
- data/lib/roqua-support/version.rb +1 -1
- data/roqua-support.gemspec +4 -4
- data/spec/roqua/core_ext/enumerable/sort_by_alphanum_spec.rb +10 -0
- data/spec/roqua/logging/roqua_logging_railtie_spec.rb +6 -0
- data/spec/roqua/scheduling/scheduler_spec.rb +2 -1
- data/spec/roqua/support/errors_spec.rb +7 -2
- data/spec/roqua/type/stripped_string_spec.rb +34 -0
- metadata +26 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 774c4b5c612eff02c808d6dac48cc599664c641deb96b97c923a6d293875a5b4
|
|
4
|
+
data.tar.gz: 0b2dd8489e5ec1a6216db145f511d7313776efe7ea07db0604f4bb4c7bfeb3e1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d69bb02afb3adb3bdf1dd64a526466d7b24f8f8b068829a8ce9dfafa2930d29de30cff451fec7ff2d91c933e390c27b2addb336124dd257856c3dc6c510d3b56
|
|
7
|
+
data.tar.gz: 316fedffd3ede41f162fb6b294b409b446b204e89412d29dd7f6cc7d07af300e6b3eb5abc8471cea6970944aae74b443adfcef4a3a25843d3b82d40ca39d24e9
|
data/.gitlab-ci.yml
CHANGED
|
@@ -5,44 +5,28 @@ before_script:
|
|
|
5
5
|
- if [ -x "$(command -v apk)" ]; then apk add sqlite-dev; fi
|
|
6
6
|
- export BUNDLE_PATH=$CI_PROJECT_DIR/.gems
|
|
7
7
|
- bundle --jobs 2 --retry 3
|
|
8
|
-
- bundle exec appraisal
|
|
9
|
-
- bundle --jobs 2 --retry 3
|
|
8
|
+
- bundle exec appraisal install
|
|
10
9
|
|
|
11
|
-
.ruby_25: &ruby_25
|
|
12
|
-
image: registry.roqua.nl/roqua/docker-base-images:ruby-2.5
|
|
13
|
-
cache:
|
|
14
|
-
key: ruby_25
|
|
15
|
-
paths:
|
|
16
|
-
- .gems
|
|
17
10
|
|
|
18
|
-
.
|
|
19
|
-
image: registry.roqua.nl/roqua/docker-base-images:ruby-2.
|
|
11
|
+
.ruby_27: &ruby_27
|
|
12
|
+
image: registry.roqua.nl/roqua/docker-base-images:ruby-2.7-builder
|
|
20
13
|
cache:
|
|
21
|
-
key:
|
|
14
|
+
key: ruby_27
|
|
22
15
|
paths:
|
|
23
16
|
- .gems
|
|
24
17
|
|
|
25
|
-
rails_51_ruby_25:
|
|
26
|
-
<<: *ruby_25
|
|
27
|
-
script:
|
|
28
|
-
- bundle exec appraisal rails51 bundle exec rspec
|
|
29
18
|
|
|
30
|
-
|
|
31
|
-
<<: *
|
|
19
|
+
rails_52_ruby_27:
|
|
20
|
+
<<: *ruby_27
|
|
32
21
|
script:
|
|
33
22
|
- bundle exec appraisal rails52 bundle exec rspec
|
|
34
23
|
|
|
35
|
-
|
|
36
|
-
<<: *
|
|
37
|
-
script:
|
|
38
|
-
- bundle exec appraisal rails52 bundle exec rspec
|
|
39
|
-
|
|
40
|
-
rails_60_ruby_25:
|
|
41
|
-
<<: *ruby_25
|
|
24
|
+
rails_60_ruby_27:
|
|
25
|
+
<<: *ruby_27
|
|
42
26
|
script:
|
|
43
27
|
- bundle exec appraisal rails60 bundle exec rspec
|
|
44
28
|
|
|
45
|
-
|
|
46
|
-
<<: *
|
|
29
|
+
rails_61_ruby_27:
|
|
30
|
+
<<: *ruby_27
|
|
47
31
|
script:
|
|
48
|
-
- bundle exec appraisal
|
|
32
|
+
- bundle exec appraisal rails61 bundle exec rspec
|
data/Appraisals
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
appraise "rails51" do
|
|
2
|
-
gem "activesupport", "~> 5.1.0"
|
|
3
|
-
gem 'sqlite3', '~> 1.3.6'
|
|
4
|
-
end
|
|
5
|
-
|
|
6
1
|
appraise "rails52" do
|
|
2
|
+
gem "active_interaction", "~> 3.0"
|
|
7
3
|
gem "activesupport", "~> 5.2.0"
|
|
8
|
-
gem 'sqlite3', '~> 1.4'
|
|
9
4
|
gem 'appsignal', '~> 2.9.8' # test each minor versions we support
|
|
10
5
|
end
|
|
11
6
|
|
|
12
7
|
appraise "rails60" do
|
|
13
8
|
gem "activesupport", "~> 6.0.0"
|
|
14
|
-
gem 'sqlite3', '~> 1.4'
|
|
15
9
|
gem 'appsignal', '~> 2.10.6'
|
|
16
10
|
end
|
|
11
|
+
|
|
12
|
+
appraise "rails61" do
|
|
13
|
+
gem "activesupport", "~> 6.1.0"
|
|
14
|
+
gem 'appsignal', '~> 3.0.0'
|
|
15
|
+
end
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
## 0.4.2
|
|
2
|
+
|
|
3
|
+
* Make sort_by_alphanum stable for chunks that parse to the same int like 04 and 4.
|
|
4
|
+
|
|
5
|
+
## 0.4.1
|
|
6
|
+
|
|
7
|
+
* Add timezone to logging timestamps. Use milliseconds instead of microseconds precision.
|
|
8
|
+
|
|
9
|
+
## 0.4.0
|
|
10
|
+
|
|
11
|
+
* Remove support for ruby 2.5 and 2.6
|
|
12
|
+
* Add stripped_string type (attributes api)
|
|
13
|
+
* Add support for appsignal v3
|
|
14
|
+
* Add support for active_interaction v4
|
|
15
|
+
|
|
16
|
+
## 0.3.5
|
|
17
|
+
|
|
18
|
+
* Update AppSignal gauge for every minute the probe runs
|
|
19
|
+
|
|
1
20
|
## 0.3.4
|
|
2
21
|
|
|
3
22
|
* gemspec and tests: Removed rails 4.2 and 5.0, remove ruby 2.3 and 2.4, added ruby 2.6, allow appsignal 2.10
|
data/Gemfile
CHANGED
|
@@ -4,11 +4,12 @@ source 'https://rubygems.org'
|
|
|
4
4
|
gemspec
|
|
5
5
|
|
|
6
6
|
gem 'appraisal'
|
|
7
|
-
|
|
7
|
+
# fix so long as we support ruby 2.6 and ealier.
|
|
8
|
+
gem 'roqua_styleguide', git: 'https://gitlab.roqua.nl/roqua/styleguide.git', ref: '9662550'
|
|
8
9
|
|
|
9
10
|
group :test do
|
|
11
|
+
gem 'sqlite3'
|
|
10
12
|
gem 'actionpack', '>= 4.0'
|
|
11
|
-
gem 'active_interaction', '~> 3.0'
|
|
12
13
|
gem 'climate_control' # For ENV modification in specs
|
|
13
14
|
gem 'combustion', '~> 1.1.1'
|
|
14
15
|
gem 'fakefs', require: 'fakefs/safe'
|
|
@@ -17,4 +18,4 @@ group :test do
|
|
|
17
18
|
gem 'rspec-instrumentation-matcher'
|
|
18
19
|
gem 'rspec-rails'
|
|
19
20
|
gem 'pry'
|
|
20
|
-
end
|
|
21
|
+
end
|
data/Gemfile.lock
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
GIT
|
|
2
2
|
remote: https://gitlab.roqua.nl/roqua/styleguide.git
|
|
3
|
-
revision:
|
|
3
|
+
revision: 9662550201987db20c03e300eddb34d8ad035613
|
|
4
|
+
ref: 9662550
|
|
4
5
|
specs:
|
|
5
6
|
roqua_styleguide (0.0.8)
|
|
6
|
-
rubocop (~> 0.
|
|
7
|
+
rubocop (~> 0.90.0)
|
|
7
8
|
rubocop-rails
|
|
8
9
|
|
|
9
10
|
PATH
|
|
10
11
|
remote: .
|
|
11
12
|
specs:
|
|
12
|
-
roqua-support (0.
|
|
13
|
-
active_interaction (
|
|
14
|
-
activesupport (>= 5.
|
|
15
|
-
appsignal (>= 2.9, <
|
|
13
|
+
roqua-support (0.4.2)
|
|
14
|
+
active_interaction (>= 3.0, < 5.0)
|
|
15
|
+
activesupport (>= 5.2, < 6.2)
|
|
16
|
+
appsignal (>= 2.9, < 3.1)
|
|
16
17
|
naught (~> 1.0)
|
|
17
18
|
with_advisory_lock (~> 3.2)
|
|
18
19
|
|
|
@@ -32,8 +33,9 @@ GEM
|
|
|
32
33
|
erubi (~> 1.4)
|
|
33
34
|
rails-dom-testing (~> 2.0)
|
|
34
35
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
|
35
|
-
active_interaction (
|
|
36
|
-
activemodel (>=
|
|
36
|
+
active_interaction (4.1.0)
|
|
37
|
+
activemodel (>= 5, < 8)
|
|
38
|
+
activesupport (>= 5, < 8)
|
|
37
39
|
activemodel (6.0.2.2)
|
|
38
40
|
activesupport (= 6.0.2.2)
|
|
39
41
|
activerecord (6.0.2.2)
|
|
@@ -49,9 +51,9 @@ GEM
|
|
|
49
51
|
bundler
|
|
50
52
|
rake
|
|
51
53
|
thor (>= 0.14.0)
|
|
52
|
-
appsignal (
|
|
54
|
+
appsignal (3.0.19)
|
|
53
55
|
rack
|
|
54
|
-
ast (2.4.
|
|
56
|
+
ast (2.4.2)
|
|
55
57
|
builder (3.2.4)
|
|
56
58
|
climate_control (0.2.0)
|
|
57
59
|
coderay (1.1.2)
|
|
@@ -59,7 +61,7 @@ GEM
|
|
|
59
61
|
activesupport (>= 3.0.0)
|
|
60
62
|
railties (>= 3.0.0)
|
|
61
63
|
thor (>= 0.14.6)
|
|
62
|
-
concurrent-ruby (1.1.
|
|
64
|
+
concurrent-ruby (1.1.8)
|
|
63
65
|
crass (1.0.6)
|
|
64
66
|
delayed_job (4.1.8)
|
|
65
67
|
activesupport (>= 3.0, < 6.1)
|
|
@@ -83,9 +85,8 @@ GEM
|
|
|
83
85
|
guard-rspec (4.2.10)
|
|
84
86
|
guard (~> 2.1)
|
|
85
87
|
rspec (>= 2.14, < 4.0)
|
|
86
|
-
i18n (1.8.
|
|
88
|
+
i18n (1.8.10)
|
|
87
89
|
concurrent-ruby (~> 1.0)
|
|
88
|
-
jaro_winkler (1.5.4)
|
|
89
90
|
listen (3.2.1)
|
|
90
91
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
91
92
|
rb-inotify (~> 0.9, >= 0.9.10)
|
|
@@ -95,7 +96,7 @@ GEM
|
|
|
95
96
|
lumberjack (1.2.4)
|
|
96
97
|
method_source (1.0.0)
|
|
97
98
|
mini_portile2 (2.4.0)
|
|
98
|
-
minitest (5.14.
|
|
99
|
+
minitest (5.14.4)
|
|
99
100
|
naught (1.1.0)
|
|
100
101
|
nenv (0.3.0)
|
|
101
102
|
nokogiri (1.10.9)
|
|
@@ -103,13 +104,13 @@ GEM
|
|
|
103
104
|
notiffany (0.1.3)
|
|
104
105
|
nenv (~> 0.1)
|
|
105
106
|
shellany (~> 0.0)
|
|
106
|
-
parallel (1.
|
|
107
|
-
parser (
|
|
108
|
-
ast (~> 2.4.
|
|
107
|
+
parallel (1.20.1)
|
|
108
|
+
parser (3.0.0.0)
|
|
109
|
+
ast (~> 2.4.1)
|
|
109
110
|
pry (0.13.1)
|
|
110
111
|
coderay (~> 1.1)
|
|
111
112
|
method_source (~> 1.0)
|
|
112
|
-
rack (2.2.
|
|
113
|
+
rack (2.2.3)
|
|
113
114
|
rack-test (1.1.0)
|
|
114
115
|
rack (>= 1.0, < 3)
|
|
115
116
|
rails-dom-testing (2.0.3)
|
|
@@ -128,6 +129,7 @@ GEM
|
|
|
128
129
|
rb-fsevent (0.10.4)
|
|
129
130
|
rb-inotify (0.10.1)
|
|
130
131
|
ffi (~> 1.0)
|
|
132
|
+
regexp_parser (2.1.1)
|
|
131
133
|
responders (3.0.0)
|
|
132
134
|
actionpack (>= 5.0)
|
|
133
135
|
railties (>= 5.0)
|
|
@@ -156,36 +158,39 @@ GEM
|
|
|
156
158
|
rspec-mocks (~> 3.9)
|
|
157
159
|
rspec-support (~> 3.9)
|
|
158
160
|
rspec-support (3.9.3)
|
|
159
|
-
rubocop (0.
|
|
160
|
-
jaro_winkler (~> 1.5.1)
|
|
161
|
+
rubocop (0.90.0)
|
|
161
162
|
parallel (~> 1.10)
|
|
162
|
-
parser (>= 2.7.
|
|
163
|
+
parser (>= 2.7.1.1)
|
|
163
164
|
rainbow (>= 2.2.2, < 4.0)
|
|
165
|
+
regexp_parser (>= 1.7)
|
|
164
166
|
rexml
|
|
167
|
+
rubocop-ast (>= 0.3.0, < 1.0)
|
|
165
168
|
ruby-progressbar (~> 1.7)
|
|
166
|
-
unicode-display_width (>= 1.4.0, <
|
|
167
|
-
rubocop-
|
|
168
|
-
|
|
169
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
|
170
|
+
rubocop-ast (0.8.0)
|
|
171
|
+
parser (>= 2.7.1.5)
|
|
172
|
+
rubocop-rails (2.9.1)
|
|
173
|
+
activesupport (>= 4.2.0)
|
|
169
174
|
rack (>= 1.1)
|
|
170
|
-
rubocop (>= 0.
|
|
171
|
-
ruby-progressbar (1.
|
|
175
|
+
rubocop (>= 0.90.0, < 2.0)
|
|
176
|
+
ruby-progressbar (1.11.0)
|
|
172
177
|
shellany (0.0.1)
|
|
178
|
+
sqlite3 (1.4.2)
|
|
173
179
|
thor (1.0.1)
|
|
174
180
|
thread_safe (0.3.6)
|
|
175
181
|
timecop (0.9.1)
|
|
176
|
-
tzinfo (1.2.
|
|
182
|
+
tzinfo (1.2.9)
|
|
177
183
|
thread_safe (~> 0.1)
|
|
178
|
-
unicode-display_width (1.
|
|
184
|
+
unicode-display_width (1.7.0)
|
|
179
185
|
with_advisory_lock (3.2.0)
|
|
180
186
|
activerecord (>= 3.2)
|
|
181
|
-
zeitwerk (2.
|
|
187
|
+
zeitwerk (2.4.2)
|
|
182
188
|
|
|
183
189
|
PLATFORMS
|
|
184
190
|
ruby
|
|
185
191
|
|
|
186
192
|
DEPENDENCIES
|
|
187
193
|
actionpack (>= 4.0)
|
|
188
|
-
active_interaction (~> 3.0)
|
|
189
194
|
appraisal
|
|
190
195
|
bundler (~> 2.0)
|
|
191
196
|
climate_control
|
|
@@ -201,6 +206,7 @@ DEPENDENCIES
|
|
|
201
206
|
rspec (>= 2.12.0, < 4.0)
|
|
202
207
|
rspec-instrumentation-matcher
|
|
203
208
|
rspec-rails
|
|
209
|
+
sqlite3
|
|
204
210
|
timecop
|
|
205
211
|
|
|
206
212
|
BUNDLED WITH
|
data/README.md
CHANGED
|
@@ -104,6 +104,29 @@ class ApiAreaController < ApplicationController
|
|
|
104
104
|
...
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
+
### Types
|
|
108
|
+
|
|
109
|
+
In initializer:
|
|
110
|
+
|
|
111
|
+
```ruby
|
|
112
|
+
require 'roqua/type'
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
In models:
|
|
116
|
+
|
|
117
|
+
```ruby
|
|
118
|
+
# strip whitespace and nil if blank.
|
|
119
|
+
attribute :firstname, :stripped_string
|
|
120
|
+
# strip, but don't nil if blank.
|
|
121
|
+
attribute :firstname, :stripped_string, allow_empty: true
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
#### option 2
|
|
125
|
+
|
|
126
|
+
`require 'roqua/type/stripped_string'`
|
|
127
|
+
|
|
128
|
+
`attribute :firstname, Roqua::Type::StrippedString.new(allow_empty: true)`
|
|
129
|
+
|
|
107
130
|
# Delayed Job activity monitoring
|
|
108
131
|
|
|
109
132
|
To add monitoring of whether Delayed Job keeps picking up jobs or checking for new jobs, add the following line to an initializer:
|
data/gemfiles/rails52.gemfile
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
5
|
gem "appraisal"
|
|
6
|
-
gem "roqua_styleguide", git: "https://gitlab.roqua.nl/roqua/styleguide.git"
|
|
6
|
+
gem "roqua_styleguide", git: "https://gitlab.roqua.nl/roqua/styleguide.git", ref: "9662550"
|
|
7
|
+
gem "active_interaction", "~> 3.0"
|
|
7
8
|
gem "activesupport", "~> 5.2.0"
|
|
8
|
-
gem "sqlite3", "~> 1.4"
|
|
9
9
|
gem "appsignal", "~> 2.9.8"
|
|
10
10
|
|
|
11
11
|
group :test do
|
|
12
|
+
gem "sqlite3"
|
|
12
13
|
gem "actionpack", ">= 4.0"
|
|
13
|
-
gem "active_interaction", "~> 3.0"
|
|
14
14
|
gem "climate_control"
|
|
15
15
|
gem "combustion", "~> 1.1.1"
|
|
16
16
|
gem "fakefs", require: "fakefs/safe"
|
data/gemfiles/rails60.gemfile
CHANGED
|
@@ -3,14 +3,13 @@
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
5
|
gem "appraisal"
|
|
6
|
-
gem "roqua_styleguide", git: "https://gitlab.roqua.nl/roqua/styleguide.git"
|
|
6
|
+
gem "roqua_styleguide", git: "https://gitlab.roqua.nl/roqua/styleguide.git", ref: "9662550"
|
|
7
7
|
gem "activesupport", "~> 6.0.0"
|
|
8
|
-
gem "sqlite3", "~> 1.4"
|
|
9
8
|
gem "appsignal", "~> 2.10.6"
|
|
10
9
|
|
|
11
10
|
group :test do
|
|
11
|
+
gem "sqlite3"
|
|
12
12
|
gem "actionpack", ">= 4.0"
|
|
13
|
-
gem "active_interaction", "~> 3.0"
|
|
14
13
|
gem "climate_control"
|
|
15
14
|
gem "combustion", "~> 1.1.1"
|
|
16
15
|
gem "fakefs", require: "fakefs/safe"
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
5
|
gem "appraisal"
|
|
6
|
-
gem "roqua_styleguide", git: "https://gitlab.roqua.nl/roqua/styleguide.git"
|
|
7
|
-
gem "activesupport", "~>
|
|
8
|
-
gem "
|
|
6
|
+
gem "roqua_styleguide", git: "https://gitlab.roqua.nl/roqua/styleguide.git", ref: "9662550"
|
|
7
|
+
gem "activesupport", "~> 6.1.0"
|
|
8
|
+
gem "appsignal", "~> 3.0.0"
|
|
9
9
|
|
|
10
10
|
group :test do
|
|
11
|
+
gem "sqlite3"
|
|
11
12
|
gem "actionpack", ">= 4.0"
|
|
12
|
-
gem "active_interaction", "~> 3.0"
|
|
13
13
|
gem "climate_control"
|
|
14
14
|
gem "combustion", "~> 1.1.1"
|
|
15
15
|
gem "fakefs", require: "fakefs/safe"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# allow datetimes to be given as unix times for activeinteractions
|
|
2
2
|
module RoquaDateTimeAsUnixFilterExtension
|
|
3
|
-
def cast(value, interaction)
|
|
3
|
+
def cast(value, interaction, **options)
|
|
4
4
|
case value
|
|
5
5
|
when Numeric, /^[0-9]+$/
|
|
6
6
|
Time.at(value.to_i).to_datetime
|
|
7
7
|
when ''
|
|
8
|
-
super(nil, interaction)
|
|
8
|
+
super(nil, interaction, **options)
|
|
9
9
|
else
|
|
10
10
|
super
|
|
11
11
|
end
|
|
@@ -15,12 +15,12 @@ ActiveInteraction::DateTimeFilter.include RoquaDateTimeAsUnixFilterExtension
|
|
|
15
15
|
|
|
16
16
|
# allow datetimes to be given as unix times as string
|
|
17
17
|
module RoquaTimeAsUnixFilterExtension
|
|
18
|
-
def cast(value, interaction)
|
|
18
|
+
def cast(value, interaction, **options)
|
|
19
19
|
case value
|
|
20
20
|
when /^[0-9]+$/
|
|
21
21
|
Time.at(value.to_i)
|
|
22
22
|
when ''
|
|
23
|
-
super(nil, interaction)
|
|
23
|
+
super(nil, interaction, **options)
|
|
24
24
|
else
|
|
25
25
|
super
|
|
26
26
|
end
|
|
@@ -21,29 +21,45 @@ module Enumerable
|
|
|
21
21
|
|
|
22
22
|
private
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
b_chunk, b = extract_alpha_or_number_group(b)
|
|
24
|
+
ALL_NUM = /\d+/
|
|
25
|
+
ALL_ALPHA = /[A-Za-z]+/
|
|
26
|
+
NON_ALPHANUM = /[^A-Za-z0-9]+/
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
def grouped_compare(a, b)
|
|
29
|
+
a_scanner = StringScanner.new(a)
|
|
30
|
+
b_scanner = StringScanner.new(b)
|
|
31
|
+
# each loop has to do exactly 1 non-nil-scan on both scanners or return a non-zero value.
|
|
32
|
+
loop do
|
|
33
|
+
ret = \
|
|
34
|
+
if a_scanner.eos?
|
|
35
|
+
-1
|
|
36
|
+
elsif (a_chunk = a_scanner.scan(ALL_NUM))
|
|
37
|
+
if (b_chunk = b_scanner.scan(ALL_NUM))
|
|
38
|
+
if a_chunk.to_i != b_chunk.to_i
|
|
30
39
|
a_chunk.to_i <=> b_chunk.to_i
|
|
31
|
-
else
|
|
40
|
+
else # 03 vs 3
|
|
32
41
|
a_chunk <=> b_chunk
|
|
33
42
|
end
|
|
34
|
-
|
|
35
|
-
|
|
43
|
+
elsif b_scanner.scan(ALL_ALPHA)
|
|
44
|
+
-1
|
|
45
|
+
else # NON_ALPHANUM
|
|
46
|
+
1
|
|
47
|
+
end
|
|
48
|
+
elsif (a_chunk = a_scanner.scan(ALL_ALPHA))
|
|
49
|
+
if (b_chunk = b_scanner.scan(ALL_ALPHA))
|
|
50
|
+
a_chunk <=> b_chunk
|
|
51
|
+
else # ALL_NUM or NON_ALPHANUM
|
|
52
|
+
1
|
|
53
|
+
end
|
|
54
|
+
else # NON_ALPHANUM
|
|
55
|
+
a_chunk = a_scanner.scan(NON_ALPHANUM)
|
|
56
|
+
if (b_chunk = b_scanner.scan(NON_ALPHANUM))
|
|
57
|
+
a_chunk <=> b_chunk
|
|
58
|
+
else
|
|
59
|
+
-1
|
|
60
|
+
end
|
|
61
|
+
end
|
|
36
62
|
return ret if ret != 0
|
|
37
|
-
}
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def extract_alpha_or_number_group(item)
|
|
41
|
-
matchdata = /([A-Za-z]+|[\d]+)/.match(item)
|
|
42
|
-
|
|
43
|
-
if matchdata.nil?
|
|
44
|
-
["", ""]
|
|
45
|
-
else
|
|
46
|
-
[matchdata[0], item = item[matchdata.offset(0)[1] .. -1]]
|
|
47
63
|
end
|
|
48
64
|
end
|
|
49
65
|
end
|
|
@@ -7,6 +7,8 @@ class RoquaLoggingRailtie < Rails::Railtie
|
|
|
7
7
|
def configure
|
|
8
8
|
Roqua.logger = ActiveSupport::Logger.new(output_stream).tap do |logger|
|
|
9
9
|
logger.formatter = Logger::Formatter.new
|
|
10
|
+
# Set the datetime_format to include timezone and use milliseconds instead of microseconds
|
|
11
|
+
logger.formatter.datetime_format = '%Y-%m-%dT%H:%M:%S.%L%z '
|
|
10
12
|
end
|
|
11
13
|
|
|
12
14
|
require 'roqua/support/request_logger'
|
|
@@ -11,6 +11,8 @@ class Roqua::Scheduling::Scheduler
|
|
|
11
11
|
raise ex if Rails.env.test?
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
|
+
|
|
15
|
+
Appsignal.increment_counter("scheduler.completed", 1)
|
|
14
16
|
end
|
|
15
17
|
end
|
|
16
18
|
|
|
@@ -27,7 +29,10 @@ class Roqua::Scheduling::Scheduler
|
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
def advisory_lock_name
|
|
30
|
-
|
|
32
|
+
db_name = ActiveRecord::Base.respond_to?(:connection_db_config) \
|
|
33
|
+
? ActiveRecord::Base.connection_db_config.database
|
|
34
|
+
: ActiveRecord::Base.connection_config[:database]
|
|
35
|
+
"#{db_name}_cron_lock"
|
|
31
36
|
end
|
|
32
37
|
|
|
33
38
|
private
|
data/lib/roqua/support/errors.rb
CHANGED
|
@@ -82,7 +82,10 @@ module Roqua
|
|
|
82
82
|
current_transaction.set_tags(labels)
|
|
83
83
|
current_transaction.add_exception(exception)
|
|
84
84
|
else
|
|
85
|
-
Appsignal.send_error exception
|
|
85
|
+
Appsignal.send_error exception do |transaction|
|
|
86
|
+
transaction.set_tags labels
|
|
87
|
+
transaction.set_namespace namespace
|
|
88
|
+
end
|
|
86
89
|
end
|
|
87
90
|
end
|
|
88
91
|
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Strips whitespace and make nil when string becomes empty.
|
|
4
|
+
module Roqua
|
|
5
|
+
module Type
|
|
6
|
+
class StrippedString < ActiveModel::Type::ImmutableString
|
|
7
|
+
# taken from strip_attributes gem
|
|
8
|
+
# Unicode invisible and whitespace characters. The POSIX character class
|
|
9
|
+
# [:space:] corresponds to the Unicode class Z ("separator"). We also
|
|
10
|
+
# include the following characters from Unicode class C ("control"), which
|
|
11
|
+
# are spaces or invisible characters that make no sense at the start or end
|
|
12
|
+
# of a string:
|
|
13
|
+
# U+180E MONGOLIAN VOWEL SEPARATOR
|
|
14
|
+
# U+200B ZERO WIDTH SPACE
|
|
15
|
+
# U+200C ZERO WIDTH NON-JOINER
|
|
16
|
+
# U+200D ZERO WIDTH JOINER
|
|
17
|
+
# U+2060 WORD JOINER
|
|
18
|
+
# U+FEFF ZERO WIDTH NO-BREAK SPACE
|
|
19
|
+
MULTIBYTE_WHITE = "\u180E\u200B\u200C\u200D\u2060\uFEFF"
|
|
20
|
+
MULTIBYTE_SPACE = /[[:space:]#{MULTIBYTE_WHITE}]/.freeze
|
|
21
|
+
|
|
22
|
+
def initialize(allow_empty: false)
|
|
23
|
+
super()
|
|
24
|
+
@allow_empty = allow_empty
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def cast(value)
|
|
28
|
+
return unless value
|
|
29
|
+
value = super(value).gsub(/\A#{MULTIBYTE_SPACE}+|#{MULTIBYTE_SPACE}+\z/, "").freeze
|
|
30
|
+
value.blank? && !@allow_empty ? nil : value
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
data/lib/roqua/type.rb
ADDED
|
@@ -6,7 +6,7 @@ class SubsetValidator < ActiveModel::EachValidator
|
|
|
6
6
|
def validate_each(record, attribute, value)
|
|
7
7
|
return unless value
|
|
8
8
|
unless value.all? { |element| options.fetch(:of).include? element }
|
|
9
|
-
record.errors
|
|
9
|
+
record.errors.add attribute, (options[:message] || I18n.t('errors.messages.subset'))
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
end
|
data/roqua-support.gemspec
CHANGED
|
@@ -18,12 +18,12 @@ Gem::Specification.new do |gem|
|
|
|
18
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
19
19
|
gem.require_paths = ["lib"]
|
|
20
20
|
|
|
21
|
-
gem.required_ruby_version = '>= 2.
|
|
22
|
-
gem.add_dependency 'active_interaction', '
|
|
23
|
-
gem.add_dependency 'activesupport', '>= 5.
|
|
21
|
+
gem.required_ruby_version = '>= 2.7'
|
|
22
|
+
gem.add_dependency 'active_interaction', '>= 3.0', '< 5.0'
|
|
23
|
+
gem.add_dependency 'activesupport', '>= 5.2', '< 6.2'
|
|
24
24
|
gem.add_dependency 'naught', '~> 1.0'
|
|
25
25
|
gem.add_dependency 'with_advisory_lock', '~> 3.2'
|
|
26
|
-
gem.add_dependency 'appsignal', '>= 2.9', '<
|
|
26
|
+
gem.add_dependency 'appsignal', '>= 2.9', '< 3.1'
|
|
27
27
|
|
|
28
28
|
gem.add_development_dependency 'bundler', '~> 2.0'
|
|
29
29
|
gem.add_development_dependency 'delayed_job_active_record'
|
|
@@ -11,8 +11,18 @@ describe Enumerable do
|
|
|
11
11
|
expect(input.sort_by_alphanum(&:reverse)).to eq ["004some10thing", "004some11thing", "3another"]
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
+
it 'treats non-alphanum as lower than alpha and num' do
|
|
15
|
+
input = %w[b3a b{c bԘb] # curlies are above alpha in utf-8, Ԙ is multi-byte
|
|
16
|
+
expect(input.sort_by_alphanum).to eq %w[b{c bԘb b3a]
|
|
17
|
+
end
|
|
18
|
+
|
|
14
19
|
it 'compares number chunks as integers' do
|
|
15
20
|
expect(%w(004 3).sort_by_alphanum).to eq %w(3 004)
|
|
16
21
|
end
|
|
22
|
+
|
|
23
|
+
it 'sorts identical integers by asci' do
|
|
24
|
+
input = %w[b4e b0004e b04e b004e]
|
|
25
|
+
expect(input.sort_by_alphanum).to eq %w[b0004e b004e b04e b4e]
|
|
26
|
+
end
|
|
17
27
|
end
|
|
18
28
|
end
|
|
@@ -27,6 +27,12 @@ Rspec.describe RoquaLoggingRailtie do
|
|
|
27
27
|
ActiveSupport::Logger.logger_outputs_to?(Roqua.logger.logger, STDOUT)
|
|
28
28
|
).to be_truthy
|
|
29
29
|
end
|
|
30
|
+
|
|
31
|
+
it 'logs using a datetimeformat including timezone' do
|
|
32
|
+
time = Time.zone.local(2021,10,10,16,13)
|
|
33
|
+
got = Roqua.logger.logger.formatter.call 'INFO', time, 'progname', '{}'
|
|
34
|
+
expect(got).to match(/I, \[2021-10-10T16:13:00.000\+0000 #\d+] INFO -- progname: {}/)
|
|
35
|
+
end
|
|
30
36
|
end
|
|
31
37
|
|
|
32
38
|
context 'when RAILS_LOG_TO_STDOUT_USING_ROQUA_LOGGER is blank' do
|
|
@@ -51,7 +51,7 @@ describe Roqua::Scheduling::Scheduler do
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
it 'generates a database specific advisory lock name' do
|
|
54
|
-
expect(ActiveRecord::Base.connection_config[:database]).to eql(':memory:')
|
|
54
|
+
# expect(ActiveRecord::Base.connection_config[:database]).to eql(':memory:')
|
|
55
55
|
expect(subject.advisory_lock_name).to eql ':memory:_cron_lock'
|
|
56
56
|
end
|
|
57
57
|
|
|
@@ -86,6 +86,7 @@ describe Roqua::Scheduling::Scheduler do
|
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
it 'counts task calls' do
|
|
89
|
+
expect(Appsignal).to receive(:increment_counter).with('scheduler.completed', 1)
|
|
89
90
|
expect(Appsignal).to receive(:increment_counter).with('scheduler.run_task.completed', 1, task_name: 'hourly')
|
|
90
91
|
subject.ping
|
|
91
92
|
end
|
|
@@ -106,16 +106,21 @@ describe 'Error reporting' do
|
|
|
106
106
|
end
|
|
107
107
|
|
|
108
108
|
it 'defaults to a background job' do
|
|
109
|
-
|
|
109
|
+
transaction = Appsignal::Transaction.new(SecureRandom.uuid, Appsignal::Transaction::FRONTEND, nil)
|
|
110
|
+
expect(Appsignal).to receive(:send_error).with(exception).and_yield(transaction)
|
|
110
111
|
Roqua::Support::Errors.report exception
|
|
112
|
+
expect(transaction.namespace).to eq Appsignal::Transaction::BACKGROUND_JOB
|
|
111
113
|
end
|
|
112
114
|
|
|
113
115
|
it 'it will send an error under the provided category' do
|
|
116
|
+
transaction = Appsignal::Transaction.new(SecureRandom.uuid, Appsignal::Transaction::FRONTEND, nil)
|
|
114
117
|
expect(Appsignal)
|
|
115
118
|
.to receive(:send_error)
|
|
116
|
-
.with(exception
|
|
119
|
+
.with(exception).and_yield(transaction)
|
|
117
120
|
|
|
118
121
|
Roqua::Support::Errors.report exception, a: 'b', namespace: :web
|
|
122
|
+
expect(transaction.namespace).to eq Appsignal::Transaction::HTTP_REQUEST
|
|
123
|
+
expect(transaction.tags).to eq a: 'b'
|
|
119
124
|
end
|
|
120
125
|
|
|
121
126
|
describe 'when a current transaction is present' do
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'roqua/type/stripped_string'
|
|
5
|
+
|
|
6
|
+
RSpec.describe Roqua::Type::StrippedString do
|
|
7
|
+
let(:cls) do
|
|
8
|
+
Class.new(ActiveRecord::Base) do
|
|
9
|
+
self.table_name = 'delayed_jobs'
|
|
10
|
+
|
|
11
|
+
attribute :locked_by, Roqua::Type::StrippedString.new
|
|
12
|
+
attribute :queue, Roqua::Type::StrippedString.new(allow_empty: true)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "strips whitespace from outside and not inside" do
|
|
17
|
+
expect(described_class.new.cast(" some name \n \t \u180E\u200B\u200C\u200D\u2060\uFEFF ")).to eq "some name"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "nils empty values by default" do
|
|
21
|
+
expect(described_class.new.cast(" \n \t ")).to eq nil
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "keeps value empty if allow_empty is true" do
|
|
25
|
+
expect(described_class.new(allow_empty: true).cast(" \n \t ")).to eq ""
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "works on active_record" do
|
|
29
|
+
instance = cls.new(locked_by: " \n \t ", queue: " \n \t ", cron: " \n \t ")
|
|
30
|
+
expect(instance.locked_by).to be_nil
|
|
31
|
+
expect(instance.queue).to eq ""
|
|
32
|
+
expect(instance.cron).to eq " \n \t "
|
|
33
|
+
end
|
|
34
|
+
end
|
metadata
CHANGED
|
@@ -1,49 +1,55 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: roqua-support
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Marten Veldthuis
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-01-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: active_interaction
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: '3.0'
|
|
20
|
+
- - "<"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '5.0'
|
|
20
23
|
type: :runtime
|
|
21
24
|
prerelease: false
|
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
26
|
requirements:
|
|
24
|
-
- - "
|
|
27
|
+
- - ">="
|
|
25
28
|
- !ruby/object:Gem::Version
|
|
26
29
|
version: '3.0'
|
|
30
|
+
- - "<"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '5.0'
|
|
27
33
|
- !ruby/object:Gem::Dependency
|
|
28
34
|
name: activesupport
|
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
|
30
36
|
requirements:
|
|
31
37
|
- - ">="
|
|
32
38
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '5.
|
|
39
|
+
version: '5.2'
|
|
34
40
|
- - "<"
|
|
35
41
|
- !ruby/object:Gem::Version
|
|
36
|
-
version: '6.
|
|
42
|
+
version: '6.2'
|
|
37
43
|
type: :runtime
|
|
38
44
|
prerelease: false
|
|
39
45
|
version_requirements: !ruby/object:Gem::Requirement
|
|
40
46
|
requirements:
|
|
41
47
|
- - ">="
|
|
42
48
|
- !ruby/object:Gem::Version
|
|
43
|
-
version: '5.
|
|
49
|
+
version: '5.2'
|
|
44
50
|
- - "<"
|
|
45
51
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: '6.
|
|
52
|
+
version: '6.2'
|
|
47
53
|
- !ruby/object:Gem::Dependency
|
|
48
54
|
name: naught
|
|
49
55
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -81,7 +87,7 @@ dependencies:
|
|
|
81
87
|
version: '2.9'
|
|
82
88
|
- - "<"
|
|
83
89
|
- !ruby/object:Gem::Version
|
|
84
|
-
version: '
|
|
90
|
+
version: '3.1'
|
|
85
91
|
type: :runtime
|
|
86
92
|
prerelease: false
|
|
87
93
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -91,7 +97,7 @@ dependencies:
|
|
|
91
97
|
version: '2.9'
|
|
92
98
|
- - "<"
|
|
93
99
|
- !ruby/object:Gem::Version
|
|
94
|
-
version: '
|
|
100
|
+
version: '3.1'
|
|
95
101
|
- !ruby/object:Gem::Dependency
|
|
96
102
|
name: bundler
|
|
97
103
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -188,9 +194,9 @@ files:
|
|
|
188
194
|
- README.md
|
|
189
195
|
- Rakefile
|
|
190
196
|
- circle.yml
|
|
191
|
-
- gemfiles/rails51.gemfile
|
|
192
197
|
- gemfiles/rails52.gemfile
|
|
193
198
|
- gemfiles/rails60.gemfile
|
|
199
|
+
- gemfiles/rails61.gemfile
|
|
194
200
|
- lib/roqua-support.rb
|
|
195
201
|
- lib/roqua-support/railtie.rb
|
|
196
202
|
- lib/roqua-support/version.rb
|
|
@@ -224,6 +230,8 @@ files:
|
|
|
224
230
|
- lib/roqua/support/request_logger.rb
|
|
225
231
|
- lib/roqua/support/stats.rb
|
|
226
232
|
- lib/roqua/support/stats/hosted_graphite_backend.rb
|
|
233
|
+
- lib/roqua/type.rb
|
|
234
|
+
- lib/roqua/type/stripped_string.rb
|
|
227
235
|
- lib/roqua/validators/subset_validator.rb
|
|
228
236
|
- roqua-support.gemspec
|
|
229
237
|
- spec/internal/config/balancer_state
|
|
@@ -250,6 +258,7 @@ files:
|
|
|
250
258
|
- spec/roqua/support/request_logger_spec.rb
|
|
251
259
|
- spec/roqua/support/stats_spec.rb
|
|
252
260
|
- spec/roqua/support_spec.rb
|
|
261
|
+
- spec/roqua/type/stripped_string_spec.rb
|
|
253
262
|
- spec/roqua/validators/subset_validator_spec.rb
|
|
254
263
|
- spec/spec_helper.rb
|
|
255
264
|
- styleguide/ruby/rubocop.yml
|
|
@@ -257,7 +266,7 @@ homepage: https://github.com/roqua/roqua-support
|
|
|
257
266
|
licenses:
|
|
258
267
|
- MIT
|
|
259
268
|
metadata: {}
|
|
260
|
-
post_install_message:
|
|
269
|
+
post_install_message:
|
|
261
270
|
rdoc_options: []
|
|
262
271
|
require_paths:
|
|
263
272
|
- lib
|
|
@@ -265,15 +274,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
265
274
|
requirements:
|
|
266
275
|
- - ">="
|
|
267
276
|
- !ruby/object:Gem::Version
|
|
268
|
-
version: '2.
|
|
277
|
+
version: '2.7'
|
|
269
278
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
270
279
|
requirements:
|
|
271
280
|
- - ">="
|
|
272
281
|
- !ruby/object:Gem::Version
|
|
273
282
|
version: '0'
|
|
274
283
|
requirements: []
|
|
275
|
-
rubygems_version: 3.
|
|
276
|
-
signing_key:
|
|
284
|
+
rubygems_version: 3.1.6
|
|
285
|
+
signing_key:
|
|
277
286
|
specification_version: 4
|
|
278
287
|
summary: Helper objects and proxies used by a lot of RoQua applications
|
|
279
288
|
test_files:
|
|
@@ -301,5 +310,6 @@ test_files:
|
|
|
301
310
|
- spec/roqua/support/request_logger_spec.rb
|
|
302
311
|
- spec/roqua/support/stats_spec.rb
|
|
303
312
|
- spec/roqua/support_spec.rb
|
|
313
|
+
- spec/roqua/type/stripped_string_spec.rb
|
|
304
314
|
- spec/roqua/validators/subset_validator_spec.rb
|
|
305
315
|
- spec/spec_helper.rb
|