fspath 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZWMyZGJiOTM2MzZkOWQwZTljNjE4Yjc3MmI5MTAxOTliNDU0OTdmZA==
4
+ YjExMmZkYzEwNGJlMDFiZDhkOTJmZjE2Yzg0M2Y0M2ZhNzI3Nzg5NQ==
5
5
  data.tar.gz: !binary |-
6
- ZWFkODdkNTRlOTQyYjFmZDVkYjZhM2JjM2VmZTQ2NWZjZGViMzliYw==
7
- !binary "U0hBNTEy":
6
+ ZjZlNTBlNzQ0ODQzN2ViOWU1NDM1ZDkzZGNkNDAzNzZhMmM2MWM1OA==
7
+ SHA512:
8
8
  metadata.gz: !binary |-
9
- ZGVhNmZhYTZjODQzNWYzMzA0OGNkOGRjNjhmNmQyNWYzNDQyMWU3ZThjNDE5
10
- MmJmYzc5NTI0NGFlYTE5ZjgxMzE1N2Y2ZDhjOTJiYmJjZjUxNzc4ODA1ZWFi
11
- ZGJmN2U4ZjEwM2ExYTk0ZGFhMzJhOWVjYmEyZDZkYjRhMjc2YTU=
9
+ ZmE5ODRjOWZkMjg1ZWM1NDU0M2NhOGM2MmE1YjVkYjg5NjEyNjJmZWNiMjNl
10
+ YzdjNzMzZjM4MjkwNGEzMTkyNjY4OTA5MTc0ZDhhOTgzYzZjMDY2YzJmZjYz
11
+ Y2MzODM0Mzk5OGU0ZmUxNDIwODYyZGNkNzkzZmI2Mzc4Y2U1YzI=
12
12
  data.tar.gz: !binary |-
13
- ZWU5Yjc2OGViYjkwMDNhNzE4MDNiMjUwZjkzZmY5NTFhYjFkYWQ2Y2RkNGRm
14
- MjM5ODE3ODE3ZmI4OGVhZjc1MzI0NmFlNGE1YTdmM2Q0ZWRkNzc2ODg0ZTM3
15
- OTI2Y2Q4ZTgyMDRhOTcxOTJkY2E0YzkwOWE1Y2UyZTYwNzBmZmU=
13
+ YmQzYzg1NTdlZWM3Y2I1OTg5YzUxMTg3ODcwYjk4YzdkMmQ1ZWE0YTJiOTFk
14
+ MDM1NDliNGRjMjFhOGIyNzY4MzY0MTk2YTlhMzFmMjY3ZTNiZTcyYWQ2ZThl
15
+ MDFkNjk5NzU0N2I3NjlhMWQwMjZiZTc5ZDgwNDAzYjIzZjFiZDA=
data/.rubocop.yml ADDED
@@ -0,0 +1,59 @@
1
+ AllCops:
2
+ Exclude:
3
+ - '*.gemspec'
4
+
5
+ Lint/EndAlignment:
6
+ AlignWith: variable
7
+
8
+ Metrics/ClassLength:
9
+ Max: 175
10
+
11
+ Metrics/MethodLength:
12
+ Max: 15
13
+
14
+ Style/AccessModifierIndentation:
15
+ EnforcedStyle: outdent
16
+
17
+ Style/BracesAroundHashParameters:
18
+ Enabled: false
19
+
20
+ Style/CaseIndentation:
21
+ IndentWhenRelativeTo: end
22
+
23
+ Style/DotPosition:
24
+ EnforcedStyle: trailing
25
+
26
+ Style/DoubleNegation:
27
+ Enabled: false
28
+
29
+ Style/Encoding:
30
+ EnforcedStyle: when_needed
31
+
32
+ Style/HashSyntax:
33
+ EnforcedStyle: hash_rockets
34
+
35
+ Style/IfUnlessModifier:
36
+ MaxLineLength: 40
37
+
38
+ Style/IndentHash:
39
+ EnforcedStyle: consistent
40
+
41
+ Style/OpMethod: # leave name in `def ~(name = nil)`
42
+ Enabled: false
43
+
44
+ Style/PercentLiteralDelimiters:
45
+ PreferredDelimiters:
46
+ '%w': '[]'
47
+ '%W': '[]'
48
+
49
+ Style/Semicolon:
50
+ AllowAsExpressionSeparator: true
51
+
52
+ Style/SpaceBeforeBlockBraces:
53
+ EnforcedStyle: no_space
54
+
55
+ Style/SpaceInsideHashLiteralBraces:
56
+ EnforcedStyle: no_space
57
+
58
+ Style/TrailingComma:
59
+ EnforcedStyleForMultiline: comma
data/.travis.yml CHANGED
@@ -3,8 +3,20 @@ rvm:
3
3
  - 1.8.7
4
4
  - 1.9.2
5
5
  - 1.9.3
6
- - 2.0.0
6
+ - '2.0'
7
+ - '2.1'
8
+ - '2.2'
7
9
  - jruby-18mode
8
10
  - jruby-19mode
9
11
  - ree
10
- script: "bundle exec rspec"
12
+ script:
13
+ if [ -n "$RUBOCOP" ]; then
14
+ bundle exec rubocop
15
+ ; else
16
+ bundle exec rspec
17
+ ; fi
18
+ matrix:
19
+ fast_finish: true
20
+ include:
21
+ - env: RUBOCOP=true
22
+ rvm: default
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2013 Ivan Kuchin
1
+ Copyright (c) 2010-2014 Ivan Kuchin
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.markdown CHANGED
@@ -1,11 +1,15 @@
1
+ [![Gem Version](https://img.shields.io/gem/v/fspath.svg?style=flat)](https://rubygems.org/gems/fspath)
2
+ [![Build Status](https://img.shields.io/travis/toy/fspath/master.svg?style=flat)](https://travis-ci.org/toy/fspath)
3
+ [![Code Climate](https://img.shields.io/codeclimate/github/toy/fspath.svg?style=flat)](https://codeclimate.com/github/toy/fspath)
4
+ [![Dependency Status](https://img.shields.io/gemnasium/toy/fspath.svg?style=flat)](https://gemnasium.com/toy/fspath)
5
+ [![Inch CI](http://inch-ci.org/github/toy/fspath.svg?branch=master&style=flat)](http://inch-ci.org/github/toy/fspath)
6
+
1
7
  # fspath
2
8
 
3
9
  Better than Pathname
4
10
 
5
11
  Check out [fspath-mac](https://rubygems.org/gems/fspath-mac) and [fspath-xattr](https://rubygems.org/gems/fspath-xattr).
6
12
 
7
- [![Build Status](https://travis-ci.org/toy/fspath.png?branch=master)](https://travis-ci.org/toy/fspath)
8
-
9
13
  ## Synopsis
10
14
 
11
15
  User dir:
@@ -56,4 +60,4 @@ Path parts:
56
60
 
57
61
  ## Copyright
58
62
 
59
- Copyright (c) 2010-2013 Ivan Kuchin. See LICENSE.txt for details.
63
+ Copyright (c) 2010-2014 Ivan Kuchin. See LICENSE.txt for details.
data/fspath.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'fspath'
5
- s.version = '2.1.0'
5
+ s.version = '2.1.1'
6
6
  s.summary = %q{Better than Pathname}
7
7
  s.homepage = "http://github.com/toy/#{s.name}"
8
8
  s.authors = ['Ivan Kuchin']
@@ -15,5 +15,8 @@ Gem::Specification.new do |s|
15
15
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
16
  s.require_paths = %w[lib]
17
17
 
18
- s.add_development_dependency 'rspec'
18
+ s.add_development_dependency 'rspec', '~> 3.0'
19
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('1.9.3')
20
+ s.add_development_dependency 'rubocop', '~> 0.28'
21
+ end
19
22
  end
data/lib/fspath.rb CHANGED
@@ -2,18 +2,26 @@ require 'pathname'
2
2
  require 'tempfile'
3
3
  require 'tmpdir'
4
4
 
5
+ # Extension of Pathname with helpful methods and fixes
5
6
  class FSPath < Pathname
7
+ # Extension of Tempfile returning instance of provided class for path
6
8
  class Tempfile < ::Tempfile
9
+ # Eats first argument which must be a class, and calls super
7
10
  def initialize(path_klass, *args)
8
- raise ArgumentError.new("#{path_klass.inspect} is not a class") unless path_klass.is_a?(Class)
11
+ unless path_klass.is_a?(Class)
12
+ fail ArgumentError, "#{path_klass.inspect} is not a class"
13
+ end
9
14
  @path_klass = path_klass
10
15
  super(*args)
11
16
  end
12
17
 
18
+ # Returns path wrapped in class provided in initialize
13
19
  def path
14
20
  @path_klass.new(super)
15
21
  end
16
22
 
23
+ # Fixes using appropriate initializer for jruby in 1.8 mode, also returns
24
+ # result of block in ruby 1.8
17
25
  def self.open(*args)
18
26
  tempfile = new(*args)
19
27
 
@@ -43,14 +51,16 @@ class FSPath < Pathname
43
51
  end.inject(:&).first
44
52
  end
45
53
 
46
- # Returns or yields temp file created by Tempfile.new with path returning FSPath
54
+ # Returns or yields temp file created by Tempfile.new with path returning
55
+ # FSPath
47
56
  def temp_file(*args, &block)
48
57
  args = %w[f] if args.empty?
49
58
  Tempfile.open(self, *args, &block)
50
59
  end
51
60
 
52
61
  # Returns or yields path as FSPath of temp file created by Tempfile.new
53
- # WARNING: loosing reference to returned object will remove file on nearest GC run
62
+ # WARNING: loosing reference to returned object will remove file on nearest
63
+ # GC run
54
64
  def temp_file_path(*args)
55
65
  if block_given?
56
66
  temp_file(*args) do |file|
@@ -126,8 +136,8 @@ class FSPath < Pathname
126
136
  paths = []
127
137
  path = @path
128
138
  paths << self
129
- while r = chop_basename(path)
130
- path, name = r
139
+ while (r = chop_basename(path))
140
+ path = r.first
131
141
  break if path.empty?
132
142
  paths << self.class.new(del_trailing_separator(path))
133
143
  end
@@ -158,7 +168,7 @@ class FSPath < Pathname
158
168
  split_names(@path).flatten
159
169
  end
160
170
 
161
- unless new('a').basename.is_a?(self)
171
+ unless pwd.is_a?(self)
162
172
  # Fixing glob
163
173
  def self.glob(*args)
164
174
  if block_given?
@@ -252,10 +262,11 @@ private
252
262
  end
253
263
  end
254
264
 
265
+ # Add FSPath method as alias to FSPath.new
255
266
  module Kernel
256
267
  # FSPath(path) method
257
- def FSPath(path)
268
+ define_method :FSPath do |path|
258
269
  FSPath.new(path)
259
270
  end
260
- private :Pathname
271
+ private :FSPath
261
272
  end
data/spec/fspath_spec.rb CHANGED
@@ -1,277 +1,277 @@
1
- $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
2
- require 'rspec'
3
1
  require 'fspath'
4
2
 
5
3
  describe FSPath do
6
4
  class ZPath < FSPath
7
5
  end
8
6
 
9
- it "should inherit from Pathname" do
10
- FSPath.new('.').should be_kind_of(Pathname)
7
+ it 'inherits from Pathname' do
8
+ expect(FSPath.new('.')).to be_kind_of(Pathname)
11
9
  end
12
10
 
13
- it "should use shortcut" do
14
- FSPath('.').should === FSPath.new('.')
11
+ it 'uses shortcut' do
12
+ expect(FSPath('.')).to eql(FSPath.new('.'))
15
13
  end
16
14
 
17
- describe "~" do
18
- it "should return current user home directory" do
19
- FSPath.~.should == FSPath(File.expand_path('~'))
15
+ describe '~' do
16
+ it 'returns current user home directory' do
17
+ expect(FSPath.~).to eq(FSPath(File.expand_path('~')))
20
18
  end
21
19
 
22
- it "should return other user home directory" do
23
- FSPath.~('root').should == FSPath(File.expand_path('~root'))
20
+ it 'returns other user home directory' do
21
+ expect(FSPath.~('root')).to eq(FSPath(File.expand_path('~root')))
24
22
  end
25
23
  end
26
24
 
27
- describe "common_dir" do
28
- it "should return dirname if called with one path" do
29
- FSPath.common_dir('/a/b/c').should == FSPath('/a/b')
25
+ describe 'common_dir' do
26
+ it 'returns dirname if called with one path' do
27
+ expect(FSPath.common_dir('/a/b/c')).to eq(FSPath('/a/b'))
30
28
  end
31
29
 
32
- it "should return common path if called with mulpitle paths" do
33
- FSPath.common_dir('/a/b/c/d/e', '/a/b/c/d/f', '/a/b/c/z').should == FSPath('/a/b/c')
30
+ it 'returns common path if called with mulpitle paths' do
31
+ expect(FSPath.common_dir('/a/b/c/d/e', '/a/b/c/d/f', '/a/b/c/z')).
32
+ to eq(FSPath('/a/b/c'))
34
33
  end
35
34
 
36
- it "should return nil if there is no common path" do
37
- FSPath.common_dir('../a', './b').should be_nil
35
+ it 'returns nil if there is no common path' do
36
+ expect(FSPath.common_dir('../a', './b')).to be_nil
38
37
  end
39
38
  end
40
39
 
41
40
  [FSPath, ZPath].each do |klass|
42
41
  describe "#{klass}.temp_file" do
43
- it "should return Tempfile with path returning instance of #{klass}" do
44
- klass.temp_file.should be_kind_of(Tempfile)
45
- klass.temp_file.path.should be_kind_of(klass)
42
+ it "returns Tempfile with path returning instance of #{klass}" do
43
+ expect(klass.temp_file).to be_kind_of(Tempfile)
44
+ expect(klass.temp_file.path).to be_kind_of(klass)
46
45
  end
47
46
 
48
- it "should yield Tempfile with path returning instance of #{klass}" do
47
+ it "yields Tempfile with path returning instance of #{klass}" do
49
48
  yielded = nil
50
49
  klass.temp_file{ |y| yielded = y }
51
- yielded.should be_kind_of(Tempfile)
52
- yielded.path.should be_kind_of(klass)
50
+ expect(yielded).to be_kind_of(Tempfile)
51
+ expect(yielded.path).to be_kind_of(klass)
53
52
  end
54
53
 
55
- it "should return result of block" do
56
- klass.temp_file{ :result }.should == :result
54
+ it 'returns result of block' do
55
+ expect(klass.temp_file{ :result }).to eq(:result)
57
56
  end
58
57
 
59
- it "should call appropriate initializer (jruby 1.8 mode bug)" do
60
- lambda {
58
+ it 'calls appropriate initializer (jruby 1.8 mode bug)' do
59
+ expect do
61
60
  klass.temp_file('abc', '.'){}
62
- }.should_not raise_error
61
+ end.not_to raise_error
63
62
  end
64
63
  end
65
64
 
66
65
  describe "#{klass}.temp_file_path" do
67
- it "should return #{klass} with temporary path" do
68
- klass.temp_file_path.should be_kind_of(klass)
66
+ it "returns #{klass} with temporary path" do
67
+ expect(klass.temp_file_path).to be_kind_of(klass)
69
68
  end
70
69
 
71
- it "should not allow GC to finalize TempFile" do
70
+ it 'does not allow GC to finalize TempFile' do
72
71
  paths = Array.new(1000){ FSPath.temp_file_path }
73
- paths.should be_all(&:exist?)
72
+ expect(paths).to be_all(&:exist?)
74
73
  GC.start
75
- paths.should be_all(&:exist?)
74
+ expect(paths).to be_all(&:exist?)
76
75
  end
77
76
 
78
- it "should yield #{klass} with temporary path" do
77
+ it "yields #{klass} with temporary path" do
79
78
  yielded = nil
80
79
  klass.temp_file_path{ |y| yielded = y }
81
- yielded.should be_kind_of(klass)
80
+ expect(yielded).to be_kind_of(klass)
82
81
  end
83
82
  end
84
83
  end
85
84
 
86
- describe "temp_dir" do
87
- it "should return result of running Dir.mktmpdir as FSPath instance" do
85
+ describe 'temp_dir' do
86
+ it 'returns result of running Dir.mktmpdir as FSPath instance' do
88
87
  @path = '/tmp/a/b/1'
89
- Dir.stub(:mktmpdir).and_return(@path)
88
+ allow(Dir).to receive(:mktmpdir).and_return(@path)
90
89
 
91
- FSPath.temp_dir.should == FSPath('/tmp/a/b/1')
90
+ expect(FSPath.temp_dir).to eq(FSPath('/tmp/a/b/1'))
92
91
  end
93
92
 
94
- it "should yield path yielded by Dir.mktmpdir as FSPath instance" do
93
+ it 'yields path yielded by Dir.mktmpdir as FSPath instance' do
95
94
  @path = '/tmp/a/b/2'
96
- Dir.stub(:mktmpdir).and_yield(@path)
95
+ allow(Dir).to receive(:mktmpdir).and_yield(@path)
97
96
 
98
97
  yielded = nil
99
98
  FSPath.temp_dir{ |y| yielded = y }
100
- yielded.should == FSPath('/tmp/a/b/2')
99
+ expect(yielded).to eq(FSPath('/tmp/a/b/2'))
101
100
  end
102
101
  end
103
102
 
104
- describe "/" do
105
- it "should join path with string" do
106
- (FSPath('a') / 'b').should == FSPath('a/b')
103
+ describe '/' do
104
+ it 'joins path with string' do
105
+ expect(FSPath('a') / 'b').to eq(FSPath('a/b'))
107
106
  end
108
107
 
109
- it "should join path with another FSPath" do
110
- (FSPath('a') / FSPath('b')).should == FSPath('a/b')
108
+ it 'joins path with another FSPath' do
109
+ expect(FSPath('a') / FSPath('b')).to eq(FSPath('a/b'))
111
110
  end
112
111
 
113
- it "should join with path starting with slash" do
114
- (FSPath('a') / '/b').should == FSPath('a/b')
112
+ it 'joins with path starting with slash' do
113
+ expect(FSPath('a') / '/b').to eq(FSPath('a/b'))
115
114
  end
116
115
  end
117
116
 
118
- describe "+" do
119
- it "should return instance of FSPath" do
120
- (FSPath('a') + 'b').should be_instance_of(FSPath)
117
+ describe '+' do
118
+ it 'returns instance of FSPath' do
119
+ expect(FSPath('a') + 'b').to be_instance_of(FSPath)
121
120
  end
122
121
 
123
- it "should join simple paths" do
124
- (FSPath('a') + 'b').should == FSPath('a/b')
122
+ it 'joins simple paths' do
123
+ expect(FSPath('a') + 'b').to eq(FSPath('a/b'))
125
124
  end
126
125
 
127
- it "should join path starting with slash" do
128
- (FSPath('a') + '/b').should == FSPath('/b')
126
+ it 'joins path starting with slash' do
127
+ expect(FSPath('a') + '/b').to eq(FSPath('/b'))
129
128
  end
130
129
  end
131
130
 
132
- describe "relative_path_from" do
133
- it "should return instance of FSPath" do
134
- (FSPath('a').relative_path_from('b')).should be_instance_of(FSPath)
131
+ describe 'relative_path_from' do
132
+ it 'returns instance of FSPath' do
133
+ expect(FSPath('a').relative_path_from('b')).to be_instance_of(FSPath)
135
134
  end
136
135
 
137
- it "should return relative path" do
138
- (FSPath('b/a').relative_path_from('b')).should == FSPath('a')
136
+ it 'returns relative path' do
137
+ expect(FSPath('b/a').relative_path_from('b')).to eq(FSPath('a'))
139
138
  end
140
139
  end
141
140
 
142
- describe "writing" do
141
+ describe 'writing' do
143
142
  before do
144
143
  @path = FSPath.new('test')
145
144
  @file = double(:file)
146
145
  @data = double(:data)
147
146
  @size = double(:size)
148
147
 
149
- @path.stub(:open).and_yield(@file)
150
- @file.stub(:write).and_return(@size)
148
+ allow(@path).to receive(:open).and_yield(@file)
149
+ allow(@file).to receive(:write).and_return(@size)
151
150
  end
152
151
 
153
- describe "write" do
154
- it "should open file for writing" do
155
- @path.should_receive(:open).with('wb')
152
+ describe 'write' do
153
+ it 'opens file for writing' do
154
+ expect(@path).to receive(:open).with('wb')
156
155
  @path.write(@data)
157
156
  end
158
157
 
159
- it "should write data" do
160
- @file.should_receive(:write).with(@data)
158
+ it 'writes data' do
159
+ expect(@file).to receive(:write).with(@data)
161
160
  @path.write(@data)
162
161
  end
163
162
 
164
- it "should return result of write" do
165
- @path.write(@data).should == @size
163
+ it 'returns result of write' do
164
+ expect(@path.write(@data)).to eq(@size)
166
165
  end
167
166
  end
168
167
 
169
- describe "append" do
170
- it "should open file for writing" do
171
- @path.should_receive(:open).with('ab')
168
+ describe 'append' do
169
+ it 'opens file for writing' do
170
+ expect(@path).to receive(:open).with('ab')
172
171
  @path.append(@data)
173
172
  end
174
173
 
175
- it "should write data" do
176
- @file.should_receive(:write).with(@data)
174
+ it 'writes data' do
175
+ expect(@file).to receive(:write).with(@data)
177
176
  @path.append(@data)
178
177
  end
179
178
 
180
- it "should return result of write" do
181
- @path.append(@data).should == @size
179
+ it 'returns result of write' do
180
+ expect(@path.append(@data)).to eq(@size)
182
181
  end
183
182
  end
184
183
  end
185
184
 
186
- describe "escape_glob" do
187
- it "should escape glob pattern characters" do
188
- FSPath('*/**/?[a-z]{abc,def}').escape_glob.should == FSPath('\*/\*\*/\?\[a-z\]\{abc,def\}')
185
+ describe 'escape_glob' do
186
+ it 'escapes glob pattern characters' do
187
+ expect(FSPath('*/**/?[a-z]{abc,def}').escape_glob).
188
+ to eq(FSPath('\*/\*\*/\?\[a-z\]\{abc,def\}'))
189
189
  end
190
190
  end
191
191
 
192
- describe "glob" do
193
- it "should join with arguments and expand glob" do
194
- FSPath.should_receive(:glob).with('a/b/c/**/*')
192
+ describe 'glob' do
193
+ it 'joins with arguments and expands glob' do
194
+ expect(FSPath).to receive(:glob).with('a/b/c/**/*')
195
195
  FSPath('a/b/c').glob('**', '*')
196
196
  end
197
197
 
198
- it "should join with arguments and expand glob" do
199
- @flags = 12345
200
- FSPath.should_receive(:glob).with('a/b/c/**/*', @flags)
198
+ it 'joins with arguments and expands glob' do
199
+ @flags = 12_345
200
+ expect(FSPath).to receive(:glob).with('a/b/c/**/*', @flags)
201
201
  FSPath('a/b/c').glob('**', '*', @flags)
202
202
  end
203
203
 
204
- it "should escape glob characters in path itself" do
205
- FSPath.should_receive(:glob).with('somewhere \[a b c\]/**/*')
204
+ it 'escapes glob characters in path itself' do
205
+ expect(FSPath).to receive(:glob).with('somewhere \[a b c\]/**/*')
206
206
  FSPath('somewhere [a b c]').glob('**', '*')
207
207
  end
208
208
  end
209
209
 
210
- describe "path parts" do
211
- describe "ascending" do
210
+ describe 'path parts' do
211
+ describe 'ascending' do
212
212
  before do
213
213
  @path = FSPath('/a/b/c')
214
214
  @ascendants = %w[/a/b/c /a/b /a /].map(&method(:FSPath))
215
215
  end
216
216
 
217
- describe "ascendants" do
218
- it "should return list of ascendants" do
219
- @path.ascendants.should == @ascendants
217
+ describe 'ascendants' do
218
+ it 'returns list of ascendants' do
219
+ expect(@path.ascendants).to eq(@ascendants)
220
220
  end
221
221
  end
222
222
 
223
- describe "ascend" do
224
- it "should return list of ascendants" do
225
- @path.ascend.should == @ascendants
223
+ describe 'ascend' do
224
+ it 'returns list of ascendants' do
225
+ expect(@path.ascend).to eq(@ascendants)
226
226
  end
227
227
 
228
- it "should yield and return list of ascendants if called with block" do
228
+ it 'yields and returns list of ascendants if called with block' do
229
229
  ascendants = []
230
- @path.ascend do |path|
230
+ expect(@path.ascend do |path|
231
231
  ascendants << path
232
- end.should == @ascendants
233
- ascendants.should == @ascendants
232
+ end).to eq(@ascendants)
233
+ expect(ascendants).to eq(@ascendants)
234
234
  end
235
235
  end
236
236
  end
237
237
 
238
- describe "descending" do
238
+ describe 'descending' do
239
239
  before do
240
240
  @path = FSPath('/a/b/c')
241
241
  @descendants = %w[/ /a /a/b /a/b/c].map(&method(:FSPath))
242
242
  end
243
243
 
244
- describe "descendants" do
245
- it "should return list of descendants" do
246
- @path.descendants.should == @descendants
244
+ describe 'descendants' do
245
+ it 'returns list of descendants' do
246
+ expect(@path.descendants).to eq(@descendants)
247
247
  end
248
248
  end
249
249
 
250
- describe "descend" do
251
- it "should return list of descendants" do
252
- @path.descend.should == @descendants
250
+ describe 'descend' do
251
+ it 'returns list of descendants' do
252
+ expect(@path.descend).to eq(@descendants)
253
253
  end
254
254
 
255
- it "should yield and return list of descendants if called with block" do
255
+ it 'yields and returns list of descendants if called with block' do
256
256
  descendants = []
257
- @path.descend do |path|
257
+ expect(@path.descend do |path|
258
258
  descendants << path
259
- end.should == @descendants
260
- descendants.should == @descendants
259
+ end).to eq(@descendants)
260
+ expect(descendants).to eq(@descendants)
261
261
  end
262
262
  end
263
263
  end
264
264
 
265
- describe "parts" do
266
- it "should return path parts as strings" do
267
- FSPath('/a/b/c').parts.should == %w[/ a b c]
265
+ describe 'parts' do
266
+ it 'returns path parts as strings' do
267
+ expect(FSPath('/a/b/c').parts).to eq(%w[/ a b c])
268
268
  end
269
269
  end
270
270
  end
271
271
 
272
- describe "returning/yield instances of FSPath" do
272
+ describe 'returning/yielding instances' do
273
273
  def fspath?(path)
274
- path.should be_instance_of(FSPath)
274
+ expect(path).to be_instance_of(FSPath)
275
275
  end
276
276
 
277
277
  def fspaths?(paths)
@@ -280,7 +280,7 @@ describe FSPath do
280
280
  end
281
281
  end
282
282
 
283
- it "should for glob" do
283
+ it 'uses FSPath for glob' do
284
284
  fspaths? FSPath(__FILE__).glob
285
285
 
286
286
  FSPath(__FILE__).glob do |path|
@@ -288,56 +288,56 @@ describe FSPath do
288
288
  end
289
289
  end
290
290
 
291
- it "should for pwd" do
291
+ it 'uses FSPath for pwd' do
292
292
  fspath? FSPath.pwd
293
293
  end
294
294
 
295
- it "should for getwd" do
295
+ it 'uses FSPath for getwd' do
296
296
  fspath? FSPath.getwd
297
297
  end
298
298
 
299
- it "should for basename" do
299
+ it 'uses FSPath for basename' do
300
300
  fspath? FSPath('a/b').basename
301
301
  end
302
302
 
303
- it "should for dirname" do
303
+ it 'uses FSPath for dirname' do
304
304
  fspath? FSPath('a/b').dirname
305
305
  end
306
306
 
307
- it "should for parent" do
307
+ it 'uses FSPath for parent' do
308
308
  fspath? FSPath('a/b').parent
309
309
  end
310
310
 
311
- it "should for cleanpath" do
311
+ it 'uses FSPath for cleanpath' do
312
312
  fspath? FSPath('a/b').cleanpath
313
313
  end
314
314
 
315
- it "should for expand_path" do
315
+ it 'uses FSPath for expand_path' do
316
316
  fspath? FSPath('a/b').expand_path
317
317
  end
318
318
 
319
- it "should for relative_path_from" do
319
+ it 'uses FSPath for relative_path_from' do
320
320
  fspath? FSPath('a').relative_path_from('b')
321
321
  end
322
322
 
323
- it "should for join" do
323
+ it 'uses FSPath for join' do
324
324
  fspath? FSPath('a').join('b', 'c')
325
325
  end
326
326
 
327
- it "should for split" do
327
+ it 'uses FSPath for split' do
328
328
  fspaths? FSPath('a/b').split
329
329
  end
330
330
 
331
- it "should for sub" do
331
+ it 'uses FSPath for sub' do
332
332
  fspath? FSPath('a/b').sub('a', 'c')
333
333
  fspath? FSPath('a/b').sub('a'){ 'c' }
334
334
  end
335
335
 
336
- it "should for sub_ext" do
336
+ it 'uses FSPath for sub_ext' do
337
337
  fspath? FSPath('a/b').sub_ext('.rb')
338
338
  end if FSPath.method_defined?(:sub_ext)
339
339
 
340
- it "should for readlink" do
340
+ it 'uses FSPath for readlink' do
341
341
  FSPath.temp_dir do |dir|
342
342
  symlink = dir + 'sym'
343
343
  symlink.make_symlink __FILE__
@@ -345,51 +345,51 @@ describe FSPath do
345
345
  end
346
346
  end
347
347
 
348
- it "should for realdirpath" do
348
+ it 'uses FSPath for realdirpath' do
349
349
  fspath? FSPath(__FILE__).realdirpath
350
350
  end if FSPath.method_defined?(:realdirpath)
351
351
 
352
- it "should for realpath" do
352
+ it 'uses FSPath for realpath' do
353
353
  fspath? FSPath(__FILE__).realpath
354
354
  end
355
355
 
356
- it "should for children" do
356
+ it 'uses FSPath for children' do
357
357
  fspaths? FSPath('.').children
358
358
  end
359
359
 
360
- it "should for dir_foreach" do
360
+ it 'uses FSPath for dir_foreach' do
361
361
  dir = FSPath('.')
362
- dir.stub(:warn)
362
+ allow(dir).to receive(:warn)
363
363
  dir.dir_foreach do |entry|
364
364
  fspath? entry
365
365
  end
366
366
  end if FSPath.method_defined?(:dir_foreach)
367
367
 
368
- it "should for each_child" do
368
+ it 'uses FSPath for each_child' do
369
369
  fspaths? FSPath('.').each_child
370
370
  fspaths? FSPath('.').each_child do |child|
371
371
  fspath? child
372
372
  end
373
373
  end if FSPath.method_defined?(:each_child)
374
374
 
375
- it "should for each_entry" do
375
+ it 'uses FSPath for each_entry' do
376
376
  FSPath('.').each_entry do |entry|
377
377
  fspath? entry
378
378
  end
379
379
  end
380
380
 
381
- it "should for entries" do
381
+ it 'uses FSPath for entries' do
382
382
  fspaths? FSPath('.').entries
383
383
  end
384
384
 
385
- it "should for find" do
385
+ it 'uses FSPath for find' do
386
386
  FSPath('.').find do |path|
387
387
  fspath? path
388
388
  end
389
389
  end
390
390
 
391
- it "should for inspect" do
392
- FSPath('a').inspect.should include('FSPath')
391
+ it 'uses FSPath for inspect' do
392
+ expect(FSPath('a').inspect).to include('FSPath')
393
393
  end
394
394
  end
395
395
  end
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fspath
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Kuchin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-08 00:00:00.000000000 Z
11
+ date: 2014-12-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '3.0'
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
- version: '0'
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '0.28'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '0.28'
27
41
  description:
28
42
  email:
29
43
  executables: []
@@ -31,6 +45,7 @@ extensions: []
31
45
  extra_rdoc_files: []
32
46
  files:
33
47
  - .gitignore
48
+ - .rubocop.yml
34
49
  - .travis.yml
35
50
  - Gemfile
36
51
  - LICENSE.txt
@@ -58,9 +73,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
73
  version: '0'
59
74
  requirements: []
60
75
  rubyforge_project: fspath
61
- rubygems_version: 2.0.3
76
+ rubygems_version: 2.4.5
62
77
  signing_key:
63
78
  specification_version: 4
64
79
  summary: Better than Pathname
65
80
  test_files:
66
81
  - spec/fspath_spec.rb
82
+ has_rdoc: