sass 3.1.21 → 3.2.0.alpha.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. data/README.md +5 -4
  2. data/REVISION +1 -1
  3. data/Rakefile +6 -15
  4. data/VERSION +1 -1
  5. data/VERSION_NAME +1 -1
  6. data/lib/sass.rb +0 -1
  7. data/lib/sass/cache_stores/base.rb +1 -3
  8. data/lib/sass/cache_stores/filesystem.rb +0 -3
  9. data/lib/sass/css.rb +49 -145
  10. data/lib/sass/engine.rb +23 -47
  11. data/lib/sass/environment.rb +5 -30
  12. data/lib/sass/exec.rb +7 -30
  13. data/lib/sass/importers/base.rb +1 -2
  14. data/lib/sass/importers/filesystem.rb +13 -18
  15. data/lib/sass/less.rb +1 -1
  16. data/lib/sass/plugin.rb +8 -4
  17. data/lib/sass/plugin/compiler.rb +67 -93
  18. data/lib/sass/plugin/configuration.rb +2 -0
  19. data/lib/sass/plugin/staleness_checker.rb +4 -14
  20. data/lib/sass/repl.rb +3 -2
  21. data/lib/sass/script.rb +1 -0
  22. data/lib/sass/script/color.rb +9 -4
  23. data/lib/sass/script/funcall.rb +3 -16
  24. data/lib/sass/script/functions.rb +55 -98
  25. data/lib/sass/script/interpolation.rb +0 -9
  26. data/lib/sass/script/lexer.rb +4 -2
  27. data/lib/sass/script/list.rb +0 -8
  28. data/lib/sass/script/literal.rb +20 -5
  29. data/lib/sass/script/node.rb +0 -8
  30. data/lib/sass/script/number.rb +11 -35
  31. data/lib/sass/script/operation.rb +0 -16
  32. data/lib/sass/script/parser.rb +5 -12
  33. data/lib/sass/script/string_interpolation.rb +0 -9
  34. data/lib/sass/script/unary_operation.rb +0 -7
  35. data/lib/sass/script/variable.rb +1 -5
  36. data/lib/sass/scss/parser.rb +54 -191
  37. data/lib/sass/scss/rx.rb +3 -15
  38. data/lib/sass/scss/static_parser.rb +3 -3
  39. data/lib/sass/selector.rb +3 -15
  40. data/lib/sass/selector/abstract_sequence.rb +2 -11
  41. data/lib/sass/selector/comma_sequence.rb +3 -8
  42. data/lib/sass/selector/sequence.rb +11 -74
  43. data/lib/sass/selector/simple.rb +1 -7
  44. data/lib/sass/selector/simple_sequence.rb +8 -28
  45. data/lib/sass/shared.rb +5 -3
  46. data/lib/sass/tree/comment_node.rb +12 -25
  47. data/lib/sass/tree/debug_node.rb +1 -1
  48. data/lib/sass/tree/directive_node.rb +0 -5
  49. data/lib/sass/tree/each_node.rb +1 -1
  50. data/lib/sass/tree/extend_node.rb +1 -1
  51. data/lib/sass/tree/for_node.rb +2 -2
  52. data/lib/sass/tree/function_node.rb +1 -1
  53. data/lib/sass/tree/if_node.rb +14 -1
  54. data/lib/sass/tree/media_node.rb +4 -4
  55. data/lib/sass/tree/mixin_def_node.rb +1 -1
  56. data/lib/sass/tree/mixin_node.rb +2 -2
  57. data/lib/sass/tree/node.rb +26 -10
  58. data/lib/sass/tree/return_node.rb +1 -1
  59. data/lib/sass/tree/root_node.rb +1 -1
  60. data/lib/sass/tree/rule_node.rb +11 -9
  61. data/lib/sass/tree/variable_node.rb +1 -1
  62. data/lib/sass/tree/visitors/base.rb +1 -1
  63. data/lib/sass/tree/visitors/check_nesting.rb +36 -29
  64. data/lib/sass/tree/visitors/convert.rb +9 -16
  65. data/lib/sass/tree/visitors/cssize.rb +9 -40
  66. data/lib/sass/tree/visitors/perform.rb +23 -79
  67. data/lib/sass/tree/visitors/to_css.rb +21 -23
  68. data/lib/sass/tree/warn_node.rb +1 -1
  69. data/lib/sass/tree/while_node.rb +1 -1
  70. data/lib/sass/util.rb +9 -147
  71. data/lib/sass/version.rb +0 -14
  72. data/test/sass/cache_test.rb +0 -15
  73. data/test/sass/conversion_test.rb +8 -50
  74. data/test/sass/css2sass_test.rb +0 -33
  75. data/test/sass/engine_test.rb +32 -283
  76. data/test/sass/extend_test.rb +0 -315
  77. data/test/sass/functions_test.rb +23 -60
  78. data/test/sass/importer_test.rb +0 -110
  79. data/test/sass/more_results/more_import.css +2 -2
  80. data/test/sass/plugin_test.rb +13 -40
  81. data/test/sass/results/import.css +2 -2
  82. data/test/sass/results/import_charset.css +0 -1
  83. data/test/sass/results/import_charset_1_8.css +0 -1
  84. data/test/sass/results/import_charset_ibm866.css +0 -1
  85. data/test/sass/results/scss_import.css +2 -2
  86. data/test/sass/results/units.css +1 -1
  87. data/test/sass/script_conversion_test.rb +0 -2
  88. data/test/sass/script_test.rb +4 -28
  89. data/test/sass/scss/css_test.rb +1 -79
  90. data/test/sass/scss/scss_test.rb +16 -96
  91. data/test/sass/templates/import_charset.sass +0 -2
  92. data/test/sass/templates/import_charset_1_8.sass +0 -2
  93. data/test/sass/templates/import_charset_ibm866.sass +0 -2
  94. data/test/sass/test_helper.rb +1 -1
  95. data/test/sass/util_test.rb +0 -28
  96. data/test/test_helper.rb +0 -2
  97. data/vendor/{listen → fssm}/LICENSE +1 -1
  98. data/vendor/fssm/README.markdown +55 -0
  99. data/vendor/fssm/Rakefile +59 -0
  100. data/vendor/fssm/VERSION.yml +5 -0
  101. data/vendor/fssm/example.rb +9 -0
  102. data/vendor/fssm/fssm.gemspec +77 -0
  103. data/vendor/fssm/lib/fssm.rb +33 -0
  104. data/vendor/fssm/lib/fssm/backends/fsevents.rb +36 -0
  105. data/vendor/fssm/lib/fssm/backends/inotify.rb +26 -0
  106. data/vendor/fssm/lib/fssm/backends/polling.rb +25 -0
  107. data/vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb +131 -0
  108. data/vendor/fssm/lib/fssm/monitor.rb +26 -0
  109. data/vendor/fssm/lib/fssm/path.rb +91 -0
  110. data/vendor/fssm/lib/fssm/pathname.rb +502 -0
  111. data/vendor/fssm/lib/fssm/state/directory.rb +57 -0
  112. data/vendor/fssm/lib/fssm/state/file.rb +24 -0
  113. data/vendor/fssm/lib/fssm/support.rb +63 -0
  114. data/vendor/fssm/lib/fssm/tree.rb +176 -0
  115. data/vendor/fssm/profile/prof-cache.rb +40 -0
  116. data/vendor/fssm/profile/prof-fssm-pathname.html +1231 -0
  117. data/vendor/fssm/profile/prof-pathname.rb +68 -0
  118. data/vendor/fssm/profile/prof-plain-pathname.html +988 -0
  119. data/vendor/fssm/profile/prof.html +2379 -0
  120. data/vendor/fssm/spec/path_spec.rb +75 -0
  121. data/vendor/fssm/spec/root/duck/quack.txt +0 -0
  122. data/vendor/fssm/spec/root/file.css +0 -0
  123. data/vendor/fssm/spec/root/file.rb +0 -0
  124. data/vendor/fssm/spec/root/file.yml +0 -0
  125. data/vendor/fssm/spec/root/moo/cow.txt +0 -0
  126. data/vendor/fssm/spec/spec_helper.rb +14 -0
  127. metadata +246 -281
  128. data/VERSION_DATE +0 -1
  129. data/lib/sass/logger.rb +0 -15
  130. data/lib/sass/logger/base.rb +0 -32
  131. data/lib/sass/logger/log_level.rb +0 -49
  132. data/lib/sass/tree/visitors/deep_copy.rb +0 -87
  133. data/lib/sass/tree/visitors/extend.rb +0 -42
  134. data/lib/sass/tree/visitors/set_options.rb +0 -97
  135. data/lib/sass/util/multibyte_string_scanner.rb +0 -134
  136. data/test/Gemfile +0 -4
  137. data/test/Gemfile.lock +0 -19
  138. data/test/sass/fixtures/test_staleness_check_across_importers.css +0 -1
  139. data/test/sass/fixtures/test_staleness_check_across_importers.scss +0 -1
  140. data/test/sass/logger_test.rb +0 -58
  141. data/test/sass/templates/_double_import_loop2.sass +0 -1
  142. data/test/sass/templates/bork5.sass +0 -3
  143. data/test/sass/templates/double_import_loop1.sass +0 -1
  144. data/test/sass/templates/nested_bork5.sass +0 -2
  145. data/test/sass/templates/single_import_loop.sass +0 -1
  146. data/test/sass/util/multibyte_string_scanner_test.rb +0 -147
  147. data/vendor/listen/CHANGELOG.md +0 -147
  148. data/vendor/listen/Gemfile +0 -23
  149. data/vendor/listen/Guardfile +0 -8
  150. data/vendor/listen/README.md +0 -312
  151. data/vendor/listen/Rakefile +0 -47
  152. data/vendor/listen/Vagrantfile +0 -96
  153. data/vendor/listen/lib/listen.rb +0 -38
  154. data/vendor/listen/lib/listen/adapter.rb +0 -167
  155. data/vendor/listen/lib/listen/adapters/darwin.rb +0 -84
  156. data/vendor/listen/lib/listen/adapters/linux.rb +0 -110
  157. data/vendor/listen/lib/listen/adapters/polling.rb +0 -66
  158. data/vendor/listen/lib/listen/adapters/windows.rb +0 -81
  159. data/vendor/listen/lib/listen/directory_record.rb +0 -318
  160. data/vendor/listen/lib/listen/listener.rb +0 -203
  161. data/vendor/listen/lib/listen/multi_listener.rb +0 -121
  162. data/vendor/listen/lib/listen/turnstile.rb +0 -28
  163. data/vendor/listen/lib/listen/version.rb +0 -3
  164. data/vendor/listen/listen.gemspec +0 -26
  165. data/vendor/listen/spec/listen/adapter_spec.rb +0 -142
  166. data/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -31
  167. data/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -41
  168. data/vendor/listen/spec/listen/adapters/polling_spec.rb +0 -68
  169. data/vendor/listen/spec/listen/adapters/windows_spec.rb +0 -24
  170. data/vendor/listen/spec/listen/directory_record_spec.rb +0 -1138
  171. data/vendor/listen/spec/listen/listener_spec.rb +0 -155
  172. data/vendor/listen/spec/listen/multi_listener_spec.rb +0 -156
  173. data/vendor/listen/spec/listen/turnstile_spec.rb +0 -56
  174. data/vendor/listen/spec/listen_spec.rb +0 -73
  175. data/vendor/listen/spec/spec_helper.rb +0 -18
  176. data/vendor/listen/spec/support/adapter_helper.rb +0 -716
  177. data/vendor/listen/spec/support/directory_record_helper.rb +0 -55
  178. data/vendor/listen/spec/support/fixtures_helper.rb +0 -29
  179. data/vendor/listen/spec/support/listeners_helper.rb +0 -144
  180. data/vendor/listen/spec/support/platform_helper.rb +0 -11
@@ -1,47 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
- task :default => :spec
6
-
7
- require 'rbconfig'
8
- namespace(:spec) do
9
- if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/i
10
- desc "Run all specs on multiple ruby versions (requires pik)"
11
- task(:portability) do
12
- %w[187 192 161].each do |version|
13
- system "cmd /c echo -----------#{version}------------ & " +
14
- "pik use #{version} & " +
15
- "bundle install & " +
16
- "bundle exec rspec spec"
17
- end
18
- end
19
- else
20
- desc "Run all specs on multiple ruby versions (requires rvm)"
21
- task(:portability) do
22
- travis_config_file = File.expand_path("../.travis.yml", __FILE__)
23
- begin
24
- travis_options ||= YAML::load_file(travis_config_file)
25
- rescue => ex
26
- puts "Travis config file '#{travis_config_file}' could not be found: #{ex.message}"
27
- return
28
- end
29
-
30
- travis_options['rvm'].each do |version|
31
- system <<-BASH
32
- bash -c 'source ~/.rvm/scripts/rvm;
33
- rvm #{version};
34
- ruby_version_string_size=`ruby -v | wc -m`
35
- echo;
36
- for ((c=1; c<$ruby_version_string_size; c++)); do echo -n "="; done
37
- echo;
38
- echo "`ruby -v`";
39
- for ((c=1; c<$ruby_version_string_size; c++)); do echo -n "="; done
40
- echo;
41
- RBXOPT="-Xrbc.db" bundle install;
42
- RBXOPT="-Xrbc.db" bundle exec rspec spec -f doc 2>&1;'
43
- BASH
44
- end
45
- end
46
- end
47
- end
@@ -1,96 +0,0 @@
1
- # -*- mode: ruby -*-
2
- # vi: set ft=ruby :
3
-
4
- Vagrant::Config.run do |config|
5
- # All Vagrant configuration is done here. The most common configuration
6
- # options are documented and commented below. For a complete reference,
7
- # please see the online documentation at vagrantup.com.
8
-
9
- # Every Vagrant virtual environment requires a box to build off of.
10
- config.vm.box = "lucid32"
11
-
12
- # The url from where the 'config.vm.box' box will be fetched if it
13
- # doesn't already exist on the user's system.
14
- # config.vm.box_url = "http://domain.com/path/to/above.box"
15
-
16
- # Boot with a GUI so you can see the screen. (Default is headless)
17
- # config.vm.boot_mode = :gui
18
-
19
- # Assign this VM to a host-only network IP, allowing you to access it
20
- # via the IP. Host-only networks can talk to the host machine as well as
21
- # any other machines on the same network, but cannot be accessed (through this
22
- # network interface) by any external networks.
23
- # config.vm.network :hostonly, "33.33.33.10"
24
-
25
- # Assign this VM to a bridged network, allowing you to connect directly to a
26
- # network using the host's network device. This makes the VM appear as another
27
- # physical device on your network.
28
- # config.vm.network :bridged
29
-
30
- # Forward a port from the guest to the host, which allows for outside
31
- # computers to access the VM, whereas host only networking does not.
32
- # config.vm.forward_port 80, 8080
33
-
34
- # Share an additional folder to the guest VM. The first argument is
35
- # an identifier, the second is the path on the guest to mount the
36
- # folder, and the third is the path on the host to the actual folder.
37
- # config.vm.share_folder "v-data", "/vagrant_data", "../data"
38
-
39
- # Enable provisioning with Puppet stand alone. Puppet manifests
40
- # are contained in a directory path relative to this Vagrantfile.
41
- # You will need to create the manifests directory and a manifest in
42
- # the file lucid32.pp in the manifests_path directory.
43
- #
44
- # An example Puppet manifest to provision the message of the day:
45
- #
46
- # # group { "puppet":
47
- # # ensure => "present",
48
- # # }
49
- # #
50
- # # File { owner => 0, group => 0, mode => 0644 }
51
- # #
52
- # # file { '/etc/motd':
53
- # # content => "Welcome to your Vagrant-built virtual machine!
54
- # # Managed by Puppet.\n"
55
- # # }
56
- #
57
- # config.vm.provision :puppet do |puppet|
58
- # puppet.manifests_path = "manifests"
59
- # puppet.manifest_file = "lucid32.pp"
60
- # end
61
-
62
- # Enable provisioning with chef solo, specifying a cookbooks path (relative
63
- # to this Vagrantfile), and adding some recipes and/or roles.
64
- #
65
- # config.vm.provision :chef_solo do |chef|
66
- # chef.cookbooks_path = "cookbooks"
67
- # chef.add_recipe "mysql"
68
- # chef.add_role "web"
69
- #
70
- # # You may also specify custom JSON attributes:
71
- # chef.json = { :mysql_password => "foo" }
72
- # end
73
-
74
- # Enable provisioning with chef server, specifying the chef server URL,
75
- # and the path to the validation key (relative to this Vagrantfile).
76
- #
77
- # The Opscode Platform uses HTTPS. Substitute your organization for
78
- # ORGNAME in the URL and validation key.
79
- #
80
- # If you have your own Chef Server, use the appropriate URL, which may be
81
- # HTTP instead of HTTPS depending on your configuration. Also change the
82
- # validation key to validation.pem.
83
- #
84
- # config.vm.provision :chef_client do |chef|
85
- # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
86
- # chef.validation_key_path = "ORGNAME-validator.pem"
87
- # end
88
- #
89
- # If you're using the Opscode platform, your validator client is
90
- # ORGNAME-validator, replacing ORGNAME with your organization name.
91
- #
92
- # IF you have your own Chef Server, the default validation client name is
93
- # chef-validator, unless you changed the configuration.
94
- #
95
- # chef.validation_client_name = "ORGNAME-validator"
96
- end
@@ -1,38 +0,0 @@
1
- module Listen
2
-
3
- autoload :Turnstile, 'listen/turnstile'
4
- autoload :Listener, 'listen/listener'
5
- autoload :MultiListener, 'listen/multi_listener'
6
- autoload :DirectoryRecord, 'listen/directory_record'
7
- autoload :Adapter, 'listen/adapter'
8
-
9
- module Adapters
10
- autoload :Darwin, 'listen/adapters/darwin'
11
- autoload :Linux, 'listen/adapters/linux'
12
- autoload :Windows, 'listen/adapters/windows'
13
- autoload :Polling, 'listen/adapters/polling'
14
- end
15
-
16
- # Listens to filesystem modifications on a either single directory or multiple directories.
17
- #
18
- # @param (see Listen::Listener#new)
19
- # @param (see Listen::MultiListener#new)
20
- #
21
- # @yield [modified, added, removed] the changed files
22
- # @yieldparam [Array<String>] modified the list of modified files
23
- # @yieldparam [Array<String>] added the list of added files
24
- # @yieldparam [Array<String>] removed the list of removed files
25
- #
26
- # @return [Listen::Listener] the file listener if no block given
27
- #
28
- def self.to(*args, &block)
29
- listener = if args.length == 1 || ! args[1].is_a?(String)
30
- Listener.new(*args, &block)
31
- else
32
- MultiListener.new(*args, &block)
33
- end
34
-
35
- block ? listener.start : listener
36
- end
37
-
38
- end
@@ -1,167 +0,0 @@
1
- require 'rbconfig'
2
- require 'thread'
3
- require 'set'
4
- require 'fileutils'
5
-
6
- module Listen
7
- class Adapter
8
- attr_accessor :directories, :latency, :paused
9
-
10
- # The default delay between checking for changes.
11
- DEFAULT_LATENCY = 0.25
12
-
13
- # The default warning message when falling back to polling adapter.
14
- POLLING_FALLBACK_MESSAGE = "WARNING: Listen has fallen back to polling, learn more at https://github.com/guard/listen#fallback."
15
-
16
- # Selects the appropriate adapter implementation for the
17
- # current OS and initializes it.
18
- #
19
- # @param [String, Array<String>] directories the directories to watch
20
- # @param [Hash] options the adapter options
21
- # @option options [Boolean] force_polling to force polling or not
22
- # @option options [String, Boolean] polling_fallback_message to change polling fallback message or remove it
23
- # @option options [Float] latency the delay between checking for changes in seconds
24
- #
25
- # @yield [changed_dirs, options] callback Callback called when a change happens
26
- # @yieldparam [Array<String>] changed_dirs the changed directories
27
- # @yieldparam [Hash] options callback options (like :recursive => true)
28
- #
29
- # @return [Listen::Adapter] the chosen adapter
30
- #
31
- def self.select_and_initialize(directories, options = {}, &callback)
32
- return Adapters::Polling.new(directories, options, &callback) if options.delete(:force_polling)
33
-
34
- if Adapters::Darwin.usable_and_works?(directories, options)
35
- Adapters::Darwin.new(directories, options, &callback)
36
- elsif Adapters::Linux.usable_and_works?(directories, options)
37
- Adapters::Linux.new(directories, options, &callback)
38
- elsif Adapters::Windows.usable_and_works?(directories, options)
39
- Adapters::Windows.new(directories, options, &callback)
40
- else
41
- unless options[:polling_fallback_message] == false
42
- Kernel.warn(options[:polling_fallback_message] || POLLING_FALLBACK_MESSAGE)
43
- end
44
- Adapters::Polling.new(directories, options, &callback)
45
- end
46
- end
47
-
48
- # Initializes the adapter.
49
- #
50
- # @param [String, Array<String>] directories the directories to watch
51
- # @param [Hash] options the adapter options
52
- # @option options [Float] latency the delay between checking for changes in seconds
53
- #
54
- # @yield [changed_dirs, options] callback Callback called when a change happens
55
- # @yieldparam [Array<String>] changed_dirs the changed directories
56
- # @yieldparam [Hash] options callback options (like :recursive => true)
57
- #
58
- # @return [Listen::Adapter] the adapter
59
- #
60
- def initialize(directories, options = {}, &callback)
61
- @directories = Array(directories)
62
- @callback = callback
63
- @latency ||= DEFAULT_LATENCY
64
- @latency = options[:latency] if options[:latency]
65
- @paused = false
66
- @mutex = Mutex.new
67
- @changed_dirs = Set.new
68
- @turnstile = Turnstile.new
69
- end
70
-
71
- # Starts the adapter.
72
- #
73
- # @param [Boolean] blocking whether or not to block the current thread after starting
74
- #
75
- def start(blocking = true)
76
- @stop = false
77
- end
78
-
79
- # Stops the adapter.
80
- #
81
- def stop
82
- @stop = true
83
- @turnstile.signal # ensure no thread is blocked
84
- end
85
-
86
- # Returns whether the adapter is statred or not
87
- #
88
- # @return [Boolean] whether the adapter is started or not
89
- #
90
- def started?
91
- @stop.nil? ? false : !@stop
92
- end
93
-
94
- # Blocks the main thread until the poll thread
95
- # calls the callback.
96
- #
97
- def wait_for_callback
98
- @turnstile.wait unless @paused
99
- end
100
-
101
- # Checks if the adapter is usable and works on the current OS.
102
- #
103
- # @param [String, Array<String>] directories the directories to watch
104
- # @param [Hash] options the adapter options
105
- # @option options [Float] latency the delay between checking for changes in seconds
106
- #
107
- # @return [Boolean] whether usable and work or not
108
- #
109
- def self.usable_and_works?(directories, options = {})
110
- usable? && Array(directories).all? { |d| works?(d, options) }
111
- end
112
-
113
- # Runs a tests to determine if the adapter can actually pick up
114
- # changes in a given directory and returns the result.
115
- #
116
- # @note This test takes some time depending the adapter latency.
117
- #
118
- # @param [String, Pathname] directory the directory to watch
119
- # @param [Hash] options the adapter options
120
- # @option options [Float] latency the delay between checking for changes in seconds
121
- #
122
- # @return [Boolean] whether the adapter works or not
123
- #
124
- def self.works?(directory, options = {})
125
- work = false
126
- test_file = "#{directory}/.listen_test"
127
- callback = lambda { |changed_dirs, options| work = true }
128
- adapter = self.new(directory, options, &callback)
129
- adapter.start(false)
130
-
131
- FileUtils.touch(test_file)
132
-
133
- t = Thread.new { sleep(adapter.latency * 5); adapter.stop }
134
-
135
- adapter.wait_for_callback
136
- work
137
- ensure
138
- Thread.kill(t) if t
139
- FileUtils.rm(test_file) if File.exists?(test_file)
140
- adapter.stop if adapter && adapter.started?
141
- end
142
-
143
- private
144
-
145
- # Polls changed directories and reports them back
146
- # when there are changes.
147
- #
148
- # @option [Boolean] recursive whether or not to pass the recursive option to the callback
149
- #
150
- def poll_changed_dirs(recursive = false)
151
- until @stop
152
- sleep(@latency)
153
- next if @changed_dirs.empty?
154
-
155
- changed_dirs = []
156
-
157
- @mutex.synchronize do
158
- changed_dirs = @changed_dirs.to_a
159
- @changed_dirs.clear
160
- end
161
-
162
- @callback.call(changed_dirs, recursive ? {:recursive => recursive} : {})
163
- @turnstile.signal
164
- end
165
- end
166
- end
167
- end
@@ -1,84 +0,0 @@
1
- module Listen
2
- module Adapters
3
-
4
- # Adapter implementation for Mac OS X `FSEvents`.
5
- #
6
- class Darwin < Adapter
7
-
8
- LAST_SEPARATOR_REGEX = /\/$/
9
-
10
- # Initializes the Adapter. See {Listen::Adapter#initialize} for more info.
11
- #
12
- def initialize(directories, options = {}, &callback)
13
- super
14
- @worker = init_worker
15
- end
16
-
17
- # Starts the adapter.
18
- #
19
- # @param [Boolean] blocking whether or not to block the current thread after starting
20
- #
21
- def start(blocking = true)
22
- @mutex.synchronize do
23
- return if @stop == false
24
- super
25
- end
26
-
27
- @worker_thread = Thread.new { @worker.run }
28
- @poll_thread = Thread.new { poll_changed_dirs }
29
-
30
- # The FSEvent worker needs sometime to startup. Turnstiles can't
31
- # be used to wait for it as it runs in a loop.
32
- # TODO: Find a better way to block until the worker starts.
33
- sleep @latency
34
- @poll_thread.join if blocking
35
- end
36
-
37
- # Stops the adapter.
38
- #
39
- def stop
40
- @mutex.synchronize do
41
- return if @stop == true
42
- super
43
- end
44
-
45
- @worker.stop
46
- Thread.kill(@worker_thread) if @worker_thread
47
- @poll_thread.join
48
- end
49
-
50
- # Checks if the adapter is usable on the current OS.
51
- #
52
- # @return [Boolean] whether usable or not
53
- #
54
- def self.usable?
55
- return false unless RbConfig::CONFIG['target_os'] =~ /darwin(1.+)?$/i
56
-
57
- require 'rb-fsevent'
58
- true
59
- rescue LoadError
60
- false
61
- end
62
-
63
- private
64
-
65
- # Initializes a FSEvent worker and adds a watcher for
66
- # each directory passed to the adapter.
67
- #
68
- # @return [FSEvent] initialized worker
69
- #
70
- def init_worker
71
- FSEvent.new.tap do |worker|
72
- worker.watch(@directories.dup, :latency => @latency) do |changes|
73
- next if @paused
74
- @mutex.synchronize do
75
- changes.each { |path| @changed_dirs << path.sub(LAST_SEPARATOR_REGEX, '') }
76
- end
77
- end
78
- end
79
- end
80
-
81
- end
82
-
83
- end
84
- end
@@ -1,110 +0,0 @@
1
- module Listen
2
- module Adapters
3
-
4
- # Listener implementation for Linux `inotify`.
5
- #
6
- class Linux < Adapter
7
-
8
- # Watched inotify events
9
- #
10
- # @see http://www.tin.org/bin/man.cgi?section=7&topic=inotify
11
- # @see https://github.com/nex3/rb-inotify/blob/master/lib/rb-inotify/notifier.rb#L99-L177
12
- #
13
- EVENTS = %w[recursive attrib create delete move close_write]
14
-
15
- # The message to show when the limit of inotify watchers is not enough
16
- #
17
- INOTIFY_LIMIT_MESSAGE = <<-EOS.gsub(/^\s*/, '')
18
- Listen error: unable to monitor directories for changes.
19
-
20
- Please head to https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers
21
- for information on how to solve this issue.
22
- EOS
23
-
24
- # Initializes the Adapter. See {Listen::Adapter#initialize} for more info.
25
- #
26
- def initialize(directories, options = {}, &callback)
27
- super
28
- @worker = init_worker
29
- rescue Errno::ENOSPC
30
- abort(INOTIFY_LIMIT_MESSAGE)
31
- end
32
-
33
- # Starts the adapter.
34
- #
35
- # @param [Boolean] blocking whether or not to block the current thread after starting
36
- #
37
- def start(blocking = true)
38
- @mutex.synchronize do
39
- return if @stop == false
40
- super
41
- end
42
-
43
- @worker_thread = Thread.new { @worker.run }
44
- @poll_thread = Thread.new { poll_changed_dirs }
45
- @poll_thread.join if blocking
46
- end
47
-
48
- # Stops the adapter.
49
- #
50
- def stop
51
- @mutex.synchronize do
52
- return if @stop == true
53
- super
54
- end
55
-
56
- @worker.stop
57
- Thread.kill(@worker_thread) if @worker_thread
58
- @poll_thread.join
59
- end
60
-
61
- # Check if the adapter is usable on the current OS.
62
- #
63
- # @return [Boolean] whether usable or not
64
- #
65
- def self.usable?
66
- return false unless RbConfig::CONFIG['target_os'] =~ /linux/i
67
-
68
- require 'rb-inotify'
69
- true
70
- rescue LoadError
71
- false
72
- end
73
-
74
- private
75
-
76
- # Initializes a INotify worker and adds a watcher for
77
- # each directory passed to the adapter.
78
- #
79
- # @return [INotify::Notifier] initialized worker
80
- #
81
- def init_worker
82
- worker = INotify::Notifier.new
83
- @directories.each do |directory|
84
- worker.watch(directory, *EVENTS.map(&:to_sym)) do |event|
85
- if @paused || (
86
- # Event on root directory
87
- event.name == ""
88
- ) || (
89
- # INotify reports changes to files inside directories as events
90
- # on the directories themselves too.
91
- #
92
- # @see http://linux.die.net/man/7/inotify
93
- event.flags.include?(:isdir) and event.flags & [:close, :modify] != []
94
- )
95
- # Skip all of these!
96
- next
97
- end
98
-
99
- @mutex.synchronize do
100
- @changed_dirs << File.dirname(event.absolute_name)
101
- end
102
- end
103
- end
104
- worker
105
- end
106
-
107
- end
108
-
109
- end
110
- end