Giter VIP home page Giter VIP logo

fspath's Introduction

Gem Version Build Status Rubocop Code Climate Depfu Inch CI

fspath

Better than Pathname

Check out fspath-mac and fspath-xattr.

Synopsis

User dir:

FSPath.~

Other user dir:

FSPath.~('other')

Common dir for paths:

FSPath.common_dir('/a/b/c/d/e/f', '/a/b/c/1/hello', '/a/b/c/2/world') # => FSPath('/a/b/c')

Temp file (args are passed to Tempfile.new):

FSPath.temp_file{ |f| …; p f.path; … }

f = FSPath.temp_file
…
f.close

Temp file path (args are passed to Tempfile.new):

FSPath.temp_file_path{ |path| …; p path; … }

path = FSPath.temp_file_path
…
# file will be removed on next GC run if reference to path is lost

Temp directory (args are passed to Dir.mktmpdir):

FSPath.temp_dir{ |dir| …; p dir; …  }

dir = FSPath.temp_dir
…
# the dir is not removed when temp_dir is run without block

Join paths:

FSPath('a') / 'b' / 'c' # => FSPath('a/b/c')

Read/write:

FSPath('a.txt').read
FSPath('b.bin').binread
FSPath('a.txt').write(text)
FSPath('b.bin').binwrite(data)
FSPath('a.txt').append(more_text)
FSPath('b.bin').binappend(more_data)

Escape glob:

FSPath('trash?/stuff [a,b,c]').escape_glob # => FSPath('trash\?/stuff \[a,b,c\]')

Expand glob:

FSPath('trash').glob('**', '*')

Ascendants:

FSPath('a/b/c').ascendants
FSPath('a/b/c').ascend # => [FSPath('a/b/c'), FSPath('a/b'), FSPath('a')]

Descendants:

FSPath('a/b/c').descendants
FSPath('a/b/c').descend # => [FSPath('a'), FSPath('a/b'), FSPath('a/b/c')]

Path parts:

FSPath('/a/b/c').parts # => ['/', 'a', 'b', 'c']

Basename and extension:

FSPath('some/dir/name.ext').prefix_suffix # => [FSPath('name'), '.ext']

Copyright

Copyright (c) 2010-2019 Ivan Kuchin. See LICENSE.txt for details.

fspath's People

Contributors

toy avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

fspath's Issues

deprecation warning

hi

I'm getting strange warning message:

~/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/fspath-2.1.1/lib/fspath.rb:128: warning: constant ::Fixnum is deprecated

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.