ichiban 1.0.9 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/ichiban/watcher.rb +37 -26
  2. metadata +1 -1
@@ -11,33 +11,11 @@ module Ichiban
11
11
 
12
12
  Ichiban.logger.out 'Starting watcher'
13
13
  begin
14
- @listener = Listen.to(
15
- File.join(Ichiban.project_root, 'html'),
16
- File.join(Ichiban.project_root, 'layouts'),
17
- File.join(Ichiban.project_root, 'assets'),
18
- File.join(Ichiban.project_root, 'models'),
19
- File.join(Ichiban.project_root, 'helpers'),
20
- File.join(Ichiban.project_root, 'scripts'),
21
- File.join(Ichiban.project_root, 'data'),
22
- File.join(Ichiban.project_root, 'webserver'),
23
- ignore: /.listen_test$/,
24
- latency: @options[:latency],
25
- ) do |modified, added, deleted|
26
- (modified + added).uniq.each do |path|
27
- if file = Ichiban::ProjectFile.from_abs(path)
28
- @loader.change(file) # Tell the Loader that this file has changed
29
- begin
30
- file.update
31
- rescue => exc
32
- Ichiban.logger.exception(exc)
33
- end
34
- end
35
- end
36
- deleted.each do |path|
37
- Ichiban::Deleter.new.delete_dest(path)
38
- end
14
+ if blocking
15
+ boot_listen_gem
16
+ else
17
+ Thread.new { boot_listen_gem }
39
18
  end
40
- @listener.start
41
19
  rescue Interrupt
42
20
  Ichiban.logger.out "Stopping watcher"
43
21
  exit 0
@@ -51,5 +29,38 @@ module Ichiban
51
29
  @listener = nil
52
30
  end
53
31
  end
32
+
33
+ private
34
+
35
+ def boot_listen_gem
36
+ @listener = Listen.to(
37
+ File.join(Ichiban.project_root, 'html'),
38
+ File.join(Ichiban.project_root, 'layouts'),
39
+ File.join(Ichiban.project_root, 'assets'),
40
+ File.join(Ichiban.project_root, 'models'),
41
+ File.join(Ichiban.project_root, 'helpers'),
42
+ File.join(Ichiban.project_root, 'scripts'),
43
+ File.join(Ichiban.project_root, 'data'),
44
+ File.join(Ichiban.project_root, 'webserver'),
45
+ ignore: /.listen_test$/,
46
+ latency: @options[:latency],
47
+ ) do |modified, added, deleted|
48
+ (modified + added).uniq.each do |path|
49
+ if file = Ichiban::ProjectFile.from_abs(path)
50
+ @loader.change(file) # Tell the Loader that this file has changed
51
+ begin
52
+ file.update
53
+ rescue => exc
54
+ Ichiban.logger.exception(exc)
55
+ end
56
+ end
57
+ end
58
+ deleted.each do |path|
59
+ Ichiban::Deleter.new.delete_dest(path)
60
+ end
61
+ end
62
+ @listener.start
63
+ sleep
64
+ end
54
65
  end
55
66
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ichiban
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: 1.0.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: