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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5298ff2018cafcc8c18f9319af1027d92c5f5a1b2c11cb683f916d65e0ba5ba
4
- data.tar.gz: ab00474b4117ae16729255445285d9b835fe1d92a6de7b5c7a10207bb684c4e1
3
+ metadata.gz: 777a262af38e7bd84dc924b8e140d8d4e00077fab74b35d6f6ee555063809981
4
+ data.tar.gz: 981cbf1c9ff4234e9ef7e220de1362ecbcad2d61ae50d77ec072d19586471028
5
5
  SHA512:
6
- metadata.gz: fd0603af29ac1189dd43b9b8beee290e091709cb218389a47dce5489bfed64aa716d9534c6848d2a735341cf7ed34149fb815d46605020f2c1806743ed7e7a44
7
- data.tar.gz: b47e003284e29761c501d27e82032011e9350e816627d16223f24657c5f8ffdb155e69753c179ffc08b7c7bd95e633bc6aa851b55c1feab64be834cbce6e5529
6
+ metadata.gz: 85211d1effb626dd6d7664a3eaa15ab1f96b456ea49588dcd231c231fb47bbe545e4ea1aacfd7971c523b1674d418f47f4b1c86aa0b472dbb7c4f98c7e6e2587
7
+ data.tar.gz: a3f499ce331105afe331dbc912a41a532d9478dae92be32da1362dc082133533f6e4b42305e22a7b5a32959093a74a753d30b47b6b3cf361cc8fb3438cef81fd
data/lib/.DS_Store ADDED
Binary file
data/lib/build/files.rb CHANGED
@@ -24,7 +24,4 @@ require_relative 'files/paths'
24
24
  require_relative 'files/glob'
25
25
  require_relative 'files/directory'
26
26
 
27
- require_relative 'files/state'
28
- require_relative 'files/monitor'
29
-
30
27
  require_relative 'files/system'
Binary file
@@ -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(:each) unless block_given?
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
@@ -55,13 +55,13 @@ module Build
55
55
  other.any?{|path| include?(path)}
56
56
  end
57
57
 
58
- def with(**args)
59
- return to_enum(:with, **args) unless block_given?
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(args)
63
+ self.each do |path|
64
+ updated_path = path.with(**options)
65
65
 
66
66
  yield path, updated_path
67
67
 
@@ -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 subpath within a given root, similar to `File.expand_path`
180
- def self.expand(subpath, root = Dir.getwd)
181
- if subpath.start_with? File::SEPARATOR
182
- self.new(subpath)
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, subpath)
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
- @full_path
227
+ # It's not guaranteed to be string.
228
+ @full_path.to_s
202
229
  end
203
230
 
204
231
  def inspect
@@ -69,5 +69,11 @@ module Build
69
69
  self.new(paths, [root])
70
70
  end
71
71
  end
72
+
73
+ class Path
74
+ def list(*relative_paths)
75
+ Paths.directory(self, relative_paths)
76
+ end
77
+ end
72
78
  end
73
79
  end
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Build
22
22
  module Files
23
- VERSION = "1.4.3"
23
+ VERSION = "1.7.1"
24
24
  end
25
25
  end
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.3
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: 2019-02-14 00:00:00.000000000 Z
11
+ date: 2021-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rb-inotify
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: bundler
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
- - !ruby/object:Gem::Dependency
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
- - ".rspec"
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
- - spec/build/files/directory_spec.rb
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.0.2
156
- signing_key:
92
+ rubygems_version: 3.2.3
93
+ signing_key:
157
94
  specification_version: 4
158
- summary: Build::Files is a set of idiomatic classes for dealing with paths and monitoring
159
- directories.
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
@@ -1,4 +0,0 @@
1
- --format documentation
2
- --backtrace
3
- --warnings
4
- --require spec_helper
data/.travis.yml DELETED
@@ -1,14 +0,0 @@
1
- language: ruby
2
- dist: xenial
3
- cache: bundler
4
-
5
- matrix:
6
- include:
7
- - rvm: 2.3
8
- - rvm: 2.4
9
- - rvm: 2.5
10
- - rvm: 2.6
11
- env: COVERAGE=BriefSummary,Coveralls
12
- - rvm: 2.6
13
- os: osx
14
- env: COVERAGE=BriefSummary,Coveralls
data/Gemfile DELETED
@@ -1,9 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in build-files.gemspec
4
- gemspec
5
-
6
- group :test do
7
- gem 'rb-fsevent'
8
- gem 'rb-inotify'
9
- end
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.