rubypath 0.3.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +5 -55
- data/CHANGELOG.md +0 -24
- data/LICENSE.txt +0 -165
- data/README.md +0 -102
- data/doc/file.README.html +0 -175
- data/lib/rubypath.rb +0 -29
- data/lib/rubypath/backend.rb +0 -92
- data/lib/rubypath/backend/mock.rb +0 -356
- data/lib/rubypath/backend/sys.rb +0 -161
- data/lib/rubypath/comparison.rb +0 -19
- data/lib/rubypath/construction.rb +0 -109
- data/lib/rubypath/dir_operations.rb +0 -160
- data/lib/rubypath/extensions.rb +0 -157
- data/lib/rubypath/file_operations.rb +0 -192
- data/lib/rubypath/file_predicates.rb +0 -32
- data/lib/rubypath/identity.rb +0 -59
- data/lib/rubypath/io_operations.rb +0 -82
- data/lib/rubypath/mock.rb +0 -42
- data/lib/rubypath/path_operations.rb +0 -311
- data/lib/rubypath/path_predicates.rb +0 -61
- data/lib/rubypath/version.rb +0 -11
- data/rubypath.gemspec +0 -22
- data/spec/README_spec.rb +0 -27
- data/spec/rubypath/comparison_spec.rb +0 -77
- data/spec/rubypath/construction_spec.rb +0 -101
- data/spec/rubypath/dir_operations_spec.rb +0 -225
- data/spec/rubypath/extensions_spec.rb +0 -270
- data/spec/rubypath/file_operations_spec.rb +0 -428
- data/spec/rubypath/file_predicates_spec.rb +0 -66
- data/spec/rubypath/identity_spec.rb +0 -21
- data/spec/rubypath/io_operations_spec.rb +0 -128
- data/spec/rubypath/path_operations_spec.rb +0 -483
- data/spec/rubypath/path_predicates_spec.rb +0 -75
- data/spec/spec_helper.rb +0 -42
- data/spec/support/describe_method.rb +0 -18
- data/spec/support/with_backend.rb +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 132e274110300f64504251d3ff47c352bbfe15c8
|
4
|
+
data.tar.gz: cc3628865507096713d6e783af1b24f1235e0ff1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f52446607fddc79bd5da72f4e77eacfb282f3d817ae7331740513b694ccf6a905760897023801b9ce96d41119bc26f701f37ca12fb9400a53904b3586ed77f38
|
7
|
+
data.tar.gz: 30bda5d8a6d2ae40e83c040d0ad95391ec6e59f858e0e9bb636c964b6a6298fb60aa29eb081ad33647c5630a37ff31400f2c10d8eedc7ae03ef0fa3188d68090
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubypath
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -31,42 +31,7 @@ email:
|
|
31
31
|
executables: []
|
32
32
|
extensions: []
|
33
33
|
extra_rdoc_files: []
|
34
|
-
files:
|
35
|
-
- CHANGELOG.md
|
36
|
-
- LICENSE.txt
|
37
|
-
- README.md
|
38
|
-
- doc/file.README.html
|
39
|
-
- lib/rubypath.rb
|
40
|
-
- lib/rubypath/backend.rb
|
41
|
-
- lib/rubypath/backend/mock.rb
|
42
|
-
- lib/rubypath/backend/sys.rb
|
43
|
-
- lib/rubypath/comparison.rb
|
44
|
-
- lib/rubypath/construction.rb
|
45
|
-
- lib/rubypath/dir_operations.rb
|
46
|
-
- lib/rubypath/extensions.rb
|
47
|
-
- lib/rubypath/file_operations.rb
|
48
|
-
- lib/rubypath/file_predicates.rb
|
49
|
-
- lib/rubypath/identity.rb
|
50
|
-
- lib/rubypath/io_operations.rb
|
51
|
-
- lib/rubypath/mock.rb
|
52
|
-
- lib/rubypath/path_operations.rb
|
53
|
-
- lib/rubypath/path_predicates.rb
|
54
|
-
- lib/rubypath/version.rb
|
55
|
-
- rubypath.gemspec
|
56
|
-
- spec/README_spec.rb
|
57
|
-
- spec/rubypath/comparison_spec.rb
|
58
|
-
- spec/rubypath/construction_spec.rb
|
59
|
-
- spec/rubypath/dir_operations_spec.rb
|
60
|
-
- spec/rubypath/extensions_spec.rb
|
61
|
-
- spec/rubypath/file_operations_spec.rb
|
62
|
-
- spec/rubypath/file_predicates_spec.rb
|
63
|
-
- spec/rubypath/identity_spec.rb
|
64
|
-
- spec/rubypath/io_operations_spec.rb
|
65
|
-
- spec/rubypath/path_operations_spec.rb
|
66
|
-
- spec/rubypath/path_predicates_spec.rb
|
67
|
-
- spec/spec_helper.rb
|
68
|
-
- spec/support/describe_method.rb
|
69
|
-
- spec/support/with_backend.rb
|
34
|
+
files: []
|
70
35
|
homepage: https://github.com/jgraichen/rubypath
|
71
36
|
licenses:
|
72
37
|
- LGPLv3
|
@@ -87,24 +52,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
52
|
version: '0'
|
88
53
|
requirements: []
|
89
54
|
rubyforge_project:
|
90
|
-
rubygems_version: 2.
|
55
|
+
rubygems_version: 2.6.13
|
91
56
|
signing_key:
|
92
57
|
specification_version: 4
|
93
58
|
summary: Path library incorporating File, Dir, Pathname, IO methods as well as a virtual
|
94
59
|
mock filesystem.
|
95
|
-
test_files:
|
96
|
-
- spec/README_spec.rb
|
97
|
-
- spec/rubypath/comparison_spec.rb
|
98
|
-
- spec/rubypath/construction_spec.rb
|
99
|
-
- spec/rubypath/dir_operations_spec.rb
|
100
|
-
- spec/rubypath/extensions_spec.rb
|
101
|
-
- spec/rubypath/file_operations_spec.rb
|
102
|
-
- spec/rubypath/file_predicates_spec.rb
|
103
|
-
- spec/rubypath/identity_spec.rb
|
104
|
-
- spec/rubypath/io_operations_spec.rb
|
105
|
-
- spec/rubypath/path_operations_spec.rb
|
106
|
-
- spec/rubypath/path_predicates_spec.rb
|
107
|
-
- spec/spec_helper.rb
|
108
|
-
- spec/support/describe_method.rb
|
109
|
-
- spec/support/with_backend.rb
|
110
|
-
has_rdoc:
|
60
|
+
test_files: []
|
data/CHANGELOG.md
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# Changes
|
2
|
-
|
3
|
-
## 0.3.2
|
4
|
-
|
5
|
-
* Fix infinite loop bug in #relative_from
|
6
|
-
* Fix handling of trailing slash in #cleanpath (and depended methods)
|
7
|
-
|
8
|
-
## 0.3.1
|
9
|
-
|
10
|
-
* Fix missing require 'tmpdir' for using with mocked backend
|
11
|
-
|
12
|
-
## 0.3.0
|
13
|
-
|
14
|
-
* Add #unlink
|
15
|
-
* Add #cleanpath
|
16
|
-
* Add #rmtree, #rmtree!, and safe variants
|
17
|
-
|
18
|
-
## 0.2.0
|
19
|
-
|
20
|
-
* Add #relative_from
|
21
|
-
|
22
|
-
## 0.1.0
|
23
|
-
|
24
|
-
* Initial release
|
data/LICENSE.txt
DELETED
@@ -1,165 +0,0 @@
|
|
1
|
-
GNU LESSER GENERAL PUBLIC LICENSE
|
2
|
-
Version 3, 29 June 2007
|
3
|
-
|
4
|
-
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
5
|
-
Everyone is permitted to copy and distribute verbatim copies
|
6
|
-
of this license document, but changing it is not allowed.
|
7
|
-
|
8
|
-
|
9
|
-
This version of the GNU Lesser General Public License incorporates
|
10
|
-
the terms and conditions of version 3 of the GNU General Public
|
11
|
-
License, supplemented by the additional permissions listed below.
|
12
|
-
|
13
|
-
0. Additional Definitions.
|
14
|
-
|
15
|
-
As used herein, "this License" refers to version 3 of the GNU Lesser
|
16
|
-
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
17
|
-
General Public License.
|
18
|
-
|
19
|
-
"The Library" refers to a covered work governed by this License,
|
20
|
-
other than an Application or a Combined Work as defined below.
|
21
|
-
|
22
|
-
An "Application" is any work that makes use of an interface provided
|
23
|
-
by the Library, but which is not otherwise based on the Library.
|
24
|
-
Defining a subclass of a class defined by the Library is deemed a mode
|
25
|
-
of using an interface provided by the Library.
|
26
|
-
|
27
|
-
A "Combined Work" is a work produced by combining or linking an
|
28
|
-
Application with the Library. The particular version of the Library
|
29
|
-
with which the Combined Work was made is also called the "Linked
|
30
|
-
Version".
|
31
|
-
|
32
|
-
The "Minimal Corresponding Source" for a Combined Work means the
|
33
|
-
Corresponding Source for the Combined Work, excluding any source code
|
34
|
-
for portions of the Combined Work that, considered in isolation, are
|
35
|
-
based on the Application, and not on the Linked Version.
|
36
|
-
|
37
|
-
The "Corresponding Application Code" for a Combined Work means the
|
38
|
-
object code and/or source code for the Application, including any data
|
39
|
-
and utility programs needed for reproducing the Combined Work from the
|
40
|
-
Application, but excluding the System Libraries of the Combined Work.
|
41
|
-
|
42
|
-
1. Exception to Section 3 of the GNU GPL.
|
43
|
-
|
44
|
-
You may convey a covered work under sections 3 and 4 of this License
|
45
|
-
without being bound by section 3 of the GNU GPL.
|
46
|
-
|
47
|
-
2. Conveying Modified Versions.
|
48
|
-
|
49
|
-
If you modify a copy of the Library, and, in your modifications, a
|
50
|
-
facility refers to a function or data to be supplied by an Application
|
51
|
-
that uses the facility (other than as an argument passed when the
|
52
|
-
facility is invoked), then you may convey a copy of the modified
|
53
|
-
version:
|
54
|
-
|
55
|
-
a) under this License, provided that you make a good faith effort to
|
56
|
-
ensure that, in the event an Application does not supply the
|
57
|
-
function or data, the facility still operates, and performs
|
58
|
-
whatever part of its purpose remains meaningful, or
|
59
|
-
|
60
|
-
b) under the GNU GPL, with none of the additional permissions of
|
61
|
-
this License applicable to that copy.
|
62
|
-
|
63
|
-
3. Object Code Incorporating Material from Library Header Files.
|
64
|
-
|
65
|
-
The object code form of an Application may incorporate material from
|
66
|
-
a header file that is part of the Library. You may convey such object
|
67
|
-
code under terms of your choice, provided that, if the incorporated
|
68
|
-
material is not limited to numerical parameters, data structure
|
69
|
-
layouts and accessors, or small macros, inline functions and templates
|
70
|
-
(ten or fewer lines in length), you do both of the following:
|
71
|
-
|
72
|
-
a) Give prominent notice with each copy of the object code that the
|
73
|
-
Library is used in it and that the Library and its use are
|
74
|
-
covered by this License.
|
75
|
-
|
76
|
-
b) Accompany the object code with a copy of the GNU GPL and this license
|
77
|
-
document.
|
78
|
-
|
79
|
-
4. Combined Works.
|
80
|
-
|
81
|
-
You may convey a Combined Work under terms of your choice that,
|
82
|
-
taken together, effectively do not restrict modification of the
|
83
|
-
portions of the Library contained in the Combined Work and reverse
|
84
|
-
engineering for debugging such modifications, if you also do each of
|
85
|
-
the following:
|
86
|
-
|
87
|
-
a) Give prominent notice with each copy of the Combined Work that
|
88
|
-
the Library is used in it and that the Library and its use are
|
89
|
-
covered by this License.
|
90
|
-
|
91
|
-
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
92
|
-
document.
|
93
|
-
|
94
|
-
c) For a Combined Work that displays copyright notices during
|
95
|
-
execution, include the copyright notice for the Library among
|
96
|
-
these notices, as well as a reference directing the user to the
|
97
|
-
copies of the GNU GPL and this license document.
|
98
|
-
|
99
|
-
d) Do one of the following:
|
100
|
-
|
101
|
-
0) Convey the Minimal Corresponding Source under the terms of this
|
102
|
-
License, and the Corresponding Application Code in a form
|
103
|
-
suitable for, and under terms that permit, the user to
|
104
|
-
recombine or relink the Application with a modified version of
|
105
|
-
the Linked Version to produce a modified Combined Work, in the
|
106
|
-
manner specified by section 6 of the GNU GPL for conveying
|
107
|
-
Corresponding Source.
|
108
|
-
|
109
|
-
1) Use a suitable shared library mechanism for linking with the
|
110
|
-
Library. A suitable mechanism is one that (a) uses at run time
|
111
|
-
a copy of the Library already present on the user's computer
|
112
|
-
system, and (b) will operate properly with a modified version
|
113
|
-
of the Library that is interface-compatible with the Linked
|
114
|
-
Version.
|
115
|
-
|
116
|
-
e) Provide Installation Information, but only if you would otherwise
|
117
|
-
be required to provide such information under section 6 of the
|
118
|
-
GNU GPL, and only to the extent that such information is
|
119
|
-
necessary to install and execute a modified version of the
|
120
|
-
Combined Work produced by recombining or relinking the
|
121
|
-
Application with a modified version of the Linked Version. (If
|
122
|
-
you use option 4d0, the Installation Information must accompany
|
123
|
-
the Minimal Corresponding Source and Corresponding Application
|
124
|
-
Code. If you use option 4d1, you must provide the Installation
|
125
|
-
Information in the manner specified by section 6 of the GNU GPL
|
126
|
-
for conveying Corresponding Source.)
|
127
|
-
|
128
|
-
5. Combined Libraries.
|
129
|
-
|
130
|
-
You may place library facilities that are a work based on the
|
131
|
-
Library side by side in a single library together with other library
|
132
|
-
facilities that are not Applications and are not covered by this
|
133
|
-
License, and convey such a combined library under terms of your
|
134
|
-
choice, if you do both of the following:
|
135
|
-
|
136
|
-
a) Accompany the combined library with a copy of the same work based
|
137
|
-
on the Library, uncombined with any other library facilities,
|
138
|
-
conveyed under the terms of this License.
|
139
|
-
|
140
|
-
b) Give prominent notice with the combined library that part of it
|
141
|
-
is a work based on the Library, and explaining where to find the
|
142
|
-
accompanying uncombined form of the same work.
|
143
|
-
|
144
|
-
6. Revised Versions of the GNU Lesser General Public License.
|
145
|
-
|
146
|
-
The Free Software Foundation may publish revised and/or new versions
|
147
|
-
of the GNU Lesser General Public License from time to time. Such new
|
148
|
-
versions will be similar in spirit to the present version, but may
|
149
|
-
differ in detail to address new problems or concerns.
|
150
|
-
|
151
|
-
Each version is given a distinguishing version number. If the
|
152
|
-
Library as you received it specifies that a certain numbered version
|
153
|
-
of the GNU Lesser General Public License "or any later version"
|
154
|
-
applies to it, you have the option of following the terms and
|
155
|
-
conditions either of that published version or of any later version
|
156
|
-
published by the Free Software Foundation. If the Library as you
|
157
|
-
received it does not specify a version number of the GNU Lesser
|
158
|
-
General Public License, you may choose any version of the GNU Lesser
|
159
|
-
General Public License ever published by the Free Software Foundation.
|
160
|
-
|
161
|
-
If the Library as you received it specifies that a proxy can decide
|
162
|
-
whether future versions of the GNU Lesser General Public License shall
|
163
|
-
apply, that proxy's public statement of acceptance of any version is
|
164
|
-
permanent authorization for you to choose that version for the
|
165
|
-
Library.
|
data/README.md
DELETED
@@ -1,102 +0,0 @@
|
|
1
|
-
# Ruby Path
|
2
|
-
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/rubypath.svg)](http://badge.fury.io/rb/rubypath)
|
4
|
-
[![Build Status](http://img.shields.io/travis/jgraichen/rubypath/master.svg)](https://travis-ci.org/jgraichen/rubypath)
|
5
|
-
[![Coverage Status](http://img.shields.io/coveralls/jgraichen/rubypath/master.svg)](https://coveralls.io/r/jgraichen/rubypath)
|
6
|
-
[![Dependency Status](http://img.shields.io/gemnasium/jgraichen/rubypath.svg)](https://gemnasium.com/jgraichen/rubypath)
|
7
|
-
[![RubyDoc Documentation](http://img.shields.io/badge/rubydoc-here-blue.svg)](http://rubydoc.info/github/jgraichen/rubypath/master/frames)
|
8
|
-
|
9
|
-
*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.
|
10
|
-
|
11
|
-
## Installation
|
12
|
-
|
13
|
-
Add `rubypath` to your Gemfile, `gemspec` or install manually.
|
14
|
-
|
15
|
-
## Usage
|
16
|
-
|
17
|
-
Using `Path` with file and directory methods:
|
18
|
-
|
19
|
-
```ruby
|
20
|
-
base = Path '/path/to/base'
|
21
|
-
src = base.mkpath 'project/src'
|
22
|
-
src.touch 'Rakefile'
|
23
|
-
src.mkdir('lib').mkdir('mylib').touch('version.rb')
|
24
|
-
#=> <Path '/path/to/base/project/src/lib/mylib/version.rb'
|
25
|
-
```
|
26
|
-
|
27
|
-
Using IO:
|
28
|
-
|
29
|
-
```ruby
|
30
|
-
src.write "module Mylib\n VERSION = '0.1.0'\nend"
|
31
|
-
|
32
|
-
src.lookup('project.yml').read
|
33
|
-
#=> "..."
|
34
|
-
```
|
35
|
-
|
36
|
-
### Mock FS in tests
|
37
|
-
|
38
|
-
Wrap specific or just all specs in a virtual filesystem:
|
39
|
-
|
40
|
-
```ruby
|
41
|
-
# spec_helper.rb
|
42
|
-
|
43
|
-
config.around(:each) do |example|
|
44
|
-
Path::Backend.mock root: :tmp, &example
|
45
|
-
end
|
46
|
-
```
|
47
|
-
|
48
|
-
Supported 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.
|
49
|
-
|
50
|
-
If 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.
|
51
|
-
|
52
|
-
You can then define a specific scenario in your specs:
|
53
|
-
|
54
|
-
```ruby
|
55
|
-
before do
|
56
|
-
Path.mock do |root, backend|
|
57
|
-
backend.cwd = '/root'
|
58
|
-
backend.current_user = 'test'
|
59
|
-
backend.homes = {'test' => '/home/test'}
|
60
|
-
|
61
|
-
home = root.mkpath('/home/test')
|
62
|
-
home.mkfile('src/test.txt').write 'CONTENT'
|
63
|
-
home.mkfile('src/test.html').write '<html><head><title></title>...'
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'should mock all FS' do
|
68
|
-
base = Path('~test').expand
|
69
|
-
expect(base.join(%w(src test.txt)).read).to eq 'CONTENT'
|
70
|
-
|
71
|
-
files = base.glob('**/*').select{|p| p.file? }
|
72
|
-
expect(files.size).to eq 2
|
73
|
-
end
|
74
|
-
```
|
75
|
-
|
76
|
-
See full API documentation here: http://rubydoc.info/gems/rubypath/Path
|
77
|
-
|
78
|
-
## Contributing
|
79
|
-
|
80
|
-
1. Fork it
|
81
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
82
|
-
3. Add specs testing SYS *and* MOCK file system
|
83
|
-
4. Commit your specs (`git commit -am 'Add specs for feature'`)
|
84
|
-
5. Add our changes for SYS *and* MOCK file system
|
85
|
-
6. Commit your changes (`git commit -am 'Add some feature'`)
|
86
|
-
7. Push to the branch (`git push origin my-new-feature`)
|
87
|
-
8. Create new Pull Request
|
88
|
-
|
89
|
-
### ToDos
|
90
|
-
|
91
|
-
* Add missing methods
|
92
|
-
* Improve MOCK FS implementation
|
93
|
-
|
94
|
-
## License
|
95
|
-
|
96
|
-
Copyright (C) 2014 Jan Graichen
|
97
|
-
|
98
|
-
This 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.
|
99
|
-
|
100
|
-
This 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.
|
101
|
-
|
102
|
-
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
data/doc/file.README.html
DELETED
@@ -1,175 +0,0 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
-
<head>
|
5
|
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
6
|
-
<title>
|
7
|
-
File: README
|
8
|
-
|
9
|
-
— Documentation by YARD 0.8.7.3
|
10
|
-
|
11
|
-
</title>
|
12
|
-
|
13
|
-
<link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
|
14
|
-
|
15
|
-
<link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
|
16
|
-
|
17
|
-
<script type="text/javascript" charset="utf-8">
|
18
|
-
hasFrames = window.top.frames.main ? true : false;
|
19
|
-
relpath = '';
|
20
|
-
framesUrl = "frames.html#!" + escape(window.location.href);
|
21
|
-
</script>
|
22
|
-
|
23
|
-
|
24
|
-
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
25
|
-
|
26
|
-
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
27
|
-
|
28
|
-
|
29
|
-
</head>
|
30
|
-
<body>
|
31
|
-
<div id="header">
|
32
|
-
<div id="menu">
|
33
|
-
|
34
|
-
<a href="_index.html">Index</a> »
|
35
|
-
<span class="title">File: README</span>
|
36
|
-
|
37
|
-
|
38
|
-
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
39
|
-
</div>
|
40
|
-
|
41
|
-
<div id="search">
|
42
|
-
|
43
|
-
<a class="full_list_link" id="class_list_link"
|
44
|
-
href="class_list.html">
|
45
|
-
Class List
|
46
|
-
</a>
|
47
|
-
|
48
|
-
<a class="full_list_link" id="method_list_link"
|
49
|
-
href="method_list.html">
|
50
|
-
Method List
|
51
|
-
</a>
|
52
|
-
|
53
|
-
<a class="full_list_link" id="file_list_link"
|
54
|
-
href="file_list.html">
|
55
|
-
File List
|
56
|
-
</a>
|
57
|
-
|
58
|
-
</div>
|
59
|
-
<div class="clear"></div>
|
60
|
-
</div>
|
61
|
-
|
62
|
-
<iframe id="search_frame"></iframe>
|
63
|
-
|
64
|
-
<div id="content"><div id='filecontents'><h1>Ruby Path</h1>
|
65
|
-
|
66
|
-
<p><a href="http://badge.fury.io/rb/rubypath"><img src="https://badge.fury.io/rb/rubypath.svg" alt="Gem Version"></a>
|
67
|
-
<a href="https://travis-ci.org/jgraichen/rubypath"><img src="http://img.shields.io/travis/jgraichen/rubypath/master.svg" alt="Build Status"></a>
|
68
|
-
<a href="https://coveralls.io/r/jgraichen/rubypath"><img src="http://img.shields.io/coveralls/jgraichen/rubypath/master.svg" alt="Coverage Status"></a>
|
69
|
-
<a href="https://gemnasium.com/jgraichen/rubypath"><img src="http://img.shields.io/gemnasium/jgraichen/rubypath.svg" alt="Dependency Status"></a>
|
70
|
-
<a href="http://rubydoc.info/github/jgraichen/rubypath/master/frames"><img src="http://img.shields.io/badge/rubydoc-here-blue.svg" alt="RubyDoc Documentation"></a></p>
|
71
|
-
|
72
|
-
<p><em>Ruby Path</em> introduces a global <code>Path</code> class unifying most <code>File</code>, <code>Dir</code>, <code>FileUtils</code>, <code>Pathname</code> and <code>IO</code> 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.</p>
|
73
|
-
|
74
|
-
<h2>Installation</h2>
|
75
|
-
|
76
|
-
<p>Add <code>rubypath</code> to your Gemfile, <code>gemspec</code> or install manually.</p>
|
77
|
-
|
78
|
-
<h2>Usage</h2>
|
79
|
-
|
80
|
-
<p>Using <code>Path</code> with file and directory methods:</p>
|
81
|
-
|
82
|
-
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_base'>base</span> <span class='op'>=</span> <span class='const'>Path</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>/path/to/base</span><span class='tstring_end'>'</span></span>
|
83
|
-
<span class='id identifier rubyid_src'>src</span> <span class='op'>=</span> <span class='id identifier rubyid_base'>base</span><span class='period'>.</span><span class='id identifier rubyid_mkpath'>mkpath</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>project/src</span><span class='tstring_end'>'</span></span>
|
84
|
-
<span class='id identifier rubyid_src'>src</span><span class='period'>.</span><span class='id identifier rubyid_touch'>touch</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Rakefile</span><span class='tstring_end'>'</span></span>
|
85
|
-
<span class='id identifier rubyid_src'>src</span><span class='period'>.</span><span class='id identifier rubyid_mkdir'>mkdir</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>lib</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_mkdir'>mkdir</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>mylib</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_touch'>touch</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>version.rb</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
86
|
-
<span class='comment'>#=> <Path '/path/to/base/project/src/lib/mylib/version.rb'
|
87
|
-
</span></code></pre>
|
88
|
-
|
89
|
-
<p>Using IO:</p>
|
90
|
-
|
91
|
-
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_src'>src</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>module Mylib\n VERSION = '0.1.0'\nend</span><span class='tstring_end'>"</span></span>
|
92
|
-
|
93
|
-
<span class='id identifier rubyid_src'>src</span><span class='period'>.</span><span class='id identifier rubyid_lookup'>lookup</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>project.yml</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span>
|
94
|
-
<span class='comment'>#=> "..."
|
95
|
-
</span></code></pre>
|
96
|
-
|
97
|
-
<h3>Mock FS in tests</h3>
|
98
|
-
|
99
|
-
<p>Wrap specific or just all specs in a virtual filesystem:</p>
|
100
|
-
|
101
|
-
<pre class="code ruby"><code class="ruby"><span class='comment'># spec_helper.rb
|
102
|
-
</span>
|
103
|
-
<span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_around'>around</span><span class='lparen'>(</span><span class='symbol'>:each</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_example'>example</span><span class='op'>|</span>
|
104
|
-
<span class='const'>Path</span><span class='op'>::</span><span class='const'>Backend</span><span class='period'>.</span><span class='id identifier rubyid_mock'>mock</span> <span class='label'>root:</span> <span class='symbol'>:tmp</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_example'>example</span>
|
105
|
-
<span class='kw'>end</span>
|
106
|
-
</code></pre>
|
107
|
-
|
108
|
-
<p>Supported options for <code>:root</code> are <code>:tmp</code> 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.</p>
|
109
|
-
|
110
|
-
<p>If not <code>:root</code> 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.</p>
|
111
|
-
|
112
|
-
<p>You can then define a specific scenario in your specs:</p>
|
113
|
-
|
114
|
-
<pre class="code ruby"><code class="ruby"> <span class='id identifier rubyid_before'>before</span> <span class='kw'>do</span>
|
115
|
-
<span class='const'>Path</span><span class='period'>.</span><span class='id identifier rubyid_mock'>mock</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_root'>root</span><span class='comma'>,</span> <span class='id identifier rubyid_backend'>backend</span><span class='op'>|</span>
|
116
|
-
<span class='id identifier rubyid_backend'>backend</span><span class='period'>.</span><span class='id identifier rubyid_cwd'>cwd</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>/root</span><span class='tstring_end'>'</span></span>
|
117
|
-
<span class='id identifier rubyid_backend'>backend</span><span class='period'>.</span><span class='id identifier rubyid_current_user'>current_user</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>test</span><span class='tstring_end'>'</span></span>
|
118
|
-
<span class='id identifier rubyid_backend'>backend</span><span class='period'>.</span><span class='id identifier rubyid_homes'>homes</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>test</span><span class='tstring_end'>'</span></span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>/home/test</span><span class='tstring_end'>'</span></span><span class='rbrace'>}</span>
|
119
|
-
|
120
|
-
<span class='id identifier rubyid_home'>home</span> <span class='op'>=</span> <span class='id identifier rubyid_root'>root</span><span class='period'>.</span><span class='id identifier rubyid_mkpath'>mkpath</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>/home/test</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
121
|
-
<span class='id identifier rubyid_home'>home</span><span class='period'>.</span><span class='id identifier rubyid_mkfile'>mkfile</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>src/test.txt</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>CONTENT</span><span class='tstring_end'>'</span></span>
|
122
|
-
<span class='id identifier rubyid_home'>home</span><span class='period'>.</span><span class='id identifier rubyid_mkfile'>mkfile</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>src/test.html</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'><html><head><title></title>...</span><span class='tstring_end'>'</span></span>
|
123
|
-
<span class='kw'>end</span>
|
124
|
-
<span class='kw'>end</span>
|
125
|
-
|
126
|
-
<span class='id identifier rubyid_it'>it</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>should mock all FS</span><span class='tstring_end'>'</span></span> <span class='kw'>do</span>
|
127
|
-
<span class='id identifier rubyid_base'>base</span> <span class='op'>=</span> <span class='const'>Path</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>~test</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_expand'>expand</span>
|
128
|
-
<span class='id identifier rubyid_expect'>expect</span><span class='lparen'>(</span><span class='id identifier rubyid_base'>base</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='qwords_beg'>%w(</span><span class='tstring_content'>src</span><span class='words_sep'> </span><span class='tstring_content'>test.txt</span><span class='words_sep'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to'>to</span> <span class='id identifier rubyid_eq'>eq</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>CONTENT</span><span class='tstring_end'>'</span></span>
|
129
|
-
|
130
|
-
<span class='id identifier rubyid_files'>files</span> <span class='op'>=</span> <span class='id identifier rubyid_base'>base</span><span class='period'>.</span><span class='id identifier rubyid_glob'>glob</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>**/*</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_p'>p</span><span class='op'>|</span> <span class='id identifier rubyid_p'>p</span><span class='period'>.</span><span class='id identifier rubyid_file?'>file?</span> <span class='rbrace'>}</span>
|
131
|
-
<span class='id identifier rubyid_expect'>expect</span><span class='lparen'>(</span><span class='id identifier rubyid_files'>files</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to'>to</span> <span class='id identifier rubyid_eq'>eq</span> <span class='int'>2</span>
|
132
|
-
<span class='kw'>end</span>
|
133
|
-
</code></pre>
|
134
|
-
|
135
|
-
<p>See full API documentation here: <a href="http://rubydoc.info/gems/rubypath/Path">http://rubydoc.info/gems/rubypath/Path</a></p>
|
136
|
-
|
137
|
-
<h2>Contributing</h2>
|
138
|
-
|
139
|
-
<ol>
|
140
|
-
<li>Fork it</li>
|
141
|
-
<li>Create your feature branch (<code>git checkout -b my-new-feature</code>)</li>
|
142
|
-
<li>Add specs testing SYS <em>and</em> MOCK file system</li>
|
143
|
-
<li>Commit your specs (<code>git commit -am 'Add specs for feature'</code>)</li>
|
144
|
-
<li>Add our changes for SYS <em>and</em> MOCK file system</li>
|
145
|
-
<li>Commit your changes (<code>git commit -am 'Add some feature'</code>)</li>
|
146
|
-
<li>Push to the branch (<code>git push origin my-new-feature</code>)</li>
|
147
|
-
<li>Create new Pull Request</li>
|
148
|
-
</ol>
|
149
|
-
|
150
|
-
<h3>ToDos</h3>
|
151
|
-
|
152
|
-
<ul>
|
153
|
-
<li>Add missing methods</li>
|
154
|
-
<li>Improve MOCK FS implementation</li>
|
155
|
-
</ul>
|
156
|
-
|
157
|
-
<h2>License</h2>
|
158
|
-
|
159
|
-
<p>Copyright (C) 2014 Jan Graichen</p>
|
160
|
-
|
161
|
-
<p>This 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.</p>
|
162
|
-
|
163
|
-
<p>This 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.</p>
|
164
|
-
|
165
|
-
<p>You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>.</p>
|
166
|
-
</div></div>
|
167
|
-
|
168
|
-
<div id="footer">
|
169
|
-
Generated on Sun Apr 27 13:05:43 2014 by
|
170
|
-
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
171
|
-
0.8.7.3 (ruby-2.1.1).
|
172
|
-
</div>
|
173
|
-
|
174
|
-
</body>
|
175
|
-
</html>
|