sixarm_ruby_yaml_load_documents_globber 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +1 -0
- data/.gemtest +0 -0
- data/INSTALL.txt +32 -0
- data/LICENSE.txt +12 -0
- data/README.rdoc +21 -0
- data/Rakefile +8 -0
- data/lib/sixarm_ruby_yaml_load_documents_globber.rb +83 -0
- data/test/sixarm_ruby_yaml_load_documents_globber_test.rb +56 -0
- data/test/test_1.yml +38 -0
- data/test/test_2.yml +38 -0
- metadata +86 -0
- metadata.gz.sig +1 -0
data.tar.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
^(�$)}-H_Y3ۨ&v�q�8���,�0��,-u`�o�3)�,�I��N��H����ݛ�1�Q��ҺWZܦ�����\܂Q=�o"�8��=�O$A+;uRS��P-���_�n����w�f�FqB
|
data/.gemtest
ADDED
File without changes
|
data/INSTALL.txt
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
= SixArm.com Ruby Gem Install
|
3
|
+
|
4
|
+
|
5
|
+
First-time users: add our gem certificate and source.
|
6
|
+
When you do this once, it works for all our gems.
|
7
|
+
|
8
|
+
sudo wget http://sixarm.com/sixarm.pem
|
9
|
+
sudo gem cert --add sixarm.pem
|
10
|
+
sudo gem sources --add http://sixarm.com
|
11
|
+
|
12
|
+
Install the gem with advanced options.
|
13
|
+
|
14
|
+
sudo gem install sixarm_ruby_yaml_loader --test --trust-policy HighSecurity
|
15
|
+
|
16
|
+
|
17
|
+
== Notes
|
18
|
+
|
19
|
+
Do you have any questions, comments, suggestions, or feedback?
|
20
|
+
Let us know, we're happy to help. Our email is sixarm@sixarm.com
|
21
|
+
|
22
|
+
Do you want to create your own high security gems?
|
23
|
+
Learn how at http://www.rubygems.org/read/chapter/21
|
24
|
+
|
25
|
+
To see your current gem certificate list:
|
26
|
+
|
27
|
+
sudo gem cert --list
|
28
|
+
|
29
|
+
Our cert looks like this:
|
30
|
+
|
31
|
+
/C=US/ST=California/L=San Francisco/O=SixArm/CN=sixarm.com
|
32
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
LICENSE
|
2
|
+
|
3
|
+
You may choose any of these licenses:
|
4
|
+
|
5
|
+
- CreativeCommons License, Non-commercial Share Alike
|
6
|
+
- LGPL, GNU Lesser General Public License
|
7
|
+
- MIT License
|
8
|
+
- Ruby License
|
9
|
+
|
10
|
+
THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
11
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
12
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
= SixArm.com » Ruby » YAML load documents via globs for many files at once
|
4
|
+
|
5
|
+
Author:: Joel Parker Henderson, joelparkerhenderson@gmail.com
|
6
|
+
Copyright:: Copyright (c) 2006-2011 Joel Parker Henderson
|
7
|
+
License:: See LICENSE.txt file
|
8
|
+
|
9
|
+
Load YAML files by specifying file globs, and yield to blocks
|
10
|
+
for more convenient processing of the results.
|
11
|
+
|
12
|
+
@example To load documents from all files that end in ".yaml"
|
13
|
+
YAML.load_documents_globber_and_yield_document('*.yaml'){|document|
|
14
|
+
#...whatever you want to do with each yaml document
|
15
|
+
}
|
16
|
+
|
17
|
+
@example To load documents from all files that end in ".yaml" and process the key-value pairs:
|
18
|
+
YAML.load_documents_globber_and_yield_key_values('*.yaml'){|key,values|
|
19
|
+
#...whatever you want to do with each yaml key and its yaml values
|
20
|
+
}
|
21
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
=begin rdoc
|
4
|
+
|
5
|
+
= SixArm.com » Ruby » YAML load documents via globs for many files at once
|
6
|
+
|
7
|
+
Author:: Joel Parker Henderson, joelparkerhenderson@gmail.com
|
8
|
+
Copyright:: Copyright (c) 2006-2011 Joel Parker Henderson
|
9
|
+
License:: See LICENSE.txt file
|
10
|
+
|
11
|
+
Load YAML files by specifying file globs, and yield to blocks
|
12
|
+
for more convenient processing of the results.
|
13
|
+
|
14
|
+
@example To load documents from all files that end in ".yaml"
|
15
|
+
YAML.load_documents_globber_and_yield_document('*.yaml'){|document|
|
16
|
+
#...whatever you want to do with each yaml document
|
17
|
+
}
|
18
|
+
|
19
|
+
@example To load documents from all files that end in ".yaml" and process the key-value pairs:
|
20
|
+
YAML.load_documents_globber_and_yield_key_values('*.yaml'){|key,values|
|
21
|
+
#...whatever you want to do with each yaml key and its yaml values
|
22
|
+
}
|
23
|
+
|
24
|
+
=end
|
25
|
+
|
26
|
+
require 'yaml'
|
27
|
+
|
28
|
+
module YAML
|
29
|
+
|
30
|
+
|
31
|
+
# Specify one or more directory patterns, load each file, and yield each YAML document to a block.
|
32
|
+
#
|
33
|
+
# @see [Dir#glob](http://www.ruby-doc.org/core/classes/Dir.html#M002347) for pattern details.
|
34
|
+
#
|
35
|
+
# @example To load documents in files ending in ".yaml"
|
36
|
+
# YAML.load_documents_via_globs_and_yield_document('/tmp/*.yaml'){|document|
|
37
|
+
# #...whatever you want to do with each yaml document
|
38
|
+
# }
|
39
|
+
#
|
40
|
+
# @example To load documents in files beginning in "foo" or "bar"
|
41
|
+
# YAML.load_documents_via_globs_and_yield_document('/tmp/foo*.yaml','/tmp/bar*.yaml','){|document|
|
42
|
+
# #...whatever you want to do with the yaml document
|
43
|
+
# }
|
44
|
+
|
45
|
+
def YAML.load_documents_globber_and_yield_document(*globs)
|
46
|
+
globs=[*globs.flatten]
|
47
|
+
globs.each do |glob|
|
48
|
+
Dir[glob].each do |filename|
|
49
|
+
File.open(filename) do |file|
|
50
|
+
YAML.load_documents(file) do |document|
|
51
|
+
yield document
|
52
|
+
end #load
|
53
|
+
end #file
|
54
|
+
end #dir
|
55
|
+
end #each
|
56
|
+
end #def
|
57
|
+
|
58
|
+
|
59
|
+
# Specify one or more directory patterns, load each file, and yield each YAML key and its values to a block.
|
60
|
+
#
|
61
|
+
# @see [Dir#glob](http://www.ruby-doc.org/core/classes/Dir.html#M002347) for pattern details.
|
62
|
+
#
|
63
|
+
# @example To load each key and its values, in files ending in ".yaml"
|
64
|
+
# YAML.load_documents_via_globs_and_yield_key_values('/tmp/*.yaml'){|yaml_key,yaml_values|
|
65
|
+
# #...whatever you want to do with each yaml key and its values
|
66
|
+
# }
|
67
|
+
#
|
68
|
+
# @example To load documents in files beginning in "foo" or "bar" and get each key and its values:
|
69
|
+
# YAML.load_documents_via_globs_and_yield_key_values('/tmp/foo*.yaml','/tmp/bar*.yaml','){|key,values|
|
70
|
+
# #...whatever you want to do with each yaml key and its yaml values
|
71
|
+
# }
|
72
|
+
def YAML.load_documents_globber_and_yield_key_values(*globs)
|
73
|
+
YAML.load_documents_globber_and_yield_document(globs){|document|
|
74
|
+
document.keys.each{|key|
|
75
|
+
yield key, document[key]
|
76
|
+
}
|
77
|
+
}
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'simplecov'
|
3
|
+
SimpleCov.start
|
4
|
+
require 'test/unit'
|
5
|
+
require 'sixarm_ruby_yaml_load_documents_globber'
|
6
|
+
|
7
|
+
class YAMLLoaderTest < Test::Unit::TestCase
|
8
|
+
|
9
|
+
MYDIR=File.join('test')
|
10
|
+
|
11
|
+
def test_load_documents_globber_data_files
|
12
|
+
dirpath=File.join(MYDIR,'test_*.yml')
|
13
|
+
expect=[File.join(MYDIR,'test_1.yml'),File.join(MYDIR,'test_2.yml')]
|
14
|
+
actual=Dir[dirpath].sort
|
15
|
+
assert_equal(expect,actual,"Dir[#{dirpath}] expects test data files")
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_load_documents_globber_and_yield_document
|
19
|
+
dirpath=File.join(MYDIR,'test_*.yml')
|
20
|
+
expect=[
|
21
|
+
"a:a1,a10,a2,a20,a3,a30;b:b1,b10,b2,b20,b3,b30;c:c1,c10,c2,c20,c3,c30",
|
22
|
+
"d:d1,d10,d2,d20,d3,d30;e:e1,e10,e2,e20,e3,e30;f:f1,f10,f2,f20,f3,f30",
|
23
|
+
"g:g1,g10,g2,g20,g3,g30;h:h1,h10,h2,h20,h3,h30;i:i1,i10,i2,i20,i3,i30",
|
24
|
+
"j:j1,j10,j2,j20,j3,j30;k:k1,k10,k2,k20,k3,k30;l:l1,l10,l2,l20,l3,l30",
|
25
|
+
"m:m1,m10,m2,m20,m3,m30;n:n1,n10,n2,n20,n3,n30;o:o1,o10,o2,o20,o3,o30",
|
26
|
+
"p:p1,p10,p2,p20,p3,p30;q:q1,q10,q2,q20,q3,q30;r:r1,r10,r2,r20,r3,r30",
|
27
|
+
]
|
28
|
+
actual=[]
|
29
|
+
YAML.load_documents_globber_and_yield_document(dirpath){|document|
|
30
|
+
actual << document.keys.map{|key|
|
31
|
+
values=document[key]; "#{key}:#{values.sort.join(",")}"
|
32
|
+
}.sort.join(";")
|
33
|
+
}
|
34
|
+
actual.sort!
|
35
|
+
assert_equal(expect,actual,'YAML.load_documents_globber_and_yield_document')
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_load_documents_globber_and_yield_key_values
|
39
|
+
dirpath=File.join(MYDIR,'test_*.yml')
|
40
|
+
expect=[
|
41
|
+
"a:a1,a10,a2,a20,a3,a30","b:b1,b10,b2,b20,b3,b30","c:c1,c10,c2,c20,c3,c30",
|
42
|
+
"d:d1,d10,d2,d20,d3,d30","e:e1,e10,e2,e20,e3,e30","f:f1,f10,f2,f20,f3,f30",
|
43
|
+
"g:g1,g10,g2,g20,g3,g30","h:h1,h10,h2,h20,h3,h30","i:i1,i10,i2,i20,i3,i30",
|
44
|
+
"j:j1,j10,j2,j20,j3,j30","k:k1,k10,k2,k20,k3,k30","l:l1,l10,l2,l20,l3,l30",
|
45
|
+
"m:m1,m10,m2,m20,m3,m30","n:n1,n10,n2,n20,n3,n30","o:o1,o10,o2,o20,o3,o30",
|
46
|
+
"p:p1,p10,p2,p20,p3,p30","q:q1,q10,q2,q20,q3,q30","r:r1,r10,r2,r20,r3,r30",
|
47
|
+
]
|
48
|
+
actual=[]
|
49
|
+
YAML.load_documents_globber_and_yield_key_values(dirpath){|key,values|
|
50
|
+
actual << "#{key}:#{values.sort.join(",")}"
|
51
|
+
}
|
52
|
+
actual.sort!
|
53
|
+
assert_equal(expect,actual,'YAML.load_documents_globber_and_yield_key_values')
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
data/test/test_1.yml
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
a:
|
2
|
+
a1: "a10"
|
3
|
+
a2: "a20"
|
4
|
+
a3: "a30"
|
5
|
+
b:
|
6
|
+
b1: "b10"
|
7
|
+
b2: "b20"
|
8
|
+
b3: "b30"
|
9
|
+
c:
|
10
|
+
c1: "c10"
|
11
|
+
c2: "c20"
|
12
|
+
c3: "c30"
|
13
|
+
---
|
14
|
+
d:
|
15
|
+
d1: "d10"
|
16
|
+
d2: "d20"
|
17
|
+
d3: "d30"
|
18
|
+
e:
|
19
|
+
e1: "e10"
|
20
|
+
e2: "e20"
|
21
|
+
e3: "e30"
|
22
|
+
f:
|
23
|
+
f1: "f10"
|
24
|
+
f2: "f20"
|
25
|
+
f3: "f30"
|
26
|
+
---
|
27
|
+
g:
|
28
|
+
g1: "g10"
|
29
|
+
g2: "g20"
|
30
|
+
g3: "g30"
|
31
|
+
h:
|
32
|
+
h1: "h10"
|
33
|
+
h2: "h20"
|
34
|
+
h3: "h30"
|
35
|
+
i:
|
36
|
+
i1: "i10"
|
37
|
+
i2: "i20"
|
38
|
+
i3: "i30"
|
data/test/test_2.yml
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
j:
|
2
|
+
j1: "j10"
|
3
|
+
j2: "j20"
|
4
|
+
j3: "j30"
|
5
|
+
k:
|
6
|
+
k1: "k10"
|
7
|
+
k2: "k20"
|
8
|
+
k3: "k30"
|
9
|
+
l:
|
10
|
+
l1: "l10"
|
11
|
+
l2: "l20"
|
12
|
+
l3: "l30"
|
13
|
+
---
|
14
|
+
m:
|
15
|
+
m1: "m10"
|
16
|
+
m2: "m20"
|
17
|
+
m3: "m30"
|
18
|
+
n:
|
19
|
+
n1: "n10"
|
20
|
+
n2: "n20"
|
21
|
+
n3: "n30"
|
22
|
+
o:
|
23
|
+
o1: "o10"
|
24
|
+
o2: "o20"
|
25
|
+
o3: "o30"
|
26
|
+
---
|
27
|
+
p:
|
28
|
+
p1: "p10"
|
29
|
+
p2: "p20"
|
30
|
+
p3: "p30"
|
31
|
+
q:
|
32
|
+
q1: "q10"
|
33
|
+
q2: "q20"
|
34
|
+
q3: "q30"
|
35
|
+
r:
|
36
|
+
r1: "r10"
|
37
|
+
r2: "r20"
|
38
|
+
r3: "r30"
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sixarm_ruby_yaml_load_documents_globber
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 1.5.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- SixArm
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain:
|
12
|
+
- |
|
13
|
+
-----BEGIN CERTIFICATE-----
|
14
|
+
MIIDBDCCAm2gAwIBAgIJAKPwEETU5bHoMA0GCSqGSIb3DQEBBQUAMGAxCzAJBgNV
|
15
|
+
BAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1TYW4gRnJhbmNp
|
16
|
+
c2NvMQ8wDQYDVQQKEwZTaXhBcm0xEzARBgNVBAMTCnNpeGFybS5jb20wHhcNMTAx
|
17
|
+
MjEzMjMyNzEzWhcNMTMwOTA4MjMyNzEzWjBgMQswCQYDVQQGEwJVUzETMBEGA1UE
|
18
|
+
CBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEPMA0GA1UEChMG
|
19
|
+
U2l4QXJtMRMwEQYDVQQDEwpzaXhhcm0uY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GN
|
20
|
+
ADCBiQKBgQC94mD9JDwBsunsOI0VR3CXXbOWg9cWaWciwFyJNFiM7A9I8KPLfXUw
|
21
|
+
QC4czUe5ZuG4WHvinrWhkrCK+1dWBqoEClxdF/FoKO5a+tonGCjjmfy81JmFjjyx
|
22
|
+
eTsjsHyvw+Qik9kpf9aj6+pnkNrVswgNHVea2o9yabbEiS6VSeJWoQIDAQABo4HF
|
23
|
+
MIHCMB0GA1UdDgQWBBQzPJtqmSgc53eDN7aSzDQwr9TALDCBkgYDVR0jBIGKMIGH
|
24
|
+
gBQzPJtqmSgc53eDN7aSzDQwr9TALKFkpGIwYDELMAkGA1UEBhMCVVMxEzARBgNV
|
25
|
+
BAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBGcmFuY2lzY28xDzANBgNVBAoT
|
26
|
+
BlNpeEFybTETMBEGA1UEAxMKc2l4YXJtLmNvbYIJAKPwEETU5bHoMAwGA1UdEwQF
|
27
|
+
MAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAooEexP/oPam1TP71SyuhxMb+uTrZbSQe
|
28
|
+
jVB+ExRwWadGwaNPUA56d39qwavwP+iu+3JpeonNMVvbWXF5naCX/dNFIeREHzER
|
29
|
+
ZDRQYMqru9TEMna6HD9zpcstF7vwThGovlOQ+3Y6plQ4nMzipXcZ9THqs65PIL0q
|
30
|
+
eabwpCbAopo=
|
31
|
+
-----END CERTIFICATE-----
|
32
|
+
|
33
|
+
date: 2011-04-17 00:00:00 -07:00
|
34
|
+
default_executable:
|
35
|
+
dependencies: []
|
36
|
+
|
37
|
+
description:
|
38
|
+
email: sixarm@sixarm.com
|
39
|
+
executables: []
|
40
|
+
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files: []
|
44
|
+
|
45
|
+
files:
|
46
|
+
- .gemtest
|
47
|
+
- Rakefile
|
48
|
+
- README.rdoc
|
49
|
+
- INSTALL.txt
|
50
|
+
- LICENSE.txt
|
51
|
+
- lib/sixarm_ruby_yaml_load_documents_globber.rb
|
52
|
+
- test/sixarm_ruby_yaml_load_documents_globber_test.rb
|
53
|
+
- test/test_1.yml
|
54
|
+
- test/test_2.yml
|
55
|
+
has_rdoc: true
|
56
|
+
homepage: http://sixarm.com/
|
57
|
+
licenses: []
|
58
|
+
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: "0"
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: "0"
|
76
|
+
requirements: []
|
77
|
+
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 1.6.2
|
80
|
+
signing_key:
|
81
|
+
specification_version: 3
|
82
|
+
summary: "SixArm.com \xC2\xBB Ruby \xC2\xBB YAML load documents via globs for many files at once"
|
83
|
+
test_files:
|
84
|
+
- test/sixarm_ruby_yaml_load_documents_globber_test.rb
|
85
|
+
- test/test_1.yml
|
86
|
+
- test/test_2.yml
|
metadata.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
�1̣�x~�(.{�ʡ����-p���&p���_���~x���Oe�n5���}@˕�;u\>�,QaN@G=�7�W�S�D.�xBM��ؗXCt��}��S!|GZ ����Ct?-^I���U�H
|