epitools 0.4.7 → 0.4.8
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/VERSION +1 -1
- data/epitools.gemspec +1 -1
- data/lib/epitools/path.rb +27 -2
- data/spec/path_spec.rb +21 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.8
|
data/epitools.gemspec
CHANGED
data/lib/epitools/path.rb
CHANGED
@@ -1,15 +1,30 @@
|
|
1
1
|
require 'epitools/basetypes'
|
2
2
|
|
3
|
+
class String
|
4
|
+
def to_path
|
5
|
+
Path.new(self)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
3
9
|
class Path
|
10
|
+
|
4
11
|
|
5
12
|
## initializers
|
6
13
|
|
7
14
|
def initialize(newpath)
|
8
15
|
self.path = newpath
|
9
16
|
end
|
17
|
+
|
18
|
+
def self.glob(str)
|
19
|
+
Dir[str].map { |entry| new(entry) }
|
20
|
+
end
|
10
21
|
|
11
|
-
def self.[](
|
12
|
-
|
22
|
+
def self.[](str)
|
23
|
+
if str =~ /[\?\*]/ and not str =~ /\\[\?\*]/ # contains glob chars? (unescaped)
|
24
|
+
glob(str)
|
25
|
+
else
|
26
|
+
new(str)
|
27
|
+
end
|
13
28
|
end
|
14
29
|
|
15
30
|
|
@@ -61,6 +76,7 @@ class Path
|
|
61
76
|
end
|
62
77
|
end
|
63
78
|
|
79
|
+
|
64
80
|
## readers
|
65
81
|
|
66
82
|
attr_reader :dirs, :base, :ext
|
@@ -127,5 +143,14 @@ class Path
|
|
127
143
|
alias_method :pathname, :path
|
128
144
|
alias_method :to_s, :path
|
129
145
|
alias_method :directory?, :dir?
|
146
|
+
|
147
|
+
|
148
|
+
## comparisons
|
149
|
+
|
150
|
+
include Comparable
|
151
|
+
|
152
|
+
def <=>(other)
|
153
|
+
self.path <=> other.path
|
154
|
+
end
|
130
155
|
|
131
156
|
end
|
data/spec/path_spec.rb
CHANGED
@@ -18,7 +18,7 @@ describe Path do
|
|
18
18
|
path.filename.should == "blah"
|
19
19
|
path.ext.should == nil
|
20
20
|
|
21
|
-
abs_path = File.join(File.
|
21
|
+
abs_path = File.join(File.expand_path(".."), "hello.mp3")
|
22
22
|
path.dir.should == abs_path
|
23
23
|
end
|
24
24
|
|
@@ -58,4 +58,24 @@ describe Path do
|
|
58
58
|
path.mtime.class.should == Time
|
59
59
|
end
|
60
60
|
|
61
|
+
it "globs" do
|
62
|
+
path = Path.new(__FILE__)
|
63
|
+
glob = path.dir + "/*spec.rb"
|
64
|
+
specs = Path.glob(glob)
|
65
|
+
path.in?(specs).should == true
|
66
|
+
end
|
67
|
+
|
68
|
+
it "Path[file] and Path[glob]s" do
|
69
|
+
path = Path.new(__FILE__)
|
70
|
+
path.should == Path[__FILE__]
|
71
|
+
|
72
|
+
glob = path.dir + "/*spec.rb"
|
73
|
+
specs = Path.glob(glob)
|
74
|
+
Path[glob].should == specs
|
75
|
+
end
|
76
|
+
|
77
|
+
it "String#to_paths" do
|
78
|
+
__FILE__.to_path.should == Path.new(__FILE__)
|
79
|
+
end
|
80
|
+
|
61
81
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epitools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 8
|
10
|
+
version: 0.4.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- epitron
|