lita-ext 1.0.0 → 1.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4297bf51b4083a9decd7c0b28fbfacdefcbf6ab0
4
- data.tar.gz: 249a40dc0c293005a58aad62b6f7b815476ee407
3
+ metadata.gz: 75dcdfaeb1c47c8f06a71a8c8790addc24e7320e
4
+ data.tar.gz: 0a577d978fcf07274f55f56c18c370ea00bb0a37
5
5
  SHA512:
6
- metadata.gz: 1b19a3fdaab026595a642472b0a6d4fe8ec1bc9ca12fda97f64f85aeb55d9b32c2b816a078e8b642087331ceb8c00af577979776fc5eba2a94604450b2e38528
7
- data.tar.gz: c409b29f698f21fa0a8bf01f0c495542bab4f95af8decdf94c811a8801db63d59e58cff5f630ce171bf084220f94e3012074ed3f1bad0b24a563f5331c9393a4
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
- │   │   └── testing.rb
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 makes it easier for you
59
- to focus on writing customer handlers for your bot. The `Lita.run` method
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, testing, and production. For example,
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
- def run_with_ext(config_path = nil)
17
- chdir_to_lita_root
18
- load_dotenv
19
- add_lib_to_load_path
20
- load_initializers
21
- load_app_handlers
22
- register_app_handlers
23
- load_environment_config
24
-
25
- run_without_ext(config_path)
26
- end
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
- private
29
+ private
30
30
 
31
- def chdir_to_lita_root
32
- Dir.chdir(Lita.root)
33
- end
31
+ def chdir_to_lita_root
32
+ Dir.chdir(Lita.root)
33
+ end
34
34
 
35
- def load_dotenv
36
- Dotenv.load ".env.#{Lita.env}", '.env'
37
- end
35
+ def load_dotenv
36
+ Dotenv.load ".env.#{Lita.env}", '.env'
37
+ end
38
38
 
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
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
- def load_initializers
45
- initializers = "#{Lita.root}/config/initializers/**/*.rb"
46
- Dir.glob(initializers).each { |initializer| require initializer }
47
- end
44
+ def load_initializers
45
+ initializers = "#{Lita.root}/config/initializers/**/*.rb"
46
+ Dir.glob(initializers).each { |initializer| require initializer }
47
+ end
48
48
 
49
- def load_app_handlers
50
- handlers = "#{Lita.root}/app/handlers/**/*.rb"
51
- Dir.glob(handlers).each { |handler| require handler }
52
- end
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
- def register_app_handlers
55
- Lita::Handler.handlers.each do |handler|
56
- unless handler.disabled?
57
- Lita.register_handler(handler)
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
- def load_environment_config
63
- environment = "#{Lita.root}/config/environments/#{Lita.env}"
64
- if File.exists?("#{environment}.rb")
65
- require environment
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
@@ -3,14 +3,6 @@ require 'lita/handler'
3
3
 
4
4
  module Lita
5
5
  class Handler
6
- def log
7
- Lita.logger
8
- end
9
-
10
- def config
11
- Lita.config.handlers[self.class.namespace]
12
- end
13
-
14
6
  def config_valid?
15
7
  valid = true
16
8
  self.class.config_options.each do |config_option|
@@ -1,5 +1,5 @@
1
1
  module Lita
2
2
  module Ext
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0.beta1"
4
4
  end
5
5
  end
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.0"
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.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-04-22 00:00:00.000000000 Z
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: '3.0'
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: '3.0'
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: '0'
162
+ version: 1.3.1
163
163
  requirements: []
164
164
  rubyforge_project:
165
165
  rubygems_version: 2.0.0