sixarm_ruby_pathname_dirnames 1.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.
- data.tar.gz.sig +1 -0
- data/.gemtest +0 -0
- data/README.md +97 -0
- data/Rakefile +8 -0
- data/VERSION +1 -0
- data/lib/sixarm_ruby_pathname_dirnames.rb +31 -0
- data/test/sixarm_ruby_pathname_dirnames_test.rb +26 -0
- metadata +78 -0
- metadata.gz.sig +1 -0
data.tar.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
��X��j���ޙ(L�[�q4W�|���s�+N�a�y�ХS�8�A]����:Z���\��o�3���x�K��<�Q5�������2��� e����o�N�]q9(u��dq��B�q����w�m�u�
|
data/.gemtest
ADDED
File without changes
|
data/README.md
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
# SixArm.com » Ruby » <br> Pathname#dirnames method to iterate on parent directories
|
2
|
+
|
3
|
+
* Docs: <http://sixarm.com/sixarm_ruby_pathname_dirnames/doc>
|
4
|
+
* Repo: <http://github.com/sixarm/sixarm_ruby_pathname_dirnames>
|
5
|
+
* Email: Joel Parker Henderson, <joel@sixarm.com>
|
6
|
+
|
7
|
+
|
8
|
+
## Introduction
|
9
|
+
|
10
|
+
This gem has one method: Pathname#dirnames.
|
11
|
+
|
12
|
+
It will return an enumerable of pathnames created by calling #dirname repeatedly.
|
13
|
+
|
14
|
+
This can be useful for traversing directories upwards to parent, grandparent, etc.
|
15
|
+
|
16
|
+
Example:
|
17
|
+
|
18
|
+
p = Pathname.new('/foo/goo/hoo.txt')
|
19
|
+
p.dirnames
|
20
|
+
#=> ['/foo/goo', '/foo', '/']
|
21
|
+
|
22
|
+
For docs go to <http://sixarm.com/sixarm_ruby_pathname_dirnames/doc>
|
23
|
+
|
24
|
+
Want to help? We're happy to get pull requests.
|
25
|
+
|
26
|
+
|
27
|
+
## Install quickstart
|
28
|
+
|
29
|
+
Install:
|
30
|
+
|
31
|
+
gem install sixarm_ruby_week
|
32
|
+
|
33
|
+
Bundler:
|
34
|
+
|
35
|
+
gem "sixarm_ruby_pathname_dirnames", "~>1.0.0"
|
36
|
+
|
37
|
+
Require:
|
38
|
+
|
39
|
+
require "sixarm_ruby_pathname_dirnames"
|
40
|
+
|
41
|
+
|
42
|
+
## Install with security (optional)
|
43
|
+
|
44
|
+
To enable high security for all our gems:
|
45
|
+
|
46
|
+
wget http://sixarm.com/sixarm.pem
|
47
|
+
gem cert --add sixarm.pem
|
48
|
+
gem sources --add http://sixarm.com
|
49
|
+
|
50
|
+
To install with high security:
|
51
|
+
|
52
|
+
gem install sixarm_ruby_pathname_dirnames --test --trust-policy HighSecurity
|
53
|
+
|
54
|
+
|
55
|
+
## Example to find a file
|
56
|
+
|
57
|
+
To find the first occurance of a file named "my.txt" in a path or its parents:
|
58
|
+
|
59
|
+
basename = "my.txt"
|
60
|
+
p = Pathname.new('/foo/goo/hoo/*')
|
61
|
+
puts p.dirnames.find{|dirname| (dirname + basename).exist?}
|
62
|
+
|
63
|
+
Note that the "*" at the end of the pathname is to give dirname something to chop off; the "*" is being used as chaff, not as a file matcher nor string matches.
|
64
|
+
|
65
|
+
|
66
|
+
## Changes
|
67
|
+
|
68
|
+
* 2012-03-22 1.0.0 Created
|
69
|
+
|
70
|
+
|
71
|
+
## License
|
72
|
+
|
73
|
+
You may choose any of these open source licenses:
|
74
|
+
|
75
|
+
* Apache License
|
76
|
+
* BSD License
|
77
|
+
* CreativeCommons License, Non-commercial Share Alike
|
78
|
+
* GNU General Public License Version 2 (GPL 2)
|
79
|
+
* GNU Lesser General Public License (LGPL)
|
80
|
+
* MIT License
|
81
|
+
* Perl Artistic License
|
82
|
+
* Ruby License
|
83
|
+
|
84
|
+
The software is provided "as is", without warranty of any kind,
|
85
|
+
express or implied, including but not limited to the warranties of
|
86
|
+
merchantability, fitness for a particular purpose and noninfringement.
|
87
|
+
|
88
|
+
In no event shall the authors or copyright holders be liable for any
|
89
|
+
claim, damages or other liability, whether in an action of contract,
|
90
|
+
tort or otherwise, arising from, out of or in connection with the
|
91
|
+
software or the use or other dealings in the software.
|
92
|
+
|
93
|
+
This license is for the included software that is created by SixArm;
|
94
|
+
some of the included software may have its own licenses, copyrights,
|
95
|
+
authors, etc. and these do take precedence over the SixArm license.
|
96
|
+
|
97
|
+
Copyright (c) 2013 Joel Parker Henderson
|
data/Rakefile
ADDED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
=begin rdoc
|
3
|
+
Please see README
|
4
|
+
=end
|
5
|
+
|
6
|
+
require 'pathname'
|
7
|
+
|
8
|
+
|
9
|
+
class Pathname
|
10
|
+
|
11
|
+
# Return an enumerable of pathnames created by calling #dirname repeatedly.
|
12
|
+
# This can be useful for traversing directories upwards to parent, grandparent, etc.
|
13
|
+
#
|
14
|
+
# Example:
|
15
|
+
# p = Pathname.new('/foo/goo/hoo.txt')
|
16
|
+
# p.dirnames
|
17
|
+
# #=> ['/foo/goo', '/foo', '/']
|
18
|
+
|
19
|
+
def dirnames
|
20
|
+
path = self # start at the current path
|
21
|
+
results = []
|
22
|
+
while true
|
23
|
+
dirname = path.dirname
|
24
|
+
break if dirname == path
|
25
|
+
results << dirname
|
26
|
+
path = dirname
|
27
|
+
end
|
28
|
+
return results
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'simplecov'
|
4
|
+
SimpleCov.start
|
5
|
+
require 'sixarm_ruby_pathname_dirnames'
|
6
|
+
|
7
|
+
describe Pathname do
|
8
|
+
|
9
|
+
describe "#dirnames" do
|
10
|
+
|
11
|
+
before do
|
12
|
+
@p = Pathname.new(__FILE__).dirname + "sixarm_ruby_pathname_dirnames_test/foo/goo/hoo/my.txt"
|
13
|
+
puts __FILE__
|
14
|
+
puts @p
|
15
|
+
end
|
16
|
+
|
17
|
+
it "returns an enumerable of the dirnames" do
|
18
|
+
dirnames = @p.dirnames
|
19
|
+
dirnames[0].to_s.must_match /\/foo\/goo\/hoo$/
|
20
|
+
dirnames[1].to_s.must_match /\/foo\/goo$/
|
21
|
+
dirnames[2].to_s.must_match /\/foo$/
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sixarm_ruby_pathname_dirnames
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- SixArm
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain:
|
12
|
+
- !binary |-
|
13
|
+
LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURCRENDQW0yZ0F3SUJB
|
14
|
+
Z0lKQUtQd0VFVFU1YkhvTUEwR0NTcUdTSWIzRFFFQkJRVUFNR0F4Q3pBSkJn
|
15
|
+
TlYKQkFZVEFsVlRNUk13RVFZRFZRUUlFd3BEWVd4cFptOXlibWxoTVJZd0ZB
|
16
|
+
WURWUVFIRXcxVFlXNGdSbkpoYm1OcApjMk52TVE4d0RRWURWUVFLRXdaVGFY
|
17
|
+
aEJjbTB4RXpBUkJnTlZCQU1UQ25OcGVHRnliUzVqYjIwd0hoY05NVEF4Ck1q
|
18
|
+
RXpNak15TnpFeldoY05NVE13T1RBNE1qTXlOekV6V2pCZ01Rc3dDUVlEVlFR
|
19
|
+
R0V3SlZVekVUTUJFR0ExVUUKQ0JNS1EyRnNhV1p2Y201cFlURVdNQlFHQTFV
|
20
|
+
RUJ4TU5VMkZ1SUVaeVlXNWphWE5qYnpFUE1BMEdBMVVFQ2hNRwpVMmw0UVhK
|
21
|
+
dE1STXdFUVlEVlFRREV3c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ElMMHEKZWFid3BDYkFvcG89
|
37
|
+
Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
|
38
|
+
date: 2012-03-22 00:00:00.000000000 Z
|
39
|
+
dependencies: []
|
40
|
+
description:
|
41
|
+
email: sixarm@sixarm.com
|
42
|
+
executables: []
|
43
|
+
extensions: []
|
44
|
+
extra_rdoc_files: []
|
45
|
+
files:
|
46
|
+
- .gemtest
|
47
|
+
- Rakefile
|
48
|
+
- README.md
|
49
|
+
- VERSION
|
50
|
+
- lib/sixarm_ruby_pathname_dirnames.rb
|
51
|
+
- test/sixarm_ruby_pathname_dirnames_test.rb
|
52
|
+
homepage: http://sixarm.com/
|
53
|
+
licenses: []
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 1.8.19
|
73
|
+
signing_key:
|
74
|
+
specification_version: 3
|
75
|
+
summary: SixArm.com » Ruby » Pathname#dirnames method to iterate on parent directories
|
76
|
+
test_files:
|
77
|
+
- test/sixarm_ruby_pathname_dirnames_test.rb
|
78
|
+
has_rdoc: true
|
metadata.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
�t&=%�����"~r��Y�{R�_��Uv<�Z\8��S�)�=��\<��.���i�@�U�tu7,�%��4����v����Ͷ�<�ɪ�?^�*^\�g�*�%�Qf/�F�)N��p%129�
|