waylon-core 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.roxanne.yml +4 -0
- data/.ruby-version +1 -1
- data/Gemfile.lock +37 -39
- data/README.md +1 -1
- data/lib/waylon/condition.rb +4 -1
- data/lib/waylon/conditions/regex.rb +3 -0
- data/lib/waylon/config.rb +1 -1
- data/lib/waylon/logger.rb +13 -6
- data/lib/waylon/message.rb +1 -0
- data/lib/waylon/rspec/test_server.rb +4 -1
- data/lib/waylon/rspec/test_user.rb +2 -2
- data/lib/waylon/skills/diagnostics.rb +4 -2
- data/lib/waylon/skills/groups.rb +7 -1
- data/lib/waylon/version.rb +1 -1
- data/scripts/release.sh +7 -0
- data/scripts/test.sh +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb29b523a0f093d01b8a9abdf5cd23d54b2815ae0430b81f8e670680959d02f6
|
4
|
+
data.tar.gz: 4c79ff418934e61e9063db9568d2397409117afd2a7519d9b4c9348233991667
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 505ad2082ae04e37478e03637b13952d81d8c26c9e8107eeded3b4247ae25f776f7d1d7d4a4fd0739edd670ba74256e33adbd22c6f46957f528c820ef371bfce
|
7
|
+
data.tar.gz: a9c1b1de874c75d7d909a83904e46360236334f652dae8ad059d5adf8b405315030245420dba3a8e159b21d99d221a502d30cfe439f2b2b77411ff06261af695
|
data/.roxanne.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.
|
1
|
+
3.1.2
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
waylon-core (0.1.
|
4
|
+
waylon-core (0.1.4)
|
5
5
|
addressable (~> 2.8)
|
6
6
|
faraday (~> 1.8)
|
7
7
|
i18n (~> 1.8)
|
@@ -16,10 +16,10 @@ GEM
|
|
16
16
|
addressable (2.8.0)
|
17
17
|
public_suffix (>= 2.0.2, < 5.0)
|
18
18
|
ast (2.4.2)
|
19
|
-
concurrent-ruby (1.1.
|
19
|
+
concurrent-ruby (1.1.10)
|
20
20
|
diff-lcs (1.5.0)
|
21
21
|
docile (1.4.0)
|
22
|
-
faraday (1.
|
22
|
+
faraday (1.10.0)
|
23
23
|
faraday-em_http (~> 1.0)
|
24
24
|
faraday-em_synchrony (~> 1.0)
|
25
25
|
faraday-excon (~> 1.1)
|
@@ -42,65 +42,64 @@ GEM
|
|
42
42
|
faraday-patron (1.0.0)
|
43
43
|
faraday-rack (1.0.0)
|
44
44
|
faraday-retry (1.0.3)
|
45
|
-
i18n (1.
|
45
|
+
i18n (1.10.0)
|
46
46
|
concurrent-ruby (~> 1.0)
|
47
|
-
json (2.6.
|
48
|
-
moneta (1.
|
47
|
+
json (2.6.2)
|
48
|
+
moneta (1.5.1)
|
49
49
|
mono_logger (1.1.1)
|
50
50
|
multi_json (1.15.0)
|
51
51
|
multipart-post (2.1.1)
|
52
52
|
mustermann (1.1.1)
|
53
53
|
ruby2_keywords (~> 0.0.1)
|
54
54
|
nio4r (2.5.8)
|
55
|
-
parallel (1.
|
56
|
-
parser (3.1.
|
55
|
+
parallel (1.22.1)
|
56
|
+
parser (3.1.2.0)
|
57
57
|
ast (~> 2.4.1)
|
58
|
-
public_suffix (4.0.
|
59
|
-
puma (5.6.
|
58
|
+
public_suffix (4.0.7)
|
59
|
+
puma (5.6.4)
|
60
60
|
nio4r (~> 2.0)
|
61
61
|
rack (2.2.3)
|
62
|
-
rack-protection (2.
|
62
|
+
rack-protection (2.2.0)
|
63
63
|
rack
|
64
64
|
rainbow (3.1.1)
|
65
65
|
rake (13.0.6)
|
66
|
-
redis (4.
|
67
|
-
redis-namespace (1.8.
|
66
|
+
redis (4.6.0)
|
67
|
+
redis-namespace (1.8.2)
|
68
68
|
redis (>= 3.0.4)
|
69
|
-
regexp_parser (2.
|
70
|
-
resque (2.2.
|
69
|
+
regexp_parser (2.4.0)
|
70
|
+
resque (2.2.1)
|
71
71
|
mono_logger (~> 1.0)
|
72
72
|
multi_json (~> 1.0)
|
73
73
|
redis-namespace (~> 1.6)
|
74
74
|
sinatra (>= 0.9.2)
|
75
|
-
vegas (~> 0.1.2)
|
76
75
|
rexml (3.2.5)
|
77
|
-
rspec (3.
|
78
|
-
rspec-core (~> 3.
|
79
|
-
rspec-expectations (~> 3.
|
80
|
-
rspec-mocks (~> 3.
|
81
|
-
rspec-core (3.
|
82
|
-
rspec-support (~> 3.
|
83
|
-
rspec-expectations (3.
|
76
|
+
rspec (3.11.0)
|
77
|
+
rspec-core (~> 3.11.0)
|
78
|
+
rspec-expectations (~> 3.11.0)
|
79
|
+
rspec-mocks (~> 3.11.0)
|
80
|
+
rspec-core (3.11.0)
|
81
|
+
rspec-support (~> 3.11.0)
|
82
|
+
rspec-expectations (3.11.0)
|
84
83
|
diff-lcs (>= 1.2.0, < 2.0)
|
85
|
-
rspec-support (~> 3.
|
86
|
-
rspec-mocks (3.
|
84
|
+
rspec-support (~> 3.11.0)
|
85
|
+
rspec-mocks (3.11.1)
|
87
86
|
diff-lcs (>= 1.2.0, < 2.0)
|
88
|
-
rspec-support (~> 3.
|
89
|
-
rspec-support (3.
|
90
|
-
rubocop (1.
|
87
|
+
rspec-support (~> 3.11.0)
|
88
|
+
rspec-support (3.11.0)
|
89
|
+
rubocop (1.29.1)
|
91
90
|
parallel (~> 1.10)
|
92
91
|
parser (>= 3.1.0.0)
|
93
92
|
rainbow (>= 2.2.2, < 4.0)
|
94
93
|
regexp_parser (>= 1.8, < 3.0)
|
95
|
-
rexml
|
96
|
-
rubocop-ast (>= 1.
|
94
|
+
rexml (>= 3.2.5, < 4.0)
|
95
|
+
rubocop-ast (>= 1.17.0, < 2.0)
|
97
96
|
ruby-progressbar (~> 1.7)
|
98
97
|
unicode-display_width (>= 1.4.0, < 3.0)
|
99
|
-
rubocop-ast (1.
|
100
|
-
parser (>= 3.
|
98
|
+
rubocop-ast (1.18.0)
|
99
|
+
parser (>= 3.1.1.0)
|
101
100
|
rubocop-rake (0.6.0)
|
102
101
|
rubocop (~> 1.0)
|
103
|
-
rubocop-rspec (2.
|
102
|
+
rubocop-rspec (2.11.1)
|
104
103
|
rubocop (~> 1.19)
|
105
104
|
ruby-progressbar (1.11.0)
|
106
105
|
ruby2_keywords (0.0.5)
|
@@ -109,22 +108,21 @@ GEM
|
|
109
108
|
simplecov-html (~> 0.11)
|
110
109
|
simplecov_json_formatter (~> 0.1)
|
111
110
|
simplecov-html (0.12.3)
|
112
|
-
simplecov_json_formatter (0.1.
|
113
|
-
sinatra (2.
|
111
|
+
simplecov_json_formatter (0.1.4)
|
112
|
+
sinatra (2.2.0)
|
114
113
|
mustermann (~> 1.0)
|
115
114
|
rack (~> 2.2)
|
116
|
-
rack-protection (= 2.
|
115
|
+
rack-protection (= 2.2.0)
|
117
116
|
tilt (~> 2.0)
|
118
117
|
tilt (2.0.10)
|
119
118
|
unicode-display_width (2.1.0)
|
120
|
-
vegas (0.1.11)
|
121
|
-
rack (>= 1.0.0)
|
122
119
|
webrick (1.7.0)
|
123
120
|
yard (0.9.27)
|
124
121
|
webrick (~> 1.7.0)
|
125
122
|
|
126
123
|
PLATFORMS
|
127
124
|
arm64-darwin-21
|
125
|
+
x86_64-linux
|
128
126
|
|
129
127
|
DEPENDENCIES
|
130
128
|
bundler (~> 2.3)
|
@@ -138,4 +136,4 @@ DEPENDENCIES
|
|
138
136
|
yard (~> 0.9, >= 0.9.27)
|
139
137
|
|
140
138
|
BUNDLED WITH
|
141
|
-
2.3.
|
139
|
+
2.3.10
|
data/README.md
CHANGED
@@ -44,7 +44,7 @@ Alone, this library isn't super useful for running a bot, but it does include a
|
|
44
44
|
|
45
45
|
## Development
|
46
46
|
|
47
|
-
Waylon's development pipeline makes heavy use of [RSpec](https://rspec.info/) for testing (and [SimpleCov](https://github.com/simplecov-ruby/simplecov) for reporting on coverage), [Rubocop](https://rubocop.org/) for linting/format checking, [YARD](https://yardoc.org/) for documentation, and [
|
47
|
+
Waylon's development pipeline makes heavy use of [RSpec](https://rspec.info/) for testing (and [SimpleCov](https://github.com/simplecov-ruby/simplecov) for reporting on coverage), [Rubocop](https://rubocop.org/) for linting/format checking, [YARD](https://yardoc.org/) for documentation, and [RoxanneCI](https://github.com/apps/roxanneci) for CI. Most of this is built-in and will work out-of-the-box for GitHub PRs.
|
48
48
|
|
49
49
|
To get started locally, after checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake` to run the tests and linting. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
50
50
|
|
data/lib/waylon/condition.rb
CHANGED
@@ -66,7 +66,10 @@ module Waylon
|
|
66
66
|
# @param message [Waylon::Message] The received message
|
67
67
|
# @return [Boolean]
|
68
68
|
def properly_mentions?(message)
|
69
|
-
|
69
|
+
return true unless mention_only?
|
70
|
+
|
71
|
+
message.to_bot?
|
72
|
+
# (mention_only? && message.to_bot?) || (!mention_only? && !message.to_bot?)
|
70
73
|
end
|
71
74
|
|
72
75
|
# Tokens is used to provide details about the message input to the action
|
@@ -18,6 +18,9 @@ module Waylon
|
|
18
18
|
@mechanism.match(input).to_a[1..]
|
19
19
|
end
|
20
20
|
|
21
|
+
# Provides the _named_ regular expression match groups as a hash
|
22
|
+
# @param input [String] The message text
|
23
|
+
# @return [Hash<Symbol,String>] The named regular expression match groups
|
21
24
|
def named_tokens(input)
|
22
25
|
match_data = @mechanism.match(input)
|
23
26
|
match_data.names.to_h { |n| [n.to_sym, match_data[n]] }
|
data/lib/waylon/config.rb
CHANGED
@@ -41,7 +41,7 @@ module Waylon
|
|
41
41
|
ENV.keys.grep(/CONF_/).each do |env_key|
|
42
42
|
conf_key = env_key.downcase.split("_")[1..].join(".")
|
43
43
|
::Waylon::Logger.log("Attempting to set #{conf_key} from #{env_key}", :debug)
|
44
|
-
self[conf_key] = ENV
|
44
|
+
self[conf_key] = ENV.fetch(env_key, nil)
|
45
45
|
end
|
46
46
|
true
|
47
47
|
end
|
data/lib/waylon/logger.rb
CHANGED
@@ -19,12 +19,18 @@ module Waylon
|
|
19
19
|
# Provides an easy way to access the underlying logger
|
20
20
|
# @return [Logger] The Logger instance
|
21
21
|
def self.logger
|
22
|
-
|
22
|
+
@logger ||= json_logger
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.logger=(logger)
|
26
|
+
@logger = logger
|
27
|
+
end
|
23
28
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
29
|
+
def self.json_logger
|
30
|
+
a_logger = ::Logger.new($stderr)
|
31
|
+
a_logger.level = level
|
32
|
+
a_logger.progname = "Waylon"
|
33
|
+
a_logger.formatter = proc do |severity, datetime, progname, msg|
|
28
34
|
json_data = JSON.dump(
|
29
35
|
ts: datetime,
|
30
36
|
severity: severity.ljust(5).to_s,
|
@@ -35,7 +41,8 @@ module Waylon
|
|
35
41
|
)
|
36
42
|
"#{json_data}\n"
|
37
43
|
end
|
38
|
-
|
44
|
+
|
45
|
+
a_logger
|
39
46
|
end
|
40
47
|
end
|
41
48
|
end
|
data/lib/waylon/message.rb
CHANGED
@@ -41,7 +41,10 @@ end
|
|
41
41
|
Waylon::RSpec::TestChannel.find_or_create("random")
|
42
42
|
|
43
43
|
# Load demo skills here
|
44
|
+
require "waylon/skills/diagnostics"
|
44
45
|
require "waylon/skills/fun"
|
46
|
+
require "waylon/skills/groups"
|
47
|
+
require "waylon/skills/help"
|
45
48
|
|
46
49
|
# Handle demo chat REPL
|
47
50
|
def adminuser
|
@@ -101,7 +104,7 @@ def handle_input(body, from: this_user, privately: true)
|
|
101
104
|
else
|
102
105
|
message_count = Waylon::RSpec::TestSense.sent_messages.size
|
103
106
|
|
104
|
-
Waylon::RSpec::TestSense.
|
107
|
+
Waylon::RSpec::TestSense.perform(msg_details(body, from, privately))
|
105
108
|
Waylon::RSpec::TestWorker.handle(Waylon::RSpec::TestSense.fake_queue)
|
106
109
|
result = Waylon::RSpec::TestSense.sent_messages[message_count..].join("\n")
|
107
110
|
puts("(@#{Waylon::RSpec::TestUser.whoami.handle}) >> #{result}")
|
@@ -147,8 +147,8 @@ module Waylon
|
|
147
147
|
# @api private
|
148
148
|
# @return [String] A generated email address
|
149
149
|
def self.email_from_name(name)
|
150
|
-
if ENV
|
151
|
-
ENV
|
150
|
+
if ENV.fetch("USER_EMAIL", nil) && name == "homer.simpson"
|
151
|
+
ENV.fetch("USER_EMAIL", nil)
|
152
152
|
else
|
153
153
|
"#{name.downcase.gsub(/[\s_-]/, ".")}@example.com"
|
154
154
|
end
|
@@ -27,8 +27,10 @@ module Waylon
|
|
27
27
|
response << " - *Test Result:* #{state ? "Success" : "Error"}"
|
28
28
|
response << " - *Read time:* #{read_time}s"
|
29
29
|
response << " - *Write time:* #{write_time}s"
|
30
|
-
|
31
|
-
|
30
|
+
if Resque.redis.connected?
|
31
|
+
response << "*Queue Monitoring:*"
|
32
|
+
response << " - Failed jobs: #{Resque::Failure.count}"
|
33
|
+
end
|
32
34
|
|
33
35
|
reply response.join("\n")
|
34
36
|
end
|
data/lib/waylon/skills/groups.rb
CHANGED
@@ -146,7 +146,13 @@ module Waylon
|
|
146
146
|
private
|
147
147
|
|
148
148
|
def all_group_keys
|
149
|
-
db.adapter.
|
149
|
+
if db.adapter.instance_of?(Moneta::Adapters::Redis)
|
150
|
+
db.adapter.backend.keys("groups.*")
|
151
|
+
else
|
152
|
+
groups = []
|
153
|
+
db.each_key { |key| groups << key if key.start_with?("groups.") }
|
154
|
+
groups
|
155
|
+
end
|
150
156
|
end
|
151
157
|
|
152
158
|
def found_user(user_string)
|
data/lib/waylon/version.rb
CHANGED
data/scripts/release.sh
ADDED
data/scripts/test.sh
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: waylon-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Gnagy
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02
|
11
|
+
date: 2022-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -288,6 +288,7 @@ files:
|
|
288
288
|
- lib/waylon/version.rb
|
289
289
|
- lib/waylon/webhook.rb
|
290
290
|
- lib/waylon/webhook_registry.rb
|
291
|
+
- scripts/release.sh
|
291
292
|
- scripts/test.sh
|
292
293
|
- waylon-core.gemspec
|
293
294
|
homepage: https://github.com/jgnagy/waylon-core
|
@@ -297,7 +298,7 @@ metadata:
|
|
297
298
|
homepage_uri: https://github.com/jgnagy/waylon-core
|
298
299
|
source_code_uri: https://github.com/jgnagy/waylon-core
|
299
300
|
changelog_uri: https://github.com/jgnagy/waylon-core/blob/main/CHANGELOG.md
|
300
|
-
post_install_message:
|
301
|
+
post_install_message:
|
301
302
|
rdoc_options: []
|
302
303
|
require_paths:
|
303
304
|
- lib
|
@@ -312,8 +313,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
312
313
|
- !ruby/object:Gem::Version
|
313
314
|
version: '0'
|
314
315
|
requirements: []
|
315
|
-
rubygems_version: 3.3.
|
316
|
-
signing_key:
|
316
|
+
rubygems_version: 3.3.7
|
317
|
+
signing_key:
|
317
318
|
specification_version: 4
|
318
319
|
summary: Core library for the Waylon bot framework
|
319
320
|
test_files: []
|