rubysl-pathname 2.2 → 2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -3
- data/lib/rubysl/pathname/pathname.rb +25 -38
- data/lib/rubysl/pathname/version.rb +1 -1
- data/spec/birthtime_spec.rb +21 -0
- data/spec/divide_spec.rb +10 -0
- data/spec/plus_spec.rb +10 -0
- metadata +7 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65cf9cbc8e563ba4b10c8d9e5c814831b9308934
|
4
|
+
data.tar.gz: 2cc26e849b2d3bf36e68ff773350ac10e464f889
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e98284b904f10e22b4647116cd5516ac2ffdb7c7c161cd73cb8fb3bd5b04d2e6bb08ad5c7b1014a35eec95f2d5dd84e448aac1f1647e92c96e6dab8d171de060
|
7
|
+
data.tar.gz: 7004611a45bfed97319cf0b262e7505250b34236535553e025b070f47817a1e0a81fb04ea4d9481dd0a7ffdf54f004c75abc3c86f8c2b8b28e46cd5a36ff0655
|
data/.travis.yml
CHANGED
@@ -201,7 +201,25 @@ class Pathname
|
|
201
201
|
proc {|a, b| a == b}
|
202
202
|
end
|
203
203
|
|
204
|
-
#
|
204
|
+
# See <tt>Dir.glob</tt>. Returns or yields Pathname objects.
|
205
|
+
def self.glob(*args) # :yield: pathname
|
206
|
+
if block_given?
|
207
|
+
Dir.glob(*args) {|f| yield self.new(f) }
|
208
|
+
else
|
209
|
+
Dir.glob(*args).map {|f| self.new(f) }
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
# See <tt>Dir.getwd</tt>. Returns the current working directory as a Pathname.
|
214
|
+
def self.getwd() self.new(Dir.getwd) end
|
215
|
+
|
216
|
+
class << self
|
217
|
+
alias pwd getwd
|
218
|
+
end
|
219
|
+
|
220
|
+
def self.birthtime(file)
|
221
|
+
File.birthtime(file)
|
222
|
+
end
|
205
223
|
|
206
224
|
#
|
207
225
|
# Create a Pathname object from the given String (or String-like object).
|
@@ -588,6 +606,8 @@ class Pathname
|
|
588
606
|
Pathname.new(plus(@path, other.to_s))
|
589
607
|
end
|
590
608
|
|
609
|
+
alias_method :/, :+
|
610
|
+
|
591
611
|
def plus(path1, path2) # -> path
|
592
612
|
prefix2 = path2
|
593
613
|
index_list2 = []
|
@@ -760,9 +780,7 @@ class Pathname
|
|
760
780
|
Pathname.new(File.join(*relpath_names))
|
761
781
|
end
|
762
782
|
end
|
763
|
-
end
|
764
783
|
|
765
|
-
class Pathname # * IO *
|
766
784
|
#
|
767
785
|
# #each_line iterates over the line in the file. It yields a String object
|
768
786
|
# for each line.
|
@@ -792,10 +810,6 @@ class Pathname # * IO *
|
|
792
810
|
|
793
811
|
# See <tt>IO.sysopen</tt>.
|
794
812
|
def sysopen(*args) IO.sysopen(@path, *args) end
|
795
|
-
end
|
796
|
-
|
797
|
-
|
798
|
-
class Pathname # * File *
|
799
813
|
|
800
814
|
# See <tt>File.atime</tt>. Returns last access time.
|
801
815
|
def atime() File.atime(@path) end
|
@@ -873,10 +887,6 @@ class Pathname # * File *
|
|
873
887
|
# See <tt>File.split</tt>. Returns the #dirname and the #basename in an
|
874
888
|
# Array.
|
875
889
|
def split() File.split(@path).map {|f| self.class.new(f) } end
|
876
|
-
end
|
877
|
-
|
878
|
-
|
879
|
-
class Pathname # * FileTest *
|
880
890
|
|
881
891
|
# See <tt>FileTest.blockdev?</tt>.
|
882
892
|
def blockdev?() FileTest.blockdev?(@path) end
|
@@ -949,22 +959,6 @@ class Pathname # * FileTest *
|
|
949
959
|
|
950
960
|
# See <tt>FileTest.zero?</tt>.
|
951
961
|
def zero?() FileTest.zero?(@path) end
|
952
|
-
end
|
953
|
-
|
954
|
-
|
955
|
-
class Pathname # * Dir *
|
956
|
-
# See <tt>Dir.glob</tt>. Returns or yields Pathname objects.
|
957
|
-
def Pathname.glob(*args) # :yield: pathname
|
958
|
-
if block_given?
|
959
|
-
Dir.glob(*args) {|f| yield self.new(f) }
|
960
|
-
else
|
961
|
-
Dir.glob(*args).map {|f| self.new(f) }
|
962
|
-
end
|
963
|
-
end
|
964
|
-
|
965
|
-
# See <tt>Dir.getwd</tt>. Returns the current working directory as a Pathname.
|
966
|
-
def Pathname.getwd() self.new(Dir.getwd) end
|
967
|
-
class << self; alias pwd getwd end
|
968
962
|
|
969
963
|
# Return the entries (files and subdirectories) in the directory, each as a
|
970
964
|
# Pathname object.
|
@@ -988,10 +982,7 @@ class Pathname # * Dir *
|
|
988
982
|
def opendir(&block) # :yield: dir
|
989
983
|
Dir.open(@path, &block)
|
990
984
|
end
|
991
|
-
end
|
992
|
-
|
993
985
|
|
994
|
-
class Pathname # * Find *
|
995
986
|
#
|
996
987
|
# Pathname#find is an iterator to traverse a directory tree in a depth first
|
997
988
|
# manner. It yields a Pathname for each file under "this" directory.
|
@@ -1013,10 +1004,7 @@ class Pathname # * Find *
|
|
1013
1004
|
Find.find(@path) {|f| yield self.class.new(f) }
|
1014
1005
|
end
|
1015
1006
|
end
|
1016
|
-
end
|
1017
1007
|
|
1018
|
-
|
1019
|
-
class Pathname # * FileUtils *
|
1020
1008
|
# See <tt>FileUtils.mkpath</tt>. Creates a full path, including any
|
1021
1009
|
# intermediate directories that don't yet exist.
|
1022
1010
|
def mkpath
|
@@ -1033,10 +1021,7 @@ class Pathname # * FileUtils *
|
|
1033
1021
|
FileUtils.rm_r(@path)
|
1034
1022
|
nil
|
1035
1023
|
end
|
1036
|
-
end
|
1037
1024
|
|
1038
|
-
|
1039
|
-
class Pathname # * mixed *
|
1040
1025
|
# Removes a file or directory, using <tt>File.unlink</tt> or
|
1041
1026
|
# <tt>Dir.unlink</tt> as necessary.
|
1042
1027
|
def unlink()
|
@@ -1047,10 +1032,12 @@ class Pathname # * mixed *
|
|
1047
1032
|
end
|
1048
1033
|
end
|
1049
1034
|
alias delete unlink
|
1050
|
-
end
|
1051
1035
|
|
1052
|
-
class Pathname
|
1053
1036
|
undef =~
|
1037
|
+
|
1038
|
+
def birthtime
|
1039
|
+
File.birthtime(@path)
|
1040
|
+
end
|
1054
1041
|
end
|
1055
1042
|
|
1056
1043
|
module Kernel
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
describe 'Pathname.birthtime' do
|
4
|
+
platform_is :osx do
|
5
|
+
it 'returns a Time instance' do
|
6
|
+
time = Pathname.birthtime(__FILE__)
|
7
|
+
|
8
|
+
time.should be_an_instance_of(Time)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'Pathname#birthtime' do
|
14
|
+
platform_is :osx do
|
15
|
+
it 'returns a Time instance' do
|
16
|
+
time = Pathname.new(__FILE__).birthtime
|
17
|
+
|
18
|
+
time.should be_an_instance_of(Time)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/divide_spec.rb
ADDED
data/spec/plus_spec.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubysl-pathname
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '2.
|
4
|
+
version: '2.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Shirai
|
@@ -86,12 +86,15 @@ files:
|
|
86
86
|
- lib/rubysl/pathname/version.rb
|
87
87
|
- rubysl-pathname.gemspec
|
88
88
|
- spec/absolute_spec.rb
|
89
|
+
- spec/birthtime_spec.rb
|
90
|
+
- spec/divide_spec.rb
|
89
91
|
- spec/equal_value_spec.rb
|
90
92
|
- spec/find_spec.rb
|
91
93
|
- spec/hash_spec.rb
|
92
94
|
- spec/kernel_spec.rb
|
93
95
|
- spec/new_spec.rb
|
94
96
|
- spec/parent_spec.rb
|
97
|
+
- spec/plus_spec.rb
|
95
98
|
- spec/relative_spec.rb
|
96
99
|
- spec/root_spec.rb
|
97
100
|
- spec/sub_spec.rb
|
@@ -121,12 +124,15 @@ specification_version: 4
|
|
121
124
|
summary: Ruby standard library pathname.
|
122
125
|
test_files:
|
123
126
|
- spec/absolute_spec.rb
|
127
|
+
- spec/birthtime_spec.rb
|
128
|
+
- spec/divide_spec.rb
|
124
129
|
- spec/equal_value_spec.rb
|
125
130
|
- spec/find_spec.rb
|
126
131
|
- spec/hash_spec.rb
|
127
132
|
- spec/kernel_spec.rb
|
128
133
|
- spec/new_spec.rb
|
129
134
|
- spec/parent_spec.rb
|
135
|
+
- spec/plus_spec.rb
|
130
136
|
- spec/relative_spec.rb
|
131
137
|
- spec/root_spec.rb
|
132
138
|
- spec/sub_spec.rb
|