Sha256: 7b47468c9b0c830dc0ca98259a07525d3ba5a2466ff78e847fe0e6b9b598722a

Contents?: true

Size: 1.98 KB

Versions: 4

Compression:

Stored size: 1.98 KB

Contents

# Pathname

Pathname represents the name of a file or directory on the filesystem,
but not the file itself.

The pathname depends on the Operating System: Unix, Windows, etc.
This library works with pathnames of local OS, however non-Unix pathnames
are supported experimentally.

A Pathname can be relative or absolute.  It's not until you try to
reference the file that it even matters whether the file exists or not.

Pathname is immutable.  It has no method for destructive update.

The goal of this class is to manipulate file path information in a neater
way than standard Ruby provides.  The examples below demonstrate the
difference.

*All* functionality from File, FileTest, and some from Dir and FileUtils is
included, in an unsurprising way.  It is essentially a facade for all of
these, and more.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'pathname'
```

And then execute:

    $ bundle install

Or install it yourself as:

    $ gem install pathname

## Usage

```ruby
require 'pathname'
pn = Pathname.new("/usr/bin/ruby")
size = pn.size              # 27662
isdir = pn.directory?       # false
dir  = pn.dirname           # Pathname:/usr/bin
base = pn.basename          # Pathname:ruby
dir, base = pn.split        # [Pathname:/usr/bin, Pathname:ruby]
data = pn.read
pn.open { |f| _ }
pn.each_line { |line| _ }
```

## Development

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.

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).

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/pathname.

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pathname-0.4.0 README.md
pathname-0.3.0 README.md
pathname-0.2.1 README.md
pathname-0.2.0 README.md