build-files 1.4.3 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/.DS_Store +0 -0
- data/lib/build/files.rb +0 -3
- data/lib/build/files/.DS_Store +0 -0
- data/lib/build/files/glob.rb +9 -6
- data/lib/build/files/list.rb +4 -4
- data/lib/build/files/path.rb +38 -11
- data/lib/build/files/paths.rb +6 -0
- data/lib/build/files/version.rb +1 -1
- metadata +14 -88
- data/.rspec +0 -4
- data/.travis.yml +0 -14
- data/Gemfile +0 -9
- data/README.md +0 -69
- data/Rakefile +0 -6
- data/build-files.gemspec +0 -28
- data/lib/build/files/handle.rb +0 -59
- data/lib/build/files/monitor.rb +0 -43
- data/lib/build/files/monitor/fsevent.rb +0 -55
- data/lib/build/files/monitor/inotify.rb +0 -53
- data/lib/build/files/monitor/polling.rb +0 -145
- data/lib/build/files/state.rb +0 -172
- data/spec/build/files/directory_spec.rb +0 -80
- data/spec/build/files/directory_spec/.dot_file.yaml +0 -0
- data/spec/build/files/directory_spec/normal_file.txt +0 -0
- data/spec/build/files/glob_spec.rb +0 -49
- data/spec/build/files/list_spec.rb +0 -182
- data/spec/build/files/monitor_spec.rb +0 -90
- data/spec/build/files/path_spec.rb +0 -205
- data/spec/build/files/state_spec.rb +0 -90
- data/spec/build/files/system_spec.rb +0 -56
- data/spec/spec_helper.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 777a262af38e7bd84dc924b8e140d8d4e00077fab74b35d6f6ee555063809981
|
4
|
+
data.tar.gz: 981cbf1c9ff4234e9ef7e220de1362ecbcad2d61ae50d77ec072d19586471028
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85211d1effb626dd6d7664a3eaa15ab1f96b456ea49588dcd231c231fb47bbe545e4ea1aacfd7971c523b1674d418f47f4b1c86aa0b472dbb7c4f98c7e6e2587
|
7
|
+
data.tar.gz: a3f499ce331105afe331dbc912a41a532d9478dae92be32da1362dc082133533f6e4b42305e22a7b5a32959093a74a753d30b47b6b3cf361cc8fb3438cef81fd
|
data/lib/.DS_Store
ADDED
Binary file
|
data/lib/build/files.rb
CHANGED
Binary file
|
data/lib/build/files/glob.rb
CHANGED
@@ -44,12 +44,15 @@ module Build
|
|
44
44
|
def full_pattern
|
45
45
|
Path.join(@root, @pattern)
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
# Enumerate all paths matching the pattern.
|
49
49
|
def each(&block)
|
50
|
-
return to_enum
|
50
|
+
return to_enum unless block_given?
|
51
51
|
|
52
|
-
Dir.glob(full_pattern) do |path|
|
52
|
+
::Dir.glob(full_pattern, ::File::FNM_DOTMATCH) do |path|
|
53
|
+
# Ignore `.` and `..` entries.
|
54
|
+
next if path =~ /\/..?$/
|
55
|
+
|
53
56
|
yield Path.new(path, @root)
|
54
57
|
end
|
55
58
|
end
|
@@ -57,15 +60,15 @@ module Build
|
|
57
60
|
def eql?(other)
|
58
61
|
self.class.eql?(other.class) and @root.eql?(other.root) and @pattern.eql?(other.pattern)
|
59
62
|
end
|
60
|
-
|
63
|
+
|
61
64
|
def hash
|
62
65
|
[@root, @pattern].hash
|
63
66
|
end
|
64
|
-
|
67
|
+
|
65
68
|
def include?(path)
|
66
69
|
File.fnmatch(full_pattern, path)
|
67
70
|
end
|
68
|
-
|
71
|
+
|
69
72
|
def rebase(root)
|
70
73
|
self.class.new(root, @pattern)
|
71
74
|
end
|
data/lib/build/files/list.rb
CHANGED
@@ -55,13 +55,13 @@ module Build
|
|
55
55
|
other.any?{|path| include?(path)}
|
56
56
|
end
|
57
57
|
|
58
|
-
def with(**
|
59
|
-
return to_enum(:with, **
|
58
|
+
def with(**options)
|
59
|
+
return to_enum(:with, **options) unless block_given?
|
60
60
|
|
61
61
|
paths = []
|
62
62
|
|
63
|
-
each do |path|
|
64
|
-
updated_path = path.with(
|
63
|
+
self.each do |path|
|
64
|
+
updated_path = path.with(**options)
|
65
65
|
|
66
66
|
yield path, updated_path
|
67
67
|
|
data/lib/build/files/path.rb
CHANGED
@@ -22,6 +22,10 @@ module Build
|
|
22
22
|
module Files
|
23
23
|
# Represents a file path with an absolute root and a relative offset:
|
24
24
|
class Path
|
25
|
+
def self.current
|
26
|
+
self.new(::Dir.pwd)
|
27
|
+
end
|
28
|
+
|
25
29
|
def self.split(path)
|
26
30
|
# Effectively dirname and basename:
|
27
31
|
dirname, separator, filename = path.rpartition(File::SEPARATOR)
|
@@ -44,6 +48,14 @@ module Build
|
|
44
48
|
end
|
45
49
|
end
|
46
50
|
|
51
|
+
def self.root(path)
|
52
|
+
if Path === path
|
53
|
+
path.root
|
54
|
+
else
|
55
|
+
File.dirname(path)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
47
59
|
# Return the shortest relative path to get to path from root. Root should be a directory with which you are computing the relative path.
|
48
60
|
def self.shortest_path(path, root)
|
49
61
|
path_components = Path.components(path)
|
@@ -89,9 +101,6 @@ module Build
|
|
89
101
|
# Effectively dirname and basename:
|
90
102
|
@root, _, @relative_path = full_path.rpartition(File::SEPARATOR)
|
91
103
|
end
|
92
|
-
|
93
|
-
# This improves the cost of hash/eql? slightly but the root cannot be deconstructed if it was an instance of Path.
|
94
|
-
# @root = @root.to_s
|
95
104
|
end
|
96
105
|
|
97
106
|
attr :root
|
@@ -101,6 +110,8 @@ module Build
|
|
101
110
|
@full_path.length
|
102
111
|
end
|
103
112
|
|
113
|
+
alias size length
|
114
|
+
|
104
115
|
def components
|
105
116
|
@components ||= @full_path.split(File::SEPARATOR).freeze
|
106
117
|
end
|
@@ -109,6 +120,21 @@ module Build
|
|
109
120
|
self.parts.last
|
110
121
|
end
|
111
122
|
|
123
|
+
def parent
|
124
|
+
root = @root
|
125
|
+
full_path = File.dirname(@full_path)
|
126
|
+
|
127
|
+
while root.size > full_path.size
|
128
|
+
root = Path.root(root)
|
129
|
+
end
|
130
|
+
|
131
|
+
if root.size == full_path.size
|
132
|
+
root = Path.root(root)
|
133
|
+
end
|
134
|
+
|
135
|
+
self.class.new(full_path, root)
|
136
|
+
end
|
137
|
+
|
112
138
|
def start_with?(*args)
|
113
139
|
@full_path.start_with?(*args)
|
114
140
|
end
|
@@ -116,7 +142,7 @@ module Build
|
|
116
142
|
alias parts components
|
117
143
|
|
118
144
|
def relative_path
|
119
|
-
@relative_path ||= Path.relative_path(@root.to_s, @full_path).freeze
|
145
|
+
@relative_path ||= Path.relative_path(@root.to_s, @full_path.to_s).freeze
|
120
146
|
end
|
121
147
|
|
122
148
|
def relative_parts
|
@@ -176,12 +202,12 @@ module Build
|
|
176
202
|
self.new(File.join(root, relative_path), root)
|
177
203
|
end
|
178
204
|
|
179
|
-
# Expand a
|
180
|
-
def self.expand(
|
181
|
-
if
|
182
|
-
self.new(
|
205
|
+
# Expand a path within a given root.
|
206
|
+
def self.expand(path, root = Dir.getwd)
|
207
|
+
if path.start_with?(File::SEPARATOR)
|
208
|
+
self.new(path)
|
183
209
|
else
|
184
|
-
self.join(root,
|
210
|
+
self.join(root, path)
|
185
211
|
end
|
186
212
|
end
|
187
213
|
|
@@ -190,7 +216,7 @@ module Build
|
|
190
216
|
end
|
191
217
|
|
192
218
|
def to_str
|
193
|
-
@full_path
|
219
|
+
@full_path.to_str
|
194
220
|
end
|
195
221
|
|
196
222
|
def to_path
|
@@ -198,7 +224,8 @@ module Build
|
|
198
224
|
end
|
199
225
|
|
200
226
|
def to_s
|
201
|
-
|
227
|
+
# It's not guaranteed to be string.
|
228
|
+
@full_path.to_s
|
202
229
|
end
|
203
230
|
|
204
231
|
def inspect
|
data/lib/build/files/paths.rb
CHANGED
data/lib/build/files/version.rb
CHANGED
metadata
CHANGED
@@ -1,45 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: build-files
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rb-fsevent
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: covered
|
14
|
+
name: bundler
|
43
15
|
requirement: !ruby/object:Gem::Requirement
|
44
16
|
requirements:
|
45
17
|
- - ">="
|
@@ -53,7 +25,7 @@ dependencies:
|
|
53
25
|
- !ruby/object:Gem::Version
|
54
26
|
version: '0'
|
55
27
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
28
|
+
name: covered
|
57
29
|
requirement: !ruby/object:Gem::Requirement
|
58
30
|
requirements:
|
59
31
|
- - ">="
|
@@ -80,64 +52,29 @@ dependencies:
|
|
80
52
|
- - "~>"
|
81
53
|
- !ruby/object:Gem::Version
|
82
54
|
version: '3.4'
|
83
|
-
|
84
|
-
name: rake
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
description:
|
55
|
+
description:
|
98
56
|
email:
|
99
|
-
- samuel.williams@oriontransfer.co.nz
|
100
57
|
executables: []
|
101
58
|
extensions: []
|
102
59
|
extra_rdoc_files: []
|
103
60
|
files:
|
104
|
-
-
|
105
|
-
- ".travis.yml"
|
106
|
-
- Gemfile
|
107
|
-
- README.md
|
108
|
-
- Rakefile
|
109
|
-
- build-files.gemspec
|
61
|
+
- lib/.DS_Store
|
110
62
|
- lib/build/files.rb
|
63
|
+
- lib/build/files/.DS_Store
|
111
64
|
- lib/build/files/composite.rb
|
112
65
|
- lib/build/files/difference.rb
|
113
66
|
- lib/build/files/directory.rb
|
114
67
|
- lib/build/files/glob.rb
|
115
|
-
- lib/build/files/handle.rb
|
116
68
|
- lib/build/files/list.rb
|
117
|
-
- lib/build/files/monitor.rb
|
118
|
-
- lib/build/files/monitor/fsevent.rb
|
119
|
-
- lib/build/files/monitor/inotify.rb
|
120
|
-
- lib/build/files/monitor/polling.rb
|
121
69
|
- lib/build/files/path.rb
|
122
70
|
- lib/build/files/paths.rb
|
123
|
-
- lib/build/files/state.rb
|
124
71
|
- lib/build/files/system.rb
|
125
72
|
- lib/build/files/version.rb
|
126
|
-
|
127
|
-
- spec/build/files/directory_spec/.dot_file.yaml
|
128
|
-
- spec/build/files/directory_spec/normal_file.txt
|
129
|
-
- spec/build/files/glob_spec.rb
|
130
|
-
- spec/build/files/list_spec.rb
|
131
|
-
- spec/build/files/monitor_spec.rb
|
132
|
-
- spec/build/files/path_spec.rb
|
133
|
-
- spec/build/files/state_spec.rb
|
134
|
-
- spec/build/files/system_spec.rb
|
135
|
-
- spec/spec_helper.rb
|
136
|
-
homepage: ''
|
73
|
+
homepage:
|
137
74
|
licenses:
|
138
75
|
- MIT
|
139
76
|
metadata: {}
|
140
|
-
post_install_message:
|
77
|
+
post_install_message:
|
141
78
|
rdoc_options: []
|
142
79
|
require_paths:
|
143
80
|
- lib
|
@@ -152,19 +89,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
89
|
- !ruby/object:Gem::Version
|
153
90
|
version: '0'
|
154
91
|
requirements: []
|
155
|
-
rubygems_version: 3.
|
156
|
-
signing_key:
|
92
|
+
rubygems_version: 3.2.3
|
93
|
+
signing_key:
|
157
94
|
specification_version: 4
|
158
|
-
summary:
|
159
|
-
|
160
|
-
test_files:
|
161
|
-
- spec/build/files/directory_spec.rb
|
162
|
-
- spec/build/files/directory_spec/.dot_file.yaml
|
163
|
-
- spec/build/files/directory_spec/normal_file.txt
|
164
|
-
- spec/build/files/glob_spec.rb
|
165
|
-
- spec/build/files/list_spec.rb
|
166
|
-
- spec/build/files/monitor_spec.rb
|
167
|
-
- spec/build/files/path_spec.rb
|
168
|
-
- spec/build/files/state_spec.rb
|
169
|
-
- spec/build/files/system_spec.rb
|
170
|
-
- spec/spec_helper.rb
|
95
|
+
summary: Abstractions for handling and mapping paths.
|
96
|
+
test_files: []
|
data/.rspec
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/README.md
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
# Build::Files
|
2
|
-
|
3
|
-
Build::Files is a set of idiomatic classes for dealing with paths and monitoring directories. File paths are represented with both root and relative parts which makes copying directory structures intuitive.
|
4
|
-
|
5
|
-
[![Build Status](https://secure.travis-ci.org/ioquatix/build-files.svg)](http://travis-ci.org/ioquatix/build-files)
|
6
|
-
[![Code Climate](https://codeclimate.com/github/ioquatix/build-files.svg)](https://codeclimate.com/github/ioquatix/build-files)
|
7
|
-
[![Coverage Status](https://coveralls.io/repos/ioquatix/build-files/badge.svg)](https://coveralls.io/r/ioquatix/build-files)
|
8
|
-
|
9
|
-
## Installation
|
10
|
-
|
11
|
-
Add this line to your application's Gemfile:
|
12
|
-
|
13
|
-
gem 'build-files'
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install build-files
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
The basic structure is the `Path`. Paths are stored with a root and relative part. By default, if no root is specified, it is the `dirname` part.
|
26
|
-
|
27
|
-
require 'build/files'
|
28
|
-
|
29
|
-
path = Build::Files::Path("/foo/bar/baz")
|
30
|
-
=> "/foo/bar"/"baz"
|
31
|
-
|
32
|
-
> path.root
|
33
|
-
=> "/foo/bar"
|
34
|
-
> path.relative_path
|
35
|
-
=> "baz"
|
36
|
-
|
37
|
-
Paths can be coerced to strings and thus are suitable arguments to `exec`/`system` functions.
|
38
|
-
|
39
|
-
## Contributing
|
40
|
-
|
41
|
-
1. Fork it
|
42
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
43
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
44
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
45
|
-
5. Create new Pull Request
|
46
|
-
|
47
|
-
## License
|
48
|
-
|
49
|
-
Released under the MIT license.
|
50
|
-
|
51
|
-
Copyright, 2014, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
|
52
|
-
|
53
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
54
|
-
of this software and associated documentation files (the "Software"), to deal
|
55
|
-
in the Software without restriction, including without limitation the rights
|
56
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
57
|
-
copies of the Software, and to permit persons to whom the Software is
|
58
|
-
furnished to do so, subject to the following conditions:
|
59
|
-
|
60
|
-
The above copyright notice and this permission notice shall be included in
|
61
|
-
all copies or substantial portions of the Software.
|
62
|
-
|
63
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
64
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
65
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
66
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
67
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
68
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
69
|
-
THE SOFTWARE.
|