rerun 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,22 +1,22 @@
1
- module Rerun
2
- module System
3
-
4
- def mac?
5
- RUBY_PLATFORM =~ /darwin/i
6
- end
7
-
8
- def windows?
9
- RUBY_PLATFORM =~ /mswin/i
10
- end
11
-
12
- def linux?
13
- RUBY_PLATFORM =~ /linux/i
14
- end
15
-
16
- def rails?
17
- rails_sig_file = File.expand_path(".")+"/config/boot.rb"
18
- File.exists? rails_sig_file
19
- end
20
-
21
- end
22
- end
1
+ module Rerun
2
+ module System
3
+
4
+ def mac?
5
+ RUBY_PLATFORM =~ /darwin/i
6
+ end
7
+
8
+ def windows?
9
+ RUBY_PLATFORM =~ /(mswin|mingw32)/i
10
+ end
11
+
12
+ def linux?
13
+ RUBY_PLATFORM =~ /linux/i
14
+ end
15
+
16
+ def rails?
17
+ rails_sig_file = File.expand_path(".")+"/config/boot.rb"
18
+ File.exists? rails_sig_file
19
+ end
20
+
21
+ end
22
+ end
@@ -1,119 +1,130 @@
1
- require 'listen'
2
-
3
- Thread.abort_on_exception = true
4
-
5
- # This class will watch a directory and alert you of
6
- # new files, modified files, deleted files.
7
- #
8
- # Now uses the Listen gem, but spawns its own thread on top.
9
- # We should probably be accessing the Listen thread directly.
10
- #
11
- # Author: Alex Chaffee
12
- #
13
- module Rerun
14
- class Watcher
15
- InvalidDirectoryError = Class.new(RuntimeError)
16
-
17
- #def self.default_ignore
18
- # Listen::Silencer.new(Listen::Listener.new).send :_default_ignore_patterns
19
- #end
20
-
21
- attr_reader :directory, :pattern, :priority
22
-
23
- # Create a file system watcher. Start it by calling #start.
24
- #
25
- # @param options[:directory] the directory to watch (default ".")
26
- # @param options[:pattern] the glob pattern to search under the watched directory (default "**/*")
27
- # @param options[:priority] the priority of the watcher thread (default 0)
28
- #
29
- def initialize(options = {}, &client_callback)
30
- @client_callback = client_callback
31
-
32
- options = {
33
- :directory => ".",
34
- :pattern => "**/*",
35
- :priority => 0,
36
- }.merge(options)
37
-
38
- @pattern = options[:pattern]
39
- @directories = options[:directory]
40
- @directories = sanitize_dirs(@directories)
41
- @priority = options[:priority]
42
- @ignore = [options[:ignore]].flatten.compact
43
- @thread = nil
44
- end
45
-
46
- def sanitize_dirs(dirs)
47
- dirs = [*dirs]
48
- dirs.map do |d|
49
- d.chomp!("/")
50
- unless FileTest.exists?(d) && FileTest.readable?(d) && FileTest.directory?(d)
51
- raise InvalidDirectoryError, "Directory '#{d}' either doesnt exist or isn't readable"
52
- end
53
- File.expand_path(d)
54
- end
55
- end
56
-
57
- def start
58
- if @thread then
59
- raise RuntimeError, "already started"
60
- end
61
-
62
- @thread = Thread.new do
63
- @listener = Listen.to(*@directories, only: watching, ignore: ignoring, wait_for_delay: 1) do |modified, added, removed|
64
- if((modified.size + added.size + removed.size) > 0)
65
- @client_callback.call(:modified => modified, :added => added, :removed => removed)
66
- end
67
- end
68
- @listener.start
69
- end
70
-
71
- @thread.priority = @priority
72
-
73
- sleep 0.1 until @listener
74
-
75
- at_exit { stop } # try really hard to clean up after ourselves
76
- end
77
-
78
- def watching
79
- Rerun::Glob.new(@pattern).to_regexp
80
- end
81
-
82
- def ignoring
83
- # todo: --no-ignore-dotfiles
84
- dotfiles = /^\.[^.]/ # at beginning of string, a real dot followed by any other character
85
- [dotfiles] + @ignore.map { |x| Rerun::Glob.new(x).to_regexp }
86
- end
87
-
88
- # kill the file watcher thread
89
- def stop
90
- @thread.wakeup rescue ThreadError
91
- begin
92
- @listener.stop
93
- rescue Exception => e
94
- puts "#{e.class}: #{e.message} stopping listener"
95
- end
96
- @thread.kill rescue ThreadError
97
- end
98
-
99
- # wait for the file watcher to finish
100
- def join
101
- @thread.join if @thread
102
- rescue Interrupt => e
103
- # don't care
104
- end
105
-
106
- def pause
107
- @listener.pause if @listener
108
- end
109
-
110
- def unpause
111
- @listener.start if @listener
112
- end
113
-
114
- def running?
115
- @listener && @listener.processing?
116
- end
117
-
118
- end
119
- end
1
+ require 'listen'
2
+
3
+ Thread.abort_on_exception = true
4
+
5
+ # This class will watch a directory and alert you of
6
+ # new files, modified files, deleted files.
7
+ #
8
+ # Now uses the Listen gem, but spawns its own thread on top.
9
+ # We should probably be accessing the Listen thread directly.
10
+ #
11
+ # Author: Alex Chaffee
12
+ #
13
+ module Rerun
14
+ class Watcher
15
+ InvalidDirectoryError = Class.new(RuntimeError)
16
+
17
+ #def self.default_ignore
18
+ # Listen::Silencer.new(Listen::Listener.new).send :_default_ignore_patterns
19
+ #end
20
+
21
+ attr_reader :directory, :pattern, :priority
22
+
23
+ # Create a file system watcher. Start it by calling #start.
24
+ #
25
+ # @param options[:directory] the directory to watch (default ".")
26
+ # @param options[:pattern] the glob pattern to search under the watched directory (default "**/*")
27
+ # @param options[:priority] the priority of the watcher thread (default 0)
28
+ #
29
+ def initialize(options = {}, &client_callback)
30
+ @client_callback = client_callback
31
+
32
+ options = {
33
+ :directory => ".",
34
+ :pattern => "**/*",
35
+ :priority => 0,
36
+ }.merge(options)
37
+
38
+ @pattern = options[:pattern]
39
+ @directories = options[:directory]
40
+ @directories = sanitize_dirs(@directories)
41
+ @priority = options[:priority]
42
+ @force_polling = options[:force_polling]
43
+ @ignore = [options[:ignore]].flatten.compact
44
+ @thread = nil
45
+ end
46
+
47
+ def sanitize_dirs(dirs)
48
+ dirs = [*dirs]
49
+ dirs.map do |d|
50
+ d.chomp!("/")
51
+ unless FileTest.exists?(d) && FileTest.readable?(d) && FileTest.directory?(d)
52
+ raise InvalidDirectoryError, "Directory '#{d}' either doesnt exist or isn't readable"
53
+ end
54
+ File.expand_path(d)
55
+ end
56
+ end
57
+
58
+ def start
59
+ if @thread then
60
+ raise RuntimeError, "already started"
61
+ end
62
+
63
+ @thread = Thread.new do
64
+ @listener = Listen.to(*@directories, only: watching, ignore: ignoring, wait_for_delay: 1, force_polling: @force_polling) do |modified, added, removed|
65
+ if((modified.size + added.size + removed.size) > 0)
66
+ @client_callback.call(:modified => modified, :added => added, :removed => removed)
67
+ end
68
+ end
69
+ @listener.start
70
+ end
71
+
72
+ @thread.priority = @priority
73
+
74
+ sleep 0.1 until @listener
75
+
76
+ at_exit { stop } # try really hard to clean up after ourselves
77
+ end
78
+
79
+ def watching
80
+ Rerun::Glob.new(@pattern).to_regexp
81
+ end
82
+
83
+ def ignoring
84
+ # todo: --no-ignore-dotfiles
85
+ dotfiles = /^\.[^.]/ # at beginning of string, a real dot followed by any other character
86
+ [dotfiles] + @ignore.map { |x| Rerun::Glob.new(x).to_regexp }
87
+ end
88
+
89
+ # kill the file watcher thread
90
+ def stop
91
+ @thread.wakeup rescue ThreadError
92
+ begin
93
+ @listener.stop
94
+ rescue Exception => e
95
+ puts "#{e.class}: #{e.message} stopping listener"
96
+ end
97
+ @thread.kill rescue ThreadError
98
+ end
99
+
100
+ # wait for the file watcher to finish
101
+ def join
102
+ @thread.join if @thread
103
+ rescue Interrupt => e
104
+ # don't care
105
+ end
106
+
107
+ def pause
108
+ @listener.pause if @listener
109
+ end
110
+
111
+ def unpause
112
+ @listener.start if @listener
113
+ end
114
+
115
+ def running?
116
+ @listener && @listener.processing?
117
+ end
118
+
119
+ def adapter
120
+ @listener &&
121
+ (backend = @listener.instance_variable_get(:@backend)) &&
122
+ backend.instance_variable_get(:@adapter)
123
+ end
124
+
125
+ def adapter_name
126
+ adapter && adapter.class.name.split('::').last
127
+ end
128
+
129
+ end
130
+ end
@@ -1,34 +1,34 @@
1
- $spec = Gem::Specification.new do |s|
2
- s.specification_version = 2 if s.respond_to? :specification_version=
3
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4
-
5
- s.name = 'rerun'
6
- s.version = '0.11.0'
7
-
8
- s.description = "Restarts your app when a file changes. A no-frills, command-line alternative to Guard, Shotgun, Autotest, etc."
9
- s.summary = "Launches an app, and restarts it whenever the filesystem changes. A no-frills, command-line alternative to Guard, Shotgun, Autotest, etc."
10
-
11
- s.authors = ["Alex Chaffee"]
12
- s.email = "alex@stinky.com"
13
-
14
- s.files = %w[
15
- README.md
16
- LICENSE
17
- Rakefile
18
- rerun.gemspec
19
- bin/rerun
20
- icons/rails_grn_sml.png
21
- icons/rails_red_sml.png] +
22
- Dir['lib/**/*.rb']
23
- s.executables = ['rerun']
24
- s.test_files = s.files.select {|path| path =~ /^spec\/.*_spec.rb/}
25
-
26
- s.extra_rdoc_files = %w[README.md]
27
-
28
- s.add_runtime_dependency 'listen', '~> 3.0'
29
-
30
- s.homepage = "http://github.com/alexch/rerun/"
31
- s.require_paths = %w[lib]
32
-
33
- s.license = 'MIT'
34
- end
1
+ $spec = Gem::Specification.new do |s|
2
+ s.specification_version = 2 if s.respond_to? :specification_version=
3
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4
+
5
+ s.name = 'rerun'
6
+ s.version = '0.12.0'
7
+
8
+ s.description = "Restarts your app when a file changes. A no-frills, command-line alternative to Guard, Shotgun, Autotest, etc."
9
+ s.summary = "Launches an app, and restarts it whenever the filesystem changes. A no-frills, command-line alternative to Guard, Shotgun, Autotest, etc."
10
+
11
+ s.authors = ["Alex Chaffee"]
12
+ s.email = "alex@stinky.com"
13
+
14
+ s.files = %w[
15
+ README.md
16
+ LICENSE
17
+ Rakefile
18
+ rerun.gemspec
19
+ bin/rerun
20
+ icons/rails_grn_sml.png
21
+ icons/rails_red_sml.png] +
22
+ Dir['lib/**/*.rb']
23
+ s.executables = ['rerun']
24
+ s.test_files = s.files.select {|path| path =~ /^spec\/.*_spec.rb/}
25
+
26
+ s.extra_rdoc_files = %w[README.md]
27
+
28
+ s.add_runtime_dependency 'listen', '~> 3.0'
29
+
30
+ s.homepage = "http://github.com/alexch/rerun/"
31
+ s.require_paths = %w[lib]
32
+
33
+ s.license = 'MIT'
34
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rerun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Chaffee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-07 00:00:00.000000000 Z
11
+ date: 2018-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: listen
@@ -39,6 +39,7 @@ files:
39
39
  - bin/rerun
40
40
  - icons/rails_grn_sml.png
41
41
  - icons/rails_red_sml.png
42
+ - lib/goo.rb
42
43
  - lib/rerun.rb
43
44
  - lib/rerun/glob.rb
44
45
  - lib/rerun/notification.rb
@@ -67,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
68
  version: '0'
68
69
  requirements: []
69
70
  rubyforge_project:
70
- rubygems_version: 2.4.8
71
+ rubygems_version: 2.5.2
71
72
  signing_key:
72
73
  specification_version: 2
73
74
  summary: Launches an app, and restarts it whenever the filesystem changes. A no-frills,