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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c42dd90f7949c457dd8225ff9f04ab3919a972ec4c4f41781784ee22e3957c47
4
- data.tar.gz: 67971cc891a87efcadb29c62dea3bf429d74c5261711a83b8ccd45bbb2322028
3
+ metadata.gz: 7f86bba6b469155aa1c26eb4e655f532d4a550429e36fab4b82eb4f3cb8f98b2
4
+ data.tar.gz: 475bb6d8318541b384a1496b9c4aa3b640bd974145fff206b5cfb5b2bee5f1f5
5
5
  SHA512:
6
- metadata.gz: 0bc313f05de84a963277fb5814202b52c73dec674b195944f4255f80fc35b72a9dd00baea026826438524393baac08da00a723dcdc1fcf24bb49dff24a323be2
7
- data.tar.gz: 1f4f1ec1ca815d7e857929ba474378d80b6e36ce5071fac4b3c1c12799a5a38eb951fc68361395274957c02ee67864dca30b8a2310d4521b65c51d97354b4788
6
+ metadata.gz: 268cbeca3ea44caea9c811b3e9ae12b63b294993c4af419be43e70f1ba599af7391ffa02fd25377f4cd254e2879075cef96fa4dc6776aab36c37ab1d9defaeed
7
+ data.tar.gz: c7ded65024e264c8c2fcad21879a0af24dba969d5d94d91015c8d6922aa303e3727babf6eb1425a50d45f6a363b7784da7162d7454c48a34f5a477fc319041f0
@@ -7,18 +7,20 @@ jobs:
7
7
  name: build (${{ matrix.ruby }} / ${{ matrix.os }})
8
8
  strategy:
9
9
  matrix:
10
- ruby: [ 2.7, 2.6, 2.5, head ]
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@master
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
- - name: Install dependencies
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
@@ -6,3 +6,6 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ Gemfile.lock
10
+ *.bundle
11
+ *.so
data/Gemfile CHANGED
@@ -4,3 +4,4 @@ gemspec
4
4
 
5
5
  gem "rake"
6
6
  gem "rake-compiler"
7
+ gem "test-unit"
data/README.md CHANGED
@@ -1,8 +1,24 @@
1
1
  # Pathname
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/pathname`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Pathname represents the name of a file or directory on the filesystem,
4
+ but not the file itself.
4
5
 
5
- TODO: Delete this and the text above, and describe your gem
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
- TODO: Write usage instructions here
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 test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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/hsbpathname.
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
 
@@ -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 rb_block_call(rb_cFile, id_foreach, 1+n, args, 0, 0);
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 rb_funcallv(rb_cFile, id_foreach, 1+n, args);
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 = rb_check_array_type(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
- require 'fileutils'
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.1.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 = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
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.1.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: 2020-12-03 00:00:00.000000000 Z
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.0.rc.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