rubysl-pathname 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/LICENSE +25 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/pathname.rb +1 -0
- data/lib/rubysl/pathname.rb +2 -0
- data/lib/rubysl/pathname/pathname.rb +1062 -0
- data/lib/rubysl/pathname/version.rb +5 -0
- data/rubysl-pathname.gemspec +23 -0
- data/spec/absolute_spec.rb +22 -0
- data/spec/equal_value_spec.rb +14 -0
- data/spec/hash_spec.rb +14 -0
- data/spec/new_spec.rb +18 -0
- data/spec/parent_spec.rb +18 -0
- data/spec/relative_spec.rb +22 -0
- data/spec/root_spec.rb +26 -0
- data/spec/sub_spec.rb +15 -0
- metadata +127 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require './lib/rubysl/pathname/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "rubysl-pathname"
|
6
|
+
spec.version = RubySL::Pathname::VERSION
|
7
|
+
spec.authors = ["Brian Shirai"]
|
8
|
+
spec.email = ["brixen@gmail.com"]
|
9
|
+
spec.description = %q{Ruby standard library pathname.}
|
10
|
+
spec.summary = %q{Ruby standard library pathname.}
|
11
|
+
spec.homepage = "https://github.com/rubysl/rubysl-pathname"
|
12
|
+
spec.license = "BSD"
|
13
|
+
|
14
|
+
spec.files = `git ls-files`.split($/)
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
20
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
21
|
+
spec.add_development_dependency "mspec", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rubysl-prettyprint", "~> 1.0"
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
describe "Pathname#absolute?" do
|
4
|
+
|
5
|
+
it "returns true for the root directory" do
|
6
|
+
Pathname.new('/').absolute?.should == true
|
7
|
+
end
|
8
|
+
|
9
|
+
it "returns true for a dir starting with a slash" do
|
10
|
+
Pathname.new('/usr/local/bin').absolute?.should == true
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns false for a dir not starting with a slash" do
|
14
|
+
Pathname.new('fish').absolute?.should == false
|
15
|
+
end
|
16
|
+
|
17
|
+
it "returns false for a dir not starting with a slash" do
|
18
|
+
Pathname.new('fish/dog/cow').absolute?.should == false
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
describe "Pathname#==" do
|
4
|
+
|
5
|
+
it "returns true when identical paths are used" do
|
6
|
+
(Pathname.new('') == Pathname.new('')).should == true
|
7
|
+
end
|
8
|
+
|
9
|
+
it "returns true when identical paths are used" do
|
10
|
+
(Pathname.new('') == Pathname.new('/usr/local/bin')).should == false
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
data/spec/hash_spec.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
describe "Pathname#hash" do
|
4
|
+
|
5
|
+
it "is equal to the hash of the pathname" do
|
6
|
+
Pathname.new('/usr/local/bin/').hash.should == '/usr/local/bin/'.hash
|
7
|
+
end
|
8
|
+
|
9
|
+
it "is not equal the hash of a different pathname" do
|
10
|
+
Pathname.new('/usr/local/bin/').hash.should_not == '/usr/bin/'.hash
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
data/spec/new_spec.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
describe "Pathname.new" do
|
4
|
+
it "returns a new Pathname Object with 1 argument" do
|
5
|
+
Pathname.new('').should be_kind_of(Pathname)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "raises an ArgumentError when called with \0" do
|
9
|
+
lambda { Pathname.new("\0")}.should raise_error(ArgumentError)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "is tainted if path is tainted" do
|
13
|
+
path = '/usr/local/bin'.taint
|
14
|
+
Pathname.new(path).tainted?.should == true
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
data/spec/parent_spec.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
describe "Pathname#parent" do
|
4
|
+
|
5
|
+
it "has parent of root as root" do
|
6
|
+
Pathname.new('/').parent.to_s.should == '/'
|
7
|
+
end
|
8
|
+
|
9
|
+
it "has parent of /usr/ as root" do
|
10
|
+
Pathname.new('/usr/').parent.to_s.should == '/'
|
11
|
+
end
|
12
|
+
|
13
|
+
it "has parent of /usr/local as root" do
|
14
|
+
Pathname.new('/usr/local').parent.to_s.should == '/usr'
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
describe "Pathname#relative?" do
|
4
|
+
|
5
|
+
it "returns false for the root directory" do
|
6
|
+
Pathname.new('/').relative?.should == false
|
7
|
+
end
|
8
|
+
|
9
|
+
it "returns false for a dir starting with a slash" do
|
10
|
+
Pathname.new('/usr/local/bin').relative?.should == false
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns true for a dir not starting with a slash" do
|
14
|
+
Pathname.new('fish').relative?.should == true
|
15
|
+
end
|
16
|
+
|
17
|
+
it "returns true for a dir not starting with a slash" do
|
18
|
+
Pathname.new('fish/dog/cow').relative?.should == true
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
data/spec/root_spec.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
describe "Pathname#root?" do
|
4
|
+
|
5
|
+
it "returns true for root directories" do
|
6
|
+
Pathname.new('/').root?.should == true
|
7
|
+
end
|
8
|
+
|
9
|
+
it "returns false for empty string" do
|
10
|
+
Pathname.new('').root?.should == false
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns false for a top level directory" do
|
14
|
+
Pathname.new('/usr').root?.should == false
|
15
|
+
end
|
16
|
+
|
17
|
+
it "returns false for a top level with .. appended directory" do
|
18
|
+
Pathname.new('/usr/..').root?.should == false
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns false for a directory below top level" do
|
22
|
+
Pathname.new('/usr/local/bin/').root?.should == false
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
data/spec/sub_spec.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
describe "Pathname#sub" do
|
4
|
+
|
5
|
+
it "replaces the pattern with rest" do
|
6
|
+
Pathname.new('/usr/local/bin/').sub(/local/, 'fish').to_s.should == '/usr/fish/bin/'
|
7
|
+
end
|
8
|
+
|
9
|
+
it "returns a new object" do
|
10
|
+
p = Pathname.new('/usr/local/bin/')
|
11
|
+
p.sub(/local/, 'fish').should_not == p
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubysl-pathname
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Shirai
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubysl-prettyprint
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.0'
|
69
|
+
description: Ruby standard library pathname.
|
70
|
+
email:
|
71
|
+
- brixen@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- .travis.yml
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- lib/pathname.rb
|
83
|
+
- lib/rubysl/pathname.rb
|
84
|
+
- lib/rubysl/pathname/pathname.rb
|
85
|
+
- lib/rubysl/pathname/version.rb
|
86
|
+
- rubysl-pathname.gemspec
|
87
|
+
- spec/absolute_spec.rb
|
88
|
+
- spec/equal_value_spec.rb
|
89
|
+
- spec/hash_spec.rb
|
90
|
+
- spec/new_spec.rb
|
91
|
+
- spec/parent_spec.rb
|
92
|
+
- spec/relative_spec.rb
|
93
|
+
- spec/root_spec.rb
|
94
|
+
- spec/sub_spec.rb
|
95
|
+
homepage: https://github.com/rubysl/rubysl-pathname
|
96
|
+
licenses:
|
97
|
+
- BSD
|
98
|
+
metadata: {}
|
99
|
+
post_install_message:
|
100
|
+
rdoc_options: []
|
101
|
+
require_paths:
|
102
|
+
- lib
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - '>='
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - '>='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
requirements: []
|
114
|
+
rubyforge_project:
|
115
|
+
rubygems_version: 2.0.7
|
116
|
+
signing_key:
|
117
|
+
specification_version: 4
|
118
|
+
summary: Ruby standard library pathname.
|
119
|
+
test_files:
|
120
|
+
- spec/absolute_spec.rb
|
121
|
+
- spec/equal_value_spec.rb
|
122
|
+
- spec/hash_spec.rb
|
123
|
+
- spec/new_spec.rb
|
124
|
+
- spec/parent_spec.rb
|
125
|
+
- spec/relative_spec.rb
|
126
|
+
- spec/root_spec.rb
|
127
|
+
- spec/sub_spec.rb
|