sass-listen 3.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +1 -0
- data/CONTRIBUTING.md +38 -0
- data/LICENSE.txt +22 -0
- data/README.md +297 -0
- data/bin/listen +12 -0
- data/lib/listen.rb +55 -0
- data/lib/listen/adapter.rb +43 -0
- data/lib/listen/adapter/base.rb +137 -0
- data/lib/listen/adapter/bsd.rb +106 -0
- data/lib/listen/adapter/config.rb +26 -0
- data/lib/listen/adapter/darwin.rb +71 -0
- data/lib/listen/adapter/linux.rb +106 -0
- data/lib/listen/adapter/polling.rb +37 -0
- data/lib/listen/adapter/windows.rb +99 -0
- data/lib/listen/backend.rb +41 -0
- data/lib/listen/change.rb +78 -0
- data/lib/listen/cli.rb +65 -0
- data/lib/listen/directory.rb +76 -0
- data/lib/listen/event/config.rb +59 -0
- data/lib/listen/event/loop.rb +117 -0
- data/lib/listen/event/processor.rb +122 -0
- data/lib/listen/event/queue.rb +56 -0
- data/lib/listen/file.rb +80 -0
- data/lib/listen/fsm.rb +131 -0
- data/lib/listen/internals/thread_pool.rb +21 -0
- data/lib/listen/listener.rb +132 -0
- data/lib/listen/listener/config.rb +45 -0
- data/lib/listen/logger.rb +32 -0
- data/lib/listen/options.rb +23 -0
- data/lib/listen/queue_optimizer.rb +132 -0
- data/lib/listen/record.rb +120 -0
- data/lib/listen/record/entry.rb +51 -0
- data/lib/listen/record/symlink_detector.rb +39 -0
- data/lib/listen/silencer.rb +97 -0
- data/lib/listen/silencer/controller.rb +48 -0
- data/lib/listen/version.rb +3 -0
- metadata +124 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
module Listen
|
2
|
+
# @private api
|
3
|
+
class Record
|
4
|
+
# Represents a directory entry (dir or file)
|
5
|
+
class Entry
|
6
|
+
# file: "/home/me/watched_dir", "app/models", "foo.rb"
|
7
|
+
# dir, "/home/me/watched_dir", "."
|
8
|
+
def initialize(root, relative, name = nil)
|
9
|
+
@root, @relative, @name = root, relative, name
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_reader :root, :relative, :name
|
13
|
+
|
14
|
+
def children
|
15
|
+
child_relative = _join
|
16
|
+
(Dir.entries(sys_path) - %w(. ..)).map do |name|
|
17
|
+
Entry.new(@root, child_relative, name)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def meta
|
22
|
+
lstat = ::File.lstat(sys_path)
|
23
|
+
{ mtime: lstat.mtime.to_f, mode: lstat.mode }
|
24
|
+
end
|
25
|
+
|
26
|
+
# record hash is e.g.
|
27
|
+
# if @record["/home/me/watched_dir"]["project/app/models"]["foo.rb"]
|
28
|
+
# if @record["/home/me/watched_dir"]["project/app"]["models"]
|
29
|
+
# record_dir_key is "project/app/models"
|
30
|
+
def record_dir_key
|
31
|
+
::File.join(*[@relative, @name].compact)
|
32
|
+
end
|
33
|
+
|
34
|
+
def sys_path
|
35
|
+
# Use full path in case someone uses chdir
|
36
|
+
::File.join(*[@root, @relative, @name].compact)
|
37
|
+
end
|
38
|
+
|
39
|
+
def real_path
|
40
|
+
@real_path ||= ::File.realpath(sys_path)
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def _join
|
46
|
+
args = [@relative, @name].compact
|
47
|
+
args.empty? ? nil : ::File.join(*args)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
module Listen
|
4
|
+
# @private api
|
5
|
+
class Record
|
6
|
+
class SymlinkDetector
|
7
|
+
WIKI = 'https://github.com/guard/listen/wiki/Duplicate-directory-errors'
|
8
|
+
|
9
|
+
SYMLINK_LOOP_ERROR = <<-EOS
|
10
|
+
** ERROR: directory is already being watched! **
|
11
|
+
|
12
|
+
Directory: %s
|
13
|
+
|
14
|
+
is already being watched through: %s
|
15
|
+
|
16
|
+
MORE INFO: #{WIKI}
|
17
|
+
EOS
|
18
|
+
|
19
|
+
class Error < RuntimeError
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
@real_dirs = Set.new
|
24
|
+
end
|
25
|
+
|
26
|
+
def verify_unwatched!(entry)
|
27
|
+
real_path = entry.real_path
|
28
|
+
@real_dirs.add?(real_path) || _fail(entry.sys_path, real_path)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def _fail(symlinked, real_path)
|
34
|
+
STDERR.puts format(SYMLINK_LOOP_ERROR, symlinked, real_path)
|
35
|
+
fail Error, 'Failed due to looped symlinks'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module Listen
|
2
|
+
class Silencer
|
3
|
+
# The default list of directories that get ignored.
|
4
|
+
DEFAULT_IGNORED_DIRECTORIES = %r{^(?:
|
5
|
+
\.git
|
6
|
+
| \.svn
|
7
|
+
| \.hg
|
8
|
+
| \.rbx
|
9
|
+
| \.bundle
|
10
|
+
| bundle
|
11
|
+
| vendor/bundle
|
12
|
+
| log
|
13
|
+
| tmp
|
14
|
+
|vendor/ruby
|
15
|
+
)(/|$)}x
|
16
|
+
|
17
|
+
# The default list of files that get ignored.
|
18
|
+
DEFAULT_IGNORED_EXTENSIONS = /(?:
|
19
|
+
# Kate's tmp\/swp files
|
20
|
+
\..*\d+\.new
|
21
|
+
| \.kate-swp
|
22
|
+
|
23
|
+
# Gedit tmp files
|
24
|
+
| \.goutputstream-.{6}
|
25
|
+
|
26
|
+
# Intellij files
|
27
|
+
| ___jb_bak___
|
28
|
+
| ___jb_old___
|
29
|
+
|
30
|
+
# Vim swap files and write test
|
31
|
+
| \.sw[px]
|
32
|
+
| \.swpx
|
33
|
+
| ^4913
|
34
|
+
|
35
|
+
# Sed temporary files - but without actual words, like 'sedatives'
|
36
|
+
| (?:^
|
37
|
+
sed
|
38
|
+
|
39
|
+
(?:
|
40
|
+
[a-zA-Z0-9]{0}[A-Z]{1}[a-zA-Z0-9]{5} |
|
41
|
+
[a-zA-Z0-9]{1}[A-Z]{1}[a-zA-Z0-9]{4} |
|
42
|
+
[a-zA-Z0-9]{2}[A-Z]{1}[a-zA-Z0-9]{3} |
|
43
|
+
[a-zA-Z0-9]{3}[A-Z]{1}[a-zA-Z0-9]{2} |
|
44
|
+
[a-zA-Z0-9]{4}[A-Z]{1}[a-zA-Z0-9]{1} |
|
45
|
+
[a-zA-Z0-9]{5}[A-Z]{1}[a-zA-Z0-9]{0}
|
46
|
+
)
|
47
|
+
)
|
48
|
+
|
49
|
+
# other files
|
50
|
+
| \.DS_Store
|
51
|
+
| \.tmp
|
52
|
+
| ~
|
53
|
+
)$/x
|
54
|
+
|
55
|
+
attr_accessor :only_patterns, :ignore_patterns
|
56
|
+
|
57
|
+
def initialize
|
58
|
+
configure({})
|
59
|
+
end
|
60
|
+
|
61
|
+
def configure(options)
|
62
|
+
@only_patterns = options[:only] ? Array(options[:only]) : nil
|
63
|
+
@ignore_patterns = _init_ignores(options[:ignore], options[:ignore!])
|
64
|
+
end
|
65
|
+
|
66
|
+
# Note: relative_path is temporarily expected to be a relative Pathname to
|
67
|
+
# make refactoring easier (ideally, it would take a string)
|
68
|
+
|
69
|
+
# TODO: switch type and path places - and verify
|
70
|
+
def silenced?(relative_path, type)
|
71
|
+
path = relative_path.to_s
|
72
|
+
|
73
|
+
if only_patterns && type == :file
|
74
|
+
return true unless only_patterns.any? { |pattern| path =~ pattern }
|
75
|
+
end
|
76
|
+
|
77
|
+
ignore_patterns.any? { |pattern| path =~ pattern }
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
attr_reader :options
|
83
|
+
|
84
|
+
def _init_ignores(ignores, overrides)
|
85
|
+
patterns = []
|
86
|
+
unless overrides
|
87
|
+
patterns << DEFAULT_IGNORED_DIRECTORIES
|
88
|
+
patterns << DEFAULT_IGNORED_EXTENSIONS
|
89
|
+
end
|
90
|
+
|
91
|
+
patterns << ignores
|
92
|
+
patterns << overrides
|
93
|
+
|
94
|
+
patterns.compact.flatten
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Listen
|
2
|
+
class Silencer
|
3
|
+
class Controller
|
4
|
+
def initialize(silencer, default_options)
|
5
|
+
@silencer = silencer
|
6
|
+
|
7
|
+
opts = default_options
|
8
|
+
|
9
|
+
@prev_silencer_options = {}
|
10
|
+
rules = [:only, :ignore, :ignore!].map do |option|
|
11
|
+
[option, opts[option]] if opts.key? option
|
12
|
+
end
|
13
|
+
|
14
|
+
_reconfigure_silencer(Hash[rules.compact])
|
15
|
+
end
|
16
|
+
|
17
|
+
def append_ignores(*regexps)
|
18
|
+
prev_ignores = Array(@prev_silencer_options[:ignore])
|
19
|
+
_reconfigure_silencer(ignore: [prev_ignores + regexps])
|
20
|
+
end
|
21
|
+
|
22
|
+
def replace_with_bang_ignores(regexps)
|
23
|
+
_reconfigure_silencer(ignore!: regexps)
|
24
|
+
end
|
25
|
+
|
26
|
+
def replace_with_only(regexps)
|
27
|
+
_reconfigure_silencer(only: regexps)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def _reconfigure_silencer(extra_options)
|
33
|
+
opts = extra_options.dup
|
34
|
+
opts = opts.map do |key, value|
|
35
|
+
[key, Array(value).flatten.compact]
|
36
|
+
end
|
37
|
+
opts = Hash[opts]
|
38
|
+
|
39
|
+
if opts.key?(:ignore) && opts[:ignore].empty?
|
40
|
+
opts.delete(:ignore)
|
41
|
+
end
|
42
|
+
|
43
|
+
@prev_silencer_options = opts
|
44
|
+
@silencer.configure(@prev_silencer_options.dup.freeze)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sass-listen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.0.7
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Thibaud Guillaume-Gentil
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rb-fsevent
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.9.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.9.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rb-inotify
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.9.7
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.9.7
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.3.5
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.3.5
|
55
|
+
description: This fork of guard/listen provides a stable API for users of the ruby
|
56
|
+
Sass CLI
|
57
|
+
email: thibaud@thibaud.gg
|
58
|
+
executables:
|
59
|
+
- listen
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- CHANGELOG.md
|
64
|
+
- CONTRIBUTING.md
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- bin/listen
|
68
|
+
- lib/listen.rb
|
69
|
+
- lib/listen/adapter.rb
|
70
|
+
- lib/listen/adapter/base.rb
|
71
|
+
- lib/listen/adapter/bsd.rb
|
72
|
+
- lib/listen/adapter/config.rb
|
73
|
+
- lib/listen/adapter/darwin.rb
|
74
|
+
- lib/listen/adapter/linux.rb
|
75
|
+
- lib/listen/adapter/polling.rb
|
76
|
+
- lib/listen/adapter/windows.rb
|
77
|
+
- lib/listen/backend.rb
|
78
|
+
- lib/listen/change.rb
|
79
|
+
- lib/listen/cli.rb
|
80
|
+
- lib/listen/directory.rb
|
81
|
+
- lib/listen/event/config.rb
|
82
|
+
- lib/listen/event/loop.rb
|
83
|
+
- lib/listen/event/processor.rb
|
84
|
+
- lib/listen/event/queue.rb
|
85
|
+
- lib/listen/file.rb
|
86
|
+
- lib/listen/fsm.rb
|
87
|
+
- lib/listen/internals/thread_pool.rb
|
88
|
+
- lib/listen/listener.rb
|
89
|
+
- lib/listen/listener/config.rb
|
90
|
+
- lib/listen/logger.rb
|
91
|
+
- lib/listen/options.rb
|
92
|
+
- lib/listen/queue_optimizer.rb
|
93
|
+
- lib/listen/record.rb
|
94
|
+
- lib/listen/record/entry.rb
|
95
|
+
- lib/listen/record/symlink_detector.rb
|
96
|
+
- lib/listen/silencer.rb
|
97
|
+
- lib/listen/silencer/controller.rb
|
98
|
+
- lib/listen/version.rb
|
99
|
+
homepage: https://github.com/sass/listen
|
100
|
+
licenses:
|
101
|
+
- MIT
|
102
|
+
metadata: {}
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: 1.9.3
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
requirements: []
|
118
|
+
rubyforge_project:
|
119
|
+
rubygems_version: 2.5.1
|
120
|
+
signing_key:
|
121
|
+
specification_version: 4
|
122
|
+
summary: Fork of guard/listen
|
123
|
+
test_files: []
|
124
|
+
has_rdoc:
|