configur 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +47 -0
- data/configur.gemspec +23 -0
- data/lib/configur.rb +39 -0
- metadata +49 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: eb37d6805380cec8569abb4eddefae12fa8b308e
|
4
|
+
data.tar.gz: ad22074f3680a1f8ef711858cb9695bb3a8e05bd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 96b4dbf35938975cf0aa77e9229a67227c95feca2766ef7ffb5a3895f169baa734633144e77e29f1a1453fc70fba4a1a5eb2b39a012b96f4efbf72d1a512f448
|
7
|
+
data.tar.gz: 220800788f60767910c47bd3522f33b667fa7636f0a9cfbe88f5985d6981d2d1ce93f0e297e2f75212a8338da5a229668f1b34eac3cfdd080d046ed562bb81b9
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Pierre Lecocq
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# Configur
|
2
|
+
|
3
|
+
Simply set configuration for you ruby class or module
|
4
|
+
|
5
|
+
## How to install it ?
|
6
|
+
|
7
|
+
### Command line way
|
8
|
+
|
9
|
+
Simply run the folowing command:
|
10
|
+
|
11
|
+
sudo gem install configur
|
12
|
+
|
13
|
+
### Bundler way
|
14
|
+
|
15
|
+
Add this to your Gemfile
|
16
|
+
|
17
|
+
gem 'configur'
|
18
|
+
|
19
|
+
## How to use it ?
|
20
|
+
|
21
|
+
No explanation, just an example to show you how easy it is:
|
22
|
+
|
23
|
+
require 'configur'
|
24
|
+
|
25
|
+
class MyClass
|
26
|
+
extend Configur
|
27
|
+
end
|
28
|
+
|
29
|
+
MyClass.configur do |config|
|
30
|
+
config.debug = true
|
31
|
+
config.app_name = 'myawesomeapp'
|
32
|
+
end
|
33
|
+
|
34
|
+
And it also works for modules. Nevermind
|
35
|
+
|
36
|
+
## Methods
|
37
|
+
|
38
|
+
After configuring your class or module, you can "query" with the following methods:
|
39
|
+
|
40
|
+
puts MyClass.get_config :app_name
|
41
|
+
puts MyClass.get_configs
|
42
|
+
|
43
|
+
Easy, isn't it?
|
44
|
+
|
45
|
+
## License
|
46
|
+
|
47
|
+
Please see the [LICENSE](https://github.com/pierre-lecocq/configur/blob/master/LICENSE) file
|
data/configur.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# File: configur.gemspec
|
2
|
+
# Time-stamp: <2014-11-25 23:54:01 pierre>
|
3
|
+
# Copyright (C) 2014 Pierre Lecocq
|
4
|
+
# Description: Configur library gemspec file
|
5
|
+
|
6
|
+
require File.expand_path('../lib/configur', __FILE__)
|
7
|
+
|
8
|
+
Gem::Specification.new do |gem|
|
9
|
+
gem.name = 'configur'
|
10
|
+
gem.require_paths = ['lib']
|
11
|
+
gem.version = Configur::VERSION
|
12
|
+
gem.files =
|
13
|
+
%w(README.md LICENSE configur.gemspec) +
|
14
|
+
`git ls-files lib spec`.split("\n")
|
15
|
+
|
16
|
+
gem.authors = ['Pierre Lecocq']
|
17
|
+
gem.email = ['pierre.lecocq@gmail.com']
|
18
|
+
gem.summary = 'Simply set configuration for you ruby class or module'
|
19
|
+
gem.description = 'Simply set configuration for you ruby class or module'
|
20
|
+
gem.homepage = 'https://github.com/pierre-lecocq/configur'
|
21
|
+
gem.date = '2014-11-25'
|
22
|
+
gem.license = 'MIT'
|
23
|
+
end
|
data/lib/configur.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# File: configur.rb
|
4
|
+
# Time-stamp: <2014-11-25 23:54:12 pierre>
|
5
|
+
# Copyright (C) 2014 Pierre Lecocq
|
6
|
+
# Description: Configur gem module
|
7
|
+
|
8
|
+
# Configur module
|
9
|
+
module Configur
|
10
|
+
# Version constant
|
11
|
+
VERSION = [1, 0, 0].join '.'
|
12
|
+
|
13
|
+
# Configur
|
14
|
+
def configur(&block)
|
15
|
+
@@_configur_data ||= {}
|
16
|
+
|
17
|
+
def block.method_missing(m, *args, &block)
|
18
|
+
name = m.to_s.gsub '=', ''
|
19
|
+
Configur.set_config name, args[0]
|
20
|
+
end
|
21
|
+
|
22
|
+
yield block
|
23
|
+
end
|
24
|
+
|
25
|
+
# Get all configs
|
26
|
+
def get_configs
|
27
|
+
@@_configur_data || {}
|
28
|
+
end
|
29
|
+
|
30
|
+
# Get a config value
|
31
|
+
def get_config(name)
|
32
|
+
@@_configur_data[name.to_sym] || nil
|
33
|
+
end
|
34
|
+
|
35
|
+
# Set a config value
|
36
|
+
def self.set_config(name, value)
|
37
|
+
@@_configur_data[name.to_sym] = value
|
38
|
+
end
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: configur
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pierre Lecocq
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-25 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Simply set configuration for you ruby class or module
|
14
|
+
email:
|
15
|
+
- pierre.lecocq@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- LICENSE
|
21
|
+
- README.md
|
22
|
+
- configur.gemspec
|
23
|
+
- lib/configur.rb
|
24
|
+
homepage: https://github.com/pierre-lecocq/configur
|
25
|
+
licenses:
|
26
|
+
- MIT
|
27
|
+
metadata: {}
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 2.2.2
|
45
|
+
signing_key:
|
46
|
+
specification_version: 4
|
47
|
+
summary: Simply set configuration for you ruby class or module
|
48
|
+
test_files: []
|
49
|
+
has_rdoc:
|