quick_config 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.
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +49 -0
- data/Rakefile +1 -0
- data/lib/quick_config.rb +29 -0
- data/lib/quick_config/version.rb +3 -0
- data/quick_config.gemspec +20 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/test_quick_config.rspec +22 -0
- metadata +60 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 TODO: Write your name
|
2
|
+
|
3
|
+
MIT License
|
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,49 @@
|
|
1
|
+
# QuickConfig
|
2
|
+
|
3
|
+
A quick and easy way to group and access your application configuration data.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'quick_config'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install quick_config
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
<pre>
|
22
|
+
#Include the gem.
|
23
|
+
<code>
|
24
|
+
require 'quick_config'
|
25
|
+
</code></pre>
|
26
|
+
|
27
|
+
<pre>
|
28
|
+
#Set property name/value pairs.
|
29
|
+
<code>
|
30
|
+
QuickConfig.set do
|
31
|
+
property :name, "K"
|
32
|
+
property :age, 12
|
33
|
+
end
|
34
|
+
</code></pre>
|
35
|
+
|
36
|
+
<pre>
|
37
|
+
#Read out previously set property
|
38
|
+
<code>
|
39
|
+
puts QuickConfig.name
|
40
|
+
puts QuickConfig.age
|
41
|
+
</code></pre>
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
1. Fork it
|
46
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
49
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/quick_config.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require "quick_config/version.rb"
|
2
|
+
|
3
|
+
module QuickConfig
|
4
|
+
extend self
|
5
|
+
|
6
|
+
def property(name, value=nil)
|
7
|
+
unless name_is_valid?(name)
|
8
|
+
raise "Property name invalid or not provided"
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_accessor name
|
12
|
+
|
13
|
+
define_method name do
|
14
|
+
value ? self.send("#{name}=", value) : instance_variable_get("@#{name}")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def set(&conf)
|
19
|
+
instance_eval(&conf)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def name_is_valid?(name)
|
25
|
+
!name.nil? \
|
26
|
+
&& (name.is_a?(Symbol) || name.is_a?(String)) \
|
27
|
+
&& !name.to_s().match(/^[a-zA-Z_]+[0-9a-zA-Z_]+$/).nil?
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'quick_config/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "quick_config"
|
8
|
+
gem.version = QuickConfig::VERSION
|
9
|
+
gem.authors = ["Kreso Tomac"]
|
10
|
+
gem.email = ["kreso.tomac@gmail.com"]
|
11
|
+
gem.description = %q{A quick and easy way to set and access configuration data in your Ruby applications.}
|
12
|
+
gem.summary = %q{Quickly set up and use application configuration data.}
|
13
|
+
gem.homepage = "http://quick-config.herokuapp.com/"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
gem.license = "MIT"
|
20
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.filter_run :focus
|
11
|
+
|
12
|
+
# Run specs in random order to surface order dependencies. If you find an
|
13
|
+
# order dependency and want to debug it, you can fix the order by providing
|
14
|
+
# the seed, which is printed after each run.
|
15
|
+
# --seed 1234
|
16
|
+
config.order = 'random'
|
17
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'quick_config'
|
3
|
+
|
4
|
+
describe QuickConfig do
|
5
|
+
@name = "K"
|
6
|
+
@age = 121
|
7
|
+
|
8
|
+
before do
|
9
|
+
QuickConfig.set do
|
10
|
+
property :name, @name
|
11
|
+
property :age, @age
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it "name property should match the name value" do
|
16
|
+
QuickConfig.name.should == @name
|
17
|
+
end
|
18
|
+
|
19
|
+
it "age property should match the age value" do
|
20
|
+
QuickConfig.age.should == @age
|
21
|
+
end
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: quick_config
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Kreso Tomac
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-29 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: A quick and easy way to set and access configuration data in your Ruby
|
15
|
+
applications.
|
16
|
+
email:
|
17
|
+
- kreso.tomac@gmail.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- .gitignore
|
23
|
+
- .rspec
|
24
|
+
- Gemfile
|
25
|
+
- LICENSE.txt
|
26
|
+
- README.md
|
27
|
+
- Rakefile
|
28
|
+
- lib/quick_config.rb
|
29
|
+
- lib/quick_config/version.rb
|
30
|
+
- quick_config.gemspec
|
31
|
+
- spec/spec_helper.rb
|
32
|
+
- spec/test_quick_config.rspec
|
33
|
+
homepage: http://quick-config.herokuapp.com/
|
34
|
+
licenses:
|
35
|
+
- MIT
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements: []
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 1.8.25
|
55
|
+
signing_key:
|
56
|
+
specification_version: 3
|
57
|
+
summary: Quickly set up and use application configuration data.
|
58
|
+
test_files:
|
59
|
+
- spec/spec_helper.rb
|
60
|
+
- spec/test_quick_config.rspec
|