build-files 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +4 -0
- data/.travis.yml +11 -2
- data/build-files.gemspec +1 -1
- data/lib/build/files/monitor.rb +18 -9
- data/lib/build/files/state.rb +0 -2
- data/lib/build/files/version.rb +1 -1
- data/spec/build/files/list_spec.rb +5 -2
- data/spec/build/files/monitor_spec.rb +7 -7
- data/spec/build/files/path_spec.rb +0 -3
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6489c135e1494d5c883e30ab38832d3a9c2afb9
|
4
|
+
data.tar.gz: a946aca100d97c1d35bf79aedf97af756d30a205
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d9c032e0525bd3f738965bdc030fb210f4c9f164c292b166bc0b9af701e1b14d201e8307d03c0afef26a1ef33dcb1479e04681e680181a3865c1f9bcb9bb285
|
7
|
+
data.tar.gz: f0a7d3c974368967e49ed50e5c0db127830ef8addf8c54efe1e464c6cf5074a622f4f4e0e84c850a2888d9ade1d6be1d53eef763e5687af04cffe28a4b1fea1f
|
data/.rspec
ADDED
data/.travis.yml
CHANGED
data/build-files.gemspec
CHANGED
@@ -21,6 +21,6 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.required_ruby_version = '>= 2.0'
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
-
spec.add_development_dependency "rspec", "~> 3.
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.4.0"
|
25
25
|
spec.add_development_dependency "rake"
|
26
26
|
end
|
data/lib/build/files/monitor.rb
CHANGED
@@ -45,9 +45,13 @@ module Build
|
|
45
45
|
def remove!
|
46
46
|
monitor.delete(self)
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
|
+
# Inform the handle that it might have been modified.
|
49
50
|
def changed!
|
50
|
-
|
51
|
+
# If @state.update! did not find any changes, don't invoke the callback:
|
52
|
+
if @state.update!
|
53
|
+
@on_changed.call(@state)
|
54
|
+
end
|
51
55
|
end
|
52
56
|
end
|
53
57
|
|
@@ -75,6 +79,7 @@ module Build
|
|
75
79
|
@directories[directory].each do |handle|
|
76
80
|
@logger.debug{"Handle changed: #{handle.inspect}"}
|
77
81
|
|
82
|
+
# Changes here may not actually require an update to the handle:
|
78
83
|
handle.changed!(*args)
|
79
84
|
end
|
80
85
|
end
|
@@ -116,16 +121,20 @@ module Build
|
|
116
121
|
handle
|
117
122
|
end
|
118
123
|
|
119
|
-
def
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
+
def default_driver
|
125
|
+
case RUBY_PLATFORM
|
126
|
+
when /linux/i then :inotify
|
127
|
+
when /darwin/i then :fsevent
|
128
|
+
else :polling
|
124
129
|
end
|
125
|
-
|
130
|
+
end
|
131
|
+
|
132
|
+
def run(options = {}, &block)
|
126
133
|
if driver = (options[:driver] || default_driver)
|
127
134
|
method_name = "run_with_#{driver}"
|
128
135
|
Files.send(method_name, self, options, &block)
|
136
|
+
else
|
137
|
+
raise ArgumentError.new("Could not find driver for platform #{RUBY_PLATFORM}!")
|
129
138
|
end
|
130
139
|
end
|
131
140
|
|
@@ -167,7 +176,7 @@ module Build
|
|
167
176
|
catch(:interrupt) do
|
168
177
|
while true
|
169
178
|
monitor.roots.each do |root|
|
170
|
-
notifier.watch root, :create, :modify, :delete do |event|
|
179
|
+
notifier.watch root, :create, :modify, :attrib, :delete do |event|
|
171
180
|
monitor.update([root])
|
172
181
|
|
173
182
|
yield
|
data/lib/build/files/state.rb
CHANGED
data/lib/build/files/version.rb
CHANGED
@@ -150,9 +150,12 @@ module Build::Files::ListSpec
|
|
150
150
|
glob = Glob.new(__dir__, "*.rb")
|
151
151
|
|
152
152
|
paths = glob.with extension: ".txt"
|
153
|
+
path = paths.first
|
153
154
|
|
154
|
-
expect(
|
155
|
-
|
155
|
+
expect(path).to be_kind_of Array
|
156
|
+
|
157
|
+
expect(path[0]).to be == glob.first
|
158
|
+
expect(path[1]).to be == glob.first.append(".txt")
|
156
159
|
end
|
157
160
|
|
158
161
|
it "should define an empty set of files" do
|
@@ -53,17 +53,17 @@ module Build::Files::MonitorSpec
|
|
53
53
|
end
|
54
54
|
|
55
55
|
touched = false
|
56
|
+
triggered = 0
|
56
57
|
|
57
58
|
thread = Thread.new do
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
59
|
+
while triggered == 0 or touched == false
|
60
|
+
sleep 0.1 if touched
|
61
|
+
|
62
|
+
path.touch
|
63
|
+
touched = true
|
64
|
+
end
|
63
65
|
end
|
64
66
|
|
65
|
-
triggered = 0
|
66
|
-
|
67
67
|
monitor.run(driver: driver) do
|
68
68
|
triggered += 1
|
69
69
|
|
@@ -92,9 +92,6 @@ module Build::Files::PathSpec
|
|
92
92
|
end
|
93
93
|
|
94
94
|
it "should give the shortest path for outer paths" do
|
95
|
-
spec_path = Path.new(__FILE__)
|
96
|
-
source_path = Path.new(File.expand_path("../../../lib/build/files/list.rb"))
|
97
|
-
|
98
95
|
input = Path.new("/a/b/c/file.cpp")
|
99
96
|
output = Path.new("/a/b/c/d/e/")
|
100
97
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: build-files
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 3.
|
33
|
+
version: 3.4.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 3.
|
40
|
+
version: 3.4.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,6 +59,7 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
+
- ".rspec"
|
62
63
|
- ".simplecov"
|
63
64
|
- ".travis.yml"
|
64
65
|
- Gemfile
|
@@ -102,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
103
|
version: '0'
|
103
104
|
requirements: []
|
104
105
|
rubyforge_project:
|
105
|
-
rubygems_version: 2.
|
106
|
+
rubygems_version: 2.4.6
|
106
107
|
signing_key:
|
107
108
|
specification_version: 4
|
108
109
|
summary: Build::Files is a set of idiomatic classes for dealing with paths and monitoring
|