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.
Files changed (78) hide show
  1. data/Rakefile +1 -1
  2. data/VERSION +1 -1
  3. data/VERSION_DATE +1 -1
  4. data/lib/sass.rb +5 -0
  5. data/lib/sass/engine.rb +3 -5
  6. data/lib/sass/plugin.rb +0 -1
  7. data/lib/sass/plugin/compiler.rb +1 -2
  8. data/lib/sass/script/functions.rb +16 -2
  9. data/lib/sass/script/lexer.rb +22 -12
  10. data/lib/sass/script/parser.rb +27 -14
  11. data/lib/sass/script/tree/variable.rb +1 -1
  12. data/lib/sass/script/value/base.rb +1 -1
  13. data/lib/sass/script/value/color.rb +29 -17
  14. data/lib/sass/script/value/list.rb +1 -1
  15. data/lib/sass/script/value/number.rb +8 -1
  16. data/lib/sass/scss/parser.rb +2 -2
  17. data/lib/sass/selector/sequence.rb +18 -19
  18. data/lib/sass/selector/simple_sequence.rb +5 -5
  19. data/lib/sass/source/map.rb +1 -1
  20. data/lib/sass/tree/node.rb +25 -0
  21. data/lib/sass/tree/variable_node.rb +5 -0
  22. data/lib/sass/tree/visitors/base.rb +4 -7
  23. data/lib/sass/tree/visitors/check_nesting.rb +2 -2
  24. data/lib/sass/tree/visitors/perform.rb +12 -7
  25. data/lib/sass/util.rb +95 -50
  26. data/lib/sass/util/normalized_map.rb +63 -14
  27. data/lib/sass/util/ordered_hash.rb +9 -5
  28. data/lib/sass/version.rb +10 -12
  29. data/test/sass/engine_test.rb +37 -0
  30. data/test/sass/functions_test.rb +9 -2
  31. data/test/sass/importer_test.rb +3 -3
  32. data/test/sass/script_test.rb +12 -10
  33. data/test/sass/source_map_test.rb +8 -8
  34. data/test/sass/util/normalized_map_test.rb +22 -1
  35. data/test/sass/util_test.rb +18 -0
  36. data/test/test_helper.rb +16 -0
  37. data/vendor/listen/CHANGELOG.md +228 -0
  38. data/vendor/listen/CONTRIBUTING.md +38 -0
  39. data/vendor/listen/Gemfile +30 -0
  40. data/vendor/listen/Guardfile +8 -0
  41. data/vendor/listen/LICENSE +20 -0
  42. data/vendor/listen/README.md +315 -0
  43. data/vendor/listen/Rakefile +47 -0
  44. data/vendor/listen/Vagrantfile +96 -0
  45. data/vendor/listen/lib/listen.rb +40 -0
  46. data/vendor/listen/lib/listen/adapter.rb +214 -0
  47. data/vendor/listen/lib/listen/adapters/bsd.rb +112 -0
  48. data/vendor/listen/lib/listen/adapters/darwin.rb +85 -0
  49. data/vendor/listen/lib/listen/adapters/linux.rb +113 -0
  50. data/vendor/listen/lib/listen/adapters/polling.rb +67 -0
  51. data/vendor/listen/lib/listen/adapters/windows.rb +87 -0
  52. data/vendor/listen/lib/listen/dependency_manager.rb +126 -0
  53. data/vendor/listen/lib/listen/directory_record.rb +371 -0
  54. data/vendor/listen/lib/listen/listener.rb +225 -0
  55. data/vendor/listen/lib/listen/multi_listener.rb +143 -0
  56. data/vendor/listen/lib/listen/turnstile.rb +28 -0
  57. data/vendor/listen/lib/listen/version.rb +3 -0
  58. data/vendor/listen/listen.gemspec +22 -0
  59. data/vendor/listen/spec/listen/adapter_spec.rb +183 -0
  60. data/vendor/listen/spec/listen/adapters/bsd_spec.rb +36 -0
  61. data/vendor/listen/spec/listen/adapters/darwin_spec.rb +37 -0
  62. data/vendor/listen/spec/listen/adapters/linux_spec.rb +47 -0
  63. data/vendor/listen/spec/listen/adapters/polling_spec.rb +68 -0
  64. data/vendor/listen/spec/listen/adapters/windows_spec.rb +30 -0
  65. data/vendor/listen/spec/listen/dependency_manager_spec.rb +107 -0
  66. data/vendor/listen/spec/listen/directory_record_spec.rb +1225 -0
  67. data/vendor/listen/spec/listen/listener_spec.rb +169 -0
  68. data/vendor/listen/spec/listen/multi_listener_spec.rb +174 -0
  69. data/vendor/listen/spec/listen/turnstile_spec.rb +56 -0
  70. data/vendor/listen/spec/listen_spec.rb +73 -0
  71. data/vendor/listen/spec/spec_helper.rb +21 -0
  72. data/vendor/listen/spec/support/adapter_helper.rb +629 -0
  73. data/vendor/listen/spec/support/directory_record_helper.rb +55 -0
  74. data/vendor/listen/spec/support/fixtures_helper.rb +29 -0
  75. data/vendor/listen/spec/support/listeners_helper.rb +156 -0
  76. data/vendor/listen/spec/support/platform_helper.rb +15 -0
  77. metadata +318 -300
  78. data/test/Gemfile.lock +0 -10
@@ -0,0 +1,143 @@
1
+ module Listen
2
+ class MultiListener < Listener
3
+ attr_reader :directories, :directories_records, :adapter
4
+
5
+ # Initializes the multiple directories listener.
6
+ #
7
+ # @param [String] directories the directories to listen to
8
+ # @param [Hash] options the listen options
9
+ # @option options [Regexp] ignore a pattern for ignoring paths
10
+ # @option options [Regexp] filter a pattern for filtering paths
11
+ # @option options [Float] latency the delay between checking for changes in seconds
12
+ # @option options [Boolean] force_polling whether to force the polling adapter or not
13
+ # @option options [String, Boolean] polling_fallback_message to change polling fallback message or remove it
14
+ #
15
+ # @yield [modified, added, removed] the changed files
16
+ # @yieldparam [Array<String>] modified the list of modified files
17
+ # @yieldparam [Array<String>] added the list of added files
18
+ # @yieldparam [Array<String>] removed the list of removed files
19
+ #
20
+ def initialize(*args, &block)
21
+ options = args.last.is_a?(Hash) ? args.pop : {}
22
+ directories = args
23
+
24
+ @block = block
25
+ @directories = directories.map { |d| Pathname.new(d).realpath.to_s }
26
+ @directories_records = @directories.map { |d| DirectoryRecord.new(d) }
27
+
28
+ ignore(*options.delete(:ignore)) if options[:ignore]
29
+ filter(*options.delete(:filter)) if options[:filter]
30
+
31
+ @adapter_options = options
32
+ end
33
+
34
+ # Starts the listener by initializing the adapter and building
35
+ # the directory record concurrently, then it starts the adapter to watch
36
+ # for changes.
37
+ #
38
+ # @param [Boolean] blocking whether or not to block the current thread after starting
39
+ #
40
+ def start(blocking = true)
41
+ t = Thread.new { @directories_records.each { |r| r.build } }
42
+ @adapter = initialize_adapter
43
+ t.join
44
+ @adapter.start(blocking)
45
+ end
46
+
47
+ # Unpauses the listener.
48
+ #
49
+ # @return [Listen::Listener] the listener
50
+ #
51
+ def unpause
52
+ @directories_records.each { |r| r.build }
53
+ @adapter.paused = false
54
+ self
55
+ end
56
+
57
+ # Adds ignored paths to the listener.
58
+ #
59
+ # @param (see Listen::DirectoryRecord#ignore)
60
+ #
61
+ # @return [Listen::Listener] the listener
62
+ #
63
+ def ignore(*paths)
64
+ @directories_records.each { |r| r.ignore(*paths) }
65
+ self
66
+ end
67
+
68
+ # Replaces ignored paths in the listener.
69
+ #
70
+ # @param (see Listen::DirectoryRecord#ignore!)
71
+ #
72
+ # @return [Listen::Listener] the listener
73
+ #
74
+ def ignore!(*paths)
75
+ @directories_records.each { |r| r.ignore!(*paths) }
76
+ self
77
+ end
78
+
79
+ # Adds file filters to the listener.
80
+ #
81
+ # @param (see Listen::DirectoryRecord#filter)
82
+ #
83
+ # @return [Listen::Listener] the listener
84
+ #
85
+ def filter(*regexps)
86
+ @directories_records.each { |r| r.filter(*regexps) }
87
+ self
88
+ end
89
+
90
+ # Replaces file filters in the listener.
91
+ #
92
+ # @param (see Listen::DirectoryRecord#filter!)
93
+ #
94
+ # @return [Listen::Listener] the listener
95
+ #
96
+ def filter!(*regexps)
97
+ @directories_records.each { |r| r.filter!(*regexps) }
98
+ self
99
+ end
100
+
101
+ # Runs the callback passing it the changes if there are any.
102
+ #
103
+ # @param (see Listen::DirectoryRecord#fetch_changes)
104
+ #
105
+ def on_change(directories_to_search, options = {})
106
+ changes = fetch_records_changes(directories_to_search, options)
107
+ unless changes.values.all? { |paths| paths.empty? }
108
+ @block.call(changes[:modified],changes[:added],changes[:removed])
109
+ end
110
+ end
111
+
112
+ private
113
+
114
+ # Initializes an adapter passing it the callback and adapters' options.
115
+ #
116
+ def initialize_adapter
117
+ callback = lambda { |changed_dirs, options| self.on_change(changed_dirs, options) }
118
+ Adapter.select_and_initialize(@directories, @adapter_options, &callback)
119
+ end
120
+
121
+ # Returns the sum of all the changes to the directories records
122
+ #
123
+ # @param (see Listen::DirectoryRecord#fetch_changes)
124
+ #
125
+ # @return [Hash] the changes
126
+ #
127
+ def fetch_records_changes(directories_to_search, options)
128
+ @directories_records.inject({}) do |h, r|
129
+ # directory records skips paths outside their range, so passing the
130
+ # whole `directories` array is not a problem.
131
+ record_changes = r.fetch_changes(directories_to_search, options.merge(:relative_paths => DEFAULT_TO_RELATIVE_PATHS))
132
+
133
+ if h.empty?
134
+ h.merge!(record_changes)
135
+ else
136
+ h.each { |k, v| h[k] += record_changes[k] }
137
+ end
138
+
139
+ h
140
+ end
141
+ end
142
+ end
143
+ end
@@ -0,0 +1,28 @@
1
+ module Listen
2
+ # Allows two threads to wait on eachother.
3
+ #
4
+ # @note Only two threads can be used with this Turnstile
5
+ # because of the current implementation.
6
+ class Turnstile
7
+
8
+ # Initialize the turnstile.
9
+ #
10
+ def initialize
11
+ # Until ruby offers semahpores, only queues can be used
12
+ # to implement a turnstile.
13
+ @q = Queue.new
14
+ end
15
+
16
+ # Blocks the current thread until a signal is received.
17
+ #
18
+ def wait
19
+ @q.pop if @q.num_waiting == 0
20
+ end
21
+
22
+ # Unblocks the waiting thread if there is one.
23
+ #
24
+ def signal
25
+ @q.push :dummy if @q.num_waiting == 1
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module Listen
2
+ VERSION = '0.7.3'
3
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'listen/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'listen'
7
+ s.version = Listen::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ['Thibaud Guillaume-Gentil', 'Maher Sallam']
10
+ s.email = ['thibaud@thibaud.me', 'maher@sallam.me']
11
+ s.homepage = 'https://github.com/guard/listen'
12
+ s.summary = 'Listen to file modifications'
13
+ s.description = 'The Listen gem listens to file modifications and notifies you about the changes. Works everywhere!'
14
+
15
+ s.required_rubygems_version = '>= 1.3.6'
16
+ s.rubyforge_project = 'listen'
17
+
18
+ s.add_development_dependency 'bundler'
19
+
20
+ s.files = Dir.glob('{lib}/**/*') + %w[CHANGELOG.md LICENSE README.md]
21
+ s.require_path = 'lib'
22
+ end
@@ -0,0 +1,183 @@
1
+ require 'spec_helper'
2
+
3
+ describe Listen::Adapter do
4
+ subject { described_class.new('dir') }
5
+
6
+ describe '#initialize' do
7
+ it 'sets the latency to the default one' do
8
+ subject.latency.should eq described_class::DEFAULT_LATENCY
9
+ end
10
+
11
+ it 'accepts a single directory to watch' do
12
+ described_class.new('dir').directories = %w{dir}
13
+ end
14
+
15
+ it 'accepts multiple directories to watch' do
16
+ described_class.new(%w{dir1 dir2}).directories.should eq %w{dir1 dir2}
17
+ end
18
+ end
19
+
20
+ describe ".select_and_initialize" do
21
+ before do
22
+ Listen::Adapters::Darwin.stub(:usable_and_works?) { false }
23
+ Listen::Adapters::Linux.stub(:usable_and_works?) { false }
24
+ Listen::Adapters::BSD.stub(:usable_and_works?) { false }
25
+ Listen::Adapters::Windows.stub(:usable_and_works?) { false }
26
+ end
27
+
28
+ context "with no specific adapter usable" do
29
+ it "returns Listen::Adapters::Polling instance" do
30
+ Kernel.stub(:warn)
31
+ Listen::Adapters::Polling.should_receive(:new).with('dir', {})
32
+ described_class.select_and_initialize('dir')
33
+ end
34
+
35
+ it 'warns with the default polling fallback message' do
36
+ Kernel.should_receive(:warn).with(/#{Listen::Adapter::POLLING_FALLBACK_MESSAGE}/)
37
+ described_class.select_and_initialize('dir')
38
+ end
39
+
40
+ context 'when the dependencies of an adapter are not satisfied' do
41
+ before do
42
+ Listen::Adapters::Darwin.stub(:usable_and_works?).and_raise(Listen::DependencyManager::Error)
43
+ Listen::Adapters::Linux.stub(:usable_and_works?).and_raise(Listen::DependencyManager::Error)
44
+ Listen::Adapters::BSD.stub(:usable_and_works?).and_raise(Listen::DependencyManager::Error)
45
+ Listen::Adapters::Windows.stub(:usable_and_works?).and_raise(Listen::DependencyManager::Error)
46
+ end
47
+
48
+ it 'invites the user to satisfy the dependencies of the adapter in the warning' do
49
+ Kernel.should_receive(:warn).with(/#{Listen::Adapter::MISSING_DEPENDENCY_MESSAGE}/)
50
+ described_class.select_and_initialize('dir')
51
+ end
52
+ end
53
+
54
+ context "with custom polling_fallback_message option" do
55
+ it "warns with the custom polling fallback message" do
56
+ Kernel.should_receive(:warn).with(/custom/)
57
+ described_class.select_and_initialize('dir', :polling_fallback_message => 'custom')
58
+ end
59
+ end
60
+
61
+ context "with polling_fallback_message to false" do
62
+ it "doesn't warn with a polling fallback message" do
63
+ Kernel.should_not_receive(:warn)
64
+ described_class.select_and_initialize('dir', :polling_fallback_message => false)
65
+ end
66
+ end
67
+ end
68
+
69
+ context "on Mac OX >= 10.6" do
70
+ before { Listen::Adapters::Darwin.stub(:usable_and_works?) { true } }
71
+
72
+ it "uses Listen::Adapters::Darwin" do
73
+ Listen::Adapters::Darwin.should_receive(:new).with('dir', {})
74
+ described_class.select_and_initialize('dir')
75
+ end
76
+
77
+ context 'when the use of the polling adapter is forced' do
78
+ it 'uses Listen::Adapters::Polling' do
79
+ Listen::Adapters::Polling.should_receive(:new).with('dir', {})
80
+ described_class.select_and_initialize('dir', :force_polling => true)
81
+ end
82
+ end
83
+ end
84
+
85
+ context "on Linux" do
86
+ before { Listen::Adapters::Linux.stub(:usable_and_works?) { true } }
87
+
88
+ it "uses Listen::Adapters::Linux" do
89
+ Listen::Adapters::Linux.should_receive(:new).with('dir', {})
90
+ described_class.select_and_initialize('dir')
91
+ end
92
+
93
+ context 'when the use of the polling adapter is forced' do
94
+ it 'uses Listen::Adapters::Polling' do
95
+ Listen::Adapters::Polling.should_receive(:new).with('dir', {})
96
+ described_class.select_and_initialize('dir', :force_polling => true)
97
+ end
98
+ end
99
+ end
100
+
101
+ context "on BSD" do
102
+ before { Listen::Adapters::BSD.stub(:usable_and_works?) { true } }
103
+
104
+ it "uses Listen::Adapters::BSD" do
105
+ Listen::Adapters::BSD.should_receive(:new).with('dir', {})
106
+ described_class.select_and_initialize('dir')
107
+ end
108
+
109
+ context 'when the use of the polling adapter is forced' do
110
+ it 'uses Listen::Adapters::Polling' do
111
+ Listen::Adapters::Polling.should_receive(:new).with('dir', {})
112
+ described_class.select_and_initialize('dir', :force_polling => true)
113
+ end
114
+ end
115
+ end
116
+
117
+ context "on Windows" do
118
+ before { Listen::Adapters::Windows.stub(:usable_and_works?) { true } }
119
+
120
+ it "uses Listen::Adapters::Windows" do
121
+ Listen::Adapters::Windows.should_receive(:new).with('dir', {})
122
+ described_class.select_and_initialize('dir')
123
+ end
124
+
125
+ context 'when the use of the polling adapter is forced' do
126
+ it 'uses Listen::Adapters::Polling' do
127
+ Listen::Adapters::Polling.should_receive(:new).with('dir', {})
128
+ described_class.select_and_initialize('dir', :force_polling => true)
129
+ end
130
+ end
131
+ end
132
+ end
133
+
134
+ [Listen::Adapters::Darwin, Listen::Adapters::Linux,
135
+ Listen::Adapters::BSD, Listen::Adapters::Windows].each do
136
+ |adapter_class|
137
+ if adapter_class.usable?
138
+ describe '.usable?' do
139
+ it 'checks the dependencies' do
140
+ adapter_class.should_receive(:load_depenencies)
141
+ adapter_class.should_receive(:dependencies_loaded?)
142
+ adapter_class.usable?
143
+ end
144
+ end
145
+
146
+ describe '.usable_and_works?' do
147
+ it 'checks if the adapter is usable' do
148
+ adapter_class.stub(:works?)
149
+ adapter_class.should_receive(:usable?)
150
+ adapter_class.usable_and_works?('dir')
151
+ end
152
+
153
+ context 'with one directory' do
154
+ it 'tests if that directory actually work' do
155
+ fixtures do |path|
156
+ adapter_class.should_receive(:works?).with(path, anything).and_return(true)
157
+ adapter_class.usable_and_works?(path)
158
+ end
159
+ end
160
+ end
161
+
162
+ context 'with multiple directories' do
163
+ it 'tests if each directory passed does actually work' do
164
+ fixtures(3) do |path1, path2, path3|
165
+ adapter_class.should_receive(:works?).exactly(3).times.with do |path, options|
166
+ [path1, path2, path3].include? path
167
+ end.and_return(true)
168
+ adapter_class.usable_and_works?([path1, path2, path3])
169
+ end
170
+ end
171
+ end
172
+ end
173
+
174
+ describe '.works?' do
175
+ it 'does work' do
176
+ fixtures do |path|
177
+ adapter_class.works?(path).should be_true
178
+ end
179
+ end
180
+ end
181
+ end
182
+ end
183
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe Listen::Adapters::BSD do
4
+ if bsd?
5
+ if Listen::Adapters::BSD.usable?
6
+ it "is usable on BSD" do
7
+ described_class.should be_usable
8
+ end
9
+
10
+ it_should_behave_like 'a filesystem adapter'
11
+ it_should_behave_like 'an adapter that call properly listener#on_change'
12
+ else
13
+ it "isn't usable on BSD with #{RbConfig::CONFIG['RUBY_INSTALL_NAME']}" do
14
+ described_class.should_not be_usable
15
+ end
16
+ end
17
+ end
18
+
19
+ if linux?
20
+ it "isn't usable on Linux" do
21
+ described_class.should_not be_usable
22
+ end
23
+ end
24
+
25
+ if mac?
26
+ it "isn't usable on Mac OS X" do
27
+ described_class.should_not be_usable
28
+ end
29
+ end
30
+
31
+ if windows?
32
+ it "isn't usable on Windows" do
33
+ described_class.should_not be_usable
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe Listen::Adapters::Darwin do
4
+ if mac?
5
+ if Listen::Adapters::Darwin.usable?
6
+ it "is usable on Mac OS X >= 10.6" do
7
+ described_class.should be_usable
8
+ end
9
+
10
+ it_should_behave_like 'a filesystem adapter'
11
+ it_should_behave_like 'an adapter that call properly listener#on_change'
12
+ else
13
+ it "isn't usable on Mac OS X with #{RbConfig::CONFIG['RUBY_INSTALL_NAME']}" do
14
+ described_class.should_not be_usable
15
+ end
16
+ end
17
+
18
+ end
19
+
20
+ if windows?
21
+ it "isn't usable on Windows" do
22
+ described_class.should_not be_usable
23
+ end
24
+ end
25
+
26
+ if linux?
27
+ it "isn't usable on Linux" do
28
+ described_class.should_not be_usable
29
+ end
30
+ end
31
+
32
+ if bsd?
33
+ it "isn't usable on BSD" do
34
+ described_class.should_not be_usable
35
+ end
36
+ end
37
+ end