sass 3.3.0.rc.1 → 3.3.0.rc.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/VERSION_DATE +1 -1
- data/lib/sass.rb +5 -0
- data/lib/sass/engine.rb +3 -5
- data/lib/sass/plugin.rb +0 -1
- data/lib/sass/plugin/compiler.rb +1 -2
- data/lib/sass/script/functions.rb +16 -2
- data/lib/sass/script/lexer.rb +22 -12
- data/lib/sass/script/parser.rb +27 -14
- data/lib/sass/script/tree/variable.rb +1 -1
- data/lib/sass/script/value/base.rb +1 -1
- data/lib/sass/script/value/color.rb +29 -17
- data/lib/sass/script/value/list.rb +1 -1
- data/lib/sass/script/value/number.rb +8 -1
- data/lib/sass/scss/parser.rb +2 -2
- data/lib/sass/selector/sequence.rb +18 -19
- data/lib/sass/selector/simple_sequence.rb +5 -5
- data/lib/sass/source/map.rb +1 -1
- data/lib/sass/tree/node.rb +25 -0
- data/lib/sass/tree/variable_node.rb +5 -0
- data/lib/sass/tree/visitors/base.rb +4 -7
- data/lib/sass/tree/visitors/check_nesting.rb +2 -2
- data/lib/sass/tree/visitors/perform.rb +12 -7
- data/lib/sass/util.rb +95 -50
- data/lib/sass/util/normalized_map.rb +63 -14
- data/lib/sass/util/ordered_hash.rb +9 -5
- data/lib/sass/version.rb +10 -12
- data/test/sass/engine_test.rb +37 -0
- data/test/sass/functions_test.rb +9 -2
- data/test/sass/importer_test.rb +3 -3
- data/test/sass/script_test.rb +12 -10
- data/test/sass/source_map_test.rb +8 -8
- data/test/sass/util/normalized_map_test.rb +22 -1
- data/test/sass/util_test.rb +18 -0
- data/test/test_helper.rb +16 -0
- data/vendor/listen/CHANGELOG.md +228 -0
- data/vendor/listen/CONTRIBUTING.md +38 -0
- data/vendor/listen/Gemfile +30 -0
- data/vendor/listen/Guardfile +8 -0
- data/vendor/listen/LICENSE +20 -0
- data/vendor/listen/README.md +315 -0
- data/vendor/listen/Rakefile +47 -0
- data/vendor/listen/Vagrantfile +96 -0
- data/vendor/listen/lib/listen.rb +40 -0
- data/vendor/listen/lib/listen/adapter.rb +214 -0
- data/vendor/listen/lib/listen/adapters/bsd.rb +112 -0
- data/vendor/listen/lib/listen/adapters/darwin.rb +85 -0
- data/vendor/listen/lib/listen/adapters/linux.rb +113 -0
- data/vendor/listen/lib/listen/adapters/polling.rb +67 -0
- data/vendor/listen/lib/listen/adapters/windows.rb +87 -0
- data/vendor/listen/lib/listen/dependency_manager.rb +126 -0
- data/vendor/listen/lib/listen/directory_record.rb +371 -0
- data/vendor/listen/lib/listen/listener.rb +225 -0
- data/vendor/listen/lib/listen/multi_listener.rb +143 -0
- data/vendor/listen/lib/listen/turnstile.rb +28 -0
- data/vendor/listen/lib/listen/version.rb +3 -0
- data/vendor/listen/listen.gemspec +22 -0
- data/vendor/listen/spec/listen/adapter_spec.rb +183 -0
- data/vendor/listen/spec/listen/adapters/bsd_spec.rb +36 -0
- data/vendor/listen/spec/listen/adapters/darwin_spec.rb +37 -0
- data/vendor/listen/spec/listen/adapters/linux_spec.rb +47 -0
- data/vendor/listen/spec/listen/adapters/polling_spec.rb +68 -0
- data/vendor/listen/spec/listen/adapters/windows_spec.rb +30 -0
- data/vendor/listen/spec/listen/dependency_manager_spec.rb +107 -0
- data/vendor/listen/spec/listen/directory_record_spec.rb +1225 -0
- data/vendor/listen/spec/listen/listener_spec.rb +169 -0
- data/vendor/listen/spec/listen/multi_listener_spec.rb +174 -0
- data/vendor/listen/spec/listen/turnstile_spec.rb +56 -0
- data/vendor/listen/spec/listen_spec.rb +73 -0
- data/vendor/listen/spec/spec_helper.rb +21 -0
- data/vendor/listen/spec/support/adapter_helper.rb +629 -0
- data/vendor/listen/spec/support/directory_record_helper.rb +55 -0
- data/vendor/listen/spec/support/fixtures_helper.rb +29 -0
- data/vendor/listen/spec/support/listeners_helper.rb +156 -0
- data/vendor/listen/spec/support/platform_helper.rb +15 -0
- metadata +318 -300
- data/test/Gemfile.lock +0 -10
@@ -0,0 +1,85 @@
|
|
1
|
+
module Listen
|
2
|
+
module Adapters
|
3
|
+
|
4
|
+
# Adapter implementation for Mac OS X `FSEvents`.
|
5
|
+
#
|
6
|
+
class Darwin < Adapter
|
7
|
+
extend DependencyManager
|
8
|
+
|
9
|
+
# Declare the adapter's dependencies
|
10
|
+
dependency 'rb-fsevent', '~> 0.9'
|
11
|
+
|
12
|
+
LAST_SEPARATOR_REGEX = /\/$/
|
13
|
+
|
14
|
+
# Initializes the Adapter. See {Listen::Adapter#initialize} for more info.
|
15
|
+
#
|
16
|
+
def initialize(directories, options = {}, &callback)
|
17
|
+
super
|
18
|
+
@worker = init_worker
|
19
|
+
end
|
20
|
+
|
21
|
+
# Starts the adapter.
|
22
|
+
#
|
23
|
+
# @param [Boolean] blocking whether or not to block the current thread after starting
|
24
|
+
#
|
25
|
+
def start(blocking = true)
|
26
|
+
@mutex.synchronize do
|
27
|
+
return if @stop == false
|
28
|
+
super
|
29
|
+
end
|
30
|
+
|
31
|
+
@worker_thread = Thread.new { @worker.run }
|
32
|
+
|
33
|
+
# The FSEvent worker needs sometime to startup. Turnstiles can't
|
34
|
+
# be used to wait for it as it runs in a loop.
|
35
|
+
# TODO: Find a better way to block until the worker starts.
|
36
|
+
sleep 0.1
|
37
|
+
|
38
|
+
@poll_thread = Thread.new { poll_changed_dirs } if @report_changes
|
39
|
+
@worker_thread.join if blocking
|
40
|
+
end
|
41
|
+
|
42
|
+
# Stops the adapter.
|
43
|
+
#
|
44
|
+
def stop
|
45
|
+
@mutex.synchronize do
|
46
|
+
return if @stop == true
|
47
|
+
super
|
48
|
+
end
|
49
|
+
|
50
|
+
@worker.stop
|
51
|
+
@worker_thread.join if @worker_thread
|
52
|
+
@poll_thread.join if @poll_thread
|
53
|
+
end
|
54
|
+
|
55
|
+
# Checks if the adapter is usable on the current OS.
|
56
|
+
#
|
57
|
+
# @return [Boolean] whether usable or not
|
58
|
+
#
|
59
|
+
def self.usable?
|
60
|
+
return false unless RbConfig::CONFIG['target_os'] =~ /darwin(1.+)?$/i
|
61
|
+
super
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
# Initializes a FSEvent worker and adds a watcher for
|
67
|
+
# each directory passed to the adapter.
|
68
|
+
#
|
69
|
+
# @return [FSEvent] initialized worker
|
70
|
+
#
|
71
|
+
def init_worker
|
72
|
+
FSEvent.new.tap do |worker|
|
73
|
+
worker.watch(@directories.dup, :latency => @latency) do |changes|
|
74
|
+
next if @paused
|
75
|
+
@mutex.synchronize do
|
76
|
+
changes.each { |path| @changed_dirs << path.sub(LAST_SEPARATOR_REGEX, '') }
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
module Listen
|
2
|
+
module Adapters
|
3
|
+
|
4
|
+
# Listener implementation for Linux `inotify`.
|
5
|
+
#
|
6
|
+
class Linux < Adapter
|
7
|
+
extend DependencyManager
|
8
|
+
|
9
|
+
# Declare the adapter's dependencies
|
10
|
+
dependency 'rb-inotify', '~> 0.9'
|
11
|
+
|
12
|
+
# Watched inotify events
|
13
|
+
#
|
14
|
+
# @see http://www.tin.org/bin/man.cgi?section=7&topic=inotify
|
15
|
+
# @see https://github.com/nex3/rb-inotify/blob/master/lib/rb-inotify/notifier.rb#L99-L177
|
16
|
+
#
|
17
|
+
EVENTS = %w[recursive attrib create delete move close_write]
|
18
|
+
|
19
|
+
# The message to show when the limit of inotify watchers is not enough
|
20
|
+
#
|
21
|
+
INOTIFY_LIMIT_MESSAGE = <<-EOS.gsub(/^\s*/, '')
|
22
|
+
Listen error: unable to monitor directories for changes.
|
23
|
+
|
24
|
+
Please head to https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers
|
25
|
+
for information on how to solve this issue.
|
26
|
+
EOS
|
27
|
+
|
28
|
+
# Initializes the Adapter. See {Listen::Adapter#initialize} for more info.
|
29
|
+
#
|
30
|
+
def initialize(directories, options = {}, &callback)
|
31
|
+
super
|
32
|
+
@worker = init_worker
|
33
|
+
rescue Errno::ENOSPC
|
34
|
+
abort(INOTIFY_LIMIT_MESSAGE)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Starts the adapter.
|
38
|
+
#
|
39
|
+
# @param [Boolean] blocking whether or not to block the current thread after starting
|
40
|
+
#
|
41
|
+
def start(blocking = true)
|
42
|
+
@mutex.synchronize do
|
43
|
+
return if @stop == false
|
44
|
+
super
|
45
|
+
end
|
46
|
+
|
47
|
+
@worker_thread = Thread.new { @worker.run }
|
48
|
+
@poll_thread = Thread.new { poll_changed_dirs } if @report_changes
|
49
|
+
|
50
|
+
@worker_thread.join if blocking
|
51
|
+
end
|
52
|
+
|
53
|
+
# Stops the adapter.
|
54
|
+
#
|
55
|
+
def stop
|
56
|
+
@mutex.synchronize do
|
57
|
+
return if @stop == true
|
58
|
+
super
|
59
|
+
end
|
60
|
+
|
61
|
+
@worker.stop
|
62
|
+
Thread.kill(@worker_thread) if @worker_thread
|
63
|
+
@poll_thread.join if @poll_thread
|
64
|
+
end
|
65
|
+
|
66
|
+
# Checks if the adapter is usable on the current OS.
|
67
|
+
#
|
68
|
+
# @return [Boolean] whether usable or not
|
69
|
+
#
|
70
|
+
def self.usable?
|
71
|
+
return false unless RbConfig::CONFIG['target_os'] =~ /linux/i
|
72
|
+
super
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
# Initializes a INotify worker and adds a watcher for
|
78
|
+
# each directory passed to the adapter.
|
79
|
+
#
|
80
|
+
# @return [INotify::Notifier] initialized worker
|
81
|
+
#
|
82
|
+
def init_worker
|
83
|
+
callback = lambda do |event|
|
84
|
+
if @paused || (
|
85
|
+
# Event on root directory
|
86
|
+
event.name == ""
|
87
|
+
) || (
|
88
|
+
# INotify reports changes to files inside directories as events
|
89
|
+
# on the directories themselves too.
|
90
|
+
#
|
91
|
+
# @see http://linux.die.net/man/7/inotify
|
92
|
+
event.flags.include?(:isdir) and event.flags & [:close, :modify] != []
|
93
|
+
)
|
94
|
+
# Skip all of these!
|
95
|
+
next
|
96
|
+
end
|
97
|
+
|
98
|
+
@mutex.synchronize do
|
99
|
+
@changed_dirs << File.dirname(event.absolute_name)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
INotify::Notifier.new.tap do |worker|
|
104
|
+
@directories.each do |directory|
|
105
|
+
worker.watch(directory, *EVENTS.map(&:to_sym), &callback)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Listen
|
2
|
+
module Adapters
|
3
|
+
|
4
|
+
# The default delay between checking for changes.
|
5
|
+
DEFAULT_POLLING_LATENCY = 1.0
|
6
|
+
|
7
|
+
# Polling Adapter that works cross-platform and
|
8
|
+
# has no dependencies. This is the adapter that
|
9
|
+
# uses the most CPU processing power and has higher
|
10
|
+
# file IO that the other implementations.
|
11
|
+
#
|
12
|
+
class Polling < Adapter
|
13
|
+
extend DependencyManager
|
14
|
+
|
15
|
+
# Initialize the Adapter. See {Listen::Adapter#initialize} for more info.
|
16
|
+
#
|
17
|
+
def initialize(directories, options = {}, &callback)
|
18
|
+
@latency ||= DEFAULT_POLLING_LATENCY
|
19
|
+
super
|
20
|
+
end
|
21
|
+
|
22
|
+
# Start the adapter.
|
23
|
+
#
|
24
|
+
# @param [Boolean] blocking whether or not to block the current thread after starting
|
25
|
+
#
|
26
|
+
def start(blocking = true)
|
27
|
+
@mutex.synchronize do
|
28
|
+
return if @stop == false
|
29
|
+
super
|
30
|
+
end
|
31
|
+
|
32
|
+
@poll_thread = Thread.new { poll }
|
33
|
+
@poll_thread.join if blocking
|
34
|
+
end
|
35
|
+
|
36
|
+
# Stop the adapter.
|
37
|
+
#
|
38
|
+
def stop
|
39
|
+
@mutex.synchronize do
|
40
|
+
return if @stop == true
|
41
|
+
super
|
42
|
+
end
|
43
|
+
|
44
|
+
@poll_thread.join
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
# Poll listener directory for file system changes.
|
50
|
+
#
|
51
|
+
def poll
|
52
|
+
until @stop
|
53
|
+
next if @paused
|
54
|
+
|
55
|
+
start = Time.now.to_f
|
56
|
+
@callback.call(@directories.dup, :recursive => true)
|
57
|
+
@turnstile.signal
|
58
|
+
nap_time = @latency - (Time.now.to_f - start)
|
59
|
+
sleep(nap_time) if nap_time > 0
|
60
|
+
end
|
61
|
+
rescue Interrupt
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
module Listen
|
4
|
+
module Adapters
|
5
|
+
|
6
|
+
# Adapter implementation for Windows `wdm`.
|
7
|
+
#
|
8
|
+
class Windows < Adapter
|
9
|
+
extend DependencyManager
|
10
|
+
|
11
|
+
# Declare the adapter's dependencies
|
12
|
+
dependency 'wdm', '~> 0.1'
|
13
|
+
|
14
|
+
# Initializes the Adapter. See {Listen::Adapter#initialize} for more info.
|
15
|
+
#
|
16
|
+
def initialize(directories, options = {}, &callback)
|
17
|
+
super
|
18
|
+
@worker = init_worker
|
19
|
+
end
|
20
|
+
|
21
|
+
# Starts the adapter.
|
22
|
+
#
|
23
|
+
# @param [Boolean] blocking whether or not to block the current thread after starting
|
24
|
+
#
|
25
|
+
def start(blocking = true)
|
26
|
+
@mutex.synchronize do
|
27
|
+
return if @stop == false
|
28
|
+
super
|
29
|
+
end
|
30
|
+
|
31
|
+
@worker_thread = Thread.new { @worker.run! }
|
32
|
+
|
33
|
+
# Wait for the worker to start. This is needed to avoid a deadlock
|
34
|
+
# when stopping immediately after starting.
|
35
|
+
sleep 0.1
|
36
|
+
|
37
|
+
@poll_thread = Thread.new { poll_changed_dirs } if @report_changes
|
38
|
+
|
39
|
+
@worker_thread.join if blocking
|
40
|
+
end
|
41
|
+
|
42
|
+
# Stops the adapter.
|
43
|
+
#
|
44
|
+
def stop
|
45
|
+
@mutex.synchronize do
|
46
|
+
return if @stop == true
|
47
|
+
super
|
48
|
+
end
|
49
|
+
|
50
|
+
@worker.stop
|
51
|
+
@worker_thread.join if @worker_thread
|
52
|
+
@poll_thread.join if @poll_thread
|
53
|
+
end
|
54
|
+
|
55
|
+
# Checks if the adapter is usable on the current OS.
|
56
|
+
#
|
57
|
+
# @return [Boolean] whether usable or not
|
58
|
+
#
|
59
|
+
def self.usable?
|
60
|
+
return false unless RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
|
61
|
+
super
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
# Initializes a WDM monitor and adds a watcher for
|
67
|
+
# each directory passed to the adapter.
|
68
|
+
#
|
69
|
+
# @return [WDM::Monitor] initialized worker
|
70
|
+
#
|
71
|
+
def init_worker
|
72
|
+
callback = Proc.new do |change|
|
73
|
+
next if @paused
|
74
|
+
@mutex.synchronize do
|
75
|
+
@changed_dirs << File.dirname(change.path)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
WDM::Monitor.new.tap do |worker|
|
80
|
+
@directories.each { |d| worker.watch_recursively(d, &callback) }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
module Listen
|
4
|
+
|
5
|
+
# The dependency-manager offers a simple DSL which allows
|
6
|
+
# classes to declare their gem dependencies and load them when
|
7
|
+
# needed.
|
8
|
+
# It raises a user-friendly exception when the dependencies
|
9
|
+
# can't be loaded which has the install command in the message.
|
10
|
+
#
|
11
|
+
module DependencyManager
|
12
|
+
|
13
|
+
GEM_LOAD_MESSAGE = <<-EOS.gsub(/^ {6}/, '')
|
14
|
+
Missing dependency '%s' (version '%s')!
|
15
|
+
EOS
|
16
|
+
|
17
|
+
GEM_INSTALL_COMMAND = <<-EOS.gsub(/^ {6}/, '')
|
18
|
+
Please run the following to satisfy the dependency:
|
19
|
+
gem install --version '%s' %s
|
20
|
+
EOS
|
21
|
+
|
22
|
+
BUNDLER_DECLARE_GEM = <<-EOS.gsub(/^ {6}/, '')
|
23
|
+
Please add the following to your Gemfile to satisfy the dependency:
|
24
|
+
gem '%s', '%s'
|
25
|
+
EOS
|
26
|
+
|
27
|
+
Dependency = Struct.new(:name, :version)
|
28
|
+
|
29
|
+
# The error raised when a dependency can't be loaded.
|
30
|
+
class Error < StandardError; end
|
31
|
+
|
32
|
+
# A list of all loaded dependencies in the dependency manager.
|
33
|
+
@_loaded_dependencies = Set.new
|
34
|
+
|
35
|
+
# class methods
|
36
|
+
class << self
|
37
|
+
|
38
|
+
# Initializes the extended class.
|
39
|
+
#
|
40
|
+
# @param [Class] the class for which some dependencies must be managed
|
41
|
+
#
|
42
|
+
def extended(base)
|
43
|
+
base.class_eval do
|
44
|
+
@_dependencies = Set.new
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Adds a loaded dependency to a list so that it doesn't have
|
49
|
+
# to be loaded again by another classes.
|
50
|
+
#
|
51
|
+
# @param [Dependency] dependency
|
52
|
+
#
|
53
|
+
def add_loaded(dependency)
|
54
|
+
@_loaded_dependencies << dependency
|
55
|
+
end
|
56
|
+
|
57
|
+
# Returns whether the dependency is alread loaded or not.
|
58
|
+
#
|
59
|
+
# @param [Dependency] dependency
|
60
|
+
# @return [Boolean]
|
61
|
+
#
|
62
|
+
def already_loaded?(dependency)
|
63
|
+
@_loaded_dependencies.include?(dependency)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Clears the list of loaded dependencies.
|
67
|
+
#
|
68
|
+
def clear_loaded
|
69
|
+
@_loaded_dependencies.clear
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Registers a new dependency.
|
74
|
+
#
|
75
|
+
# @param [String] name the name of the gem
|
76
|
+
# @param [String] version the version of the gem
|
77
|
+
#
|
78
|
+
def dependency(name, version)
|
79
|
+
@_dependencies << Dependency.new(name, version)
|
80
|
+
end
|
81
|
+
|
82
|
+
# Loads the registered dependencies.
|
83
|
+
#
|
84
|
+
# @raise DependencyManager::Error if the dependency can't be loaded.
|
85
|
+
#
|
86
|
+
def load_depenencies
|
87
|
+
@_dependencies.each do |dependency|
|
88
|
+
begin
|
89
|
+
next if DependencyManager.already_loaded?(dependency)
|
90
|
+
gem(dependency.name, dependency.version)
|
91
|
+
require(dependency.name)
|
92
|
+
DependencyManager.add_loaded(dependency)
|
93
|
+
@_dependencies.delete(dependency)
|
94
|
+
rescue Gem::LoadError
|
95
|
+
args = [dependency.name, dependency.version]
|
96
|
+
command = if running_under_bundler?
|
97
|
+
BUNDLER_DECLARE_GEM % args
|
98
|
+
else
|
99
|
+
GEM_INSTALL_COMMAND % args.reverse
|
100
|
+
end
|
101
|
+
message = GEM_LOAD_MESSAGE % args
|
102
|
+
|
103
|
+
raise Error.new(message + command)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# Returns whether all the dependencies has been loaded or not.
|
109
|
+
#
|
110
|
+
# @return [Boolean]
|
111
|
+
#
|
112
|
+
def dependencies_loaded?
|
113
|
+
@_dependencies.empty?
|
114
|
+
end
|
115
|
+
|
116
|
+
private
|
117
|
+
|
118
|
+
# Returns whether we are running under bundler or not
|
119
|
+
#
|
120
|
+
# @return [Boolean]
|
121
|
+
#
|
122
|
+
def running_under_bundler?
|
123
|
+
!!(File.exists?('Gemfile') && ENV['BUNDLE_GEMFILE'])
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|