ego 0.1.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.
@@ -0,0 +1,3 @@
1
+ module Ego
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,65 @@
1
+ require 'ego/options'
2
+
3
+ RSpec.describe Ego::Options do
4
+ it 'defaults to interpret-mode' do
5
+ opts = Ego::Options.new(['foo'])
6
+ expect(opts.mode).to eq(:interpret)
7
+ end
8
+
9
+ it 'can be set to version-mode' do
10
+ opts = Ego::Options.new(['-v'])
11
+ expect(opts.mode).to eq(:version)
12
+ end
13
+
14
+ it 'can be set to help-mode' do
15
+ opts = Ego::Options.new(['-h'])
16
+ expect(opts.mode).to eq(:help)
17
+ end
18
+
19
+ it 'defaults to help-mode with no arguments' do
20
+ opts = Ego::Options.new([])
21
+ expect(opts.mode).to eq(:help)
22
+ end
23
+
24
+ it 'defaults to not verbose' do
25
+ opts = Ego::Options.new(['foo'])
26
+ expect(opts.verbose).to be false
27
+ end
28
+
29
+ it 'can be set to verbose' do
30
+ opts = Ego::Options.new(['-V', 'foo'])
31
+ expect(opts.verbose).to be true
32
+ end
33
+
34
+ it 'sets the query to remaining args join with spaces' do
35
+ opts = Ego::Options.new(['foo', 'bar'])
36
+ expect(opts.query).to eq('foo bar')
37
+ end
38
+
39
+ it 'sets the robot name' do
40
+ opts = Ego::Options.new(['foo'])
41
+ expect(opts.robot_name).to_not be_nil
42
+ end
43
+
44
+ it 'sets the usage' do
45
+ opts = Ego::Options.new(['foo'])
46
+ expect(opts.usage).to be_instance_of OptionParser
47
+ end
48
+
49
+ it 'does not set a usage error normally' do
50
+ opts = Ego::Options.new(['foo'])
51
+ expect(opts.usage_error).to be_nil
52
+ end
53
+
54
+ context 'with invalid option' do
55
+ it 'sets a usage error message' do
56
+ opts = Ego::Options.new(['--does-not-exist'])
57
+ expect(opts.usage_error).to eq('invalid option: --does-not-exist')
58
+ end
59
+
60
+ it 'sets help-mode' do
61
+ opts = Ego::Options.new(['--does-not-exist'])
62
+ expect(opts.mode).to eq(:help)
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,43 @@
1
+ require 'ego/robot'
2
+
3
+ RSpec.describe Ego::Robot do
4
+ it 'sets its name' do
5
+ formatter = double('Ego::Formatter')
6
+ options = double('Ego::Options')
7
+ allow(options).to receive(:verbose)
8
+ expect(options).to receive_messages(robot_name: 'foo')
9
+
10
+ robot = Ego::Robot.new(options, formatter)
11
+ expect(robot.name).to eq('foo')
12
+ end
13
+
14
+ describe '#debug' do
15
+ context 'in non-verbose mode' do
16
+ before(:example) do
17
+ @options = double('Ego::Options')
18
+ allow(@options).to receive_messages(robot_name: 'foo', verbose: false)
19
+ @formatter = double('Ego::Formatter')
20
+ end
21
+
22
+ it 'does nothing' do
23
+ expect(@formatter).not_to receive(:debug)
24
+ robot = Ego::Robot.new(@options, @formatter)
25
+ robot.debug 'foo'
26
+ end
27
+ end
28
+
29
+ context 'in verbose mode' do
30
+ before(:example) do
31
+ @options = double('Ego::Options')
32
+ allow(@options).to receive_messages(robot_name: 'foo', verbose: true)
33
+ @formatter = double('Ego::Formatter')
34
+ end
35
+
36
+ it 'passes the message to the formatter' do
37
+ expect(@formatter).to receive(:debug).with('foo')
38
+ robot = Ego::Robot.new(@options, @formatter)
39
+ robot.debug 'foo'
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,23 @@
1
+ RSpec.configure do |config|
2
+ config.expect_with :rspec do |expectations|
3
+ # This option will default to `true` in RSpec 4. It makes the `description`
4
+ # and `failure_message` of custom matchers include text for helper methods
5
+ # defined using `chain`, e.g.:
6
+ # be_bigger_than(2).and_smaller_than(4).description
7
+ # # => "be bigger than 2 and smaller than 4"
8
+ # ...rather than:
9
+ # # => "be bigger than 2"
10
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
11
+ end
12
+
13
+ # Limits the available syntax to the non-monkey patched syntax that is
14
+ # recommended. For more details, see:
15
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
16
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
17
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
18
+ config.disable_monkey_patching!
19
+
20
+ # This setting enables warnings. It's recommended, but in some cases may
21
+ # be too noisy due to issues in dependencies.
22
+ config.warnings = true
23
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ego
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Noah Frederick
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: colorize
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.7'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.7'
83
+ description: |2
84
+ Ego is a personal command-line assistant that provides a flexible, natural
85
+ language interface (sort of) for interacting with other programs. Think of
86
+ it as a single-user IRC bot that can be extended with handlers for various
87
+ natural-language queries.
88
+ email:
89
+ - acc.rubygems@noahfrederick.com
90
+ executables:
91
+ - ego
92
+ extensions: []
93
+ extra_rdoc_files: []
94
+ files:
95
+ - ".gitignore"
96
+ - ".rspec"
97
+ - Gemfile
98
+ - Guardfile
99
+ - LICENSE.txt
100
+ - README.md
101
+ - Rakefile
102
+ - bin/ego
103
+ - ego.gemspec
104
+ - lib/ego.rb
105
+ - lib/ego/filesystem.rb
106
+ - lib/ego/formatter.rb
107
+ - lib/ego/handler.rb
108
+ - lib/ego/handler/default.rb
109
+ - lib/ego/handler/echo.rb
110
+ - lib/ego/handler/greet.rb
111
+ - lib/ego/handler/handlers.rb
112
+ - lib/ego/handler/self.rb
113
+ - lib/ego/listener.rb
114
+ - lib/ego/options.rb
115
+ - lib/ego/robot.rb
116
+ - lib/ego/runner.rb
117
+ - lib/ego/version.rb
118
+ - spec/ego/options_spec.rb
119
+ - spec/ego/robot_spec.rb
120
+ - spec/spec_helper.rb
121
+ homepage: https://github.com/noahfrederick/ego
122
+ licenses:
123
+ - GPL-3.0+
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 2.2.2
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: An extensible personal command-line assistant
145
+ test_files:
146
+ - spec/ego/options_spec.rb
147
+ - spec/ego/robot_spec.rb
148
+ - spec/spec_helper.rb