dotconfig 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +6 -0
- data/CHANGELOG.md +6 -1
- data/README.md +1 -1
- data/dotconfig.gemspec +1 -0
- data/lib/dot_config.rb +6 -0
- data/lib/dot_config/configuration.rb +11 -0
- data/lib/dot_config/version.rb +1 -1
- metadata +18 -1
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# DotConfig
|
1
|
+
# DotConfig [![Build Status](https://travis-ci.org/GRoguelon/DotConfig.png?branch=master)](https://travis-ci.org/GRoguelon/DotConfig)
|
2
2
|
|
3
3
|
The DotConfig gem give you access to your configuration via the dot syntax. You instantiate DotConfig::Configuration with a Hash and you will retrieve the values in calling the key as method name.
|
4
4
|
|
data/dotconfig.gemspec
CHANGED
data/lib/dot_config.rb
CHANGED
@@ -16,6 +16,12 @@ module DotConfig
|
|
16
16
|
# which represent the YAML file to load.
|
17
17
|
# @param [Boolean] writing Determines if the +Configuration+ is mutable.
|
18
18
|
# @return [Configuration] The +Configuration+ instance.
|
19
|
+
# @example Generate a new instance of the +DotConfig::Configuration+ class with an initial hash:
|
20
|
+
# DotConfig.new(your_hash) #=> #<DotConfig::Configuration:0x007fa5d38f4fa0>
|
21
|
+
# DotConfig.new(your_hash, true) #=> #<DotConfig::Configuration:0x007fa5d38f4fa0>
|
22
|
+
# @example Generate a new instance of the +DotConfig::Configuration+ class with a YAML file:
|
23
|
+
# DotConfig.new(yaml_path) #=> #<DotConfig::Configuration:0x007fa5d38f4fa0>
|
24
|
+
# DotConfig.new(yaml_path, true) #=> #<DotConfig::Configuration:0x007fa5d38f4fa0>
|
19
25
|
def self.new(config, writing = false)
|
20
26
|
if config.is_a?(Hash)
|
21
27
|
Configuration.new(config: config, writing: writing)
|
@@ -5,6 +5,17 @@ module DotConfig
|
|
5
5
|
# This class gives you access to the configuration with dot syntax.
|
6
6
|
#
|
7
7
|
# @author {mailto:geoffrey.roguelon@gmail.com Geoffrey Roguelon}
|
8
|
+
# @example Using the dot syntax (readonly):
|
9
|
+
# app_config = DotConfig::Configuration.new #=> #<DotConfig::Configuration:0x007fa5d38f4fa0>
|
10
|
+
# app_config.config = { ruby: { rails => '4.0.0', sinatra: '1.3.3' } }
|
11
|
+
# app_config.ruby.rails #=> '4.0.0'
|
12
|
+
# app_config.python #=> NoMethodError: undefined method `python' for #<DotConfig::Configuration:0x007fa5d38c23c0>
|
13
|
+
# @example Using the dot syntax:
|
14
|
+
# app_config = DotConfig::Configuration.new(writing: true) #=> #<DotConfig::Configuration:0x007fa5d38f4fa0>
|
15
|
+
# app_config.config = { ruby: { rails => '4.0.0', sinatra: '1.3.3' } }
|
16
|
+
# app_config.ruby.rails #=> '4.0.0'
|
17
|
+
# app_config.ruby.rails = '3.2.9'
|
18
|
+
# app_config.ruby.rails #=> '3.2.9'
|
8
19
|
class Configuration
|
9
20
|
|
10
21
|
# @!attribute config [r]
|
data/lib/dot_config/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dotconfig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '3.0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
30
46
|
description: ! 'Simplify your configuration with: DotConfig.new(language: :ruby).language
|
31
47
|
#=> ''Ruby''.'
|
32
48
|
email: geoffrey.roguelon@gmail.com
|
@@ -35,6 +51,7 @@ extensions: []
|
|
35
51
|
extra_rdoc_files: []
|
36
52
|
files:
|
37
53
|
- .gitignore
|
54
|
+
- .travis.yml
|
38
55
|
- CHANGELOG.md
|
39
56
|
- Gemfile
|
40
57
|
- LICENSE.txt
|