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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1223139fb3d6756ba4fa2e1d31345948af47760e
4
- data.tar.gz: 7d51f944928e9b7991ba2fa15c9d4cf3e089478d
2
+ SHA256:
3
+ metadata.gz: 32c2e6183d6b17e9968202223f0c6ced2fb3519eefe3fbac7f345bc2dacb59f1
4
+ data.tar.gz: 78db0b54f78f4ba2e8c851c5f8bcb2079b11e38b2e43f1f2a1899a0bf8453739
5
5
  SHA512:
6
- metadata.gz: c609fc68fe2d354164126903190829106d7e8f1059d8cc5be91e44ffa579db97be42cf60d2d895c3322d14c20df7fce471879aaa653bc8bf8d4e895a913b4045
7
- data.tar.gz: 34031526ce6bca9e3a406fe5d6667a704c782406c1ce7885af4776ecef5f6694036116428b1a69b15c7a7a1f80772db399e893db450cd8e5ffa30ba1dc27b1cd
6
+ metadata.gz: 65210d7d6ce90722a51561460ee375de0d4e4b08443aaa3d4e87584b6067bd5631cf549f214922fe48988b699b364faababcb2b0328a7ea40d3803d744e78443
7
+ data.tar.gz: c33f6c2ea16c068065fc25ed0aed92bfc402eff7ea882946be5d29b91b6d407ce5ddc1d06b98f26ce1686ac5a1bb8d16ceada1939a8ce5273503e28e6afd2f63
data/.travis.yml CHANGED
@@ -1,7 +1,10 @@
1
1
  language: ruby
2
2
 
3
+ sudo: false
4
+
3
5
  rvm:
4
- - 2.1.9
5
- - 2.2.7
6
- - 2.3.4
7
- - 2.4.1
6
+ - 2.1.10
7
+ - 2.2.9
8
+ - 2.3.6
9
+ - 2.4.3
10
+ - 2.5.0
data/Gemfile CHANGED
@@ -1,2 +1,7 @@
1
1
  source 'https://rubygems.org'
2
+
3
+ group :development do
4
+ gem 'json', '~> 2.1'
5
+ end
6
+
2
7
  gemspec
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
- * Add support for additional source-file types (e.g XML)
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.add_dependency('json', '~> 2.1')
29
-
30
- gem.add_development_dependency 'bundler', '~> 1.4'
31
- gem.add_development_dependency 'pry', '~> 0.10'
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
@@ -1,11 +1,12 @@
1
- require 'json'
1
+ safe_require('json')
2
2
 
3
-
4
- module Foundry
5
- module Parsers
6
- class JSON
7
- def parse(str)
8
- ::JSON.parse(str)
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
@@ -1,11 +1,12 @@
1
- require 'yaml'
1
+ safe_require('yaml')
2
2
 
3
-
4
- module Foundry
5
- module Parsers
6
- class YAML
7
- def parse(str)
8
- ::YAML.load(str)
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
@@ -1,2 +1,3 @@
1
1
  require 'foundry/parsers/json'
2
+ require 'foundry/parsers/xml'
2
3
  require 'foundry/parsers/yaml'
@@ -1,11 +1,12 @@
1
- require 'erb'
1
+ safe_require('erb')
2
2
 
3
-
4
- module Foundry
5
- module TemplateEngines
6
- class ERB
7
- def evaluate(str)
8
- ::ERB.new(str).result
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
@@ -1,3 +1,3 @@
1
1
  module Foundry
2
- VERSION = '0.6.0'
2
+ VERSION = '0.6.1'
3
3
  end
data/lib/foundry.rb CHANGED
@@ -1,3 +1,9 @@
1
+ def safe_require(name)
2
+ require name
3
+ rescue LoadError
4
+ false
5
+ end
6
+
1
7
  require 'foundry/parsers'
2
8
  require 'foundry/refinements'
3
9
  require 'foundry/sources'
@@ -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.0
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: 2017-05-23 00:00:00.000000000 Z
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.10'
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.10'
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.0'
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.0'
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.6'
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.6'
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.0'
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.0'
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.6.10
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