lita_dotenv 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 87394108708b354c9bfc2573e9ac4a6e3a7478ee
4
+ data.tar.gz: 15b7cba8cbaecedc1e4312de1031cc0750a5c060
5
+ SHA512:
6
+ metadata.gz: 3c0875868a1e45494736f4936d61952e3fc31cc7f95808c93f796161d23d0ed63868dc623fd1d7aa91a4ae220b155e416df15778d5e7e6172fbb1ce03eabd9c4
7
+ data.tar.gz: f71a86d5370df3943aa04e89c6e4114117cc91b54666639eb999f6d533bcffb5ba72e1b9547d263659a1bdcd09e3fa985edd64fe0315ee9a16d57d7ee829360d
data/CHANGELOG.md ADDED
@@ -0,0 +1,4 @@
1
+ CHANGELOG
2
+ ---------
3
+ - **0.0.1** - 2016-09-02
4
+ - Initial commit
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 John Wang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,91 @@
1
+ Lita Dotenv Config Loader
2
+ =========================
3
+
4
+ [![Gem Version][gem-version-svg]][gem-version-link]
5
+ [![Dependency Status][dependency-status-svg]][dependency-status-link]
6
+ [![Code Climate][codeclimate-status-svg]][codeclimate-status-link]
7
+ [![Scrutinizer Code Quality][scrutinizer-status-svg]][scrutinizer-status-link]
8
+ [![Downloads][downloads-svg]][downloads-link]
9
+ [![Docs][docs-rubydoc-svg]][docs-rubydoc-link]
10
+ [![License][license-svg]][license-link]
11
+
12
+ `lita-dotenv_config` is `.env` config loader for [Lita](https://www.lita.io/).
13
+
14
+ ## Installation
15
+
16
+ Add `lita-dotenv_config` to your Lita instance's Gemfile:
17
+
18
+ ``` ruby
19
+ gem "lita-dotenv_config"
20
+ ```
21
+
22
+ ## Configuration
23
+
24
+ ### .env
25
+
26
+ `DotenvConfig` uses a simple parser that follows the following rules for assigning ENV variable names to Lita paths:
27
+
28
+ 1. all paths begin with `LITA_`
29
+ 2. all paths are designed to match Lita configure paths
30
+ 3. optional type coercion is available by setting the type as a suffix:
31
+ 1. Symbol: __TYPESYM
32
+ 2. Boolean: __TYPEBOOL
33
+ 3. Integer: __TYPEINT
34
+ 4. underscores are handled in paths by using camelCase
35
+
36
+ ```
37
+ LITA_ROBOT_NAME=Configbot # config.robot.name = 'Configbot'
38
+ LITA_ROBOT_LOCALE__TYPESYM=en # config.robot.locale = :en
39
+ LITA_ROBOT_logLevel__TYPESYM=info # config.robot.log_level = :info
40
+ ```
41
+
42
+ ### lita_config.rb
43
+
44
+ ```ruby
45
+ Lita.configure do |config|
46
+ config = Lita::Extensions::DotenvConfig.new(config).config
47
+ end
48
+ ```
49
+
50
+ ## Change Log
51
+
52
+ See [CHANGELOG.md](CHANGELOG.md)
53
+
54
+ ## Links
55
+
56
+ Project Repo
57
+
58
+ * https://github.com/grokify/lita-dotenv_config
59
+
60
+ Lita
61
+
62
+ * https://www.lita.io/
63
+
64
+ ## Contributing
65
+
66
+ 1. Fork it ( http://github.com/grokify/lita-dotenv_config/fork )
67
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
68
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
69
+ 4. Push to the branch (`git push origin my-new-feature`)
70
+ 5. Create new Pull Request
71
+
72
+ ## License
73
+
74
+ Lita Dotenv Config Loader is available under the MIT license. See [LICENSE.txt](LICENSE.txt) for details.
75
+
76
+ Lita Dotenv Config Loader © 2016 by John Wang
77
+
78
+ [gem-version-svg]: https://badge.fury.io/rb/lita-dotenv_config.svg
79
+ [gem-version-link]: http://badge.fury.io/rb/lita-dotenv_config
80
+ [downloads-svg]: http://ruby-gem-downloads-badge.herokuapp.com/lita-dotenv_config
81
+ [downloads-link]: https://rubygems.org/gems/lita-dotenv_config
82
+ [dependency-status-svg]: https://gemnasium.com/grokify/lita-dotenv_config.svg
83
+ [dependency-status-link]: https://gemnasium.com/grokify/lita-dotenv_config
84
+ [codeclimate-status-svg]: https://codeclimate.com/github/grokify/lita-dotenv_config/badges/gpa.svg
85
+ [codeclimate-status-link]: https://codeclimate.com/github/grokify/lita-dotenv_config
86
+ [scrutinizer-status-svg]: https://scrutinizer-ci.com/g/grokify/lita-dotenv_config/badges/quality-score.png?b=master
87
+ [scrutinizer-status-link]: https://scrutinizer-ci.com/g/grokify/lita-dotenv_config/?branch=master
88
+ [docs-rubydoc-svg]: https://img.shields.io/badge/docs-rubydoc-blue.svg
89
+ [docs-rubydoc-link]: http://www.rubydoc.info/gems/lita-dotenv_config/
90
+ [license-svg]: https://img.shields.io/badge/license-MIT-blue.svg
91
+ [license-link]: https://github.com/grokify/lita-dotenv_config/blob/master/LICENSE.txt
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,11 @@
1
+ module LitaDotenv
2
+ VERSION = '0.0.1'
3
+
4
+ autoload :Loader, 'lita_dotenv/loader'
5
+
6
+ class << self
7
+ def new(config)
8
+ LitaDotenv::Loader.new config
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,49 @@
1
+ require 'dotenv'
2
+
3
+ module LitaDotenv
4
+ class Loader
5
+ attr_accessor :config
6
+
7
+ def initialize(config)
8
+ @config = config
9
+ Dotenv.load
10
+ config_env
11
+ end
12
+
13
+ def config_env
14
+ ENV.keys.grep(/^LITA_/i) do |key|
15
+ val = ENV[key]
16
+ slugs = key.split('__')
17
+
18
+ # Convert value types
19
+ if slugs.length==2
20
+ type = slugs[1].downcase
21
+ if type=='typesym'
22
+ val = val.to_sym
23
+ elsif type == 'typebool'
24
+ val = val.downcase == 'true' ? true : false
25
+ elsif type == 'typeint' && type =~ /^s*[0-9]+\s*$/
26
+ val = val.to_i
27
+ end
28
+ end
29
+
30
+ # Convert path
31
+ path = slugs[0].split('_')
32
+ path.shift # Remove LITA prefix
33
+ path.each_with_index do |part, i|
34
+ if part =~ /[a-z]/
35
+ path[i] = part.gsub(/([A-Z])/, '_\1')
36
+ end
37
+ path[i].downcase!
38
+ end
39
+ if path.length == 2
40
+ @config.send(path[0]).send("#{path[1]}=",val)
41
+ elsif path.length == 3
42
+ @config.send(path[0]).send(path[1]).send("#{path[2]}=",val)
43
+ else
44
+ raise "Config path length #{path.length} not supported for #{path.join('.')}."
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
metadata ADDED
@@ -0,0 +1,163 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita_dotenv
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - John Wang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-09-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dotenv
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.1.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 2.1.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: lita
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 4.4.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 4.4.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rack-test
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: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
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.0.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 3.0.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 0.9.2
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 0.9.2
111
+ - !ruby/object:Gem::Dependency
112
+ name: coveralls
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: A Lita .env config loader.
126
+ email:
127
+ - johncwang@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - CHANGELOG.md
133
+ - Gemfile
134
+ - LICENSE.txt
135
+ - README.md
136
+ - Rakefile
137
+ - lib/lita_dotenv.rb
138
+ - lib/lita_dotenv/loader.rb
139
+ homepage: https://github.com/grokify/lita-dotenv_config
140
+ licenses:
141
+ - MIT
142
+ metadata: {}
143
+ post_install_message:
144
+ rdoc_options: []
145
+ require_paths:
146
+ - lib
147
+ required_ruby_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ required_rubygems_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ requirements: []
158
+ rubyforge_project:
159
+ rubygems_version: 2.5.1
160
+ signing_key:
161
+ specification_version: 4
162
+ summary: A Lita .env config loader that loads ENV values directly into Lita's configuration.
163
+ test_files: []