gconfig 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fcafb29a5b923dae57d1ee80976230fc32bce481
4
+ data.tar.gz: bff8f33d2ef1d377c635695bd9e1237b6e175a72
5
+ SHA512:
6
+ metadata.gz: d40ed917bd73e6a5ffd832392a20f00dffcc2c3cd10879a7739dd105fa541945fd92d032ddbad2df212045931c2206982f73dac6a813b7e2245b6efd595ee293
7
+ data.tar.gz: 403dc0479156e241bf4b0efaadc44c87ce9a6711ce66d02bda818e477a1ab3afda3c79884a4b9325ad7f2e4da3ab9f4614611ba4dadce198f1babb1c6f5eb62b
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /*.gem
11
+ /*~
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.2
4
+ before_install: gem install bundler -v 1.10.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gconfig.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Gaëtan JUVIN
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,45 @@
1
+ # GConfig
2
+
3
+ Easy configuration gem.
4
+
5
+ ## Installation
6
+
7
+ ```ruby
8
+ gem 'gconfig'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install gconfig
18
+
19
+ ## Usage
20
+
21
+ ```
22
+ require 'gconfig'
23
+
24
+ module MyModule
25
+ extend GConfig
26
+ default mailer_sender: 'toto@example.com', age: 3
27
+ default name: 'Nicolas'
28
+ default last_name: 'Dulac'
29
+
30
+ ...
31
+ end
32
+
33
+ MyModule.config do |config|
34
+ config.mailer_sender = 'donotreply@example.com'
35
+ end
36
+
37
+ puts MyModule.config.mailer_sender
38
+ puts MyModule.config.age
39
+
40
+ ```
41
+
42
+
43
+ ## License
44
+
45
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "gconfig"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,34 @@
1
+ # encoding: utf-8
2
+
3
+ ##
4
+ ## gconfig.gemspec
5
+ ## Gaetan JUVIN 16/07/2015
6
+ ##
7
+
8
+ lib = File.expand_path('../lib', __FILE__)
9
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
10
+ require 'gconfig/version'
11
+
12
+ Gem::Specification.new do |spec|
13
+ spec.name = 'gconfig'
14
+ spec.version = GConfig::VERSION
15
+ spec.authors = ['Gaëtan JUVIN']
16
+ spec.email = ['gaetanjuvin@gmail.com']
17
+
18
+ spec.summary = %q{A gem to provide a configuration system for other gem.}
19
+ spec.homepage = 'https://github.com/GaetanJUVIN/gconfig'
20
+ spec.license = 'MIT'
21
+
22
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
23
+ # delete this section to allow pushing this gem to any host.
24
+ if spec.respond_to?(:metadata)
25
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
26
+ else
27
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
28
+ end
29
+
30
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.10"
34
+ end
@@ -0,0 +1,52 @@
1
+ # encoding: utf-8
2
+
3
+ ##
4
+ ## configuration.rb
5
+ ## Gaetan JUVIN 16/07/2015
6
+ ##
7
+
8
+ require "gconfig/version"
9
+
10
+ #### Configuration module
11
+
12
+ # require 'gconfig'
13
+ #
14
+ # module MyModule
15
+ # extend GConfig
16
+ # default mailer_sender: 'toto@example.com', age: 3
17
+ # default name: 'Nicolas'
18
+ # default last_name: 'Dulac'
19
+ # ...
20
+ # end
21
+ #
22
+ # MyModule.config do |config|
23
+ # config.mailer_sender = 'donotreply@example.com'
24
+ # end
25
+ #
26
+ # puts MyModule.config.mailer_sender
27
+ # puts MyModule.config.age
28
+
29
+ module GConfig
30
+ def config
31
+ @config ||= Configuration.new
32
+ yield @config if block_given?
33
+ @config
34
+ end
35
+
36
+ def default(*args)
37
+ args.each do |arg|
38
+ raise 'default :key => :value' unless arg.is_a?(Hash)
39
+ arg.each do |key, value|
40
+ self.config.generate_parameters(key, value)
41
+ end
42
+ end
43
+ end
44
+
45
+ class Configuration
46
+ # Generate automatically instance variable for any parameters
47
+ def generate_parameters(name, value)
48
+ self.instance_variable_set("@#{name}", value)
49
+ self.class.send(:attr_accessor, name)
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,3 @@
1
+ module GConfig
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gconfig
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Gaëtan JUVIN
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ description:
28
+ email:
29
+ - gaetanjuvin@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - ".travis.yml"
36
+ - Gemfile
37
+ - LICENSE.txt
38
+ - README.md
39
+ - Rakefile
40
+ - bin/console
41
+ - bin/setup
42
+ - gconfig.gemspec
43
+ - lib/gconfig.rb
44
+ - lib/gconfig/version.rb
45
+ homepage: https://github.com/GaetanJUVIN/gconfig
46
+ licenses:
47
+ - MIT
48
+ metadata:
49
+ allowed_push_host: https://rubygems.org
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubyforge_project:
66
+ rubygems_version: 2.2.2
67
+ signing_key:
68
+ specification_version: 4
69
+ summary: A gem to provide a configuration system for other gem.
70
+ test_files: []