gaston 0.3.3 → 0.4.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.
- checksums.yaml +4 -4
- data/lib/gaston.rb +5 -4
- data/lib/gaston/builder.rb +26 -0
- data/lib/gaston/version.rb +1 -1
- metadata +18 -3
- data/lib/gaston/store.rb +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a7ca490d6511962c5dce0fed59d3c09ff58bd16
|
4
|
+
data.tar.gz: b1b049947299d61791c885b2c615c934757f50ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9777bf0fe380c53fd6e74346ccd271b8f5a71e866099512ffd8558b18097c8e93af0db91937ca553de5cfc0ec4b1f3b344db58940a3322aae51cffc65f331897
|
7
|
+
data.tar.gz: 1e98991a1df38789c6a944b1ce98507d9c1b8875f504387e6c15ae18c325d7c0f7b7fa314068c04a8c7d4138d69fd93a48a52133febeda2b2fe2bbec672f399d
|
data/lib/gaston.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'yaml'
|
3
3
|
require 'singleton'
|
4
|
+
require 'inflecto'
|
4
5
|
|
5
6
|
class Gaston
|
6
7
|
include Singleton
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
require_relative 'gaston/configuration'
|
9
|
+
require_relative 'gaston/builder'
|
10
|
+
require_relative 'gaston/parse'
|
10
11
|
if defined?(Rails) && defined?(Rails::Generators)
|
11
12
|
require 'gaston/generators/gaston/config_generator'
|
12
13
|
end
|
@@ -17,7 +18,7 @@ class Gaston
|
|
17
18
|
# @since 0.0.1
|
18
19
|
#
|
19
20
|
def store
|
20
|
-
@store ||= Gaston::
|
21
|
+
@store ||= Gaston::Builder.new(self.class, hash_from_files)
|
21
22
|
end
|
22
23
|
|
23
24
|
class << self
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
class Gaston
|
3
|
+
class Builder
|
4
|
+
class << self
|
5
|
+
def new(parent, hash={})
|
6
|
+
hash.each_with_object({}) do |(key, store), hsh|
|
7
|
+
if store.is_a?(Hash)
|
8
|
+
camelize = Inflecto.camelize(key)
|
9
|
+
klass = if parent.const_defined? camelize, false
|
10
|
+
Inflecto.constantize("#{parent}::#{camelize}")
|
11
|
+
else
|
12
|
+
parent.const_set camelize, Class.new(Hash)
|
13
|
+
end
|
14
|
+
store = klass[Gaston::Builder.new(klass, store)]
|
15
|
+
end
|
16
|
+
if parent.instance_methods.include? key.to_sym
|
17
|
+
warn "#{key} method already exists on #{parent}, value: #{store}"
|
18
|
+
else
|
19
|
+
hsh[key] = store
|
20
|
+
parent.send(:define_method, key, -> { store })
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/gaston/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gaston
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- chatgris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-04-
|
11
|
+
date: 2013-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: inflecto
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rspec
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -33,12 +47,12 @@ files:
|
|
33
47
|
- LICENSE
|
34
48
|
- README.md
|
35
49
|
- lib/gaston.rb
|
50
|
+
- lib/gaston/builder.rb
|
36
51
|
- lib/gaston/configuration.rb
|
37
52
|
- lib/gaston/generators/gaston/config_generator.rb
|
38
53
|
- lib/gaston/generators/templates/_gaston.rb
|
39
54
|
- lib/gaston/generators/templates/gaston/.gitkeep
|
40
55
|
- lib/gaston/parse.rb
|
41
|
-
- lib/gaston/store.rb
|
42
56
|
- lib/gaston/version.rb
|
43
57
|
homepage: http://chatgris.github.com/Gaston
|
44
58
|
licenses: []
|
@@ -64,3 +78,4 @@ signing_key:
|
|
64
78
|
specification_version: 4
|
65
79
|
summary: Dead simple Ruby config store.
|
66
80
|
test_files: []
|
81
|
+
has_rdoc:
|
data/lib/gaston/store.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
class Gaston
|
3
|
-
class Store < Hash
|
4
|
-
|
5
|
-
# Initialize Store.
|
6
|
-
#
|
7
|
-
# @param [ Hash ] Hash config to be stored.
|
8
|
-
#
|
9
|
-
# @since 0.0.1
|
10
|
-
#
|
11
|
-
def initialize(hash={})
|
12
|
-
hash.each do |key, value|
|
13
|
-
if hash.respond_to? key
|
14
|
-
warn "#{key} method already exists on Hash, value: #{value}"
|
15
|
-
else
|
16
|
-
value.is_a?(Hash) ? self[key] = self.class.new(value) : self[key] = value
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
# Search into store for value.
|
22
|
-
#
|
23
|
-
# @param [ String || Symbol ] key store.
|
24
|
-
#
|
25
|
-
# @since 0.0.1
|
26
|
-
#
|
27
|
-
def method_missing(method, *args, &block)
|
28
|
-
return self[method.to_s] if has_key? method.to_s
|
29
|
-
return self[method.to_sym] if has_key? method.to_sym
|
30
|
-
super
|
31
|
-
end
|
32
|
-
|
33
|
-
# Implement respond_to?
|
34
|
-
#
|
35
|
-
# @since 0.0.1
|
36
|
-
#
|
37
|
-
def respond_to?(method)
|
38
|
-
has_key?(method.to_s) || has_key?(method.to_sym) || super
|
39
|
-
end
|
40
|
-
|
41
|
-
end # Store
|
42
|
-
end #Gaston
|