sixarm_ruby_yaml_load_glob 2.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7dca5c30897715a706f17141e24ec14f11bead08
4
+ data.tar.gz: 3e3bd8c8b08205c469b7ad47f027dfba849c30ab
5
+ SHA512:
6
+ metadata.gz: 0e19e65710d39381b1be61b2f1eaa322948c8030bdf2e1dca9c08178d1ad7a98decb95aa7add936c2c328f63610a47ac1ae744a5d20d5d5aac40b8b79e3942c1
7
+ data.tar.gz: 50dde8641736996fddf671316691fc929ace3ccae5d5681b08bbb2c93281fb6b3abd8ced1d802146c86588b893c3cb19b31959c640c0ef52199e76be52cf8879
checksums.yaml.gz.sig ADDED
@@ -0,0 +1,3 @@
1
+ �@RM���J"K�'MxŝǞ=B߯�tX�y�4�7���cN{��eW���B��#���`�����J&^Ԯ�
2
+ U+��{�b�A�?í:�}9�`�G�Ȭ��W
3
+ �@�� '4��q����Y��ޙ�͞jqK�v}f�T�w�׌���I������3 ��o:��K`��'G�C���s���t0*Đ�7������z��tk�H���Ňz��� %�V��?+�MD�VL���g5��U�C���,�O��M��<�N����=
data.tar.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ xΟԮ
2
+ H,SS�� �����Ǧ���}�wv��!���`��ە��ʷ���M"/AF��z(� ���l�����n�,U��0Q3���z�j�kG艇Y�-5w�!$�K(p��,�����^�s�۝������Ӑ��Z^�B�O�=񂓩�g+6rgg�����4KxteГ�}�w�q��؏:���"Tbr����
data/.gemtest ADDED
File without changes
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,28 @@
1
+ # Contributing
2
+
3
+ Thank you for contributing!
4
+
5
+ If you would like to contribute a donation, an easy way is to use PayPal to sixarm@sixarm.com.
6
+
7
+ If you would like to contribute help, the next section is for you.
8
+
9
+
10
+ ## Contributing to the source
11
+
12
+ We love pull requests for improvments to the source code and documentation.
13
+
14
+ There are three easy steps:
15
+
16
+ 1. Fork the repo.
17
+
18
+ * Before you do any work please run our existing tests to make sure the code runs cleanly.
19
+
20
+ 2. Work as you like.
21
+
22
+ * Please create tests. This helps us know that all your code runs cleanly.
23
+
24
+ 3. Push to your fork and submit a pull request.
25
+
26
+ * We'll take a look as soon as we can; this is typically within a business day.
27
+
28
+ Thank you again!
data/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # SixArm.com » Ruby » <br> YAML load glob to documents
2
+
3
+
4
+ * Doc: <http://sixarm.com/sixarm_ruby_yaml_load_glob/doc>
5
+ * Gem: <http://rubygems.org/gems/sixarm_ruby_yaml_load_glob>
6
+ * Repo: <http://github.com/sixarm/sixarm_ruby_yaml_load_glob>
7
+ * Email: Joel Parker Henderson, <joel@sixarm.com>
8
+
9
+
10
+ ## Introduction
11
+
12
+ Load YAML documents by using file globs, and iterate on the results.
13
+
14
+ Example: iterate on the documents
15
+
16
+ YAML.load_glob_documents("*.yml","*.yaml"){|document|
17
+ ...
18
+ }
19
+
20
+ Example: iterate on the documents' keys and values
21
+
22
+ YAML.load_glob_keys("*.yaml"){|key,values|
23
+ ...
24
+ }
25
+
26
+ For docs go to <http://sixarm.com/sixarm_ruby_yaml_load_glob/doc>
27
+
28
+ Want to help? We're happy to get pull requests.
29
+
30
+
31
+ ## Install quickstart
32
+
33
+ Install:
34
+
35
+ gem install sixarm_ruby_yaml_load_glob
36
+
37
+ Bundler:
38
+
39
+ gem "sixarm_ruby_yaml_load_glob", "~>2.0.0"
40
+
41
+ Require:
42
+
43
+ require "sixarm_ruby_yaml_load_glob"
44
+
45
+
46
+ ## Install with security (optional)
47
+
48
+ To enable high security for all our gems:
49
+
50
+ wget http://sixarm.com/sixarm.pem
51
+ gem cert --add sixarm.pem
52
+ gem sources --add http://sixarm.com
53
+
54
+ To install with high security:
55
+
56
+ gem install sixarm_ruby_yaml_load_glob --test --trust-policy HighSecurity
57
+
58
+
59
+ ## Changes
60
+
61
+ * 2014-03-12 2.0.0 Upgrade for Ruby 2, Psych 2, and short method names.
62
+ * 2012-03-14 1.5.0 Update docs, tests
63
+
64
+
65
+ ## License
66
+
67
+ You may choose any of these open source licenses:
68
+
69
+ * Apache License
70
+ * BSD License
71
+ * CreativeCommons License, Non-commercial Share Alike
72
+ * GNU General Public License Version 2 (GPL 2)
73
+ * GNU Lesser General Public License (LGPL)
74
+ * MIT License
75
+ * Perl Artistic License
76
+ * Ruby License
77
+
78
+ The software is provided "as is", without warranty of any kind,
79
+ express or implied, including but not limited to the warranties of
80
+ merchantability, fitness for a particular purpose and noninfringement.
81
+
82
+ In no event shall the authors or copyright holders be liable for any
83
+ claim, damages or other liability, whether in an action of contract,
84
+ tort or otherwise, arising from, out of or in connection with the
85
+ software or the use or other dealings in the software.
86
+
87
+ This license is for the included software that is created by SixArm;
88
+ some of the included software may have its own licenses, copyrights,
89
+ authors, etc. and these do take precedence over the SixArm license.
90
+
91
+ Copyright (c) 2005-2013 Joel Parker Henderson
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'rake'
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new(:test) do |t|
6
+ t.libs << 'lib' << 'test'
7
+ t.pattern = 'test/*.rb'
8
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 2.0.0
@@ -0,0 +1,53 @@
1
+ # -*- coding: utf-8 -*-
2
+ =begin rdoc
3
+ Please see README
4
+ =end
5
+
6
+ require 'yaml'
7
+
8
+ module YAML
9
+
10
+ # Specify file glob patterns, load each file, and yield each YAML document to a block.
11
+ #
12
+ # @see [Dir#glob](http://www.ruby-doc.org/core/classes/Dir.html#M002347) for pattern details.
13
+ #
14
+ # @example To load file names that end with ".yml" or ".yaml"
15
+ #
16
+ # YAML.load_glob_documents("*.yml","*.yaml"){|document|
17
+ # ...
18
+ # }
19
+ #
20
+ def YAML.load_glob_documents(*globs)
21
+ globs=[*globs.flatten]
22
+ globs.each do |glob|
23
+ Dir[glob].each do |filename|
24
+ File.open(filename) do |file|
25
+ YAML.load_stream(file) do |document|
26
+ yield document
27
+ end #load
28
+ end #file
29
+ end #dir
30
+ end #each
31
+ end #def
32
+
33
+ # Specify file glob patterns, load each file, and yield each YAML key and its values to a block.
34
+ #
35
+ # @see [Dir#glob](http://www.ruby-doc.org/core/classes/Dir.html#M002347) for pattern details.
36
+ #
37
+ # @example To load file names that end with "*.yml" or "*.yaml"
38
+ #
39
+ # YAML.load_glob_keys("*.yml","*.yaml"){|key, values|
40
+ # ...
41
+ # }
42
+ #
43
+ def YAML.load_glob_keys(*globs)
44
+ YAML.load_glob_documents(globs){|document|
45
+ document.keys.map{|key|
46
+ yield key, document[key]
47
+ }
48
+ }
49
+ end
50
+
51
+ end
52
+
53
+
@@ -0,0 +1,56 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'minitest/autorun'
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+ require 'sixarm_ruby_yaml_load_glob'
6
+
7
+ class YAMLGlobTest < Minitest::Test
8
+
9
+ MYDIR=File.join('test')
10
+
11
+ def test_load_glob_test_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_glob_documents
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_glob_documents(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_glob_documents')
36
+ end
37
+
38
+ def test_load_glob_keys
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_glob_keys(dirpath){|key,values|
50
+ actual << "#{key}:#{values.sort.join(",")}"
51
+ }
52
+ actual.sort!
53
+ assert_equal(expect,actual,'YAML.load_glob_keys')
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,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sixarm_ruby_yaml_load_glob
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
5
+ platform: ruby
6
+ authors:
7
+ - SixArm
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDbDCCAlSgAwIBAgIBATANBgkqhkiG9w0BAQUFADA+MQ8wDQYDVQQDDAZzaXhh
14
+ cm0xFjAUBgoJkiaJk/IsZAEZF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tpGuvhwVDU0x5dg
30
+ sWRVEyjnjnNuAeLP9zv43IDXjS22L2efhap7IOinYjcecpfXJgQaU+6BFAY4sdkQ
31
+ S1STYSfs3qySBxxAeEyZTw==
32
+ -----END CERTIFICATE-----
33
+ date: 2014-03-13 00:00:00.000000000 Z
34
+ dependencies: []
35
+ description: 'Extends YAML with #load_glob_documents and #load_glob_keys'
36
+ email: sixarm@sixarm.com
37
+ executables: []
38
+ extensions: []
39
+ extra_rdoc_files: []
40
+ files:
41
+ - ".gemtest"
42
+ - CONTRIBUTING.md
43
+ - README.md
44
+ - Rakefile
45
+ - VERSION
46
+ - lib/sixarm_ruby_yaml_load_glob.rb
47
+ - test/sixarm_ruby_yaml_load_glob_test.rb
48
+ - test/test_1.yml
49
+ - test/test_2.yml
50
+ homepage: http://sixarm.com/
51
+ licenses:
52
+ - BSD
53
+ - GPL
54
+ - MIT
55
+ - PAL
56
+ - Various
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 2.2.0
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: SixArm.com » Ruby » YAML load glob to documents
78
+ test_files:
79
+ - test/sixarm_ruby_yaml_load_glob_test.rb
80
+ - test/test_1.yml
81
+ - test/test_2.yml
82
+ has_rdoc: true
metadata.gz.sig ADDED
Binary file