foundry 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +7 -4
- data/Gemfile +5 -0
- data/README.md +23 -12
- data/TODO +1 -1
- data/foundry.gemspec +4 -7
- data/lib/foundry/parsers/json.rb +8 -7
- data/lib/foundry/parsers/xml.rb +20 -0
- data/lib/foundry/parsers/yaml.rb +8 -7
- data/lib/foundry/parsers.rb +1 -0
- data/lib/foundry/template_engines/erb.rb +8 -7
- data/lib/foundry/version.rb +1 -1
- data/lib/foundry.rb +6 -0
- data/spec/parsers/xml_spec.rb +16 -0
- metadata +14 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 32c2e6183d6b17e9968202223f0c6ced2fb3519eefe3fbac7f345bc2dacb59f1
|
4
|
+
data.tar.gz: 78db0b54f78f4ba2e8c851c5f8bcb2079b11e38b2e43f1f2a1899a0bf8453739
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65210d7d6ce90722a51561460ee375de0d4e4b08443aaa3d4e87584b6067bd5631cf549f214922fe48988b699b364faababcb2b0328a7ea40d3803d744e78443
|
7
|
+
data.tar.gz: c33f6c2ea16c068065fc25ed0aed92bfc402eff7ea882946be5d29b91b6d407ce5ddc1d06b98f26ce1686ac5a1bb8d16ceada1939a8ce5273503e28e6afd2f63
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -11,8 +11,8 @@ This gem aims to keep it simple and fully decouple the two concerns.
|
|
11
11
|
|
12
12
|
Features:
|
13
13
|
|
14
|
-
* Can load JSON or YAML from a local-file
|
15
|
-
* Can load JSON or YAML from a HTTP/HTTPS endpoint
|
14
|
+
* Can load JSON, XML or YAML from a local-file
|
15
|
+
* Can load JSON, XML or YAML from a HTTP/HTTPS endpoint
|
16
16
|
* Supports Basic Authentication for HTTP{,S} endpoints
|
17
17
|
* Supports ERB interpolation
|
18
18
|
* Returns an easy to navigate object-graph
|
@@ -95,7 +95,27 @@ Inheritance support:
|
|
95
95
|
# The examples below assume that there are two files available, relative to the
|
96
96
|
# `root_path`, named "file1.yml" and "file2.yml" (and that "file2.yml" inherits
|
97
97
|
# from "file1.yml" -- it is immaterial at this point whether the file-format is
|
98
|
-
# JSON or YAML).
|
98
|
+
# JSON, XML or YAML).
|
99
|
+
#
|
100
|
+
# When using the JSON parser, the file contents would be as follows:
|
101
|
+
#
|
102
|
+
# === file1.json ===
|
103
|
+
#
|
104
|
+
# { "value1": "value" }
|
105
|
+
#
|
106
|
+
# === file2.json ===
|
107
|
+
#
|
108
|
+
# { "inherit": "file1.json", "value2": "value" }
|
109
|
+
#
|
110
|
+
# When using the XML parser, the file contents would be as follows:
|
111
|
+
#
|
112
|
+
# === file1.xml ===
|
113
|
+
#
|
114
|
+
# <config><value1>value</value1></config>
|
115
|
+
#
|
116
|
+
# === file2.json ===
|
117
|
+
#
|
118
|
+
# <config inherit="file1.xml"><value2>value</value2></config>
|
99
119
|
#
|
100
120
|
# When using the YAML parser, the file contents would be as follows:
|
101
121
|
#
|
@@ -110,15 +130,6 @@ Inheritance support:
|
|
110
130
|
# value2: value
|
111
131
|
# inherit: file1.yml
|
112
132
|
#
|
113
|
-
# When using the JSON parser, the file contents would be as follows:
|
114
|
-
#
|
115
|
-
# === file1.json ===
|
116
|
-
#
|
117
|
-
# { "value1": "value" }
|
118
|
-
#
|
119
|
-
# === file2.json ===
|
120
|
-
#
|
121
|
-
# { "inherit": "file1.json", "value2": "value" }
|
122
133
|
#
|
123
134
|
# It is also assumed that the files have already been loaded and processed by a
|
124
135
|
# call to `Foundry::Configurator.configure` (into a variable named `config`).
|
data/TODO
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
63b761d7-11d7-11e8-9f1a-8c85909b0be6 00000000-0000-0000-0000-000000000000 jzaleski jzaleski 1518647742 1518647742 a Add support for additional source-file types (e.g XML)
|
data/foundry.gemspec
CHANGED
@@ -25,11 +25,8 @@ Gem::Specification.new do |gem|
|
|
25
25
|
|
26
26
|
gem.required_ruby_version = '>= 2.1.0'
|
27
27
|
|
28
|
-
gem.
|
29
|
-
|
30
|
-
gem.add_development_dependency '
|
31
|
-
gem.add_development_dependency '
|
32
|
-
gem.add_development_dependency 'rake', '~> 12.0'
|
33
|
-
gem.add_development_dependency 'rspec', '~> 3.6'
|
34
|
-
gem.add_development_dependency 'webmock', '~> 3.0'
|
28
|
+
gem.add_development_dependency 'pry', '~> 0.11'
|
29
|
+
gem.add_development_dependency 'rake', '~> 12.3'
|
30
|
+
gem.add_development_dependency 'rspec', '~> 3.7'
|
31
|
+
gem.add_development_dependency 'webmock', '~> 3.3'
|
35
32
|
end
|
data/lib/foundry/parsers/json.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
-
|
1
|
+
safe_require('json')
|
2
2
|
|
3
|
-
|
4
|
-
module Foundry
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
if defined?(JSON)
|
4
|
+
module Foundry
|
5
|
+
module Parsers
|
6
|
+
class JSON
|
7
|
+
def parse(str)
|
8
|
+
::JSON.parse(str)
|
9
|
+
end
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
safe_require('rexml/document')
|
2
|
+
|
3
|
+
if defined?(REXML::Document)
|
4
|
+
module Foundry
|
5
|
+
module Parsers
|
6
|
+
class XML
|
7
|
+
def parse(str)
|
8
|
+
raise TypeError if str.nil?
|
9
|
+
root_node = REXML::Document.new(str).first
|
10
|
+
raise ArgumentError unless root_node.name == 'config'
|
11
|
+
result = {}
|
12
|
+
root_node.children.each { |node| result[node.name] = node.text }
|
13
|
+
inherit = root_node.attributes['inherit']
|
14
|
+
result['inherit'] = inherit unless inherit.nil?
|
15
|
+
result
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/foundry/parsers/yaml.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
-
|
1
|
+
safe_require('yaml')
|
2
2
|
|
3
|
-
|
4
|
-
module Foundry
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
if defined?(YAML)
|
4
|
+
module Foundry
|
5
|
+
module Parsers
|
6
|
+
class YAML
|
7
|
+
def parse(str)
|
8
|
+
::YAML.load(str)
|
9
|
+
end
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
data/lib/foundry/parsers.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
-
|
1
|
+
safe_require('erb')
|
2
2
|
|
3
|
-
|
4
|
-
module Foundry
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
if defined?(ERB)
|
4
|
+
module Foundry
|
5
|
+
module TemplateEngines
|
6
|
+
class ERB
|
7
|
+
def evaluate(str)
|
8
|
+
::ERB.new(str).result
|
9
|
+
end
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
data/lib/foundry/version.rb
CHANGED
data/lib/foundry.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Foundry::Parsers::XML do
|
4
|
+
it 'can parse XML' do
|
5
|
+
expect(subject.parse('<config><foo>bar</foo></config>')).to \
|
6
|
+
eq({ 'foo' => 'bar' })
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'will raise an error if the XML is not in the correct format' do
|
10
|
+
expect { subject.parse('<foo>bar</foo>') }.to raise_error ArgumentError
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'will raise an error if the XML is unparseable' do
|
14
|
+
expect { subject.parse(nil) }.to raise_error TypeError
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,99 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foundry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan W. Zaleski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: json
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '2.1'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '2.1'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bundler
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.4'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.4'
|
41
13
|
- !ruby/object:Gem::Dependency
|
42
14
|
name: pry
|
43
15
|
requirement: !ruby/object:Gem::Requirement
|
44
16
|
requirements:
|
45
17
|
- - "~>"
|
46
18
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0.
|
19
|
+
version: '0.11'
|
48
20
|
type: :development
|
49
21
|
prerelease: false
|
50
22
|
version_requirements: !ruby/object:Gem::Requirement
|
51
23
|
requirements:
|
52
24
|
- - "~>"
|
53
25
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0.
|
26
|
+
version: '0.11'
|
55
27
|
- !ruby/object:Gem::Dependency
|
56
28
|
name: rake
|
57
29
|
requirement: !ruby/object:Gem::Requirement
|
58
30
|
requirements:
|
59
31
|
- - "~>"
|
60
32
|
- !ruby/object:Gem::Version
|
61
|
-
version: '12.
|
33
|
+
version: '12.3'
|
62
34
|
type: :development
|
63
35
|
prerelease: false
|
64
36
|
version_requirements: !ruby/object:Gem::Requirement
|
65
37
|
requirements:
|
66
38
|
- - "~>"
|
67
39
|
- !ruby/object:Gem::Version
|
68
|
-
version: '12.
|
40
|
+
version: '12.3'
|
69
41
|
- !ruby/object:Gem::Dependency
|
70
42
|
name: rspec
|
71
43
|
requirement: !ruby/object:Gem::Requirement
|
72
44
|
requirements:
|
73
45
|
- - "~>"
|
74
46
|
- !ruby/object:Gem::Version
|
75
|
-
version: '3.
|
47
|
+
version: '3.7'
|
76
48
|
type: :development
|
77
49
|
prerelease: false
|
78
50
|
version_requirements: !ruby/object:Gem::Requirement
|
79
51
|
requirements:
|
80
52
|
- - "~>"
|
81
53
|
- !ruby/object:Gem::Version
|
82
|
-
version: '3.
|
54
|
+
version: '3.7'
|
83
55
|
- !ruby/object:Gem::Dependency
|
84
56
|
name: webmock
|
85
57
|
requirement: !ruby/object:Gem::Requirement
|
86
58
|
requirements:
|
87
59
|
- - "~>"
|
88
60
|
- !ruby/object:Gem::Version
|
89
|
-
version: '3.
|
61
|
+
version: '3.3'
|
90
62
|
type: :development
|
91
63
|
prerelease: false
|
92
64
|
version_requirements: !ruby/object:Gem::Requirement
|
93
65
|
requirements:
|
94
66
|
- - "~>"
|
95
67
|
- !ruby/object:Gem::Version
|
96
|
-
version: '3.
|
68
|
+
version: '3.3'
|
97
69
|
description: |2
|
98
70
|
Let's face it, there are a number of problems when application/environment
|
99
71
|
configuration logic is too tightly coupled with the configuration-data itself.
|
@@ -116,6 +88,7 @@ files:
|
|
116
88
|
- lib/foundry/configurator.rb
|
117
89
|
- lib/foundry/parsers.rb
|
118
90
|
- lib/foundry/parsers/json.rb
|
91
|
+
- lib/foundry/parsers/xml.rb
|
119
92
|
- lib/foundry/parsers/yaml.rb
|
120
93
|
- lib/foundry/refinements.rb
|
121
94
|
- lib/foundry/refinements/hash.rb
|
@@ -127,6 +100,7 @@ files:
|
|
127
100
|
- lib/foundry/version.rb
|
128
101
|
- spec/configurator_spec.rb
|
129
102
|
- spec/parsers/json_spec.rb
|
103
|
+
- spec/parsers/xml_spec.rb
|
130
104
|
- spec/parsers/yaml_spec.rb
|
131
105
|
- spec/refinements/hash_spec.rb
|
132
106
|
- spec/sources/file_spec.rb
|
@@ -153,13 +127,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
127
|
version: '0'
|
154
128
|
requirements: []
|
155
129
|
rubyforge_project:
|
156
|
-
rubygems_version: 2.
|
130
|
+
rubygems_version: 2.7.3
|
157
131
|
signing_key:
|
158
132
|
specification_version: 4
|
159
133
|
summary: An application configuration gem that aims to keep it simple
|
160
134
|
test_files:
|
161
135
|
- spec/configurator_spec.rb
|
162
136
|
- spec/parsers/json_spec.rb
|
137
|
+
- spec/parsers/xml_spec.rb
|
163
138
|
- spec/parsers/yaml_spec.rb
|
164
139
|
- spec/refinements/hash_spec.rb
|
165
140
|
- spec/sources/file_spec.rb
|