rerun 0.13.0 → 0.13.1

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|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
+ 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,131 +1,134 @@
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
- count = modified.size + added.size + removed.size
66
- if count > 0
67
- @client_callback.call(:modified => modified, :added => added, :removed => removed)
68
- end
69
- end
70
- @listener.start
71
- end
72
-
73
- @thread.priority = @priority
74
-
75
- sleep 0.1 until @listener
76
-
77
- at_exit { stop } # try really hard to clean up after ourselves
78
- end
79
-
80
- def watching
81
- Rerun::Glob.new(@pattern).to_regexp
82
- end
83
-
84
- def ignoring
85
- # todo: --no-ignore-dotfiles
86
- dotfiles = /^\.[^.]/ # at beginning of string, a real dot followed by any other character
87
- [dotfiles] + @ignore.map { |x| Rerun::Glob.new(x).to_regexp }
88
- end
89
-
90
- # kill the file watcher thread
91
- def stop
92
- @thread.wakeup rescue ThreadError
93
- begin
94
- @listener.stop
95
- rescue Exception => e
96
- puts "#{e.class}: #{e.message} stopping listener"
97
- end
98
- @thread.kill rescue ThreadError
99
- end
100
-
101
- # wait for the file watcher to finish
102
- def join
103
- @thread.join if @thread
104
- rescue Interrupt => e
105
- # don't care
106
- end
107
-
108
- def pause
109
- @listener.pause if @listener
110
- end
111
-
112
- def unpause
113
- @listener.start if @listener
114
- end
115
-
116
- def running?
117
- @listener && @listener.processing?
118
- end
119
-
120
- def adapter
121
- @listener &&
122
- (backend = @listener.instance_variable_get(:@backend)) &&
123
- backend.instance_variable_get(:@adapter)
124
- end
125
-
126
- def adapter_name
127
- adapter && adapter.class.name.split('::').last
128
- end
129
-
130
- end
131
- 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, :ignore_dotfiles
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
+ :ignore_dotfiles => true,
37
+ }.merge(options)
38
+
39
+ @pattern = options[:pattern]
40
+ @directories = options[:directory]
41
+ @directories = sanitize_dirs(@directories)
42
+ @priority = options[:priority]
43
+ @force_polling = options[:force_polling]
44
+ @ignore = [options[:ignore]].flatten.compact
45
+ @ignore_dotfiles = options[:ignore_dotfiles]
46
+ @thread = nil
47
+ end
48
+
49
+ def sanitize_dirs(dirs)
50
+ dirs = [*dirs]
51
+ dirs.map do |d|
52
+ d.chomp!("/")
53
+ unless FileTest.exists?(d) && FileTest.readable?(d) && FileTest.directory?(d)
54
+ raise InvalidDirectoryError, "Directory '#{d}' either doesnt exist or isn't readable"
55
+ end
56
+ File.expand_path(d)
57
+ end
58
+ end
59
+
60
+ def start
61
+ if @thread then
62
+ raise RuntimeError, "already started"
63
+ end
64
+
65
+ @thread = Thread.new do
66
+ @listener = Listen.to(*@directories, only: watching, ignore: ignoring, wait_for_delay: 1, force_polling: @force_polling) do |modified, added, removed|
67
+ count = modified.size + added.size + removed.size
68
+ if count > 0
69
+ @client_callback.call(:modified => modified, :added => added, :removed => removed)
70
+ end
71
+ end
72
+ @listener.start
73
+ end
74
+
75
+ @thread.priority = @priority
76
+
77
+ sleep 0.1 until @listener
78
+
79
+ at_exit { stop } # try really hard to clean up after ourselves
80
+ end
81
+
82
+ def watching
83
+ Rerun::Glob.new(@pattern).to_regexp
84
+ end
85
+
86
+ def ignoring
87
+ patterns = []
88
+ if ignore_dotfiles
89
+ patterns << /^\.[^.]/ # at beginning of string, a real dot followed by any other character
90
+ end
91
+ patterns + @ignore.map { |x| Rerun::Glob.new(x).to_regexp }
92
+ end
93
+
94
+ # kill the file watcher thread
95
+ def stop
96
+ @thread.wakeup rescue ThreadError
97
+ begin
98
+ @listener.stop
99
+ rescue Exception => e
100
+ puts "#{e.class}: #{e.message} stopping listener"
101
+ end
102
+ @thread.kill rescue ThreadError
103
+ end
104
+
105
+ # wait for the file watcher to finish
106
+ def join
107
+ @thread.join if @thread
108
+ rescue Interrupt
109
+ # don't care
110
+ end
111
+
112
+ def pause
113
+ @listener.pause if @listener
114
+ end
115
+
116
+ def unpause
117
+ @listener.start if @listener
118
+ end
119
+
120
+ def running?
121
+ @listener && @listener.processing?
122
+ end
123
+
124
+ def adapter
125
+ @listener &&
126
+ (backend = @listener.instance_variable_get(:@backend)) &&
127
+ backend.instance_variable_get(:@adapter)
128
+ end
129
+
130
+ def adapter_name
131
+ adapter && adapter.class.name.split('::').last
132
+ end
133
+ end
134
+ 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.13.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.13.1'
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.13.0
4
+ version: 0.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Chaffee
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-26 00:00:00.000000000 Z
11
+ date: 2020-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: listen
@@ -52,7 +52,7 @@ homepage: http://github.com/alexch/rerun/
52
52
  licenses:
53
53
  - MIT
54
54
  metadata: {}
55
- post_install_message:
55
+ post_install_message:
56
56
  rdoc_options: []
57
57
  require_paths:
58
58
  - lib
@@ -67,9 +67,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  requirements: []
70
- rubyforge_project:
71
- rubygems_version: 2.5.2
72
- signing_key:
70
+ rubygems_version: 3.1.2
71
+ signing_key:
73
72
  specification_version: 2
74
73
  summary: Launches an app, and restarts it whenever the filesystem changes. A no-frills,
75
74
  command-line alternative to Guard, Shotgun, Autotest, etc.