lita-ext 1.0.0 → 1.1.0.beta1
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 +4 -4
- data/README.md +8 -4
- data/bin/lita-ext +0 -0
- data/lib/lita/ext/core.rb +43 -40
- data/lib/lita/ext/handler.rb +0 -8
- data/lib/lita/ext/version.rb +1 -1
- data/lita-ext.gemspec +1 -1
- data/spec/lita/ext/handler_spec.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75dcdfaeb1c47c8f06a71a8c8790addc24e7320e
|
4
|
+
data.tar.gz: 0a577d978fcf07274f55f56c18c370ea00bb0a37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05aea7c818d5b85354edcb315d4096aa19d76fc4c9e4e2ab049f7de2840e3b9ab536532b0a3ddd9fa0503eca004d9c8e4ec06dda1bffa71050f44d942a941e1c
|
7
|
+
data.tar.gz: afb90d18b63adfb600066c0948bba3d13dd914a01948f139eeda465b84530b048b9371d5c7d9088a9ea353e35a89e600abd4c39e07b075e6e44268d48688243c
|
data/README.md
CHANGED
@@ -18,7 +18,7 @@ The layout of a Lita::Ext bot:
|
|
18
18
|
│ ├── environments
|
19
19
|
│ │ ├── development.rb
|
20
20
|
│ │ ├── production.rb
|
21
|
-
│ │ └──
|
21
|
+
│ │ └── staging.rb
|
22
22
|
│ └── initializers
|
23
23
|
│ └── initialize_foo.rb
|
24
24
|
├── lib
|
@@ -55,8 +55,8 @@ Or install it yourself as:
|
|
55
55
|
|
56
56
|
### Startup Process
|
57
57
|
|
58
|
-
Lita::Ext performs serveral actions at startup that
|
59
|
-
to focus on writing
|
58
|
+
Lita::Ext performs serveral actions at startup that make it easier for you
|
59
|
+
to focus on writing custom handlers for your bot. The `Lita.run` method
|
60
60
|
performs the following additional actions:
|
61
61
|
|
62
62
|
1. Change directory to the `Lita.root` directory.
|
@@ -82,7 +82,7 @@ environment is set with the `LITA_ENV` environment variable and defaults
|
|
82
82
|
to `"development"` when not set. The Lita environment will determine which
|
83
83
|
environment configuration to load form the `config/environments` directory
|
84
84
|
and which Dotenv settings file to load. Environments can be used to run
|
85
|
-
different adapters for development,
|
85
|
+
different adapters for development, staging, and production. For example,
|
86
86
|
you can use the shell adapter for the development environment and the
|
87
87
|
[Campfire adapter](https://github.com/josacar/lita-campfire) in production.
|
88
88
|
|
@@ -138,3 +138,7 @@ Example:
|
|
138
138
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
139
139
|
4. Push to the branch (`git push origin my-new-feature`)
|
140
140
|
5. Create new Pull Request
|
141
|
+
|
142
|
+
***
|
143
|
+
|
144
|
+
Unless otherwise specified, all content copyright © 2014, [Rails Machine, LLC](http://railsmachine.com)
|
data/bin/lita-ext
CHANGED
File without changes
|
data/lib/lita/ext/core.rb
CHANGED
@@ -12,58 +12,61 @@ module Lita
|
|
12
12
|
def root
|
13
13
|
@root ||= ENV['LITA_ROOT'] ||= File.expand_path('.')
|
14
14
|
end
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
alias_method_chain :run, :ext
|
17
|
+
module Ext
|
18
|
+
class Core
|
19
|
+
def self.call(payload)
|
20
|
+
chdir_to_lita_root
|
21
|
+
load_dotenv
|
22
|
+
add_lib_to_load_path
|
23
|
+
load_initializers
|
24
|
+
load_app_handlers
|
25
|
+
register_app_handlers
|
26
|
+
load_environment_config
|
27
|
+
end
|
28
28
|
|
29
|
-
|
29
|
+
private
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
def chdir_to_lita_root
|
32
|
+
Dir.chdir(Lita.root)
|
33
|
+
end
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
def load_dotenv
|
36
|
+
Dotenv.load ".env.#{Lita.env}", '.env'
|
37
|
+
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
def add_lib_to_load_path
|
40
|
+
lib = File.expand_path('lib', Lita.root)
|
41
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
42
|
+
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
def load_initializers
|
45
|
+
initializers = "#{Lita.root}/config/initializers/**/*.rb"
|
46
|
+
Dir.glob(initializers).each { |initializer| require initializer }
|
47
|
+
end
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
def load_app_handlers
|
50
|
+
handlers = "#{Lita.root}/app/handlers/**/*.rb"
|
51
|
+
Dir.glob(handlers).each { |handler| require handler }
|
52
|
+
end
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
def register_app_handlers
|
55
|
+
Lita::Handler.handlers.each do |handler|
|
56
|
+
unless handler.disabled?
|
57
|
+
Lita.register_handler(handler)
|
58
|
+
end
|
58
59
|
end
|
59
60
|
end
|
60
|
-
end
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
def load_environment_config
|
63
|
+
environment = "#{Lita.root}/config/environments/#{Lita.env}"
|
64
|
+
if File.exists?("#{environment}.rb")
|
65
|
+
require environment
|
66
|
+
end
|
66
67
|
end
|
67
68
|
end
|
69
|
+
|
70
|
+
Lita.register_hook(:before_run, Core)
|
68
71
|
end
|
69
72
|
end
|
data/lib/lita/ext/handler.rb
CHANGED
data/lib/lita/ext/version.rb
CHANGED
data/lita-ext.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_runtime_dependency "lita", "~> 3.
|
21
|
+
spec.add_runtime_dependency "lita", "~> 3.3.1"
|
22
22
|
spec.add_runtime_dependency "dotenv"
|
23
23
|
spec.add_runtime_dependency "activesupport"
|
24
24
|
|
@@ -21,7 +21,7 @@ describe Lita::Handler, lita: true do
|
|
21
21
|
it "auto-registers Lita::Handler sub-classes" do
|
22
22
|
class TestHandler < Lita::Handler
|
23
23
|
end
|
24
|
-
Lita.send(:register_app_handlers)
|
24
|
+
Lita::Ext::Core.new.send(:register_app_handlers)
|
25
25
|
expect(Lita.handlers).to include(TestHandler)
|
26
26
|
end
|
27
27
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.1.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Traywick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.3.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 3.3.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: dotenv
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -157,9 +157,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
157
157
|
version: '0'
|
158
158
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
159
|
requirements:
|
160
|
-
- - '
|
160
|
+
- - '>'
|
161
161
|
- !ruby/object:Gem::Version
|
162
|
-
version:
|
162
|
+
version: 1.3.1
|
163
163
|
requirements: []
|
164
164
|
rubyforge_project:
|
165
165
|
rubygems_version: 2.0.0
|