{"id":16956981,"url":"https://github.com/jgraichen/rubypath","last_synced_at":"2025-04-11T21:44:30.438Z","repository":{"id":16106117,"uuid":"18851145","full_name":"jgraichen/rubypath","owner":"jgraichen","description":"Path library incorporating File, Dir, Pathname, IO methods as well as a virtual mock filesystem.","archived":false,"fork":false,"pushed_at":"2022-02-25T21:17:20.000Z","size":118,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-05-01T21:22:10.708Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jgraichen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-04-16T18:36:41.000Z","updated_at":"2022-02-25T21:17:15.000Z","dependencies_parsed_at":"2022-09-08T02:01:17.250Z","dependency_job_id":null,"html_url":"https://github.com/jgraichen/rubypath","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgraichen%2Frubypath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgraichen%2Frubypath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgraichen%2Frubypath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgraichen%2Frubypath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jgraichen","download_url":"https://codeload.github.com/jgraichen/rubypath/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248487510,"owners_count":21112187,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T22:16:33.275Z","updated_at":"2025-04-11T21:44:30.410Z","avatar_url":"https://github.com/jgraichen.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ruby Path\n\n[![Gem Version](https://badge.fury.io/rb/rubypath.svg)](http://badge.fury.io/rb/rubypath)\n[![Build Status](http://img.shields.io/travis/jgraichen/rubypath/master.svg)](https://travis-ci.org/jgraichen/rubypath)\n[![Coverage Status](http://img.shields.io/coveralls/jgraichen/rubypath/master.svg)](https://coveralls.io/r/jgraichen/rubypath)\n[![Dependency Status](http://img.shields.io/gemnasium/jgraichen/rubypath.svg)](https://gemnasium.com/jgraichen/rubypath)\n[![RubyDoc Documentation](http://img.shields.io/badge/rubydoc-here-blue.svg)](http://rubydoc.info/github/jgraichen/rubypath/master/frames)\n\n*Ruby Path* introduces a global `Path` class unifying most `File`, `Dir`, `FileUtils`, `Pathname` and `IO` operations with a flexible and powerful Object-Interface and still adding new useful methods and functions like mocking a whole file system for fast and reliable testing.\n\n## Installation\n\nAdd `rubypath` to your Gemfile, `gemspec` or install manually.\n\n## Usage\n\nUsing `Path` with file and directory methods:\n\n```ruby\nbase = Path '/path/to/base'\nsrc  = base.mkpath 'project/src'\nsrc.touch 'Rakefile'\nsrc.mkdir('lib').mkdir('mylib').touch('version.rb')\n#=\u003e \u003cPath '/path/to/base/project/src/lib/mylib/version.rb'\n```\n\nUsing IO:\n\n```ruby\nsrc.write \"module Mylib\\n  VERSION = '0.1.0'\\nend\"\n\nsrc.lookup('project.yml').read\n#=\u003e \"...\"\n```\n\n### Mock FS in tests\n\nWrap specific or just all specs in a virtual filesystem:\n\n```ruby\n# spec_helper.rb\n\nconfig.around(:each) do |example|\n  Path::Backend.mock root: :tmp, \u0026example\nend\n```\n\nSupported options for `:root` are `:tmp` using the real filesystem but scoping all actions into a temporary directory similar to chroot or a custom defined path to use as \"chroot\" directory. This mode does not allow to stub users, home directories and some attributes.\n\nIf not `:root` is specified a completely virtual in-memory filesystem will be used. This backend allows to even specify available users and home directories, the current user etc.\n\nYou can then define a specific scenario in your specs:\n\n```ruby\n    before do\n      Path.mock do |root, backend|\n        backend.cwd          = '/root'\n        backend.current_user = 'test'\n        backend.homes        = {'test' =\u003e '/home/test'}\n\n        home = root.mkpath('/home/test')\n        home.mkfile('src/test.txt').write 'CONTENT'\n        home.mkfile('src/test.html').write '\u003chtml\u003e\u003chead\u003e\u003ctitle\u003e\u003c/title\u003e...'\n      end\n    end\n\n    it 'should mock all FS' do\n      base = Path('~test').expand\n      expect(base.join(%w(src test.txt)).read).to eq 'CONTENT'\n\n      files = base.glob('**/*').select{|p| p.file? }\n      expect(files.size).to eq 2\n    end\n```\n\nSee full API documentation here: http://rubydoc.info/gems/rubypath/Path\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Add specs testing SYS *and* MOCK file system\n4. Commit your specs (`git commit -am 'Add specs for feature'`)\n5. Add our changes for SYS *and* MOCK file system\n6. Commit your changes (`git commit -am 'Add some feature'`)\n7. Push to the branch (`git push origin my-new-feature`)\n8. Create new Pull Request\n\n### ToDos\n\n* Add missing methods\n* Improve MOCK FS implementation\n\n## License\n\nCopyright (C) 2014 Jan Graichen\n\nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License along with this program.  If not, see \u003chttp://www.gnu.org/licenses/\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjgraichen%2Frubypath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjgraichen%2Frubypath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjgraichen%2Frubypath/lists"}