rita 0.1.0 → 5.0.0.alpha.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +19 -0
  3. data/.rubocop.yml +51 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +16 -0
  6. data/CONTRIBUTING.md +18 -0
  7. data/Gemfile +5 -0
  8. data/{LICENSE.txt → LICENSE} +1 -3
  9. data/README.md +17 -24
  10. data/Rakefile +5 -5
  11. data/bin/lita +7 -0
  12. data/lib/lita/adapter.rb +147 -0
  13. data/lib/lita/adapters/shell.rb +126 -0
  14. data/lib/lita/adapters/test.rb +62 -0
  15. data/lib/lita/authorization.rb +112 -0
  16. data/lib/lita/callback.rb +39 -0
  17. data/lib/lita/cli.rb +218 -0
  18. data/lib/lita/configurable.rb +47 -0
  19. data/lib/lita/configuration_builder.rb +247 -0
  20. data/lib/lita/configuration_validator.rb +95 -0
  21. data/lib/lita/default_configuration.rb +122 -0
  22. data/lib/lita/errors.rb +25 -0
  23. data/lib/lita/handler/chat_router.rb +141 -0
  24. data/lib/lita/handler/common.rb +208 -0
  25. data/lib/lita/handler/event_router.rb +84 -0
  26. data/lib/lita/handler/http_router.rb +31 -0
  27. data/lib/lita/handler.rb +15 -0
  28. data/lib/lita/handlers/authorization.rb +129 -0
  29. data/lib/lita/handlers/help.rb +171 -0
  30. data/lib/lita/handlers/info.rb +66 -0
  31. data/lib/lita/handlers/room.rb +36 -0
  32. data/lib/lita/handlers/users.rb +37 -0
  33. data/lib/lita/http_callback.rb +46 -0
  34. data/lib/lita/http_route.rb +83 -0
  35. data/lib/lita/logger.rb +43 -0
  36. data/lib/lita/message.rb +124 -0
  37. data/lib/lita/middleware_registry.rb +39 -0
  38. data/lib/lita/namespace.rb +29 -0
  39. data/lib/lita/plugin_builder.rb +43 -0
  40. data/lib/lita/rack_app.rb +100 -0
  41. data/lib/lita/registry.rb +164 -0
  42. data/lib/lita/response.rb +65 -0
  43. data/lib/lita/robot.rb +273 -0
  44. data/lib/lita/room.rb +119 -0
  45. data/lib/lita/route_validator.rb +82 -0
  46. data/lib/lita/rspec/handler.rb +127 -0
  47. data/lib/lita/rspec/matchers/chat_route_matcher.rb +53 -0
  48. data/lib/lita/rspec/matchers/event_route_matcher.rb +29 -0
  49. data/lib/lita/rspec/matchers/http_route_matcher.rb +34 -0
  50. data/lib/lita/rspec.rb +48 -0
  51. data/lib/lita/source.rb +81 -0
  52. data/lib/lita/store.rb +23 -0
  53. data/lib/lita/target.rb +3 -0
  54. data/lib/lita/template.rb +71 -0
  55. data/lib/lita/template_resolver.rb +52 -0
  56. data/lib/lita/timer.rb +49 -0
  57. data/lib/lita/user.rb +157 -0
  58. data/lib/lita/util.rb +31 -0
  59. data/lib/lita/version.rb +6 -0
  60. data/lib/lita.rb +166 -0
  61. data/lib/rita.rb +2 -7
  62. data/rita.gemspec +50 -0
  63. data/spec/lita/adapter_spec.rb +54 -0
  64. data/spec/lita/adapters/shell_spec.rb +99 -0
  65. data/spec/lita/authorization_spec.rb +122 -0
  66. data/spec/lita/configuration_builder_spec.rb +247 -0
  67. data/spec/lita/configuration_validator_spec.rb +114 -0
  68. data/spec/lita/default_configuration_spec.rb +242 -0
  69. data/spec/lita/handler/chat_router_spec.rb +236 -0
  70. data/spec/lita/handler/common_spec.rb +289 -0
  71. data/spec/lita/handler/event_router_spec.rb +121 -0
  72. data/spec/lita/handler/http_router_spec.rb +155 -0
  73. data/spec/lita/handler_spec.rb +62 -0
  74. data/spec/lita/handlers/authorization_spec.rb +111 -0
  75. data/spec/lita/handlers/help_spec.rb +124 -0
  76. data/spec/lita/handlers/info_spec.rb +67 -0
  77. data/spec/lita/handlers/room_spec.rb +24 -0
  78. data/spec/lita/handlers/users_spec.rb +35 -0
  79. data/spec/lita/logger_spec.rb +28 -0
  80. data/spec/lita/message_spec.rb +178 -0
  81. data/spec/lita/plugin_builder_spec.rb +41 -0
  82. data/spec/lita/response_spec.rb +62 -0
  83. data/spec/lita/robot_spec.rb +285 -0
  84. data/spec/lita/room_spec.rb +136 -0
  85. data/spec/lita/rspec/handler_spec.rb +33 -0
  86. data/spec/lita/rspec_spec.rb +162 -0
  87. data/spec/lita/source_spec.rb +68 -0
  88. data/spec/lita/store_spec.rb +23 -0
  89. data/spec/lita/template_resolver_spec.rb +42 -0
  90. data/spec/lita/template_spec.rb +52 -0
  91. data/spec/lita/timer_spec.rb +32 -0
  92. data/spec/lita/user_spec.rb +167 -0
  93. data/spec/lita/util_spec.rb +18 -0
  94. data/spec/lita_spec.rb +227 -0
  95. data/spec/spec_helper.rb +35 -0
  96. data/spec/templates/basic.erb +1 -0
  97. data/spec/templates/basic.irc.erb +1 -0
  98. data/spec/templates/helpers.erb +1 -0
  99. data/spec/templates/interpolated.erb +1 -0
  100. data/templates/locales/en.yml +137 -0
  101. data/templates/plugin/Gemfile +5 -0
  102. data/templates/plugin/README.tt +29 -0
  103. data/templates/plugin/Rakefile +8 -0
  104. data/templates/plugin/gemspec.tt +27 -0
  105. data/templates/plugin/gitignore +18 -0
  106. data/templates/plugin/lib/lita/plugin_type/plugin.tt +19 -0
  107. data/templates/plugin/lib/plugin.tt +16 -0
  108. data/templates/plugin/locales/en.yml.tt +4 -0
  109. data/templates/plugin/spec/lita/plugin_type/plugin_spec.tt +6 -0
  110. data/templates/plugin/spec/spec_helper.tt +8 -0
  111. data/templates/plugin/templates/gitkeep +0 -0
  112. data/templates/robot/Gemfile +5 -0
  113. data/templates/robot/lita_config.rb +28 -0
  114. metadata +386 -20
  115. data/.standard.yml +0 -3
  116. data/CHANGELOG.md +0 -5
  117. data/CODE_OF_CONDUCT.md +0 -132
  118. data/lib/rita/version.rb +0 -5
  119. data/sig/rita.rbs +0 -4
data/spec/lita_spec.rb ADDED
@@ -0,0 +1,227 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ describe Lita do
6
+ let(:registry) { Lita::Registry.new }
7
+ before { described_class.register_adapter(:shell, Lita::Adapters::Shell) }
8
+
9
+ it "memoizes a Configuration" do
10
+ expect(described_class.config).to eql(described_class.config)
11
+ end
12
+
13
+ it "keeps track of registered hooks" do
14
+ hook = double("hook")
15
+ described_class.register_hook("Foo ", hook)
16
+ described_class.register_hook(:foO, hook)
17
+ expect(described_class.hooks[:foo]).to eq(Set.new([hook]))
18
+ end
19
+
20
+ describe ".configure" do
21
+ it "yields the Configuration object" do
22
+ described_class.configure { |c| c.robot.name = "Not Lita" }
23
+ expect(described_class.config.robot.name).to eq("Not Lita")
24
+ end
25
+ end
26
+
27
+ describe ".load_locales" do
28
+ let(:load_path) do
29
+ load_path = double("Array")
30
+ allow(load_path).to receive(:concat)
31
+ load_path
32
+ end
33
+
34
+ let(:new_locales) { %w[foo bar] }
35
+
36
+ before do
37
+ allow(I18n).to receive(:load_path).and_return(load_path)
38
+ allow(I18n).to receive(:reload!)
39
+ end
40
+
41
+ it "appends the locale files to I18n.load_path" do
42
+ expect(I18n.load_path).to receive(:concat).with(new_locales)
43
+ described_class.load_locales(new_locales)
44
+ end
45
+
46
+ it "reloads I18n" do
47
+ expect(I18n).to receive(:reload!)
48
+ described_class.load_locales(new_locales)
49
+ end
50
+
51
+ it "wraps single paths in an array" do
52
+ expect(I18n.load_path).to receive(:concat).with(["foo"])
53
+ described_class.load_locales("foo")
54
+ end
55
+ end
56
+
57
+ describe ".locale=" do
58
+ it "sets I18n.locale to the normalized locale" do
59
+ expect(I18n).to receive(:locale=).with("es-MX.UTF-8")
60
+ described_class.locale = "es_MX.UTF-8"
61
+ end
62
+ end
63
+
64
+ describe ".default_locale=" do
65
+ it "sets I18n.default_locale to the normalized locale" do
66
+ expect(I18n).to receive(:default_locale=).with("zh-TW")
67
+ described_class.default_locale = "zh_TW"
68
+ end
69
+ end
70
+
71
+ describe ".redis" do
72
+ let(:redis_namespace) { instance_double("Redis") }
73
+
74
+ before do
75
+ if described_class.instance_variable_defined?(:@redis)
76
+ described_class.remove_instance_variable(:@redis)
77
+ end
78
+
79
+ allow(redis_namespace).to receive(:ping).and_return("PONG")
80
+ allow(Redis::Namespace).to receive(:new).and_return(redis_namespace)
81
+ end
82
+
83
+ it "memoizes a Redis::Namespace" do
84
+ expect(described_class.redis).to equal(redis_namespace)
85
+ expect(described_class.redis).to eql(described_class.redis)
86
+ end
87
+
88
+ it "raises a RedisError if it can't connect to Redis" do
89
+ allow(redis_namespace).to receive(:ping).and_raise(Redis::CannotConnectError)
90
+ expect { Lita.redis }.to raise_error(Lita::RedisError, /could not connect to Redis/)
91
+ end
92
+
93
+ context "with test mode off" do
94
+ around do |example|
95
+ test_mode = Lita.test_mode?
96
+ Lita.test_mode = false
97
+ example.run
98
+ Lita.test_mode = test_mode
99
+ end
100
+
101
+ it "logs a fatal warning and raises an exception if it can't connect to Redis" do
102
+ allow(redis_namespace).to receive(:ping).and_raise(Redis::CannotConnectError)
103
+
104
+ expect(Lita.logger).to receive(:fatal)
105
+ expect { Lita.redis }.to raise_error(SystemExit)
106
+ end
107
+ end
108
+ end
109
+
110
+ describe ".register_adapter" do
111
+ let(:robot) { Lita::Robot.new(registry) }
112
+
113
+ it "builds an adapter out of a provided block" do
114
+ # rubocop:disable Lint/EmptyBlock
115
+ described_class.register_adapter(:foo) {}
116
+ # rubocop:enable Lint/EmptyBlock
117
+
118
+ expect(Lita.logger).to receive(:warn).with(/not implemented/)
119
+
120
+ Lita.adapters[:foo].new(robot).run
121
+ end
122
+
123
+ it "raises if a non-class object is passed as the adapter" do
124
+ expect do
125
+ described_class.register_adapter(:foo, :bar)
126
+ end.to raise_error(ArgumentError, /requires a class/)
127
+ end
128
+ end
129
+
130
+ describe ".register_handler" do
131
+ it "builds a handler out of a provided block" do
132
+ # rubocop:disable Lint/EmptyBlock
133
+ described_class.register_handler(:foo) {}
134
+ # rubocop:enable Lint/EmptyBlock
135
+ #
136
+ expect(described_class.handlers.to_a.last.namespace).to eq("foo")
137
+ end
138
+
139
+ it "raises if a non-class object is the only argument" do
140
+ expect do
141
+ described_class.register_handler(:foo)
142
+ end.to raise_error(ArgumentError, /requires a class/)
143
+ end
144
+ end
145
+
146
+ describe ".reset" do
147
+ it "clears the config" do
148
+ described_class.config.robot.name = "Foo"
149
+ described_class.reset
150
+ expect(described_class.config.robot.name).to eq("Lita")
151
+ end
152
+
153
+ it "clears adapters" do
154
+ described_class.register_adapter(:foo, Class.new)
155
+ described_class.reset
156
+ expect(described_class.adapters).to be_empty
157
+ end
158
+
159
+ it "clears handlers" do
160
+ described_class.register_handler(Class.new)
161
+ described_class.reset
162
+ expect(described_class.handlers).to be_empty
163
+ end
164
+
165
+ it "clears hooks" do
166
+ described_class.register_hook(:foo, double)
167
+ described_class.reset
168
+ expect(described_class.hooks).to be_empty
169
+ end
170
+ end
171
+
172
+ describe ".load_config" do
173
+ let(:hook) { double("Hook") }
174
+ let(:validator) { instance_double("Lita::ConfigurationValidator", call: nil) }
175
+
176
+ before do
177
+ allow(
178
+ Lita::ConfigurationValidator
179
+ ).to receive(:new).with(described_class).and_return(validator)
180
+ end
181
+
182
+ after { described_class.reset }
183
+
184
+ it "calls before_run hooks" do
185
+ described_class.register_hook(:before_run, hook)
186
+ expect(hook).to receive(:call).with(config_path: "path/to/config")
187
+ described_class.load_config("path/to/config")
188
+ end
189
+
190
+ it "calls config_finalized hooks" do
191
+ described_class.register_hook(:config_finalized, hook)
192
+ expect(hook).to receive(:call).with(config_path: "path/to/config")
193
+ described_class.load_config("path/to/config")
194
+ end
195
+
196
+ it "raises if the configuration is not valid" do
197
+ allow(validator).to receive(:call).and_raise(SystemExit)
198
+
199
+ expect { described_class.load_config }.to raise_error(SystemExit)
200
+ end
201
+ end
202
+
203
+ describe ".run" do
204
+ let(:validator) { instance_double("Lita::ConfigurationValidator", call: nil) }
205
+ let(:robot) { double("Lita::Robot", run: nil) }
206
+
207
+ before do
208
+ allow(Lita::Robot).to receive(:new).and_return(robot)
209
+ allow(Lita::ConfigurationBuilder).to receive(:load_user_config)
210
+ allow(
211
+ Lita::ConfigurationValidator
212
+ ).to receive(:new).with(described_class).and_return(validator)
213
+ end
214
+
215
+ after { described_class.reset }
216
+
217
+ it "runs a new Robot" do
218
+ expect(robot).to receive(:run)
219
+ described_class.run
220
+ end
221
+
222
+ it "loads configuration from a config file" do
223
+ expect(described_class).to receive(:load_config).with("path/to/config")
224
+ described_class.run("path/to/config")
225
+ end
226
+ end
227
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Generate code coverage metrics outside CI.
4
+ unless ENV["CI"]
5
+ require "simplecov"
6
+ SimpleCov.start { add_filter "/spec/" }
7
+ end
8
+
9
+ require "pry"
10
+ require "lita/rspec"
11
+
12
+ RSpec.configure do |config|
13
+ config.mock_with :rspec do |mocks_config|
14
+ mocks_config.verify_doubled_constant_names = true
15
+ mocks_config.verify_partial_doubles = true
16
+ end
17
+
18
+ # Lita calls `exit(false)` in a few places. If an RSpec example hits one of these calls and it
19
+ # wasn't explicitly stubbed, the example will stop at exactly that point, but will be reported by
20
+ # RSpec as having passed, and will also change RSpec's exit code to 1. This situation indicates
21
+ # either a missing stub or a real bug, so we catch it here and fail loudly.
22
+ #
23
+ # https://github.com/rspec/rspec-core/issues/2246
24
+ config.around do |example|
25
+ example.run
26
+ rescue SystemExit => e
27
+ raise <<~ERROR
28
+ Unhandled SystemExit! This will cause RSpec to exit 1 but show the example as passing!"
29
+
30
+ Full backtrace:
31
+
32
+ #{e.backtrace.join("\n")}
33
+ ERROR
34
+ end
35
+ end
@@ -0,0 +1 @@
1
+ Template rendered from a file!
@@ -0,0 +1 @@
1
+ IRC template rendered from a file!
@@ -0,0 +1 @@
1
+ <%= reverse_name(@first, @last) %>
@@ -0,0 +1 @@
1
+ I love <%= @first %> <%= @last %>!
@@ -0,0 +1,137 @@
1
+ en:
2
+ lita:
3
+ adapters:
4
+ shell:
5
+ startup_message: Type "exit" or "quit" to end the session.
6
+ core:
7
+ register_adapter:
8
+ block_or_class_required: Lita.register_adapter requires a class in its two argument form.
9
+ register_handler:
10
+ block_or_class_required: Lita.register_handler requires a class in its single argument form.
11
+ adapter:
12
+ method_not_implemented: "This adapter has not implemented #%{method}."
13
+ cli:
14
+ no_gemfile_warning: >-
15
+ The default command "start" must be run inside a Lita project. Try running `lita new` to
16
+ generate a new Lita project or `lita help` to see all commands.
17
+ license_notice: >-
18
+ If you plan to release this plugin as open source software, consider adding a LICENSE file
19
+ to the root of the repository.
20
+
21
+ Common open source software licenses can be found at https://choosealicense.com/.
22
+ github_user_question: What is your GitHub username?
23
+ config:
24
+ exception: |
25
+ Lita configuration file could not be processed. The exception was:
26
+ %{message}
27
+ Full backtrace:
28
+ %{backtrace}
29
+ locale_deprecated: >-
30
+ `config.robot.locale` and `config.robot.default_locale` are deprecated and will be removed
31
+ in Lita 6.0. Use the environment variable LC_ALL, LC_MESSAGES, or LANG to set the program's
32
+ locale instead.
33
+ missing_required_adapter_attribute: >-
34
+ Configuration attribute "%{attribute}" is required for "%{adapter}" adapter.
35
+ missing_required_handler_attribute: >-
36
+ Configuration attribute "%{attribute}" is required for "%{handler}" handler.
37
+ type_error: >-
38
+ Configuration type error: "%{attribute}" must be one of: %{types}.
39
+ validation_error: >-
40
+ Validation error on attribute "%{attribute}": %{message}
41
+ handler:
42
+ dispatch: "Dispatching message to %{handler}#%{method}."
43
+ exception: |
44
+ %{handler} crashed. The exception was:
45
+ %{message}
46
+ Full backtrace:
47
+ %{backtrace}
48
+ handlers:
49
+ authorization:
50
+ help:
51
+ add_key: auth add USER GROUP
52
+ add_value: Add USER to authorization group GROUP. Requires admin privileges.
53
+ remove_key: auth remove USER GROUP
54
+ remove_value: Remove USER from authorization group GROUP. Requires admin privileges.
55
+ list_key: "auth list [GROUP]"
56
+ list_value: >-
57
+ List authorization groups and the users in them. If GROUP is supplied,
58
+ only lists that group.
59
+ user_added: "%{user} was added to %{group}."
60
+ user_already_in: "%{user} was already in %{group}."
61
+ user_removed: "%{user} was removed from %{group}."
62
+ user_not_in: "%{user} was not in %{group}."
63
+ empty_state: There are no authorization groups yet.
64
+ empty_state_group: "There is no authorization group named %{group}."
65
+ format: "Format"
66
+ admin_management: Administrators can only be managed via Lita config.
67
+ no_user_found: 'No user was found with the identifier "%{identifier}".'
68
+ help:
69
+ handler_contains: Handler "%{handler}" defines the following commands
70
+ help:
71
+ help_value: Lists help information for terms and command the robot will respond to.
72
+ help_query_key: "help QUERY"
73
+ help_query_value: Lists help information for commands matching QUERY.
74
+ info: >-
75
+ Send the message "%{address}help QUERY" to see matching help messages. QUERY may be the
76
+ name of a handler, text matching a message pattern a handler responds to, or text
77
+ matching the description of a message pattern a handler responds to. The following
78
+ handlers are installed:
79
+ no_help_found: "No matching handlers, message patterns, or descriptions found."
80
+ pattern_or_description_contains: Message patterns or descriptions that match "%{query}"
81
+ unauthorized: " [Unauthorized]"
82
+ info:
83
+ help:
84
+ info_value: Replies with the current version of Lita.
85
+ room:
86
+ help:
87
+ join_key: join ROOM_ID
88
+ join_value: Makes the robot join the room with room ID ROOM_ID.
89
+ part_key: part ROOM_ID
90
+ part_value: Makes the robot part from the room with room ID ROOM_ID.
91
+ users:
92
+ find_empty_state: No matching users found.
93
+ help:
94
+ find_key: users find SEARCH_TERM
95
+ find_value: Find a Lita user by ID, name, or mention name.
96
+ http:
97
+ exception: |
98
+ Lita's built-in web server could not be started. The exception was:
99
+ %{message}
100
+ Full backtrace:
101
+ %{backtrace}
102
+ plugin:
103
+ name_required: Plugins that are anonymous classes must set a namespace or define self.name.
104
+ redis:
105
+ exception: |
106
+ Lita could not connect to Redis. The exception was:
107
+ %{message}
108
+ Full backtrace:
109
+ %{backtrace}
110
+ test_mode_exception: |
111
+ Lita could not connect to Redis. The exception was:
112
+ %{message}
113
+ robot:
114
+ unknown_adapter: "Unknown adapter: :%{adapter}."
115
+ rspec:
116
+ full_suite_required: Lita::RSpec requires both RSpec::Mocks and RSpec::Expectations.
117
+ version_3_required: RSpec::Core 3 or greater is required to use Lita::RSpec.
118
+ rack_test_required: Rack::Test is required to use the `http` method of Lita::RSpec.
119
+ lita_3_compatibility_mode: >-
120
+ WARNING: Lita 3 compatibility mode is deprecated in Lita 5 and will be removed in Lita 6.
121
+ It no longer has any effect. Please remove any calls to `Lita.version_3_compatibility_mode`.
122
+ route_failure: |-
123
+ Expected message "%{message}" to route to :%{route}, but didn't.
124
+ negative_route_failure: |-
125
+ Expected message "%{message}" not to route to :%{route}, but did.
126
+ http_route_failure: |-
127
+ Expected request "%{method} %{path}" to route to :%{route}, but didn't.
128
+ negative_http_route_failure: |-
129
+ Expected request "%{method} %{path}" not to route to :%{route}, but did.
130
+ event_subscription_failure: |-
131
+ Expected triggering event "%{event}" to invoke :%{route}, but didn't.
132
+ negative_event_subscription_failure: |-
133
+ Expected triggering event "%{event}" not to invoke :%{route}, but did.
134
+ source:
135
+ user_or_room_required: Either a user or a room is required.
136
+ template:
137
+ missing_template: Missing template file at %{path}.
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
@@ -0,0 +1,29 @@
1
+ # <%= config[:gem_name] %>
2
+
3
+ TODO: Add a description of the plugin.
4
+
5
+ ## Installation
6
+
7
+ <%- if config[:plugin_type] == "extension" -%>
8
+ Add <%= config[:gem_name] %> to your Lita plugin's gemspec:
9
+
10
+ ``` ruby
11
+ spec.add_runtime_dependency "<%= config[:gem_name] %>"
12
+ ```
13
+ <%- else -%>
14
+ Add <%= config[:gem_name] %> to your Lita instance's Gemfile:
15
+
16
+ ``` ruby
17
+ gem "<%= config[:gem_name] %>"
18
+ ```
19
+ <%- end -%>
20
+
21
+ <%- unless config[:plugin_type] == "extension" -%>
22
+ ## Configuration
23
+
24
+ TODO: Describe any configuration attributes the plugin exposes.
25
+
26
+ <%- end -%>
27
+ ## Usage
28
+
29
+ TODO: Describe the plugin's features and how to use them.
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,27 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "<%= config[:gem_name] %>"
3
+ spec.version = "0.1.0"
4
+ spec.authors = ["<%= config[:author] %>"]
5
+ spec.email = ["<%= config[:email] %>"]
6
+ spec.description = "TODO: Add a description"
7
+ spec.summary = "TODO: Add a summary"
8
+ spec.homepage = "TODO: Add a homepage"
9
+ spec.license = "TODO: Add a license"
10
+ spec.metadata = { "lita_plugin_type" => "<%= config[:plugin_type] %>" }
11
+
12
+ spec.files = `git ls-files`.split($/)
13
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
14
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.require_paths = ["lib"]
16
+
17
+ spec.add_runtime_dependency "lita", ">= <%= config[:required_lita_version] %>"
18
+
19
+ spec.add_development_dependency "bundler", "~> 2.0"
20
+ if RUBY_PLATFORM != 'java'
21
+ spec.add_development_dependency "pry-byebug"
22
+ end
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "rack-test"
25
+ spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "simplecov"
27
+ end
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ lita_config.rb
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lita
4
+ module <%= config[:constant_namespace] %>
5
+ class <%= config[:constant_name] %><% unless config[:plugin_type] == "extension" %> < <%= config[:plugin_type].capitalize %><% end %>
6
+ # insert <%= config[:plugin_type] %> code here
7
+
8
+ <%- if config[:plugin_type] == "adapter" -%>
9
+ Lita.register_adapter(:<%= config[:name] %>, self)
10
+ <%- elsif config[:plugin_type] == "handler" -%>
11
+ Lita.register_handler(self)
12
+ <%- else -%>
13
+ # If your extension needs to register with a Lita hook, uncomment the
14
+ # following line and change the hook name to the appropriate value:
15
+ # Lita.register_hook(:hook_name, self)
16
+ <%- end -%>
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lita"
4
+
5
+ Lita.load_locales Dir[File.expand_path(
6
+ File.join("..", "..", "locales", "*.yml"), __FILE__
7
+ )]
8
+
9
+ require "lita/<%= config[:namespace] %>/<%= config[:name] %>"
10
+ <%- if config[:plugin_type] == "handler" -%>
11
+
12
+ Lita::<%= config[:constant_namespace] %>::<%= config[:constant_name] %>.template_root File.expand_path(
13
+ File.join("..", "..", "templates"),
14
+ __FILE__
15
+ )
16
+ <%- end -%>
@@ -0,0 +1,4 @@
1
+ en:
2
+ lita:
3
+ <%= config[:namespace] %>:
4
+ <%= config[:name] %>:
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ describe Lita::<%= config[:constant_namespace] %>::<%= config[:constant_name] %>, <%= config[:spec_type] %>: true do
6
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "simplecov"
4
+ require "coveralls"
5
+ SimpleCov.start { add_filter "/spec/" }
6
+
7
+ require "<%= config[:gem_name] %>"
8
+ require "lita/rspec"
File without changes
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "lita"
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ Lita.configure do |config|
4
+ # The name your robot will use.
5
+ config.robot.name = "Lita"
6
+
7
+ ## An array identifiers for users who are considered administrators. These
8
+ ## users have the ability to add and remove other users from authorization
9
+ ## groups. What is considered a user ID will change depending on which adapter
10
+ ## you use.
11
+ # config.robot.admins = ["1", "2"]
12
+
13
+ # The adapter you want to connect with. Make sure you've added the
14
+ # appropriate gem to the Gemfile.
15
+ config.robot.adapter = :shell
16
+
17
+ ## Example: Set options for the chosen adapter.
18
+ # config.adapter.username = "myname"
19
+ # config.adapter.password = "secret"
20
+
21
+ ## Example: Set options for the Redis connection.
22
+ # config.redis[:host] = "127.0.0.1"
23
+ # config.redis[:port] = 1234
24
+
25
+ ## Example: Set configuration for any loaded handlers. See the handler's
26
+ ## documentation for options.
27
+ # config.handlers.example_handler.example_attribute = "example value"
28
+ end