path 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: dc79568913620a232363ac1c8337e5b163a1a910
4
- data.tar.gz: 3b1e928062bba5999f0ffd1afd6ac8895b7838a0
2
+ SHA256:
3
+ metadata.gz: efcdf8c91dddaf7c18d7d833a664da77428c72f354bc73fbc89d9fb1d2fe4eb8
4
+ data.tar.gz: 9e1dea71086a4eb45b6aac1ad91c417432820985a2cdd222e77f1dc458fee1d7
5
5
  SHA512:
6
- metadata.gz: 81762a43a917e1b34e483753bdb72bfe5256a4eb777c07f32a5ae108b166ef67da09bef20af735b4c3e3154bdb606fffd7cc5134c99e9e474d4bb1d5ed99927e
7
- data.tar.gz: 8456c2c9eda72afbe858e5a22cf6648297acd75a3101d5b5abc7a4d4a117dcae2e86b807f0ec585367295a2b2354f4ce3272917ef6e0a7c16d3f9ce7d7530b0f
6
+ metadata.gz: 40610513248438fbc3038167c1aaff927d725107d2cfcdaf87d6d38036c9cc2fe432ce4e658fcefdd367cb42e3f467ded88cc81be273f73e53fe8dd2e13336e5
7
+ data.tar.gz: e09e515fbdf68768d9a39ac4e68d6665095f7216784d5ebbfa5e5b2261b904fd09d6d7eb010a54b398d825d0ccd224066c63aca6bf29919bedc2c2652e840417
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # Path - a Path manipulation library
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/path.png)](https://rubygems.org/gems/path)
4
- [![Build Status](https://travis-ci.org/eregon/path.svg?branch=master)](https://travis-ci.org/eregon/path)
5
- [![Build Status](https://ci.appveyor.com/api/projects/status/jg6fx1692mw8mu58/branch/master?svg=true)](https://ci.appveyor.com/project/eregon/path/branch/master)
3
+ [![Gem Version](https://badge.fury.io/rb/path.svg)](https://rubygems.org/gems/path)
4
+ [![CI](https://github.com/eregon/path/actions/workflows/ci.yml/badge.svg)](https://github.com/eregon/path/actions/workflows/ci.yml)
6
5
 
7
6
  [Path](http://rubydoc.info/github/eregon/path/master/Path) is a library to manage paths.
8
7
  It is similar to Pathname, but has some extra goodness.
@@ -167,6 +166,17 @@ which will show where `+` is used as String concatenation.
167
166
  Coming from a path library using `+` as #join, one should just use the default (`Path.configure(:+ => :warning)`),
168
167
  which will show where `+` is used.
169
168
 
169
+ ## Migration from path 1.x
170
+
171
+ A couple methods changed since 1.x, all mentioned in the [ChangeLog](Changelog.md).
172
+
173
+ One of the easiest way is to grep for the changed methods.
174
+ Here is a list of each with a direct replacement.
175
+
176
+ * Path.here => Path.file
177
+ * Path#base => Path#stem
178
+ * Path#ext => Path#pure_ext (it now returns a leading dot)
179
+
170
180
  ## Status
171
181
 
172
182
  This is still in the early development stage, you should expect many additions and some changes.
data/lib/path/dir.rb CHANGED
@@ -96,7 +96,8 @@ class Path
96
96
  end
97
97
 
98
98
  # Returns the children of the directory (files and subdirectories, not
99
- # recursive) as an array of Path objects. By default, the returned
99
+ # recursive) as an array of Path objects. The children paths are always
100
+ # sorted to ensure a deterministic order. By default, the returned
100
101
  # paths will have enough information to access the files. If you set
101
102
  # +with_directory+ to +false+, then the returned paths will contain the
102
103
  # filename only.
@@ -123,10 +124,12 @@ class Path
123
124
  result << Path.new(e)
124
125
  end
125
126
  }
127
+ result.sort!
126
128
  result
127
129
  end
128
130
 
129
131
  # Iterates over the children of the directory (files and subdirectories, not recursive).
132
+ # The children paths are always sorted to ensure a deterministic order.
130
133
  # By default, the yielded paths will have enough information to access the files.
131
134
  # If you set +with_directory+ to +false+, then the returned paths will contain the filename only.
132
135
  #
@@ -158,6 +161,7 @@ class Path
158
161
  # Equivalent of +parent.children - [self]+.
159
162
  # Returns the siblings, the files in the same directory as the current +path+.
160
163
  # Returns only the root if +path+ is the root.
164
+ # The sibling paths are always sorted to ensure a deterministic order.
161
165
  def siblings(with_directory = true)
162
166
  if root?
163
167
  [self]
@@ -80,8 +80,8 @@ class Path
80
80
  # Install +file+ into +path+ (the "prefix", which should be a directory).
81
81
  # If +file+ is not same as +path/file+, replaces it.
82
82
  # See +FileUtils.install+ (arguments are swapped).
83
- def install(file, options = {})
84
- FileUtils.install(file, @path, options)
83
+ def install(file, **options)
84
+ FileUtils.install(file, @path, **options)
85
85
  end
86
86
 
87
87
  # Recusively changes permissions. See +FileUtils.chmod_R+ and +File.chmod+.
data/lib/path/identity.rb CHANGED
@@ -80,9 +80,11 @@ class Path
80
80
  # Returns the +path+ as a String.
81
81
  # {#path} is implemented for better readability (+file.path+ instead of +file.to_s+) and as an accessor.
82
82
  # {#to_path} is implemented so Path objects are usable with +open+, etc.
83
+ # {#to_str} is implemented so Path objects are usable with +open+, etc with Ruby 1.8 (it is not defined in Ruby 1.9).
83
84
  attr_reader :path
84
85
  alias :to_s :path
85
86
  alias :to_path :path
87
+ alias :to_str :path if RUBY_VERSION < '1.9'
86
88
 
87
89
  # Compare this path with +other+. The comparison is string-based.
88
90
  # Be aware that two different paths (+foo.txt+ and +./foo.txt+)
@@ -133,7 +133,6 @@ class Path
133
133
  def init
134
134
  @path = validate(@path)
135
135
 
136
- taint if @path.tainted?
137
136
  @path.freeze
138
137
  freeze
139
138
  end
data/lib/path/io.rb CHANGED
@@ -64,11 +64,11 @@ class Path
64
64
  end
65
65
  end
66
66
 
67
- if IO.respond_to? :write and !RUBY_DESCRIPTION.start_with?('jruby')
67
+ if IO.respond_to? :write and RUBY_ENGINE != 'jruby'
68
68
  # Appends +contents+ to +self+. See +IO.write+ or +IO#write+.
69
- def append(contents, open_args = {})
69
+ def append(contents, **open_args)
70
70
  open_args[:mode] = 'a'
71
- IO.write(@path, contents, open_args)
71
+ IO.write(@path, contents, **open_args)
72
72
  end
73
73
  else
74
74
  def append(contents, *open_args)
@@ -30,4 +30,9 @@ class Path
30
30
  false
31
31
  end
32
32
  end
33
+
34
+ # Whether this is a hidden path, i.e. starting with a dot.
35
+ def hidden?
36
+ basename.to_s.start_with?('.')
37
+ end
33
38
  end
data/lib/path/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class Path
2
2
  # The version of the gem.
3
3
  # Set here to avoid duplication and allow introspection.
4
- VERSION = '2.0.0'
4
+ VERSION = '2.1.0'
5
5
  end
data/path.gemspec CHANGED
@@ -10,4 +10,5 @@ Gem::Specification.new do |s|
10
10
  s.files = Dir['lib/**/*.rb'] + %w[README.md LICENSE path.gemspec]
11
11
  s.licenses = ['MIT']
12
12
  s.version = Path::VERSION
13
+ s.required_ruby_version = '>= 2.6.0'
13
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: path
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - eregon
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-13 00:00:00.000000000 Z
11
+ date: 2023-04-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Path is a library to easily manage paths and with a lot of extra goodness.
14
14
  email: eregontp@gmail.com
@@ -38,7 +38,7 @@ homepage: https://github.com/eregon/path
38
38
  licenses:
39
39
  - MIT
40
40
  metadata: {}
41
- post_install_message:
41
+ post_install_message:
42
42
  rdoc_options: []
43
43
  require_paths:
44
44
  - lib
@@ -46,17 +46,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: '0'
49
+ version: 2.6.0
50
50
  required_rubygems_version: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  requirements: []
56
- rubyforge_project:
57
- rubygems_version: 2.5.1
58
- signing_key:
56
+ rubygems_version: 3.3.26
57
+ signing_key:
59
58
  specification_version: 4
60
59
  summary: The Path manipulation library
61
60
  test_files: []
62
- has_rdoc: