ego 0.5.0 → 0.6.0

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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +20 -0
  3. data/.rubocop_todo.yml +36 -0
  4. data/Gemfile +2 -0
  5. data/Guardfile +9 -2
  6. data/Rakefile +5 -1
  7. data/bin/ego +2 -0
  8. data/ego.gemspec +22 -17
  9. data/lib/ego.rb +3 -1
  10. data/lib/ego/capability.rb +2 -0
  11. data/lib/ego/filesystem.rb +2 -0
  12. data/lib/ego/handler.rb +8 -2
  13. data/lib/ego/options.rb +13 -8
  14. data/lib/ego/plugin.rb +3 -1
  15. data/lib/ego/plugin_helper.rb +18 -16
  16. data/lib/ego/plugins/capabilities.rb +9 -3
  17. data/lib/ego/plugins/fallback.rb +9 -7
  18. data/lib/ego/plugins/robot_io.rb +2 -0
  19. data/lib/ego/plugins/social.rb +3 -1
  20. data/lib/ego/plugins/status.rb +2 -0
  21. data/lib/ego/plugins/system.rb +4 -2
  22. data/lib/ego/printer.rb +9 -5
  23. data/lib/ego/robot.rb +9 -6
  24. data/lib/ego/robot_error.rb +2 -0
  25. data/lib/ego/runner.rb +12 -7
  26. data/lib/ego/version.rb +3 -1
  27. data/spec/ego/acceptance/help_spec.rb +9 -0
  28. data/spec/ego/acceptance/no_args_spec.rb +9 -0
  29. data/spec/ego/acceptance/shell_spec.rb +11 -0
  30. data/spec/ego/acceptance/simple_query_spec.rb +9 -0
  31. data/spec/ego/acceptance/template_spec.rb +43 -0
  32. data/spec/ego/acceptance/usage_error_spec.rb +17 -0
  33. data/spec/ego/acceptance/version_spec.rb +9 -0
  34. data/spec/ego/capability_spec.rb +2 -0
  35. data/spec/ego/handler_spec.rb +18 -6
  36. data/spec/ego/options_spec.rb +8 -1
  37. data/spec/ego/plugin_helper_spec.rb +4 -2
  38. data/spec/ego/plugin_spec.rb +5 -4
  39. data/spec/ego/plugins/capabilities_spec.rb +4 -4
  40. data/spec/ego/plugins/fallback_spec.rb +16 -6
  41. data/spec/ego/plugins/robot_io_spec.rb +3 -3
  42. data/spec/ego/plugins/social_spec.rb +3 -3
  43. data/spec/ego/plugins/status_spec.rb +3 -3
  44. data/spec/ego/plugins/system_spec.rb +8 -8
  45. data/spec/ego/printer_spec.rb +86 -86
  46. data/spec/ego/robot_error_spec.rb +2 -0
  47. data/spec/ego/robot_spec.rb +24 -22
  48. data/spec/ego/runner_spec.rb +12 -0
  49. data/spec/spec_helper.rb +5 -48
  50. data/spec/support/aruba.rb +3 -0
  51. data/spec/support/plugin_helper.rb +64 -0
  52. metadata +71 -9
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'ego/runner'
2
4
 
3
5
  RSpec.describe Ego::Runner do
@@ -21,6 +23,16 @@ RSpec.describe Ego::Runner do
21
23
  end
22
24
  end
23
25
 
26
+ context 'with --template' do
27
+ subject { described_class.new(['--template']) }
28
+
29
+ it 'prints plug-in template' do
30
+ expect { subject.run }.to output(
31
+ /^Ego.plugin /
32
+ ).to_stdout
33
+ end
34
+ end
35
+
24
36
  context 'with --version' do
25
37
  subject { described_class.new(['--version']) }
26
38
 
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ Dir[File.expand_path('support/**/*.rb', __dir__)].each { |f| require_relative f }
4
+
1
5
  RSpec.configure do |config|
2
6
  config.expect_with :rspec do |expectations|
3
7
  # This option will default to `true` in RSpec 4. It makes the `description`
@@ -19,52 +23,5 @@ RSpec.configure do |config|
19
23
 
20
24
  # This setting enables warnings. It's recommended, but in some cases may
21
25
  # be too noisy due to issues in dependencies.
22
- config.warnings = true
23
- end
24
-
25
- # Get a new robot instance with plugin.
26
- #
27
- # @param plugin [String] basename of plugin script
28
- # @return [Ego::Robot] the decorated robot instance
29
- def robot_with_plugin(plugin)
30
- require 'ego'
31
-
32
- options = double('Ego::Options')
33
- opt_parser = double('OptionParser')
34
-
35
- allow(opt_parser).to receive_messages({
36
- program_name: 'ego',
37
- })
38
-
39
- allow(options).to receive_messages({
40
- robot_name: 'TestBot',
41
- verbose: false,
42
- usage: opt_parser,
43
- })
44
-
45
- robot = Ego::Robot.new(options)
46
- robot.extend(Ego::Printer) # Needed to test most robot output
47
- String.disable_colorization = true
48
-
49
- paths = Ego::Filesystem.builtin_plugins.select do |path|
50
- path.end_with?("/#{plugin}.rb")
51
- end
52
-
53
- Ego::Plugin.class_variable_set :@@plugins, {}
54
- Ego::Plugin.load paths
55
- Ego::Plugin.decorate(robot).ready
56
- end
57
-
58
- RSpec::Matchers.define :handle_query do |query|
59
- match do |robot|
60
- !robot.first_handler_for(query).nil?
61
- end
62
- end
63
-
64
- RSpec::Matchers.define :be_able_to do |desc|
65
- match do |robot|
66
- robot.capabilities.select do |capability|
67
- capability.desc == desc
68
- end.any?
69
- end
26
+ config.warnings = false
70
27
  end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'aruba/rspec'
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Provide robot with plug-in loaded as test subject.
4
+ RSpec.shared_context 'robot with plug-in' do
5
+ subject do |example|
6
+ options = double('Ego::Options')
7
+ opt_parser = double('OptionParser')
8
+
9
+ allow(opt_parser).to receive_messages(
10
+ program_name: 'ego'
11
+ )
12
+
13
+ allow(options).to receive_messages(
14
+ robot_name: 'TestBot',
15
+ verbose: false,
16
+ usage: opt_parser
17
+ )
18
+
19
+ robot = described_class.new(options)
20
+
21
+ with_plugin(robot, example.metadata[:plugin]).ready
22
+ end
23
+ end
24
+
25
+ RSpec.configure do |config|
26
+ # Set up the test subject when :plugin metadata is set.
27
+ config.include_context 'robot with plug-in', :plugin
28
+ end
29
+
30
+ # Decorate object with plugin.
31
+ #
32
+ # @param obj [Object] the object to decorate
33
+ # @param plugin [String] basename of plugin script
34
+ # @return [Object] the decorated object
35
+ def with_plugin(obj, plugin)
36
+ require 'ego'
37
+
38
+ obj.extend(Ego::Printer) # Needed to test most robot output
39
+ String.disable_colorization = true
40
+
41
+ paths = Ego::Filesystem.builtin_plugins.select do |path|
42
+ path.end_with?("/#{plugin}.rb")
43
+ end
44
+
45
+ Ego::Plugin.class_variable_set :@@plugins, {}
46
+ Ego::Plugin.load paths
47
+ Ego::Plugin.decorate(obj)
48
+ end
49
+
50
+ # Can the robot understand `query`?
51
+ RSpec::Matchers.define :handle_query do |query|
52
+ match do |robot|
53
+ !robot.first_handler_for(query).nil?
54
+ end
55
+ end
56
+
57
+ # Does the robot have a capability matching `desc`?
58
+ RSpec::Matchers.define :be_able_to do |desc|
59
+ match do |robot|
60
+ robot.capabilities.select do |capability|
61
+ capability.desc == desc
62
+ end.any?
63
+ end
64
+ end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ego
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noah Frederick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-03 00:00:00.000000000 Z
11
+ date: 2018-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: aruba
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0.pre.alpha.2
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0.pre.alpha.2
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -25,7 +39,7 @@ dependencies:
25
39
  - !ruby/object:Gem::Version
26
40
  version: '1.6'
27
41
  - !ruby/object:Gem::Dependency
28
- name: rake
42
+ name: guard-rspec
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - ">="
@@ -39,21 +53,21 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: rspec
56
+ name: guard-rubocop
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - "~>"
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
- version: '3.4'
61
+ version: '0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - "~>"
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
- version: '3.4'
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: guard-rspec
70
+ name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - ">="
@@ -66,6 +80,34 @@ dependencies:
66
80
  - - ">="
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.7'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.7'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.52.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.52.1
69
111
  - !ruby/object:Gem::Dependency
70
112
  name: colorize
71
113
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +150,8 @@ extra_rdoc_files: []
108
150
  files:
109
151
  - ".gitignore"
110
152
  - ".rspec"
153
+ - ".rubocop.yml"
154
+ - ".rubocop_todo.yml"
111
155
  - ".travis.yml"
112
156
  - ".yardopts"
113
157
  - Gemfile
@@ -135,6 +179,13 @@ files:
135
179
  - lib/ego/robot_error.rb
136
180
  - lib/ego/runner.rb
137
181
  - lib/ego/version.rb
182
+ - spec/ego/acceptance/help_spec.rb
183
+ - spec/ego/acceptance/no_args_spec.rb
184
+ - spec/ego/acceptance/shell_spec.rb
185
+ - spec/ego/acceptance/simple_query_spec.rb
186
+ - spec/ego/acceptance/template_spec.rb
187
+ - spec/ego/acceptance/usage_error_spec.rb
188
+ - spec/ego/acceptance/version_spec.rb
138
189
  - spec/ego/capability_spec.rb
139
190
  - spec/ego/handler_spec.rb
140
191
  - spec/ego/options_spec.rb
@@ -151,6 +202,8 @@ files:
151
202
  - spec/ego/robot_spec.rb
152
203
  - spec/ego/runner_spec.rb
153
204
  - spec/spec_helper.rb
205
+ - spec/support/aruba.rb
206
+ - spec/support/plugin_helper.rb
154
207
  homepage: https://github.com/noahfrederick/ego
155
208
  licenses:
156
209
  - GPL-3.0+
@@ -176,6 +229,13 @@ signing_key:
176
229
  specification_version: 4
177
230
  summary: An extensible personal command-line assistant
178
231
  test_files:
232
+ - spec/ego/acceptance/help_spec.rb
233
+ - spec/ego/acceptance/no_args_spec.rb
234
+ - spec/ego/acceptance/shell_spec.rb
235
+ - spec/ego/acceptance/simple_query_spec.rb
236
+ - spec/ego/acceptance/template_spec.rb
237
+ - spec/ego/acceptance/usage_error_spec.rb
238
+ - spec/ego/acceptance/version_spec.rb
179
239
  - spec/ego/capability_spec.rb
180
240
  - spec/ego/handler_spec.rb
181
241
  - spec/ego/options_spec.rb
@@ -192,3 +252,5 @@ test_files:
192
252
  - spec/ego/robot_spec.rb
193
253
  - spec/ego/runner_spec.rb
194
254
  - spec/spec_helper.rb
255
+ - spec/support/aruba.rb
256
+ - spec/support/plugin_helper.rb