filepath 0.6 → 0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,51 +2,51 @@
2
2
 
3
3
  require File.join(File.dirname(__FILE__), 'spec_helper')
4
4
 
5
- describe FilePathList do
5
+ describe FilepathList do
6
6
  describe "#initialize" do
7
- it "creates an empty FilePathList" do
8
- list = FilePathList.new()
7
+ it "creates an empty FilepathList" do
8
+ list = FilepathList.new()
9
9
 
10
10
  list.should be_empty
11
11
  end
12
12
 
13
- it "creates a FilePathList from an Array of Strings" do
13
+ it "creates a FilepathList from an Array of Strings" do
14
14
  paths = %w{a/b c/d e/f}
15
- list = FilePathList.new(paths)
15
+ list = FilepathList.new(paths)
16
16
 
17
17
  list.should have(3).items
18
- list.each { |path| path.should be_a(FilePath) }
18
+ list.each { |path| path.should be_a(Filepath) }
19
19
  end
20
20
 
21
- it "creates a FilePathList from an Array of FilePaths" do
21
+ it "creates a FilepathList from an Array of Filepaths" do
22
22
  paths = %w{a/b c/d e/f}.map(&:as_path)
23
- list = FilePathList.new(paths)
23
+ list = FilepathList.new(paths)
24
24
 
25
25
  list.should have(3).items
26
- list.each { |path| path.should be_a(FilePath) }
26
+ list.each { |path| path.should be_a(Filepath) }
27
27
  end
28
28
 
29
- it "creates a FilePathList from an Array of Arrays" do
29
+ it "creates a FilepathList from an Array of Arrays" do
30
30
  paths = [%w{a b}, %w{c d}, %w{e f}]
31
- list = FilePathList.new(paths)
31
+ list = FilepathList.new(paths)
32
32
 
33
33
  list.should have(3).items
34
- list.each { |path| path.should be_a(FilePath) }
34
+ list.each { |path| path.should be_a(Filepath) }
35
35
  end
36
36
  end
37
37
 
38
38
  describe "#/" do
39
39
  it "adds the same string to all the paths" do
40
- list = FilePathList.new(%w{foo faa}) / 'bar'
40
+ list = FilepathList.new(%w{foo faa}) / 'bar'
41
41
  list[0].should eq 'foo/bar'
42
42
  list[1].should eq 'faa/bar'
43
43
  end
44
44
  end
45
45
 
46
46
  describe "#+" do
47
- it "concatenates two FilePathLists" do
48
- list1 = FilePathList.new(%w{a b c})
49
- list2 = FilePathList.new(%w{d e})
47
+ it "concatenates two FilepathLists" do
48
+ list1 = FilepathList.new(%w{a b c})
49
+ list2 = FilepathList.new(%w{d e})
50
50
 
51
51
  list = list1 + list2
52
52
  list.should have(5).items
@@ -60,7 +60,7 @@ describe FilePathList do
60
60
 
61
61
  describe "#-" do
62
62
  it "removes a list (as array of strings) from another list" do
63
- list1 = FilePathList.new(%w{a/b /a/c e/d})
63
+ list1 = FilepathList.new(%w{a/b /a/c e/d})
64
64
  list2 = list1 - %w{a/b e/d}
65
65
 
66
66
  list2.should have(1).item
@@ -69,8 +69,8 @@ describe FilePathList do
69
69
  end
70
70
 
71
71
  describe "#<<" do
72
- it "adds a new to path to a existing FilePathList" do
73
- list1 = FilePathList.new(%w{a/b /c/d})
72
+ it "adds a new to path to a existing FilepathList" do
73
+ list1 = FilepathList.new(%w{a/b /c/d})
74
74
  list2 = list1 << "e/f"
75
75
 
76
76
  list1.should have(2).items
@@ -84,11 +84,11 @@ describe FilePathList do
84
84
 
85
85
  describe "#*" do
86
86
  describe "calculates the cartesian product between" do
87
- it "two FilePathLists" do
87
+ it "two FilepathLists" do
88
88
  p1 = %w{a b c}
89
89
  p2 = %w{1 2}
90
- list1 = FilePathList.new(p1)
91
- list2 = FilePathList.new(p2)
90
+ list1 = FilepathList.new(p1)
91
+ list2 = FilepathList.new(p2)
92
92
 
93
93
  all_paths = p1.product(p2).map { |x| x.join('/') }
94
94
 
@@ -97,29 +97,29 @@ describe FilePathList do
97
97
  list.should include(*all_paths)
98
98
  end
99
99
 
100
- it "a FilePathList and a string" do
100
+ it "a FilepathList and a string" do
101
101
  p1 = %w{a b c}
102
102
  p2 = "abc"
103
103
 
104
- list = FilePathList.new(p1) * p2
104
+ list = FilepathList.new(p1) * p2
105
105
  list.should have(3).items
106
106
  list.should include(*%w{a/abc b/abc c/abc})
107
107
  end
108
108
 
109
- it "a FilePathList and a FilePath" do
109
+ it "a FilepathList and a Filepath" do
110
110
  p1 = %w{a b c}
111
- p2 = FilePath.new("x")
111
+ p2 = Filepath.new("x")
112
112
 
113
- list = FilePathList.new(p1) * p2
113
+ list = FilepathList.new(p1) * p2
114
114
  list.should have(3).items
115
115
  list.should include(*%w{a/x b/x c/x})
116
116
  end
117
117
 
118
- it "a FilePath and an array of strings" do
118
+ it "a Filepath and an array of strings" do
119
119
  p1 = %w{a b c}
120
120
  p2 = ["1", "2"]
121
121
 
122
- list = FilePathList.new(p1) * p2
122
+ list = FilepathList.new(p1) * p2
123
123
  list.should have(6).items
124
124
  list.should include(*%w{a/1 b/1 a/2 b/2 c/1 c/2})
125
125
  end
@@ -129,14 +129,14 @@ describe FilePathList do
129
129
  describe "#remove_common_segments" do
130
130
  it "works on lists of files from the same dir" do
131
131
  paths = %w{a/b/x1 a/b/x2 a/b/x3}
132
- list = FilePathList.new(paths).remove_common_segments
132
+ list = FilepathList.new(paths).remove_common_segments
133
133
 
134
134
  list.should have(3).items
135
135
  list.should include(*%w{x1 x2 x3})
136
136
  end
137
137
 
138
138
  it "works on lists of files from different dirs" do
139
- list1 = FilePathList.new(%w{a/b/x1 a/b/c/x2 a/b/d/e/x3})
139
+ list1 = FilepathList.new(%w{a/b/x1 a/b/c/x2 a/b/d/e/x3})
140
140
  list2 = list1.remove_common_segments
141
141
 
142
142
  list2.should have(3).items
@@ -145,7 +145,7 @@ describe FilePathList do
145
145
 
146
146
  it "works on lists of files with no common segments" do
147
147
  paths = %w{a/b a/d g/f}
148
- list1 = FilePathList.new(paths)
148
+ list1 = FilepathList.new(paths)
149
149
  list2 = list1.remove_common_segments
150
150
 
151
151
  list1.should == list2
@@ -153,23 +153,23 @@ describe FilePathList do
153
153
 
154
154
  it "works on lists that contain duplicates only" do
155
155
  paths = %w{a/b a/b a/b}
156
- list1 = FilePathList.new(paths)
156
+ list1 = FilepathList.new(paths)
157
157
  list2 = list1.remove_common_segments
158
158
 
159
- list2.should == FilePathList.new(['.', '.', '.'])
159
+ list2.should == FilepathList.new(['.', '.', '.'])
160
160
  end
161
161
  end
162
162
 
163
163
  describe "#include?" do
164
164
  it "says that 'a/c' is included in [<a/b>, <a/c>, </a/d>]" do
165
- list = FilePathList.new(%w{a/b a/c /a/d})
165
+ list = FilepathList.new(%w{a/b a/c /a/d})
166
166
  list.should include("a/c")
167
167
  end
168
168
  end
169
169
 
170
170
  describe "#to_s" do
171
171
  it "returns files separated by a comma`" do
172
- list = FilePathList.new(%w{a/b a/c /a/d})
172
+ list = FilepathList.new(%w{a/b a/c /a/d})
173
173
  list.to_s.should == "a/b:a/c:/a/d"
174
174
  end
175
175
  end
@@ -177,53 +177,53 @@ describe FilePathList do
177
177
  describe "#==" do
178
178
  let(:list) { ['a/b', 'c/d', 'e/f'].as_path_list }
179
179
 
180
- it "compares a FilePathList to another FilePathList" do
181
- list2 = FilePathList.new << 'a/b' << 'c/d' << 'e/f'
180
+ it "compares a FilepathList to another FilepathList" do
181
+ list2 = FilepathList.new << 'a/b' << 'c/d' << 'e/f'
182
182
  list3 = list2 << 'g/h'
183
183
 
184
184
  list.should eq(list2)
185
185
  list.should_not eq(list3)
186
186
  end
187
187
 
188
- it "compares a FilePathList to an Array of Strings" do
188
+ it "compares a FilepathList to an Array of Strings" do
189
189
  list.should eq(%w{a/b c/d e/f})
190
190
  list.should_not eq(%w{a/a b/b c/c})
191
191
  end
192
192
  end
193
193
 
194
- describe FilePathList::ArrayMethods do
195
- let(:list) { FilePathList.new(%w{a.foo b.bar c.foo d.foo b.bar}) }
194
+ describe FilepathList::ArrayMethods do
195
+ let(:list) { FilepathList.new(%w{a.foo b.bar c.foo d.foo b.bar}) }
196
196
 
197
197
  describe "#all?" do
198
198
  it "checks whether a block applies to a list" do
199
199
  ok = list.all? { |path| path.extension? }
200
- ok.should be_true
200
+ ok.should be true
201
201
  end
202
202
  end
203
203
 
204
204
  describe "#any?" do
205
205
  it "check whether a block does not apply to any path" do
206
206
  ok = list.any? { |path| path.basename == "a.foo" }
207
- ok.should be_true
207
+ ok.should be true
208
208
  end
209
209
  end
210
210
 
211
211
  describe "#none?" do
212
212
  it "check whether a block does not apply to any path" do
213
213
  ok = list.none? { |path| path.absolute? }
214
- ok.should be_true
214
+ ok.should be true
215
215
  end
216
216
  end
217
217
  end
218
218
 
219
- describe FilePathList::EntriesMethods do
220
- let(:list) { FilePathList.new(%w{a.foo b.bar c.foo d.foo b.bar}) }
219
+ describe FilepathList::EntriesMethods do
220
+ let(:list) { FilepathList.new(%w{a.foo b.bar c.foo d.foo b.bar}) }
221
221
 
222
222
  describe "#select" do
223
223
  it "keeps paths matching a Regex" do
224
224
  remaining = list.select(/bar$/)
225
225
 
226
- remaining.should be_a FilePathList
226
+ remaining.should be_a FilepathList
227
227
  remaining.should have(2).items
228
228
  remaining.each { |path| path.extension.should == 'bar' }
229
229
  end
@@ -240,7 +240,7 @@ describe FilePathList do
240
240
  it "excludes paths matching a Regex" do
241
241
  remaining = list.exclude(/bar$/)
242
242
 
243
- remaining.should be_a FilePathList
243
+ remaining.should be_a FilepathList
244
244
  remaining.should have(3).items
245
245
  remaining.each { |path| path.extension.should == 'foo' }
246
246
  end
@@ -248,7 +248,7 @@ describe FilePathList do
248
248
  it "excludes all the paths for which the block returns true" do
249
249
  remaining = list.exclude { |path| path.extension?('bar') }
250
250
 
251
- remaining.should be_a FilePathList
251
+ remaining.should be_a FilepathList
252
252
  remaining.should have(3).items
253
253
  remaining.each { |path| path.extension.should == 'foo' }
254
254
  end
@@ -258,9 +258,9 @@ describe FilePathList do
258
258
  it "applies a block to each path" do
259
259
  mapped = list.map { |path| path.remove_extension }
260
260
 
261
- mapped.should be_a FilePathList
261
+ mapped.should be_a FilepathList
262
262
  mapped.should have(list.size).items
263
- mapped.each { |path| path.extension?.should be_false }
263
+ mapped.each { |path| path.extension?.should be false }
264
264
  end
265
265
  end
266
266
  end
@@ -269,11 +269,11 @@ end
269
269
 
270
270
  describe Array do
271
271
  describe "#as_path_list" do
272
- it "generates a FilePathList from an Array" do
272
+ it "generates a FilepathList from an Array" do
273
273
  paths = %w{/a/b c/d /f/g}
274
274
  list = paths.as_path_list
275
275
 
276
- list.should be_a(FilePathList)
276
+ list.should be_a(FilepathList)
277
277
  list.should include(*paths)
278
278
  end
279
279
  end
@@ -0,0 +1,21 @@
1
+ # This is free software released into the public domain (CC0 license).
2
+
3
+ FIXTURES_DIR = File.join(%w{spec fixtures})
4
+ FIXTURES_FAKE_ENTRIES = [
5
+ 'd1',
6
+ ['d1', 'd11'],
7
+ ['d1', 'd12'],
8
+ ['d1', 'd13'],
9
+ ['d1', 'f11'],
10
+ ['d1', 'f12'],
11
+ ['d1', 'l11'],
12
+ 'd2',
13
+ ['d2', 'd21'],
14
+ ['d2', 'd22'],
15
+ 'd3',
16
+ 'f1',
17
+ 'dx',
18
+ 'p1',
19
+ 'p2',
20
+ 's1',
21
+ ].map { |entry| File.join(FIXTURES_DIR, *Array(entry)) }
@@ -1,12 +1,22 @@
1
- # This is free software released into the public domain (CC0 license).
2
-
3
1
  LIB_DIR = File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib]))
4
2
  $LOAD_PATH.unshift(LIB_DIR) unless $LOAD_PATH.include?(LIB_DIR)
5
3
 
6
4
  require 'filepath'
7
5
 
6
+ require File.join(File.dirname(__FILE__), 'fixtures')
7
+
8
8
  RSpec.configure do |config|
9
9
  config.filter_run_excluding :broken => true
10
+
11
+ config.expect_with :rspec do |rspec|
12
+ rspec.syntax = [:should, :expect]
13
+ end
14
+
15
+ config.mock_with :rspec do |mocks|
16
+ mocks.syntax = [:should, :expect]
17
+ end
10
18
  end
11
19
 
12
- FIXTURES_DIR = File.join(%w{spec fixtures})
20
+ require 'rspec/collection_matchers'
21
+
22
+ # This is free software released into the public domain (CC0 license).
@@ -2,25 +2,7 @@
2
2
 
3
3
  require 'rake/clean'
4
4
 
5
- FIXTURES_DIR = File.join(%w{spec fixtures})
6
- FIXTURES_FAKE_ENTRIES = [
7
- 'd1',
8
- ['d1', 'd11'],
9
- ['d1', 'd12'],
10
- ['d1', 'd13'],
11
- ['d1', 'f11'],
12
- ['d1', 'f12'],
13
- ['d1', 'l11'],
14
- 'd2',
15
- ['d2', 'd21'],
16
- ['d2', 'd22'],
17
- 'd3',
18
- 'f1',
19
- 'dx',
20
- 'p1',
21
- 'p2',
22
- 's1',
23
- ].map { |entry| File.join(FIXTURES_DIR, *Array(entry)) }
5
+ require File.join(File.dirname(__FILE__), 'fixtures')
24
6
 
25
7
  CLEAN.concat FIXTURES_FAKE_ENTRIES
26
8
 
metadata CHANGED
@@ -1,71 +1,84 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filepath
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.6'
4
+ version: '0.7'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gioele Barabucci
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-15 00:00:00.000000000 Z
11
+ date: 2017-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: 'filepath is built around two main classes: `FilePath`, that represents
56
- paths, and `FilePathList`, lists of paths. The instances of these classes are immutable
57
- objects with dozens of convience methods for common operations such as calculating
58
- relative paths, concatenating paths, finding all the files in a directory or modifing
59
- all the extensions of a list of file '
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-collection_matchers
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: The Filepath class provides immutable objects with dozens of convenience
70
+ methods for common operations such as calculating relative paths, concatenating
71
+ paths, finding all the files in a directory or modifying all the extensions of a
72
+ list of filenames at once.
60
73
  email:
61
74
  - gioele@svario.it
62
75
  executables: []
63
76
  extensions: []
64
77
  extra_rdoc_files: []
65
78
  files:
66
- - .gitignore
67
- - .travis.yml
68
- - .yardopts
79
+ - ".gitignore"
80
+ - ".travis.yml"
81
+ - ".yardopts"
69
82
  - COPYING
70
83
  - Gemfile
71
84
  - README.md
@@ -78,6 +91,7 @@ files:
78
91
  - lib/filepath/filepathlist.rb
79
92
  - spec/filepath_spec.rb
80
93
  - spec/filepathlist_spec.rb
94
+ - spec/fixtures.rb
81
95
  - spec/spec_helper.rb
82
96
  - spec/tasks.rb
83
97
  homepage: http://github.com/gioele/filepath
@@ -90,23 +104,24 @@ require_paths:
90
104
  - lib
91
105
  required_ruby_version: !ruby/object:Gem::Requirement
92
106
  requirements:
93
- - - '>='
107
+ - - ">="
94
108
  - !ruby/object:Gem::Version
95
109
  version: '0'
96
110
  required_rubygems_version: !ruby/object:Gem::Requirement
97
111
  requirements:
98
- - - '>='
112
+ - - ">="
99
113
  - !ruby/object:Gem::Version
100
114
  version: '0'
101
115
  requirements: []
102
116
  rubyforge_project:
103
- rubygems_version: 2.0.4
117
+ rubygems_version: 2.6.11
104
118
  signing_key:
105
119
  specification_version: 4
106
- summary: filepath is a small library that helps dealing with files, directories and
107
- paths in general; a modern replacement for the standard Pathname.
120
+ summary: A small library to manipulate paths; a modern replacement for the standard
121
+ Pathname.
108
122
  test_files:
109
123
  - spec/filepath_spec.rb
110
124
  - spec/filepathlist_spec.rb
125
+ - spec/fixtures.rb
111
126
  - spec/spec_helper.rb
112
127
  - spec/tasks.rb