fspath 2.0.3 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +1 -1
- data/fspath.gemspec +1 -1
- data/lib/fspath.rb +8 -2
- data/spec/fspath_spec.rb +7 -1
- metadata +5 -7
- data/spec/spec_helper.rb +0 -2
data/README.markdown
CHANGED
data/fspath.gemspec
CHANGED
data/lib/fspath.rb
CHANGED
@@ -96,13 +96,13 @@ class FSPath < Pathname
|
|
96
96
|
|
97
97
|
# Escape characters in glob pattern
|
98
98
|
def escape_glob
|
99
|
-
self.class.new(
|
99
|
+
self.class.new(escape_glob_string)
|
100
100
|
end
|
101
101
|
|
102
102
|
# Expand glob
|
103
103
|
def glob(*args, &block)
|
104
104
|
flags = args.last.is_a?(Fixnum) ? args.pop : nil
|
105
|
-
args = [File.join(
|
105
|
+
args = [File.join(escape_glob_string, *args)]
|
106
106
|
args << flags if flags
|
107
107
|
self.class.glob(*args, &block)
|
108
108
|
end
|
@@ -136,6 +136,12 @@ class FSPath < Pathname
|
|
136
136
|
def parts(&block)
|
137
137
|
split_names(@path).flatten
|
138
138
|
end
|
139
|
+
|
140
|
+
private
|
141
|
+
|
142
|
+
def escape_glob_string
|
143
|
+
@path.gsub(/([\*\?\[\]\{\}])/, '\\\\\1')
|
144
|
+
end
|
139
145
|
end
|
140
146
|
|
141
147
|
module Kernel
|
data/spec/fspath_spec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
2
|
+
require 'rspec'
|
2
3
|
require 'fspath'
|
3
4
|
|
4
5
|
describe FSPath do
|
@@ -189,6 +190,11 @@ describe FSPath do
|
|
189
190
|
FSPath.should_receive(:glob).with('a/b/c/**/*', @flags)
|
190
191
|
FSPath('a/b/c').glob('**', '*', @flags)
|
191
192
|
end
|
193
|
+
|
194
|
+
it "should escape glob characters in path itself" do
|
195
|
+
FSPath.should_receive(:glob).with('somewhere \[a b c\]/**/*')
|
196
|
+
FSPath('somewhere [a b c]').glob('**', '*')
|
197
|
+
end
|
192
198
|
end
|
193
199
|
|
194
200
|
describe "path parts" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fspath
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 2.0.
|
9
|
+
- 4
|
10
|
+
version: 2.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ivan Kuchin
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-03-05 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rspec
|
@@ -46,7 +46,6 @@ files:
|
|
46
46
|
- fspath.gemspec
|
47
47
|
- lib/fspath.rb
|
48
48
|
- spec/fspath_spec.rb
|
49
|
-
- spec/spec_helper.rb
|
50
49
|
homepage: http://github.com/toy/fspath
|
51
50
|
licenses:
|
52
51
|
- MIT
|
@@ -76,11 +75,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
75
|
requirements: []
|
77
76
|
|
78
77
|
rubyforge_project: fspath
|
79
|
-
rubygems_version: 1.8.
|
78
|
+
rubygems_version: 1.8.17
|
80
79
|
signing_key:
|
81
80
|
specification_version: 3
|
82
81
|
summary: Better than Pathname
|
83
82
|
test_files:
|
84
83
|
- spec/fspath_spec.rb
|
85
|
-
- spec/spec_helper.rb
|
86
84
|
has_rdoc:
|
data/spec/spec_helper.rb
DELETED