data_reader 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.hound.yml +1 -1
- data/lib/data_reader/version.rb +1 -1
- data/lib/data_reader.rb +31 -6
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f73829d7eaf46a4dba02827cbe1c13255e6316bc
|
4
|
+
data.tar.gz: 3f21945b2bd955f00a6ca318930c9d6e28f0300f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f73e7f233816684826fb5d22f5c1138b2e9ea4733f4f69c0852b3a653433a776ec508636cef0b1e05ec572fa7227dfe4298601488fca1bbf925eed4d07f0e71e
|
7
|
+
data.tar.gz: 69d0030724241ad7fcd2489d1604e872d18a0841470a24d3f8e5b4c36b49063725a5cc17493a2ca0a5814c5afeae1d4286ce8334e3642bd95b83d597a1d755e2
|
data/.hound.yml
CHANGED
data/lib/data_reader/version.rb
CHANGED
data/lib/data_reader.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "data_reader/version"
|
2
|
+
require "pathname"
|
2
3
|
require "yaml"
|
3
4
|
require "erb"
|
4
5
|
|
@@ -10,25 +11,49 @@ module DataReader
|
|
10
11
|
def data_path
|
11
12
|
return @data_path if @data_path
|
12
13
|
return default_data_path if respond_to? :default_data_path
|
14
|
+
|
13
15
|
nil
|
14
16
|
end
|
15
17
|
|
16
18
|
def data_source
|
17
19
|
return @data_source if @data_source
|
20
|
+
|
18
21
|
nil
|
19
22
|
end
|
20
23
|
|
21
24
|
def load(file_list)
|
22
25
|
files = file_list.include?(',') ? file_list.split(',') : [file_list]
|
23
26
|
files = files.collect(&:strip)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
)
|
27
|
+
|
28
|
+
@data_source = files.inject({}) do |all_data, file|
|
29
|
+
data = include_key(::YAML.safe_load(include_data(file)))
|
30
|
+
all_data.merge!(data) if data
|
28
31
|
end
|
29
32
|
end
|
30
33
|
|
31
|
-
def include_data(
|
32
|
-
|
34
|
+
def include_data(file)
|
35
|
+
filename = Pathname.new(file).absolute? ? file : "#{@data_path}/#{file}"
|
36
|
+
ERB.new(IO.read(filename)).result(binding) if File.exist?(filename)
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def include_key(data)
|
42
|
+
include_data = {}
|
43
|
+
|
44
|
+
if data.key?('_include_')
|
45
|
+
[data['_include_']].flatten.each do |file_path|
|
46
|
+
include_data.merge!(load(file_path))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
data.delete('_include_')
|
51
|
+
data.merge!(include_data)
|
52
|
+
|
53
|
+
data.each do |key, value|
|
54
|
+
data[key] = include_key(value) if value.is_a?(Hash)
|
55
|
+
end
|
56
|
+
|
57
|
+
data
|
33
58
|
end
|
34
59
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: data_reader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Nyman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -107,7 +107,7 @@ licenses:
|
|
107
107
|
- MIT
|
108
108
|
metadata: {}
|
109
109
|
post_install_message: "\n(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)\n
|
110
|
-
\ DataReader 1.0
|
110
|
+
\ DataReader 1.1.0 has been installed.\n(::) (::) (::) (::) (::) (::) (::) (::)
|
111
111
|
(::) (::) (::) (::)\n "
|
112
112
|
rdoc_options: []
|
113
113
|
require_paths:
|
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
124
|
version: '0'
|
125
125
|
requirements: []
|
126
126
|
rubyforge_project:
|
127
|
-
rubygems_version: 2.
|
127
|
+
rubygems_version: 2.5.2.2
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
130
|
summary: Provides a standard method for reading YAML data files
|