ruboty 1.2.1 → 1.3.1
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 +5 -5
- data/.travis.yml +1 -1
- data/CHANGELOG.md +61 -0
- data/README.md +36 -23
- data/lib/ruboty.rb +2 -2
- data/lib/ruboty/action.rb +1 -1
- data/lib/ruboty/actions/help.rb +8 -3
- data/lib/ruboty/adapters/shell.rb +2 -2
- data/lib/ruboty/command_builder.rb +3 -0
- data/lib/ruboty/robot.rb +14 -0
- data/lib/ruboty/version.rb +1 -1
- data/ruboty.gemspec +3 -2
- data/spec/ruboty/adapter_builder_spec.rb +2 -2
- data/spec/ruboty/adapters/shell_spec.rb +17 -9
- data/spec/ruboty/commands/generate_spec.rb +2 -2
- data/spec/ruboty/commands/run_spec.rb +1 -1
- data/spec/ruboty/env/validatable_spec.rb +2 -2
- data/spec/ruboty/handlers/base_spec.rb +1 -1
- data/spec/ruboty/handlers/help_spec.rb +2 -2
- data/spec/ruboty/handlers/ping_spec.rb +1 -1
- data/spec/ruboty/handlers/whoami_spec.rb +1 -1
- data/spec/ruboty/robot_spec.rb +3 -3
- data/spec/spec_helper.rb +0 -6
- metadata +6 -23
- data/lib/ruboty/logger.rb +0 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: ec54bcc0403dac7136b366e3a6e2ab709c763aef91b459ae1f2f2ecc2e3324dc
|
|
4
|
+
data.tar.gz: cc0cb0a79dbe93896e854ba66971aed2e5b001010263561835d46a5550d88933
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 347f987239002a95e7dc94c19358cd187aafbfb07a59dba0e6c0f04f989752041f01b4fa9891e3e2e63827339caa93ff33ec4776d32d61047a325c9a2c93c2cf
|
|
7
|
+
data.tar.gz: 646abd7e05b42051e27201a818c9e80b0c2a0285daf35d11923adfc94da08f0a3fc4c2a69ad06e02a28ac88ed4dd9f30380c91ac7661af2cec4b07de4f78fbec
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,124 +1,185 @@
|
|
|
1
|
+
## 1.3.1
|
|
2
|
+
|
|
3
|
+
- Support unicode spaces like U+00a0 (thx @sugi)
|
|
4
|
+
|
|
5
|
+
## 1.3.0
|
|
6
|
+
|
|
7
|
+
- Add --daemonize option
|
|
8
|
+
- Add --pid option
|
|
9
|
+
- Require Ruby 2.2.2 or later for ActiveSupport
|
|
10
|
+
|
|
11
|
+
## 1.2.4
|
|
12
|
+
|
|
13
|
+
- Improve help command output (thx @k0kubun)
|
|
14
|
+
|
|
15
|
+
## 1.2.3
|
|
16
|
+
|
|
17
|
+
- User default Logger class (thx @eagletmt)
|
|
18
|
+
|
|
19
|
+
## 1.2.2
|
|
20
|
+
|
|
21
|
+
- Support ^D on shell adapter (thx @suu-g)
|
|
22
|
+
|
|
1
23
|
## 1.2.1
|
|
24
|
+
|
|
2
25
|
- Refer Bundler from top-level
|
|
3
26
|
|
|
4
27
|
## 1.2.0
|
|
28
|
+
|
|
5
29
|
- Add DISABLE_DEFAULT_HANDLERS env
|
|
6
30
|
- Get away from help message indentation
|
|
7
31
|
- Support filter query on help handler (e.g. `@ruboty help ping`)
|
|
8
32
|
|
|
9
33
|
## 1.1.9
|
|
34
|
+
|
|
10
35
|
- Support slop both version 3 and 4
|
|
11
36
|
|
|
12
37
|
## 1.1.8
|
|
38
|
+
|
|
13
39
|
- Fix shell adapter
|
|
14
40
|
|
|
15
41
|
## 1.1.7
|
|
42
|
+
|
|
16
43
|
- Enable sync option of stdout to prevent buffering
|
|
17
44
|
|
|
18
45
|
## 1.1.6
|
|
46
|
+
|
|
19
47
|
- Add LOG_LEVEL env
|
|
20
48
|
|
|
21
49
|
## 1.1.5
|
|
50
|
+
|
|
22
51
|
- Use slop version 4 or higher
|
|
23
52
|
- Fix --load option (thx @amacou)
|
|
24
53
|
|
|
25
54
|
## 1.1.4
|
|
55
|
+
|
|
26
56
|
- Support slop version 4
|
|
27
57
|
|
|
28
58
|
## 1.1.3
|
|
59
|
+
|
|
29
60
|
- Fix slop version (thx @parroty)
|
|
30
61
|
|
|
31
62
|
## 1.1.2
|
|
63
|
+
|
|
32
64
|
- Fix message matching pattern so that "rubotyping" is not responded
|
|
33
65
|
|
|
34
66
|
## 1.1.1
|
|
67
|
+
|
|
35
68
|
- Use action's returned-value to check if :missing action is invoked or not
|
|
36
69
|
|
|
37
70
|
## 1.1.0
|
|
71
|
+
|
|
38
72
|
- Add :missing option for handler to respond with messages that didn't match any handlers
|
|
39
73
|
|
|
40
74
|
## 1.0.4
|
|
75
|
+
|
|
41
76
|
- Support RUBOTY_NAME and obsolete ROBOT_NAME
|
|
42
77
|
|
|
43
78
|
## 1.0.3
|
|
79
|
+
|
|
44
80
|
- Fix help handler
|
|
45
81
|
|
|
46
82
|
## 1.0.2
|
|
83
|
+
|
|
47
84
|
- Add RUBOTY_ENV to change bundled gems with environment
|
|
48
85
|
|
|
49
86
|
## 1.0.1
|
|
87
|
+
|
|
50
88
|
- Ignore if no Gemfile found in current directory or given path
|
|
51
89
|
|
|
52
90
|
## 1.0.0
|
|
91
|
+
|
|
53
92
|
- Rename: Ellen -> Ruboty
|
|
54
93
|
|
|
55
94
|
## 0.2.8
|
|
95
|
+
|
|
56
96
|
- Use Ruboty::Message#from_name in whoami action
|
|
57
97
|
|
|
58
98
|
## 0.2.7
|
|
99
|
+
|
|
59
100
|
- Add Ruboty::Message#from_name for rich chat service
|
|
60
101
|
|
|
61
102
|
## 0.2.6
|
|
103
|
+
|
|
62
104
|
- Add `who am i?` handler
|
|
63
105
|
- Sort commands in help message
|
|
64
106
|
|
|
65
107
|
## 0.2.5
|
|
108
|
+
|
|
66
109
|
- Hide action defined with `:hidden` option in Help message
|
|
67
110
|
|
|
68
111
|
## 0.2.4
|
|
112
|
+
|
|
69
113
|
- Reveal message prefix pattern as a class method
|
|
70
114
|
|
|
71
115
|
## 0.2.3
|
|
116
|
+
|
|
72
117
|
- Help message is formatted if adapter supported
|
|
73
118
|
|
|
74
119
|
## 0.2.2
|
|
120
|
+
|
|
75
121
|
- Now `Ruboty::Robot#say(message)` can use `message[:original]`
|
|
76
122
|
|
|
77
123
|
## 0.2.1
|
|
124
|
+
|
|
78
125
|
- Store shell history in ~/.ruboty_history
|
|
79
126
|
|
|
80
127
|
## 0.2.0
|
|
128
|
+
|
|
81
129
|
- Change adapter & message interface
|
|
82
130
|
|
|
83
131
|
## 0.1.3
|
|
132
|
+
|
|
84
133
|
- Change Ruboty::Message interface
|
|
85
134
|
|
|
86
135
|
## 0.1.2
|
|
136
|
+
|
|
87
137
|
- Make Handler validatable
|
|
88
138
|
|
|
89
139
|
## 0.1.1
|
|
140
|
+
|
|
90
141
|
- Improve Brain interface
|
|
91
142
|
|
|
92
143
|
## 0.1.0
|
|
144
|
+
|
|
93
145
|
- Deprecate --adapter option
|
|
94
146
|
|
|
95
147
|
## 0.0.9
|
|
148
|
+
|
|
96
149
|
- Adapt mention name to `@<name>: <text>` format
|
|
97
150
|
|
|
98
151
|
## 0.0.8
|
|
152
|
+
|
|
99
153
|
- Mount Brain
|
|
100
154
|
- Change handler interface
|
|
101
155
|
|
|
102
156
|
## 0.0.7
|
|
157
|
+
|
|
103
158
|
- Add PING handler
|
|
104
159
|
|
|
105
160
|
## 0.0.6
|
|
161
|
+
|
|
106
162
|
- `ruboty help` to show actions list
|
|
107
163
|
|
|
108
164
|
## 0.0.5
|
|
165
|
+
|
|
109
166
|
- Now Action can access to MatchData object via Message
|
|
110
167
|
- ENV["ROBOT_NAME"] or "ruboty" is default name
|
|
111
168
|
- Robot only responds to mention unless :all option specified
|
|
112
169
|
|
|
113
170
|
## 0.0.4
|
|
171
|
+
|
|
114
172
|
- Add --dotenv option to load .env before running
|
|
115
173
|
|
|
116
174
|
## 0.0.3
|
|
175
|
+
|
|
117
176
|
- Add env DSL to define adapter
|
|
118
177
|
|
|
119
178
|
## 0.0.2
|
|
179
|
+
|
|
120
180
|
- Add Handler DSL Syntax
|
|
121
181
|
- Add --load option to load a ruby file before running
|
|
122
182
|
|
|
123
183
|
## 0.0.1
|
|
184
|
+
|
|
124
185
|
- 1st release
|
data/README.md
CHANGED
|
@@ -1,44 +1,55 @@
|
|
|
1
|
-
# Ruboty
|
|
1
|
+
# Ruboty
|
|
2
|
+
|
|
3
|
+
[](https://rubygems.org/gems/ruboty)
|
|
4
|
+
[](https://travis-ci.org/r7kamura/ruboty)
|
|
2
5
|
|
|
3
6
|
Ruby + Bot = Ruboty.
|
|
4
7
|
|
|
5
8
|
## Dependencies
|
|
6
|
-
|
|
9
|
+
|
|
10
|
+
- Ruby 2.2.2
|
|
7
11
|
|
|
8
12
|
## Adapter
|
|
9
|
-
Adapter hooks up your robot to chat services.
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
Adapter hooks up ruboty to chat services.
|
|
15
|
+
|
|
16
|
+
- Slack
|
|
17
|
+
- [ruboty-slack](https://github.com/r7kamura/ruboty-slack) (XMPP gateway)
|
|
18
|
+
- [ruboty-slack_rtm](https://github.com/rosylilly/ruboty-slack_rtm) (Bot RTM API)
|
|
19
|
+
- [ruboty-twitter](https://github.com/r7kamura/ruboty-twitter)
|
|
20
|
+
- [ruboty-hipchat](https://github.com/r7kamura/ruboty-hipchat)
|
|
21
|
+
- [ruboty-idobata](https://github.com/hanachin/ruboty-idobata)
|
|
22
|
+
- [ruboty-chatwork](https://github.com/mhag/ruboty-chatwork)
|
|
23
|
+
- [ruboty-discord](https://github.com/ykzts/ruboty-discord)
|
|
15
24
|
|
|
16
25
|
## Brain
|
|
17
|
-
Brain persists your robot's memory.
|
|
18
26
|
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
Brain persists memories.
|
|
28
|
+
|
|
29
|
+
- [ruboty-leveldb](https://github.com/nownabe/ruboty-leveldb)
|
|
30
|
+
- [ruboty-redis](https://github.com/r7kamura/ruboty-redis)
|
|
21
31
|
|
|
22
32
|
## Handler
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
|
|
34
|
+
Handler provides various behaviors.
|
|
35
|
+
|
|
36
|
+
- [ruboty-alias](https://github.com/r7kamura/ruboty-alias)
|
|
37
|
+
- [ruboty-cron](https://github.com/r7kamura/ruboty-cron)
|
|
38
|
+
- [ruboty-echo](https://github.com/taiki45/ruboty-echo)
|
|
39
|
+
- [ruboty-github](https://github.com/r7kamura/ruboty-github)
|
|
40
|
+
- [ruboty-google_image](https://github.com/r7kamura/ruboty-google_image)
|
|
41
|
+
- [ruboty-kokodeikku](https://github.com/r7kamura/ruboty-kokodeikku)
|
|
42
|
+
- [ruboty-lgtm](https://github.com/negipo/ruboty-lgtm)
|
|
43
|
+
- [ruboty-syoboi_calendar](https://github.com/r7kamura/ruboty-syoboi_calendar)
|
|
44
|
+
- [ruboty-talk](https://github.com/r7kamura/ruboty-talk)
|
|
35
45
|
|
|
36
46
|
[Other plugins are hosted on Rubygems.](https://rubygems.org/search?utf8=%E2%9C%93&query=ruboty-)
|
|
37
47
|
|
|
38
48
|
## Configuration
|
|
49
|
+
|
|
39
50
|
Store configuration value in envorinment variables.
|
|
40
51
|
They are easy to change between deploys without changing any code.
|
|
41
|
-
We recommend to put `.env` and run with `ruboty --dotenv` option to manage them.
|
|
52
|
+
We recommend to put `.env` and run with `ruboty --dotenv` option to manage them .
|
|
42
53
|
|
|
43
54
|
All you need to use your favorite plugins is to write their names into Gemfile.
|
|
44
55
|
Ruboty will load them before running.
|
|
@@ -52,6 +63,7 @@ gem "ruboty-slack"
|
|
|
52
63
|
```
|
|
53
64
|
|
|
54
65
|
## ENV
|
|
66
|
+
|
|
55
67
|
```
|
|
56
68
|
DISABLE_DEFAULT_HANDLERS - Pass 1 to disable default handlers (default: nil)
|
|
57
69
|
LOG_LEVEL - Log level for debug (default: 3)
|
|
@@ -60,6 +72,7 @@ RUBOTY_NAME - Name to respond to mention (default: ruboty)
|
|
|
60
72
|
```
|
|
61
73
|
|
|
62
74
|
## Deploy
|
|
75
|
+
|
|
63
76
|
See [r7kamura/ruboty-template](https://github.com/r7kamura/ruboty-template) for example.
|
|
64
77
|
|
|
65
78
|
[](https://heroku.com/deploy?template=https://github.com/r7kamura/ruboty-template)
|
data/lib/ruboty.rb
CHANGED
|
@@ -3,6 +3,7 @@ require "active_support/core_ext/module/delegation"
|
|
|
3
3
|
require "active_support/core_ext/string/inflections"
|
|
4
4
|
require "bundler"
|
|
5
5
|
require "dotenv"
|
|
6
|
+
require "logger"
|
|
6
7
|
require "mem"
|
|
7
8
|
require "slop"
|
|
8
9
|
|
|
@@ -13,7 +14,7 @@ module Ruboty
|
|
|
13
14
|
def logger
|
|
14
15
|
@logger ||= begin
|
|
15
16
|
$stdout.sync = true
|
|
16
|
-
logger =
|
|
17
|
+
logger = Logger.new($stdout)
|
|
17
18
|
logger.level = ENV["LOG_LEVEL"] ? ENV["LOG_LEVEL"].to_i : Logger::INFO
|
|
18
19
|
logger
|
|
19
20
|
end
|
|
@@ -55,7 +56,6 @@ require "ruboty/commands/generate"
|
|
|
55
56
|
require "ruboty/commands/help"
|
|
56
57
|
require "ruboty/commands/run"
|
|
57
58
|
require "ruboty/handlers/base"
|
|
58
|
-
require "ruboty/logger"
|
|
59
59
|
require "ruboty/message"
|
|
60
60
|
require "ruboty/robot"
|
|
61
61
|
require "ruboty/version"
|
data/lib/ruboty/action.rb
CHANGED
data/lib/ruboty/actions/help.rb
CHANGED
|
@@ -2,19 +2,24 @@ module Ruboty
|
|
|
2
2
|
module Actions
|
|
3
3
|
class Help < Base
|
|
4
4
|
def call
|
|
5
|
-
|
|
5
|
+
descriptions = filtered_descriptions
|
|
6
|
+
if descriptions.empty?
|
|
7
|
+
message.reply("No description matched to '#{message[:filter]}'")
|
|
8
|
+
else
|
|
9
|
+
message.reply(descriptions.join("\n"), code: true)
|
|
10
|
+
end
|
|
6
11
|
end
|
|
7
12
|
|
|
8
13
|
private
|
|
9
14
|
|
|
10
|
-
def
|
|
15
|
+
def filtered_descriptions
|
|
11
16
|
descriptions = all_descriptions
|
|
12
17
|
if message[:filter]
|
|
13
18
|
descriptions.select! do |description|
|
|
14
19
|
description.include?(message[:filter])
|
|
15
20
|
end
|
|
16
21
|
end
|
|
17
|
-
descriptions
|
|
22
|
+
descriptions
|
|
18
23
|
end
|
|
19
24
|
|
|
20
25
|
def all_descriptions
|
|
@@ -28,7 +28,7 @@ module Ruboty
|
|
|
28
28
|
private
|
|
29
29
|
|
|
30
30
|
def explain
|
|
31
|
-
|
|
31
|
+
puts USAGE
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
def read
|
|
@@ -45,7 +45,7 @@ module Ruboty
|
|
|
45
45
|
|
|
46
46
|
def step
|
|
47
47
|
case body = read
|
|
48
|
-
when "exit", "quit"
|
|
48
|
+
when "exit", "quit", nil
|
|
49
49
|
stop
|
|
50
50
|
else
|
|
51
51
|
robot.receive(body: body, source: SOURCE)
|
|
@@ -27,13 +27,16 @@ module Ruboty
|
|
|
27
27
|
|
|
28
28
|
def options
|
|
29
29
|
Slop.parse(arguments) do |options|
|
|
30
|
+
options.on("--daemon", "Run as a daemon.")
|
|
30
31
|
options.on("--dotenv", "Load .env before running.")
|
|
31
32
|
options.on("-g", "--generate", "Generate a new chatterbot with ./ruboty/ directory if specified.")
|
|
32
33
|
options.on("-h", "--help", "Display this help message.")
|
|
33
34
|
if Slop::VERSION >= "4.0.0"
|
|
34
35
|
options.string("-l", "--load", "Load a ruby file before running.")
|
|
36
|
+
options.string("--pid", "Write the PID to a file.")
|
|
35
37
|
else
|
|
36
38
|
options.on("-l", "--load=", "Load a ruby file before running.")
|
|
39
|
+
options.on("--pid=", "Write the PID to a file.")
|
|
37
40
|
end
|
|
38
41
|
end
|
|
39
42
|
end
|
data/lib/ruboty/robot.rb
CHANGED
|
@@ -14,9 +14,11 @@ module Ruboty
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def run
|
|
17
|
+
daemon
|
|
17
18
|
dotenv
|
|
18
19
|
bundle
|
|
19
20
|
setup
|
|
21
|
+
pid
|
|
20
22
|
remember
|
|
21
23
|
handle
|
|
22
24
|
adapt
|
|
@@ -69,6 +71,10 @@ module Ruboty
|
|
|
69
71
|
end
|
|
70
72
|
memoize :env
|
|
71
73
|
|
|
74
|
+
def daemon
|
|
75
|
+
Process.daemon(true, false) if options[:daemon]
|
|
76
|
+
end
|
|
77
|
+
|
|
72
78
|
def dotenv
|
|
73
79
|
Dotenv.load if options[:dotenv]
|
|
74
80
|
end
|
|
@@ -89,5 +95,13 @@ module Ruboty
|
|
|
89
95
|
def handle
|
|
90
96
|
handlers
|
|
91
97
|
end
|
|
98
|
+
|
|
99
|
+
def pid
|
|
100
|
+
path = options[:pid]
|
|
101
|
+
if path
|
|
102
|
+
File.open(path, "w") { |f| f.write(Process.pid) }
|
|
103
|
+
at_exit { File.unlink(path) }
|
|
104
|
+
end
|
|
105
|
+
end
|
|
92
106
|
end
|
|
93
107
|
end
|
data/lib/ruboty/version.rb
CHANGED
data/ruboty.gemspec
CHANGED
|
@@ -16,13 +16,14 @@ Gem::Specification.new do |spec|
|
|
|
16
16
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
17
17
|
spec.require_paths = ["lib"]
|
|
18
18
|
|
|
19
|
+
spec.required_ruby_version = ">= 2.2.2"
|
|
20
|
+
|
|
19
21
|
spec.add_dependency "activesupport"
|
|
20
22
|
spec.add_dependency "bundler"
|
|
21
23
|
spec.add_dependency "dotenv"
|
|
22
24
|
spec.add_dependency "mem"
|
|
23
25
|
spec.add_dependency "slop"
|
|
24
|
-
spec.add_development_dependency "codeclimate-test-reporter", ">= 0.3.0"
|
|
25
26
|
spec.add_development_dependency "rake"
|
|
26
|
-
spec.add_development_dependency "rspec", "
|
|
27
|
+
spec.add_development_dependency "rspec", "3.4.0"
|
|
27
28
|
spec.add_development_dependency "simplecov"
|
|
28
29
|
end
|
|
@@ -12,7 +12,7 @@ describe Ruboty::AdapterBuilder do
|
|
|
12
12
|
describe "#build" do
|
|
13
13
|
context "with no other adapter class definition" do
|
|
14
14
|
it "returns a Ruboty::Adapters::Shell as a default adapter" do
|
|
15
|
-
builder.build.
|
|
15
|
+
expect(builder.build).to be_a Ruboty::Adapters::Shell
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|
|
@@ -29,7 +29,7 @@ describe Ruboty::AdapterBuilder do
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
it "returns an instance of that adapter class" do
|
|
32
|
-
builder.build.
|
|
32
|
+
expect(builder.build).to be_a another_adapter_class
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
end
|
|
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
|
2
2
|
|
|
3
3
|
describe Ruboty::Adapters::Shell do
|
|
4
4
|
before do
|
|
5
|
-
Ruboty.logger.
|
|
5
|
+
allow(Ruboty.logger).to receive(:info)
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
let(:adapter) do
|
|
@@ -16,32 +16,40 @@ describe Ruboty::Adapters::Shell do
|
|
|
16
16
|
describe "#run" do
|
|
17
17
|
context "with `exit`" do
|
|
18
18
|
it "stops" do
|
|
19
|
-
Readline.
|
|
20
|
-
adapter.
|
|
19
|
+
allow(Readline).to receive(:readline).and_return("exit")
|
|
20
|
+
expect(adapter).to receive(:stop).and_call_original
|
|
21
21
|
adapter.run
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
context "with `quit`" do
|
|
26
26
|
it "stops" do
|
|
27
|
-
Readline.
|
|
28
|
-
adapter.
|
|
27
|
+
allow(Readline).to receive(:readline).and_return("quit")
|
|
28
|
+
expect(adapter).to receive(:stop).and_call_original
|
|
29
|
+
adapter.run
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
context "with EOF" do
|
|
34
|
+
it "stops" do
|
|
35
|
+
allow(Readline).to receive(:readline).and_return(nil)
|
|
36
|
+
expect(adapter).to receive(:stop).and_call_original
|
|
29
37
|
adapter.run
|
|
30
38
|
end
|
|
31
39
|
end
|
|
32
40
|
|
|
33
41
|
context "with Inturrupt from console" do
|
|
34
42
|
it "stops" do
|
|
35
|
-
Readline.
|
|
36
|
-
adapter.
|
|
43
|
+
allow(Readline).to receive(:readline).and_raise(Interrupt)
|
|
44
|
+
expect(adapter).to receive(:stop).and_call_original
|
|
37
45
|
adapter.run
|
|
38
46
|
end
|
|
39
47
|
end
|
|
40
48
|
|
|
41
49
|
context "without `exit` nor `quit`" do
|
|
42
50
|
it "passes given message to robot" do
|
|
43
|
-
Readline.
|
|
44
|
-
robot.
|
|
51
|
+
allow(Readline).to receive(:readline).and_return("a", "exit")
|
|
52
|
+
expect(robot).to receive(:receive).with(body: "a", source: described_class::SOURCE)
|
|
45
53
|
adapter.run
|
|
46
54
|
end
|
|
47
55
|
end
|
|
@@ -21,7 +21,7 @@ describe Ruboty::Commands::Generate do
|
|
|
21
21
|
context "with normal condition" do
|
|
22
22
|
it "generates ./ruboty/ directory from our templates" do
|
|
23
23
|
call
|
|
24
|
-
File.
|
|
24
|
+
expect(File).to be_exist("./ruboty/")
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
@@ -31,7 +31,7 @@ describe Ruboty::Commands::Generate do
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
it "exits process with dying message" do
|
|
34
|
-
Ruboty.logger.
|
|
34
|
+
expect(Ruboty.logger).to receive(:error).with("Error: ./ruboty/ already exists.")
|
|
35
35
|
expect { call }.to raise_error(SystemExit)
|
|
36
36
|
end
|
|
37
37
|
end
|
|
@@ -39,8 +39,8 @@ describe Ruboty::Env::Validatable do
|
|
|
39
39
|
describe "#validate!" do
|
|
40
40
|
context "without required ENV" do
|
|
41
41
|
it "dies with usage as erorr message" do
|
|
42
|
-
Ruboty.logger.
|
|
43
|
-
Ruboty.
|
|
42
|
+
expect(Ruboty.logger).to receive(:error).with(/description of A/)
|
|
43
|
+
expect(Ruboty).to receive(:exit)
|
|
44
44
|
instance.validate!
|
|
45
45
|
end
|
|
46
46
|
end
|
|
@@ -24,7 +24,7 @@ describe Ruboty::Handlers::Help do
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
it "responds to `@ruboty help` and says each handler's description" do
|
|
27
|
-
robot.
|
|
27
|
+
expect(robot).to receive(:say).with(
|
|
28
28
|
body: body,
|
|
29
29
|
code: true,
|
|
30
30
|
from: to,
|
|
@@ -42,7 +42,7 @@ describe Ruboty::Handlers::Help do
|
|
|
42
42
|
|
|
43
43
|
context "with filter" do
|
|
44
44
|
it "filters descriptions by given filter" do
|
|
45
|
-
robot.
|
|
45
|
+
expect(robot).to receive(:say).with(
|
|
46
46
|
hash_including(
|
|
47
47
|
body: "ruboty /ping\\z/i - Return PONG to PING",
|
|
48
48
|
),
|
data/spec/ruboty/robot_spec.rb
CHANGED
|
@@ -12,12 +12,12 @@ describe Ruboty::Robot do
|
|
|
12
12
|
describe "#brain" do
|
|
13
13
|
context "without any Brain class" do
|
|
14
14
|
it "returns a Ruboty::Brains::Memory" do
|
|
15
|
-
instance.brain.
|
|
15
|
+
expect(instance.brain).to be_a Ruboty::Brains::Memory
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
it "can be used as a Hash object" do
|
|
19
19
|
instance.brain.data["a"] = 1
|
|
20
|
-
instance.brain.data["a"].
|
|
20
|
+
expect(instance.brain.data["a"]).to eq 1
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
|
|
@@ -31,7 +31,7 @@ describe Ruboty::Robot do
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
it "returns its instance as a Brain" do
|
|
34
|
-
instance.brain.
|
|
34
|
+
expect(instance.brain).to be_a another_brain_class
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
require "simplecov"
|
|
2
2
|
SimpleCov.start
|
|
3
3
|
|
|
4
|
-
if ENV["CI"]
|
|
5
|
-
require "codeclimate-test-reporter"
|
|
6
|
-
CodeClimate::TestReporter.start
|
|
7
|
-
end
|
|
8
|
-
|
|
9
4
|
require "active_support/core_ext/string/strip"
|
|
10
5
|
require "ruboty"
|
|
11
6
|
|
|
12
7
|
RSpec.configure do |config|
|
|
13
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
|
14
8
|
config.run_all_when_everything_filtered = true
|
|
15
9
|
config.filter_run :focus
|
|
16
10
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruboty
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryo Nakamura
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-07-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -80,20 +80,6 @@ dependencies:
|
|
|
80
80
|
- - ">="
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '0'
|
|
83
|
-
- !ruby/object:Gem::Dependency
|
|
84
|
-
name: codeclimate-test-reporter
|
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
|
86
|
-
requirements:
|
|
87
|
-
- - ">="
|
|
88
|
-
- !ruby/object:Gem::Version
|
|
89
|
-
version: 0.3.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.3.0
|
|
97
83
|
- !ruby/object:Gem::Dependency
|
|
98
84
|
name: rake
|
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -114,14 +100,14 @@ dependencies:
|
|
|
114
100
|
requirements:
|
|
115
101
|
- - '='
|
|
116
102
|
- !ruby/object:Gem::Version
|
|
117
|
-
version:
|
|
103
|
+
version: 3.4.0
|
|
118
104
|
type: :development
|
|
119
105
|
prerelease: false
|
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
121
107
|
requirements:
|
|
122
108
|
- - '='
|
|
123
109
|
- !ruby/object:Gem::Version
|
|
124
|
-
version:
|
|
110
|
+
version: 3.4.0
|
|
125
111
|
- !ruby/object:Gem::Dependency
|
|
126
112
|
name: simplecov
|
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -176,7 +162,6 @@ files:
|
|
|
176
162
|
- lib/ruboty/handlers/help.rb
|
|
177
163
|
- lib/ruboty/handlers/ping.rb
|
|
178
164
|
- lib/ruboty/handlers/whoami.rb
|
|
179
|
-
- lib/ruboty/logger.rb
|
|
180
165
|
- lib/ruboty/message.rb
|
|
181
166
|
- lib/ruboty/robot.rb
|
|
182
167
|
- lib/ruboty/version.rb
|
|
@@ -205,15 +190,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
205
190
|
requirements:
|
|
206
191
|
- - ">="
|
|
207
192
|
- !ruby/object:Gem::Version
|
|
208
|
-
version:
|
|
193
|
+
version: 2.2.2
|
|
209
194
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
195
|
requirements:
|
|
211
196
|
- - ">="
|
|
212
197
|
- !ruby/object:Gem::Version
|
|
213
198
|
version: '0'
|
|
214
199
|
requirements: []
|
|
215
|
-
|
|
216
|
-
rubygems_version: 2.4.5
|
|
200
|
+
rubygems_version: 3.0.3
|
|
217
201
|
signing_key:
|
|
218
202
|
specification_version: 4
|
|
219
203
|
summary: Ruby + Bot = Ruboty
|
|
@@ -229,4 +213,3 @@ test_files:
|
|
|
229
213
|
- spec/ruboty/handlers/whoami_spec.rb
|
|
230
214
|
- spec/ruboty/robot_spec.rb
|
|
231
215
|
- spec/spec_helper.rb
|
|
232
|
-
has_rdoc:
|