pathname 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +10 -8
- data/.gitignore +3 -0
- data/Gemfile +1 -0
- data/README.md +32 -6
- data/Rakefile +8 -0
- data/ext/pathname/pathname.c +7 -3
- data/{ext/pathname/lib → lib}/pathname.rb +4 -4
- data/pathname.gemspec +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f86bba6b469155aa1c26eb4e655f532d4a550429e36fab4b82eb4f3cb8f98b2
|
4
|
+
data.tar.gz: 475bb6d8318541b384a1496b9c4aa3b640bd974145fff206b5cfb5b2bee5f1f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 268cbeca3ea44caea9c811b3e9ae12b63b294993c4af419be43e70f1ba599af7391ffa02fd25377f4cd254e2879075cef96fa4dc6776aab36c37ab1d9defaeed
|
7
|
+
data.tar.gz: c7ded65024e264c8c2fcad21879a0af24dba969d5d94d91015c8d6922aa303e3727babf6eb1425a50d45f6a363b7784da7162d7454c48a34f5a477fc319041f0
|
data/.github/workflows/test.yml
CHANGED
@@ -7,18 +7,20 @@ jobs:
|
|
7
7
|
name: build (${{ matrix.ruby }} / ${{ matrix.os }})
|
8
8
|
strategy:
|
9
9
|
matrix:
|
10
|
-
ruby: [
|
11
|
-
os: [ ubuntu-latest, macos-latest ]
|
10
|
+
ruby: [ '3.0', head ]
|
11
|
+
os: [ ubuntu-latest, macos-latest, windows-latest ]
|
12
|
+
exclude:
|
13
|
+
- { os: windows-latest , ruby: head }
|
14
|
+
include:
|
15
|
+
- { os: windows-latest , ruby: mingw }
|
16
|
+
- { os: windows-latest , ruby: mswin }
|
12
17
|
runs-on: ${{ matrix.os }}
|
13
18
|
steps:
|
14
|
-
- uses: actions/checkout@
|
19
|
+
- uses: actions/checkout@v2
|
15
20
|
- name: Set up Ruby
|
16
21
|
uses: ruby/setup-ruby@v1
|
17
22
|
with:
|
18
23
|
ruby-version: ${{ matrix.ruby }}
|
19
|
-
|
20
|
-
run: |
|
21
|
-
gem install bundler --no-document
|
22
|
-
bundle install
|
24
|
+
bundler-cache: true # 'bundle install' and cache
|
23
25
|
- name: Run test
|
24
|
-
run: rake compile test
|
26
|
+
run: bundle exec rake compile test
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,24 @@
|
|
1
1
|
# Pathname
|
2
2
|
|
3
|
-
|
3
|
+
Pathname represents the name of a file or directory on the filesystem,
|
4
|
+
but not the file itself.
|
4
5
|
|
5
|
-
|
6
|
+
The pathname depends on the Operating System: Unix, Windows, etc.
|
7
|
+
This library works with pathnames of local OS, however non-Unix pathnames
|
8
|
+
are supported experimentally.
|
9
|
+
|
10
|
+
A Pathname can be relative or absolute. It's not until you try to
|
11
|
+
reference the file that it even matters whether the file exists or not.
|
12
|
+
|
13
|
+
Pathname is immutable. It has no method for destructive update.
|
14
|
+
|
15
|
+
The goal of this class is to manipulate file path information in a neater
|
16
|
+
way than standard Ruby provides. The examples below demonstrate the
|
17
|
+
difference.
|
18
|
+
|
19
|
+
*All* functionality from File, FileTest, and some from Dir and FileUtils is
|
20
|
+
included, in an unsurprising way. It is essentially a facade for all of
|
21
|
+
these, and more.
|
6
22
|
|
7
23
|
## Installation
|
8
24
|
|
@@ -22,15 +38,25 @@ Or install it yourself as:
|
|
22
38
|
|
23
39
|
## Usage
|
24
40
|
|
25
|
-
|
41
|
+
```ruby
|
42
|
+
require 'pathname'
|
43
|
+
pn = Pathname.new("/usr/bin/ruby")
|
44
|
+
size = pn.size # 27662
|
45
|
+
isdir = pn.directory? # false
|
46
|
+
dir = pn.dirname # Pathname:/usr/bin
|
47
|
+
base = pn.basename # Pathname:ruby
|
48
|
+
dir, base = pn.split # [Pathname:/usr/bin, Pathname:ruby]
|
49
|
+
data = pn.read
|
50
|
+
pn.open { |f| _ }
|
51
|
+
pn.each_line { |line| _ }
|
52
|
+
```
|
26
53
|
|
27
54
|
## Development
|
28
55
|
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake
|
56
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake` to compile this and run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
57
|
|
31
58
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
59
|
|
33
60
|
## Contributing
|
34
61
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
36
|
-
|
62
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/pathname.
|
data/Rakefile
CHANGED
@@ -3,9 +3,17 @@ require "rake/testtask"
|
|
3
3
|
|
4
4
|
Rake::TestTask.new(:test) do |t|
|
5
5
|
t.libs << "test/lib"
|
6
|
+
t.ruby_opts << "-rhelper"
|
6
7
|
t.test_files = FileList["test/**/test_*.rb"]
|
7
8
|
end
|
8
9
|
|
10
|
+
task :sync_tool do
|
11
|
+
require 'fileutils'
|
12
|
+
FileUtils.cp "../ruby/tool/lib/core_assertions.rb", "./test/lib"
|
13
|
+
FileUtils.cp "../ruby/tool/lib/envutil.rb", "./test/lib"
|
14
|
+
FileUtils.cp "../ruby/tool/lib/find_executable.rb", "./test/lib"
|
15
|
+
end
|
16
|
+
|
9
17
|
require 'rake/extensiontask'
|
10
18
|
Rake::ExtensionTask.new("pathname")
|
11
19
|
|
data/ext/pathname/pathname.c
CHANGED
@@ -360,10 +360,10 @@ path_each_line(int argc, VALUE *argv, VALUE self)
|
|
360
360
|
args[0] = get_strpath(self);
|
361
361
|
n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
|
362
362
|
if (rb_block_given_p()) {
|
363
|
-
return
|
363
|
+
return rb_block_call_kw(rb_cFile, id_foreach, 1+n, args, 0, 0, RB_PASS_CALLED_KEYWORDS);
|
364
364
|
}
|
365
365
|
else {
|
366
|
-
return
|
366
|
+
return rb_funcallv_kw(rb_cFile, id_foreach, 1+n, args, RB_PASS_CALLED_KEYWORDS);
|
367
367
|
}
|
368
368
|
}
|
369
369
|
|
@@ -834,7 +834,7 @@ path_split(VALUE self)
|
|
834
834
|
VALUE str = get_strpath(self);
|
835
835
|
VALUE ary, dirname, basename;
|
836
836
|
ary = rb_funcall(rb_cFile, id_split, 1, str);
|
837
|
-
ary
|
837
|
+
Check_Type(ary, T_ARRAY);
|
838
838
|
dirname = rb_ary_entry(ary, 0);
|
839
839
|
basename = rb_ary_entry(ary, 1);
|
840
840
|
dirname = rb_class_new_instance(1, &dirname, rb_obj_class(self));
|
@@ -1512,6 +1512,10 @@ path_f_pathname(VALUE self, VALUE str)
|
|
1512
1512
|
void
|
1513
1513
|
Init_pathname(void)
|
1514
1514
|
{
|
1515
|
+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
|
1516
|
+
rb_ext_ractor_safe(true);
|
1517
|
+
#endif
|
1518
|
+
|
1515
1519
|
InitVM(pathname);
|
1516
1520
|
|
1517
1521
|
rb_cPathname = rb_define_class("Pathname", rb_cObject);
|
@@ -575,13 +575,14 @@ end
|
|
575
575
|
|
576
576
|
|
577
577
|
class Pathname # * FileUtils *
|
578
|
+
autoload(:FileUtils, 'fileutils')
|
579
|
+
|
578
580
|
# Creates a full path, including any intermediate directories that don't yet
|
579
581
|
# exist.
|
580
582
|
#
|
581
583
|
# See FileUtils.mkpath and FileUtils.mkdir_p
|
582
|
-
def mkpath
|
583
|
-
|
584
|
-
FileUtils.mkpath(@path)
|
584
|
+
def mkpath(mode: nil)
|
585
|
+
FileUtils.mkpath(@path, mode: mode)
|
585
586
|
nil
|
586
587
|
end
|
587
588
|
|
@@ -591,7 +592,6 @@ class Pathname # * FileUtils *
|
|
591
592
|
def rmtree
|
592
593
|
# The name "rmtree" is borrowed from File::Path of Perl.
|
593
594
|
# File::Path provides "mkpath" and "rmtree".
|
594
|
-
require 'fileutils'
|
595
595
|
FileUtils.rm_r(@path)
|
596
596
|
nil
|
597
597
|
end
|
data/pathname.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "pathname"
|
3
|
-
spec.version = "0.
|
3
|
+
spec.version = "0.2.0"
|
4
4
|
spec.authors = ["Tanaka Akira"]
|
5
5
|
spec.email = ["akr@fsij.org"]
|
6
6
|
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
20
|
end
|
21
21
|
spec.bindir = "exe"
|
22
|
-
spec.executables =
|
22
|
+
spec.executables = []
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
spec.extensions = %w[ext/pathname/extconf.rb]
|
25
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pathname
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tanaka Akira
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Representation of the name of a file or directory on the filesystem
|
14
14
|
email:
|
@@ -27,8 +27,8 @@ files:
|
|
27
27
|
- bin/console
|
28
28
|
- bin/setup
|
29
29
|
- ext/pathname/extconf.rb
|
30
|
-
- ext/pathname/lib/pathname.rb
|
31
30
|
- ext/pathname/pathname.c
|
31
|
+
- lib/pathname.rb
|
32
32
|
- pathname.gemspec
|
33
33
|
homepage: https://github.com/ruby/pathname
|
34
34
|
licenses:
|
@@ -52,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '0'
|
54
54
|
requirements: []
|
55
|
-
rubygems_version: 3.2.
|
55
|
+
rubygems_version: 3.2.22
|
56
56
|
signing_key:
|
57
57
|
specification_version: 4
|
58
58
|
summary: Representation of the name of a file or directory on the filesystem
|