sass 3.4.25 → 3.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (237) hide show
  1. checksums.yaml +4 -4
  2. data/CODE_OF_CONDUCT.md +1 -1
  3. data/CONTRIBUTING.md +3 -3
  4. data/README.md +17 -9
  5. data/VERSION +1 -1
  6. data/VERSION_DATE +1 -1
  7. data/VERSION_NAME +1 -1
  8. data/extra/sass-spec-ref.sh +9 -1
  9. data/lib/sass.rb +0 -7
  10. data/lib/sass/cache_stores/filesystem.rb +1 -1
  11. data/lib/sass/css.rb +1 -2
  12. data/lib/sass/engine.rb +39 -29
  13. data/lib/sass/environment.rb +26 -5
  14. data/lib/sass/error.rb +2 -2
  15. data/lib/sass/exec/base.rb +2 -13
  16. data/lib/sass/exec/sass_scss.rb +1 -5
  17. data/lib/sass/features.rb +1 -0
  18. data/lib/sass/importers/filesystem.rb +6 -4
  19. data/lib/sass/logger/base.rb +11 -0
  20. data/lib/sass/plugin/compiler.rb +20 -50
  21. data/lib/sass/plugin/configuration.rb +2 -2
  22. data/lib/sass/railtie.rb +1 -1
  23. data/lib/sass/script/css_parser.rb +4 -1
  24. data/lib/sass/script/functions.rb +308 -81
  25. data/lib/sass/script/lexer.rb +63 -9
  26. data/lib/sass/script/parser.rb +287 -118
  27. data/lib/sass/script/tree/funcall.rb +35 -34
  28. data/lib/sass/script/tree/interpolation.rb +0 -3
  29. data/lib/sass/script/tree/list_literal.rb +23 -8
  30. data/lib/sass/script/tree/map_literal.rb +2 -2
  31. data/lib/sass/script/tree/node.rb +0 -8
  32. data/lib/sass/script/tree/operation.rb +1 -8
  33. data/lib/sass/script/value.rb +2 -0
  34. data/lib/sass/script/value/arg_list.rb +1 -1
  35. data/lib/sass/script/value/base.rb +17 -0
  36. data/lib/sass/script/value/callable.rb +25 -0
  37. data/lib/sass/script/value/color.rb +8 -2
  38. data/lib/sass/script/value/function.rb +19 -0
  39. data/lib/sass/script/value/helpers.rb +37 -11
  40. data/lib/sass/script/value/list.rb +35 -14
  41. data/lib/sass/script/value/map.rb +2 -2
  42. data/lib/sass/script/value/number.rb +3 -2
  43. data/lib/sass/scss/css_parser.rb +6 -1
  44. data/lib/sass/scss/parser.rb +145 -56
  45. data/lib/sass/scss/rx.rb +5 -11
  46. data/lib/sass/scss/static_parser.rb +20 -42
  47. data/lib/sass/selector.rb +4 -0
  48. data/lib/sass/selector/abstract_sequence.rb +7 -6
  49. data/lib/sass/selector/comma_sequence.rb +9 -5
  50. data/lib/sass/selector/pseudo.rb +20 -3
  51. data/lib/sass/selector/sequence.rb +35 -10
  52. data/lib/sass/selector/simple.rb +9 -2
  53. data/lib/sass/selector/simple_sequence.rb +8 -4
  54. data/lib/sass/source/map.rb +2 -6
  55. data/lib/sass/stack.rb +21 -1
  56. data/lib/sass/tree/charset_node.rb +1 -1
  57. data/lib/sass/tree/prop_node.rb +45 -53
  58. data/lib/sass/tree/rule_node.rb +6 -8
  59. data/lib/sass/tree/visitors/check_nesting.rb +1 -1
  60. data/lib/sass/tree/visitors/convert.rb +2 -3
  61. data/lib/sass/tree/visitors/cssize.rb +4 -15
  62. data/lib/sass/tree/visitors/deep_copy.rb +1 -1
  63. data/lib/sass/tree/visitors/extend.rb +2 -8
  64. data/lib/sass/tree/visitors/perform.rb +23 -15
  65. data/lib/sass/tree/visitors/set_options.rb +1 -1
  66. data/lib/sass/tree/visitors/to_css.rb +49 -22
  67. data/lib/sass/util.rb +72 -310
  68. data/lib/sass/util/multibyte_string_scanner.rb +127 -131
  69. data/lib/sass/util/normalized_map.rb +1 -8
  70. data/lib/sass/version.rb +0 -4
  71. metadata +55 -202
  72. data/Rakefile +0 -453
  73. data/lib/sass/script/css_variable_warning.rb +0 -52
  74. data/lib/sass/util/cross_platform_random.rb +0 -19
  75. data/lib/sass/util/ordered_hash.rb +0 -192
  76. data/test/sass-spec.yml +0 -3
  77. data/test/sass/cache_test.rb +0 -131
  78. data/test/sass/callbacks_test.rb +0 -61
  79. data/test/sass/compiler_test.rb +0 -236
  80. data/test/sass/conversion_test.rb +0 -2188
  81. data/test/sass/css2sass_test.rb +0 -526
  82. data/test/sass/css_variable_test.rb +0 -132
  83. data/test/sass/data/hsl-rgb.txt +0 -319
  84. data/test/sass/encoding_test.rb +0 -219
  85. data/test/sass/engine_test.rb +0 -3447
  86. data/test/sass/exec_test.rb +0 -96
  87. data/test/sass/extend_test.rb +0 -1733
  88. data/test/sass/fixtures/test_staleness_check_across_importers.css +0 -1
  89. data/test/sass/fixtures/test_staleness_check_across_importers.scss +0 -1
  90. data/test/sass/functions_test.rb +0 -1977
  91. data/test/sass/importer_test.rb +0 -421
  92. data/test/sass/logger_test.rb +0 -58
  93. data/test/sass/mock_importer.rb +0 -49
  94. data/test/sass/more_results/more1.css +0 -9
  95. data/test/sass/more_results/more1_with_line_comments.css +0 -26
  96. data/test/sass/more_results/more_import.css +0 -29
  97. data/test/sass/more_templates/_more_partial.sass +0 -2
  98. data/test/sass/more_templates/more1.sass +0 -23
  99. data/test/sass/more_templates/more_import.sass +0 -11
  100. data/test/sass/plugin_test.rb +0 -556
  101. data/test/sass/results/alt.css +0 -4
  102. data/test/sass/results/basic.css +0 -9
  103. data/test/sass/results/cached_import_option.css +0 -3
  104. data/test/sass/results/compact.css +0 -5
  105. data/test/sass/results/complex.css +0 -86
  106. data/test/sass/results/compressed.css +0 -1
  107. data/test/sass/results/expanded.css +0 -19
  108. data/test/sass/results/filename_fn.css +0 -3
  109. data/test/sass/results/if.css +0 -3
  110. data/test/sass/results/import.css +0 -31
  111. data/test/sass/results/import_charset.css +0 -5
  112. data/test/sass/results/import_charset_1_8.css +0 -5
  113. data/test/sass/results/import_charset_ibm866.css +0 -5
  114. data/test/sass/results/import_content.css +0 -1
  115. data/test/sass/results/line_numbers.css +0 -49
  116. data/test/sass/results/mixins.css +0 -95
  117. data/test/sass/results/multiline.css +0 -24
  118. data/test/sass/results/nested.css +0 -22
  119. data/test/sass/results/options.css +0 -1
  120. data/test/sass/results/parent_ref.css +0 -13
  121. data/test/sass/results/script.css +0 -16
  122. data/test/sass/results/scss_import.css +0 -31
  123. data/test/sass/results/scss_importee.css +0 -2
  124. data/test/sass/results/subdir/nested_subdir/nested_subdir.css +0 -1
  125. data/test/sass/results/subdir/subdir.css +0 -3
  126. data/test/sass/results/units.css +0 -11
  127. data/test/sass/results/warn.css +0 -0
  128. data/test/sass/results/warn_imported.css +0 -0
  129. data/test/sass/script_conversion_test.rb +0 -357
  130. data/test/sass/script_test.rb +0 -1431
  131. data/test/sass/scss/css_test.rb +0 -1281
  132. data/test/sass/scss/rx_test.rb +0 -160
  133. data/test/sass/scss/scss_test.rb +0 -4205
  134. data/test/sass/scss/test_helper.rb +0 -37
  135. data/test/sass/source_map_test.rb +0 -1055
  136. data/test/sass/superselector_test.rb +0 -210
  137. data/test/sass/templates/_cached_import_option_partial.scss +0 -1
  138. data/test/sass/templates/_double_import_loop2.sass +0 -1
  139. data/test/sass/templates/_filename_fn_import.scss +0 -11
  140. data/test/sass/templates/_imported_charset_ibm866.sass +0 -4
  141. data/test/sass/templates/_imported_charset_utf8.sass +0 -4
  142. data/test/sass/templates/_imported_content.sass +0 -3
  143. data/test/sass/templates/_partial.sass +0 -2
  144. data/test/sass/templates/_same_name_different_partiality.scss +0 -1
  145. data/test/sass/templates/alt.sass +0 -16
  146. data/test/sass/templates/basic.sass +0 -23
  147. data/test/sass/templates/bork1.sass +0 -2
  148. data/test/sass/templates/bork2.sass +0 -2
  149. data/test/sass/templates/bork3.sass +0 -2
  150. data/test/sass/templates/bork4.sass +0 -2
  151. data/test/sass/templates/bork5.sass +0 -3
  152. data/test/sass/templates/cached_import_option.scss +0 -3
  153. data/test/sass/templates/compact.sass +0 -17
  154. data/test/sass/templates/complex.sass +0 -305
  155. data/test/sass/templates/compressed.sass +0 -15
  156. data/test/sass/templates/double_import_loop1.sass +0 -1
  157. data/test/sass/templates/expanded.sass +0 -17
  158. data/test/sass/templates/filename_fn.scss +0 -18
  159. data/test/sass/templates/if.sass +0 -11
  160. data/test/sass/templates/import.sass +0 -12
  161. data/test/sass/templates/import_charset.sass +0 -9
  162. data/test/sass/templates/import_charset_1_8.sass +0 -6
  163. data/test/sass/templates/import_charset_ibm866.sass +0 -11
  164. data/test/sass/templates/import_content.sass +0 -4
  165. data/test/sass/templates/importee.less +0 -2
  166. data/test/sass/templates/importee.sass +0 -19
  167. data/test/sass/templates/line_numbers.sass +0 -13
  168. data/test/sass/templates/mixin_bork.sass +0 -5
  169. data/test/sass/templates/mixins.sass +0 -76
  170. data/test/sass/templates/multiline.sass +0 -20
  171. data/test/sass/templates/nested.sass +0 -25
  172. data/test/sass/templates/nested_bork1.sass +0 -2
  173. data/test/sass/templates/nested_bork2.sass +0 -2
  174. data/test/sass/templates/nested_bork3.sass +0 -2
  175. data/test/sass/templates/nested_bork4.sass +0 -2
  176. data/test/sass/templates/nested_import.sass +0 -2
  177. data/test/sass/templates/nested_mixin_bork.sass +0 -6
  178. data/test/sass/templates/options.sass +0 -2
  179. data/test/sass/templates/parent_ref.sass +0 -25
  180. data/test/sass/templates/same_name_different_ext.sass +0 -2
  181. data/test/sass/templates/same_name_different_ext.scss +0 -1
  182. data/test/sass/templates/same_name_different_partiality.scss +0 -1
  183. data/test/sass/templates/script.sass +0 -101
  184. data/test/sass/templates/scss_import.scss +0 -12
  185. data/test/sass/templates/scss_importee.scss +0 -1
  186. data/test/sass/templates/single_import_loop.sass +0 -1
  187. data/test/sass/templates/subdir/import_up1.scss +0 -1
  188. data/test/sass/templates/subdir/import_up2.scss +0 -1
  189. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +0 -2
  190. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +0 -3
  191. data/test/sass/templates/subdir/subdir.sass +0 -6
  192. data/test/sass/templates/units.sass +0 -11
  193. data/test/sass/templates/warn.sass +0 -3
  194. data/test/sass/templates/warn_imported.sass +0 -4
  195. data/test/sass/test_helper.rb +0 -8
  196. data/test/sass/util/multibyte_string_scanner_test.rb +0 -155
  197. data/test/sass/util/normalized_map_test.rb +0 -51
  198. data/test/sass/util/subset_map_test.rb +0 -91
  199. data/test/sass/util_test.rb +0 -438
  200. data/test/sass/value_helpers_test.rb +0 -179
  201. data/test/test_helper.rb +0 -110
  202. data/vendor/listen/CHANGELOG.md +0 -1
  203. data/vendor/listen/CONTRIBUTING.md +0 -38
  204. data/vendor/listen/Gemfile +0 -20
  205. data/vendor/listen/Guardfile +0 -8
  206. data/vendor/listen/LICENSE +0 -20
  207. data/vendor/listen/README.md +0 -349
  208. data/vendor/listen/Rakefile +0 -5
  209. data/vendor/listen/Vagrantfile +0 -96
  210. data/vendor/listen/lib/listen.rb +0 -54
  211. data/vendor/listen/lib/listen/adapter.rb +0 -327
  212. data/vendor/listen/lib/listen/adapters/bsd.rb +0 -75
  213. data/vendor/listen/lib/listen/adapters/darwin.rb +0 -48
  214. data/vendor/listen/lib/listen/adapters/linux.rb +0 -81
  215. data/vendor/listen/lib/listen/adapters/polling.rb +0 -58
  216. data/vendor/listen/lib/listen/adapters/windows.rb +0 -91
  217. data/vendor/listen/lib/listen/directory_record.rb +0 -406
  218. data/vendor/listen/lib/listen/listener.rb +0 -323
  219. data/vendor/listen/lib/listen/turnstile.rb +0 -32
  220. data/vendor/listen/lib/listen/version.rb +0 -3
  221. data/vendor/listen/listen.gemspec +0 -28
  222. data/vendor/listen/spec/listen/adapter_spec.rb +0 -149
  223. data/vendor/listen/spec/listen/adapters/bsd_spec.rb +0 -36
  224. data/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -37
  225. data/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -47
  226. data/vendor/listen/spec/listen/adapters/polling_spec.rb +0 -68
  227. data/vendor/listen/spec/listen/adapters/windows_spec.rb +0 -30
  228. data/vendor/listen/spec/listen/directory_record_spec.rb +0 -1250
  229. data/vendor/listen/spec/listen/listener_spec.rb +0 -258
  230. data/vendor/listen/spec/listen/turnstile_spec.rb +0 -56
  231. data/vendor/listen/spec/listen_spec.rb +0 -67
  232. data/vendor/listen/spec/spec_helper.rb +0 -25
  233. data/vendor/listen/spec/support/adapter_helper.rb +0 -666
  234. data/vendor/listen/spec/support/directory_record_helper.rb +0 -57
  235. data/vendor/listen/spec/support/fixtures_helper.rb +0 -29
  236. data/vendor/listen/spec/support/listeners_helper.rb +0 -179
  237. data/vendor/listen/spec/support/platform_helper.rb +0 -15
@@ -1,179 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../test_helper'
3
-
4
- class ValueHelpersTest < MiniTest::Test
5
- include Sass::Script
6
- include Sass::Script::Value::Helpers
7
-
8
- def test_bool
9
- assert_same Value::Bool::TRUE, bool(true)
10
- assert_same Value::Bool::FALSE, bool(false)
11
- assert_same Value::Bool::FALSE, bool(nil)
12
- assert_same Value::Bool::TRUE, bool(Object.new)
13
- end
14
-
15
- def test_hex_color_with_three_digits
16
- color = hex_color("F07")
17
- assert_equal 255, color.red
18
- assert_equal 0, color.green
19
- assert_equal 119, color.blue
20
- assert_equal 1, color.alpha
21
- end
22
-
23
- def test_hex_color_without_hash
24
- color_without_hash = hex_color("FF007F")
25
- assert_equal 255, color_without_hash.red
26
- assert_equal 0, color_without_hash.green
27
- assert_equal 127, color_without_hash.blue
28
- assert_equal 1, color_without_hash.alpha
29
- end
30
-
31
- def test_hex_color_with_hash
32
- color_with_hash = hex_color("#FF007F")
33
- assert_equal 255, color_with_hash.red
34
- assert_equal 0, color_with_hash.green
35
- assert_equal 127, color_with_hash.blue
36
- assert_equal 1, color_with_hash.alpha
37
- end
38
-
39
- def test_malformed_hex_color
40
- assert_raises ArgumentError do
41
- hex_color("green")
42
- end
43
- assert_raises ArgumentError do
44
- hex_color("#abcd")
45
- end
46
- end
47
-
48
-
49
- def test_hex_color_with_alpha
50
- color_with_alpha = hex_color("FF007F", 0.5)
51
- assert_equal 0.5, color_with_alpha.alpha
52
- end
53
-
54
- def test_hex_color_alpha_clamps_0_to_1
55
- assert_equal 1, hex_color("FF007F", 50).alpha
56
- end
57
-
58
- def test_hsl_color_without_alpha
59
- no_alpha = hsl_color(1, 0.5, 1)
60
- assert_equal 1, no_alpha.hue
61
- assert_equal 0.5, no_alpha.saturation
62
- assert_equal 1, no_alpha.lightness
63
- assert_equal 1, no_alpha.alpha
64
- end
65
-
66
- def test_hsl_color_with_alpha
67
- has_alpha = hsl_color(1, 0.5, 1, 0.5)
68
- assert_equal 1, has_alpha.hue
69
- assert_equal 0.5, has_alpha.saturation
70
- assert_equal 1, has_alpha.lightness
71
- assert_equal 0.5, has_alpha.alpha
72
- end
73
-
74
- def test_rgb_color_without_alpha
75
- no_alpha = rgb_color(255, 0, 0)
76
- assert_equal 255, no_alpha.red
77
- assert_equal 0, no_alpha.green
78
- assert_equal 0, no_alpha.blue
79
- assert_equal 1, no_alpha.alpha
80
- end
81
-
82
- def test_rgb_color_with_alpha
83
- has_alpha = rgb_color(255, 255, 255, 0.5)
84
- assert_equal 255, has_alpha.red
85
- assert_equal 255, has_alpha.green
86
- assert_equal 255, has_alpha.blue
87
- assert_equal 0.5, has_alpha.alpha
88
- end
89
-
90
- def test_number
91
- n = number(1)
92
- assert_equal 1, n.value
93
- assert_equal "1", n.to_sass
94
- end
95
-
96
- def test_number_with_single_unit
97
- n = number(1, "px")
98
- assert_equal 1, n.value
99
- assert_equal "1px", n.to_sass
100
- end
101
-
102
- def test_number_with_singal_numerator_and_denominator
103
- ratio = number(1, "px/em")
104
- assert_equal "1px/em", ratio.to_sass
105
- end
106
-
107
- def test_number_with_many_numerator_and_denominator_units
108
- complex = number(1, "px*in/em*%")
109
- assert_equal "1in*px/%*em", complex.to_sass
110
- end
111
-
112
- def test_number_with_many_numerator_and_denominator_units_with_spaces
113
- complex = number(1, "px * in / em * %")
114
- assert_equal "1in*px/%*em", complex.to_sass
115
- end
116
-
117
- def test_number_with_malformed_units
118
- assert_raises ArgumentError do
119
- number(1, "px/em/%")
120
- end
121
- assert_raises ArgumentError do
122
- number(1, "/")
123
- end
124
- assert_raises ArgumentError do
125
- number(1, "px/")
126
- end
127
- end
128
-
129
- def test_space_list
130
- l = list(number(1, "px"), hex_color("#f71"), :space)
131
- l.options = {}
132
- assert_kind_of Sass::Script::Value::List, l
133
- assert_equal "1px #f71", l.to_sass
134
- end
135
-
136
- def test_comma_list
137
- l = list(number(1, "px"), hex_color("#f71"), :comma)
138
- l.options = {}
139
- assert_kind_of Sass::Script::Value::List, l
140
- assert_equal "1px, #f71", l.to_sass
141
- end
142
-
143
- def test_missing_list_type
144
- assert_raises ArgumentError do
145
- list(number(1, "px"), hex_color("#f71"))
146
- end
147
- end
148
-
149
- def test_null
150
- assert_kind_of Sass::Script::Value::Null, null
151
- end
152
-
153
- def test_quoted_string
154
- s = quoted_string("sassy string")
155
- s.options = {}
156
- assert_kind_of Sass::Script::Value::String, s
157
- assert_equal "sassy string", s.value
158
- assert_equal :string, s.type
159
- assert_equal '"sassy string"', s.to_sass
160
- end
161
-
162
- def test_identifier
163
- s = identifier("a-sass-ident")
164
- s.options = {}
165
- assert_kind_of Sass::Script::Value::String, s
166
- assert_equal "a-sass-ident", s.value
167
- assert_equal :identifier, s.type
168
- assert_equal "a-sass-ident", s.to_sass
169
- end
170
-
171
- def test_unquoted_string
172
- s = unquoted_string("a-sass-ident")
173
- s.options = {}
174
- assert_kind_of Sass::Script::Value::String, s
175
- assert_equal "a-sass-ident", s.value
176
- assert_equal :identifier, s.type
177
- assert_equal "a-sass-ident", s.to_sass
178
- end
179
- end
@@ -1,110 +0,0 @@
1
- lib_dir = File.dirname(__FILE__) + '/../lib'
2
-
3
- require 'minitest/autorun'
4
- require 'fileutils'
5
- $:.unshift lib_dir unless $:.include?(lib_dir)
6
- require 'sass'
7
- require 'mathn' if ENV['MATHN'] == 'true'
8
-
9
- Sass::RAILS_LOADED = true unless defined?(Sass::RAILS_LOADED)
10
-
11
- Sass.tests_running = true
12
-
13
- if defined?(Encoding)
14
- $-w, w = false, $-w
15
- Encoding.default_external = 'UTF-8'
16
- $-w = w
17
- end
18
-
19
- module Sass::Script::Functions
20
- def option(name)
21
- Sass::Script::Value::String.new(@options[name.value.to_sym].to_s)
22
- end
23
- end
24
-
25
- class MiniTest::Test
26
- def munge_filename(opts = {})
27
- opts[:filename] ||= filename_for_test(opts[:syntax] || :sass)
28
- opts[:sourcemap_filename] ||= sourcemap_filename_for_test
29
- opts
30
- end
31
-
32
- def test_name
33
- caller.
34
- map {|c| Sass::Util.caller_info(c)[2]}.
35
- compact.
36
- map {|c| c.sub(/^(block|rescue) in /, '')}.
37
- find {|c| c =~ /^test_/}
38
- end
39
-
40
- def filename_for_test(syntax = :sass)
41
- "#{test_name}_inline.#{syntax}"
42
- end
43
-
44
- def sourcemap_filename_for_test(syntax = :sass)
45
- "#{test_name}_inline.css.map"
46
- end
47
-
48
- def clean_up_sassc
49
- path = File.dirname(__FILE__) + "/../.sass-cache"
50
- Sass::Util.retry_on_windows {FileUtils.rm_r(path) if File.exist?(path)}
51
- end
52
-
53
- def assert_warning(message)
54
- the_real_stderr, $stderr = $stderr, StringIO.new
55
- result = yield
56
-
57
- if message.is_a?(Regexp)
58
- assert_match message, $stderr.string.strip
59
- else
60
- assert_equal message.strip, $stderr.string.strip
61
- end
62
- result
63
- ensure
64
- $stderr = the_real_stderr
65
- end
66
-
67
- def assert_no_warning
68
- the_real_stderr, $stderr = $stderr, StringIO.new
69
- result = yield
70
- assert_equal '', $stderr.string
71
- result
72
- ensure
73
- $stderr = the_real_stderr
74
- end
75
-
76
- def silence_warnings(&block)
77
- Sass::Util.silence_warnings(&block)
78
- end
79
-
80
- def assert_raise_message(klass, message)
81
- yield
82
- rescue Exception => e
83
- assert_instance_of(klass, e)
84
- assert_equal(message, e.message)
85
- else
86
- flunk "Expected exception #{klass}, none raised"
87
- end
88
-
89
- def assert_raise_line(line)
90
- yield
91
- rescue Sass::SyntaxError => e
92
- assert_equal(line, e.sass_line)
93
- else
94
- flunk "Expected exception on line #{line}, none raised"
95
- end
96
- end
97
-
98
- module PublicApiLinter
99
- def lint_api(api_class, duck_type_class)
100
- define_method :test_lint_instance do
101
- assert lint_instance.is_a?(duck_type_class)
102
- end
103
- api_class.instance_methods.each do |meth|
104
- define_method :"test_has_#{meth}" do
105
- assert lint_instance.respond_to?(meth),
106
- "#{duck_type_class.name} does not implement #{meth}"
107
- end
108
- end
109
- end
110
- end
@@ -1 +0,0 @@
1
- # Moved to [Github releases](https://github.com/guard/listen/releases) page.
@@ -1,38 +0,0 @@
1
- Contribute to Listen
2
- ===================
3
-
4
- File an issue
5
- -------------
6
-
7
- You can report bugs and feature requests to [GitHub Issues](https://github.com/guard/listen/issues).
8
-
9
- **Please don't ask question in the issue tracker**, instead ask them in our
10
- [Google group](http://groups.google.com/group/guard-dev) or on `#guard` (irc.freenode.net).
11
-
12
- Try to figure out where the issue belongs to: Is it an issue with Listen itself or with Guard?
13
-
14
- When you file a bug, please try to follow these simple rules if applicable:
15
-
16
- * Make sure you run Listen with `bundle exec` first.
17
- * Add your `Guardfile` (if used) and `Gemfile` to the issue.
18
- * Make sure that the issue is reproducible with your description.
19
-
20
- **It's most likely that your bug gets resolved faster if you provide as much information as possible!**
21
-
22
- Development
23
- -----------
24
-
25
- * Documentation hosted at [RubyDoc](http://rubydoc.info/github/guard/listen/master/frames).
26
- * Source hosted at [GitHub](https://github.com/guard/listen).
27
-
28
- Pull requests are very welcome! Please try to follow these simple rules if applicable:
29
-
30
- * Please create a topic branch for every separate change you make.
31
- * Make sure your patches are well tested. All specs run with `rake spec` must pass.
32
- * Update the [Yard](http://yardoc.org/) documentation.
33
- * Update the [README](https://github.com/guard/listen/blob/master/README.md).
34
- * Update the [CHANGELOG](https://github.com/guard/listen/blob/master/CHANGELOG.md) for noteworthy changes.
35
- * Please **do not change** the version number.
36
-
37
- For questions please join us in our [Google group](http://groups.google.com/group/guard-dev) or on
38
- `#guard` (irc.freenode.net).
@@ -1,20 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
4
-
5
- gem 'rake'
6
-
7
- require 'rbconfig'
8
- gem 'wdm', '>= 0.1.0' if RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
9
-
10
- group :development do
11
- gem 'guard-rspec'
12
- gem 'yard'
13
- gem 'redcarpet'
14
- gem 'pimpmychangelog'
15
- end
16
-
17
- group :test do
18
- gem 'rspec'
19
- gem 'coveralls', :require => false
20
- end
@@ -1,8 +0,0 @@
1
- guard :rspec, :all_on_start => false, :all_after_pass => false do
2
- watch(%r{^spec/.+_spec\.rb$})
3
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
- watch('spec/support/adapter_helper.rb') { "spec/listen/adapters" }
5
- watch('spec/support/listener_helper.rb') { "spec/listen/listener_spec.rb" }
6
- watch('spec/support/fixtures_helper.rb') { "spec" }
7
- watch('spec/spec_helper.rb') { "spec" }
8
- end
@@ -1,20 +0,0 @@
1
- Copyright (c) 2013 Thibaud Guillaume-Gentil
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,349 +0,0 @@
1
- # Listen [![Gem Version](https://badge.fury.io/rb/listen.png)](http://badge.fury.io/rb/listen) [![Build Status](https://secure.travis-ci.org/guard/listen.png?branch=master)](http://travis-ci.org/guard/listen) [![Dependency Status](https://gemnasium.com/guard/listen.png)](https://gemnasium.com/guard/listen) [![Code Climate](https://codeclimate.com/github/guard/listen.png)](https://codeclimate.com/github/guard/listen) [![Coverage Status](https://coveralls.io/repos/guard/listen/badge.png?branch=master)](https://coveralls.io/r/guard/listen)
2
-
3
- The Listen gem listens to file modifications and notifies you about the changes.
4
-
5
- ## Features
6
-
7
- * Works everywhere!
8
- * Supports watching multiple directories from a single listener.
9
- * OS-specific adapters for Mac OS X 10.6+, Linux, *BSD and Windows.
10
- * Automatic fallback to polling if OS-specific adapter doesn't work.
11
- * Detects file modification, addition and removal.
12
- * File content checksum comparison for modifications made under the same second.
13
- * Allows supplying regexp-patterns to ignore and filter paths for better results.
14
- * Tested on all Ruby environments via [Travis CI](https://travis-ci.org/guard/listen).
15
-
16
- ## Pending features
17
-
18
- Still not implemented, pull requests are welcome.
19
-
20
- * Symlinks support. [#25](https://github.com/guard/listen/issues/25)
21
- * Signal handling. [#105](https://github.com/guard/listen/issues/105)
22
- * Non-recursive directory scanning. [#111](https://github.com/guard/listen/issues/111)
23
-
24
- ## Install
25
-
26
- ### Using Bundler
27
-
28
- The simplest way to install Listen is to use Bundler.
29
-
30
- Add Listen to your Gemfile:
31
-
32
- ```ruby
33
- group :development do
34
- gem 'listen'
35
- end
36
- ```
37
-
38
- and install it by running Bundler:
39
-
40
- ```bash
41
- $ bundle
42
- ```
43
-
44
- ### Install the gem with RubyGems
45
-
46
- ```bash
47
- $ gem install listen
48
- ```
49
-
50
- ### On Windows
51
-
52
- If your are on Windows and using Ruby MRI >= 1.9.2 you can try to use the [`wdm`](https://github.com/Maher4Ever/wdm) instead of polling.
53
- Please add the following to your Gemfile:
54
-
55
- ```ruby
56
- require 'rbconfig'
57
- gem 'wdm', '>= 0.1.0' if RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
58
- ```
59
-
60
- ## Usage
61
-
62
- There are **two ways** to use Listen:
63
-
64
- 1. Block API: Call `Listen.to`/`Listen.to!` with either a single directory or multiple directories, then define the `change` callback in a block.
65
- 2. "Object" API: Create a `listener` object and use it in a chainable way.
66
-
67
- ### Block API
68
-
69
- ``` ruby
70
- # Listen to a single directory.
71
- Listen.to('dir/path/to/listen', :filter => /\.rb$/, :ignore => %r{ignored/path/}) do |modified, added, removed|
72
- # ...
73
- end
74
-
75
- # Listen to multiple directories.
76
- Listen.to('dir/to/awesome_app', 'dir/to/other_app', :filter => /\.rb$/, :latency => 0.1) do |modified, added, removed|
77
- # ...
78
- end
79
- ```
80
-
81
- ### "Object" API
82
-
83
- ``` ruby
84
- listener = Listen.to('dir/path/to/listen')
85
- listener = listener.ignore(%r{^ignored/path/})
86
- listener = listener.filter(/\.rb$/)
87
- listener = listener.latency(0.5)
88
- listener = listener.force_polling(true)
89
- listener = listener.polling_fallback_message(false)
90
- listener = listener.force_adapter(Listen::Adapters::Linux)
91
- listener = listener.change(&callback)
92
- listener.start
93
- ```
94
-
95
- **Note**: All the "Object" API methods except `start`/`start!` return the listener
96
- and are thus chainable:
97
-
98
- ``` ruby
99
- Listen.to('dir/path/to/listen')
100
- .ignore(%r{^ignored/path/})
101
- .filter(/\.rb$/)
102
- .latency(0.5)
103
- .force_polling(true)
104
- .polling_fallback_message('custom message')
105
- .change(&callback)
106
- .start
107
- ```
108
-
109
- ### Pause/Unpause
110
-
111
- Listener can also easily be paused/unpaused:
112
-
113
- ``` ruby
114
- listener = Listen.to('dir/path/to/listen')
115
- listener.start # non-blocking mode
116
- listener.pause # stop listening to changes
117
- listener.paused? # => true
118
- listener.unpause # start listening to changes again
119
- listener.stop # stop completely the listener
120
- ```
121
-
122
- ## Changes callback
123
-
124
- Changes to the listened-to directories gets reported back to the user in a callback.
125
- The registered callback gets invoked, when there are changes, with **three** parameters:
126
- `modified_paths`, `added_paths` and `removed_paths` in that particular order.
127
-
128
- You can register a callback in two ways. The first way is by passing a block when calling
129
- the `Listen.to`/`Listen.to!` method or when initializing a listener object:
130
-
131
- ```ruby
132
- Listen.to('path/to/app') do |modified, added, removed|
133
- # This block will be called when there are changes.
134
- end
135
-
136
- # or ...
137
-
138
- listener = Listen::Listener.new('path/to/app') do |modified, added, removed|
139
- # This block will be called when there are changes.
140
- end
141
-
142
- ```
143
-
144
- The second way to register a callback is by calling the `#change` method on a
145
- listener passing it a block:
146
-
147
- ```ruby
148
- # Create a callback
149
- callback = Proc.new do |modified, added, removed|
150
- # This proc will be called when there are changes.
151
- end
152
-
153
- listener = Listen.to('dir')
154
- listener.change(&callback) # convert the callback to a block and register it
155
-
156
- listener.start
157
- ```
158
-
159
- ### Paths in callbacks
160
-
161
- Listeners invoke callbacks passing them absolute paths by default:
162
-
163
- ```ruby
164
- # Assume someone changes the 'style.css' file in '/home/user/app/css' after creating
165
- # the listener.
166
- Listen.to('/home/user/app/css') do |modified, added, removed|
167
- modified.inspect # => ['/home/user/app/css/style.css']
168
- end
169
- ```
170
-
171
- #### Relative paths in callbacks
172
-
173
- When creating a listener for a **single** path (more specifically a `Listen::Listener` instance),
174
- you can pass `:relative_paths => true` as an option to get relative paths in
175
- your callback:
176
-
177
- ```ruby
178
- # Assume someone changes the 'style.css' file in '/home/user/app/css' after creating
179
- # the listener.
180
- Listen.to('/home/user/app/css', :relative_paths => true) do |modified, added, removed|
181
- modified.inspect # => ['style.css']
182
- end
183
- ```
184
-
185
- Passing the `:relative_paths => true` option won't work when listening to multiple
186
- directories:
187
-
188
- ```ruby
189
- # Assume someone changes the 'style.css' file in '/home/user/app/css' after creating
190
- # the listener.
191
- Listen.to('/home/user/app/css', '/home/user/app/js', :relative_paths => true) do |modified, added, removed|
192
- modified.inspect # => ['/home/user/app/css/style.css']
193
- end
194
- ```
195
-
196
- ## Options
197
-
198
- All the following options can be set through the `Listen.to`/`Listen.to!` params
199
- or via ["Object" API](#object-api) methods:
200
-
201
- ```ruby
202
- :ignore => %r{app/CMake/}, /\.pid$/ # Ignore a list of paths (root directory or sub-dir)
203
- # default: See DEFAULT_IGNORED_DIRECTORIES and DEFAULT_IGNORED_EXTENSIONS in Listen::DirectoryRecord
204
-
205
- :filter => /\.rb$/, /\.coffee$/ # Filter files to listen to via a regexps list.
206
- # default: none
207
-
208
- :latency => 0.5 # Set the delay (**in seconds**) between checking for changes
209
- # default: 0.25 sec (1.0 sec for polling)
210
-
211
- :force_adapter => Listen::Adapters::Linux # Force the use of a particular adapter class
212
- # default: none
213
-
214
- :force_polling => true # Force the use of the polling adapter
215
- # default: none
216
-
217
- :polling_fallback_message => 'custom message' # Set a custom polling fallback message (or disable it with false)
218
- # default: "Listen will be polling for changes. Learn more at https://github.com/guard/listen#polling-fallback."
219
-
220
- :relative_paths => true # Enable the use of relative paths in the callback.
221
- # default: false
222
- ```
223
-
224
- ### Note on the patterns for ignoring and filtering paths
225
-
226
- Just like the unix convention of beginning absolute paths with the
227
- directory-separator (forward slash `/` in unix) and with no prefix for relative paths,
228
- Listen doesn't prefix relative paths (to the watched directory) with a directory-separator.
229
-
230
- Therefore make sure _NOT_ to prefix your regexp-patterns for filtering or ignoring paths
231
- with a directory-separator, otherwise they won't work as expected.
232
-
233
- As an example: to ignore the `build` directory in a C-project, use `%r{build/}`
234
- and not `%r{/build/}`.
235
-
236
- Use `#filter!` and `#ignore!` methods to overwrites default patterns.
237
-
238
- ## Blocking listening to changes
239
-
240
- Calling `Listen.to` with a block doesn't block the current thread. If you want
241
- to block the current thread instead until the listener is stopped (which needs
242
- to be done from another thread), you can use `Listen.to!`.
243
-
244
- Similarly, if you're using the "Object" API, you can use `#start!` instead of `#start` to block the
245
- current thread until the listener is stopped.
246
-
247
- Here is an example of using a listener in the blocking mode:
248
-
249
- ```ruby
250
- Listen.to!('dir/path/to/listen') # block execution
251
-
252
- # Code here will not run until the listener is stopped
253
-
254
- ```
255
-
256
- Here is an example of using a listener started with the "Object" API in blocking mode:
257
-
258
- ```ruby
259
- listener = Listen.to('dir/path/to/listen')
260
- listener.start! # block execution
261
-
262
- # Code here will not run until the listener is stopped
263
-
264
- ```
265
-
266
- **Note**: Using the `Listen.to!` helper-method with or without a callback-block
267
- will always start the listener right away and block execution of the current thread.
268
-
269
- ## Listen adapters
270
-
271
- The Listen gem has a set of adapters to notify it when there are changes.
272
- There are 4 OS-specific adapters to support Mac, Linux, *BSD and Windows.
273
- These adapters are fast as they use some system-calls to implement the notifying function.
274
-
275
- There is also a polling adapter which is a cross-platform adapter and it will
276
- work on any system. This adapter is unfortunately slower than the rest of the adapters.
277
-
278
- The Listen gem will choose the best and working adapter for your machine automatically. If you
279
- want to force the use of the polling adapter, either use the `:force_polling` option
280
- while initializing the listener or call the `#force_polling` method on your listener
281
- before starting it.
282
-
283
- It is also possible to force the use of a particular adapter, by using the `:force_adapter`
284
- option. This option skips the usual adapter choosing mechanism and uses the given
285
- adapter class instead. The adapter choosing mechanism requires write permission
286
- to your watched directories and will needlessly load code, which isn't always desirable.
287
-
288
- ## Polling fallback
289
-
290
- When a OS-specific adapter doesn't work the Listen gem automatically falls back to the polling adapter.
291
- Here are some things you could try to avoid the polling fallback:
292
-
293
- * [Update your Dropbox client](http://www.dropbox.com/downloading) (if used).
294
- * Increase latency. (Please [open an issue](https://github.com/guard/listen/issues/new)
295
- if you think that default is too low.)
296
- * Move or rename the listened folder.
297
- * Update/reboot your OS.
298
-
299
- If your application keeps using the polling-adapter and you can't figure out why, feel free to [open an issue](https://github.com/guard/listen/issues/new) (and be sure to [give all the details](https://github.com/guard/listen/blob/master/CONTRIBUTING.md)).
300
-
301
- ## Development [![Dependency Status](https://gemnasium.com/guard/listen.png?branch=master)](https://gemnasium.com/guard/listen)
302
-
303
- * Documentation hosted at [RubyDoc](http://rubydoc.info/github/guard/listen/master/frames).
304
- * Source hosted at [GitHub](https://github.com/guard/listen).
305
-
306
- Pull requests are very welcome! Please try to follow these simple rules if applicable:
307
-
308
- * Please create a topic branch for every separate change you make.
309
- * Make sure your patches are well tested. All specs must pass on [Travis CI](https://travis-ci.org/guard/listen).
310
- * Update the [Yard](http://yardoc.org/) documentation.
311
- * Update the [README](https://github.com/guard/listen/blob/master/README.md).
312
- * Update the [CHANGELOG](https://github.com/guard/listen/blob/master/CHANGELOG.md) for noteworthy changes (don't forget to run `bundle exec pimpmychangelog` and watch the magic happen)!
313
- * Please **do not change** the version number.
314
-
315
- For questions please join us in our [Google group](http://groups.google.com/group/guard-dev) or on
316
- `#guard` (irc.freenode.net).
317
-
318
- ## Acknowledgments
319
-
320
- * [Michael Kessler (netzpirat)][] for having written the [initial specs](https://github.com/guard/listen/commit/1e457b13b1bb8a25d2240428ce5ed488bafbed1f).
321
- * [Travis Tilley (ttilley)][] for this awesome work on [fssm][] & [rb-fsevent][].
322
- * [Nathan Weizenbaum (nex3)][] for [rb-inotify][], a thorough inotify wrapper.
323
- * [Mathieu Arnold (mat813)][] for [rb-kqueue][], a simple kqueue wrapper.
324
- * [stereobooster][] for [rb-fchange][], windows support wouldn't exist without him.
325
- * [Yehuda Katz (wycats)][] for [vigilo][], that has been a great source of inspiration.
326
-
327
- ## Authors
328
-
329
- * [Thibaud Guillaume-Gentil][] ([@thibaudgg](http://twitter.com/thibaudgg))
330
- * [Maher Sallam][] ([@mahersalam](http://twitter.com/mahersalam))
331
-
332
- ## Contributors
333
-
334
- [https://github.com/guard/listen/contributors](https://github.com/guard/listen/contributors)
335
-
336
- [Thibaud Guillaume-Gentil]: https://github.com/thibaudgg
337
- [Maher Sallam]: https://github.com/Maher4Ever
338
- [Michael Kessler (netzpirat)]: https://github.com/netzpirat
339
- [Travis Tilley (ttilley)]: https://github.com/ttilley
340
- [fssm]: https://github.com/ttilley/fssm
341
- [rb-fsevent]: https://github.com/thibaudgg/rb-fsevent
342
- [Mathieu Arnold (mat813)]: https://github.com/mat813
343
- [Nathan Weizenbaum (nex3)]: https://github.com/nex3
344
- [rb-inotify]: https://github.com/nex3/rb-inotify
345
- [stereobooster]: https://github.com/stereobooster
346
- [rb-fchange]: https://github.com/stereobooster/rb-fchange
347
- [rb-kqueue]: https://github.com/mat813/rb-kqueue
348
- [Yehuda Katz (wycats)]: https://github.com/wycats
349
- [vigilo]: https://github.com/wycats/vigilo