haml 2.2.24 → 3.0.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of haml might be problematic. Click here for more details.

Files changed (168) hide show
  1. data/.yardopts +0 -1
  2. data/README.md +91 -151
  3. data/REMEMBER +11 -1
  4. data/Rakefile +73 -55
  5. data/VERSION +1 -1
  6. data/VERSION_NAME +1 -1
  7. data/bin/css2sass +7 -1
  8. data/bin/sass-convert +7 -0
  9. data/extra/haml-mode.el +2 -1
  10. data/lib/haml/buffer.rb +22 -4
  11. data/lib/haml/engine.rb +5 -1
  12. data/lib/haml/exec.rb +231 -46
  13. data/lib/haml/filters.rb +19 -8
  14. data/lib/haml/helpers.rb +47 -20
  15. data/lib/haml/helpers/action_view_extensions.rb +2 -4
  16. data/lib/haml/helpers/action_view_mods.rb +11 -8
  17. data/lib/haml/helpers/xss_mods.rb +13 -2
  18. data/lib/haml/html.rb +179 -48
  19. data/lib/haml/html/erb.rb +141 -0
  20. data/lib/haml/precompiler.rb +40 -15
  21. data/lib/haml/railtie.rb +1 -5
  22. data/lib/haml/root.rb +3 -0
  23. data/lib/haml/template.rb +4 -14
  24. data/lib/haml/util.rb +120 -30
  25. data/lib/haml/version.rb +25 -2
  26. data/lib/sass.rb +5 -1
  27. data/lib/sass/callbacks.rb +50 -0
  28. data/lib/sass/css.rb +40 -191
  29. data/lib/sass/engine.rb +170 -74
  30. data/lib/sass/environment.rb +8 -2
  31. data/lib/sass/error.rb +163 -25
  32. data/lib/sass/files.rb +31 -28
  33. data/lib/sass/plugin.rb +268 -87
  34. data/lib/sass/plugin/rails.rb +9 -4
  35. data/lib/sass/repl.rb +1 -1
  36. data/lib/sass/script.rb +31 -29
  37. data/lib/sass/script/bool.rb +1 -0
  38. data/lib/sass/script/color.rb +290 -23
  39. data/lib/sass/script/css_lexer.rb +22 -0
  40. data/lib/sass/script/css_parser.rb +28 -0
  41. data/lib/sass/script/funcall.rb +22 -3
  42. data/lib/sass/script/functions.rb +523 -33
  43. data/lib/sass/script/interpolation.rb +42 -0
  44. data/lib/sass/script/lexer.rb +169 -52
  45. data/lib/sass/script/literal.rb +58 -9
  46. data/lib/sass/script/node.rb +79 -1
  47. data/lib/sass/script/number.rb +20 -5
  48. data/lib/sass/script/operation.rb +49 -3
  49. data/lib/sass/script/parser.rb +162 -28
  50. data/lib/sass/script/string.rb +50 -2
  51. data/lib/sass/script/unary_operation.rb +25 -2
  52. data/lib/sass/script/variable.rb +21 -4
  53. data/lib/sass/scss.rb +14 -0
  54. data/lib/sass/scss/css_parser.rb +39 -0
  55. data/lib/sass/scss/parser.rb +683 -0
  56. data/lib/sass/scss/rx.rb +112 -0
  57. data/lib/sass/scss/script_lexer.rb +13 -0
  58. data/lib/sass/scss/script_parser.rb +25 -0
  59. data/lib/sass/tree/comment_node.rb +69 -27
  60. data/lib/sass/tree/debug_node.rb +7 -2
  61. data/lib/sass/tree/directive_node.rb +41 -35
  62. data/lib/sass/tree/for_node.rb +6 -0
  63. data/lib/sass/tree/if_node.rb +13 -1
  64. data/lib/sass/tree/import_node.rb +52 -27
  65. data/lib/sass/tree/mixin_def_node.rb +18 -0
  66. data/lib/sass/tree/mixin_node.rb +41 -6
  67. data/lib/sass/tree/node.rb +197 -70
  68. data/lib/sass/tree/prop_node.rb +152 -57
  69. data/lib/sass/tree/root_node.rb +118 -0
  70. data/lib/sass/tree/rule_node.rb +193 -96
  71. data/lib/sass/tree/variable_node.rb +9 -5
  72. data/lib/sass/tree/while_node.rb +4 -0
  73. data/test/benchmark.rb +5 -5
  74. data/test/haml/engine_test.rb +147 -10
  75. data/test/haml/{rhtml/_av_partial_1.rhtml → erb/_av_partial_1.erb} +1 -1
  76. data/test/haml/{rhtml/_av_partial_2.rhtml → erb/_av_partial_2.erb} +1 -1
  77. data/test/haml/{rhtml/action_view.rhtml → erb/action_view.erb} +1 -1
  78. data/test/haml/{rhtml/standard.rhtml → erb/standard.erb} +0 -0
  79. data/test/haml/helper_test.rb +91 -24
  80. data/test/haml/html2haml/erb_tests.rb +410 -0
  81. data/test/haml/html2haml_test.rb +210 -66
  82. data/test/haml/results/filters.xhtml +1 -1
  83. data/test/haml/results/just_stuff.xhtml +2 -0
  84. data/test/haml/spec_test.rb +44 -0
  85. data/test/haml/template_test.rb +22 -2
  86. data/test/haml/templates/helpers.haml +0 -13
  87. data/test/haml/templates/just_stuff.haml +2 -0
  88. data/test/haml/util_test.rb +48 -0
  89. data/test/sass/callbacks_test.rb +61 -0
  90. data/test/sass/conversion_test.rb +884 -0
  91. data/test/sass/css2sass_test.rb +99 -18
  92. data/test/sass/data/hsl-rgb.txt +319 -0
  93. data/test/sass/engine_test.rb +1049 -131
  94. data/test/sass/functions_test.rb +398 -47
  95. data/test/sass/more_results/more_import.css +1 -1
  96. data/test/sass/more_templates/more_import.sass +3 -3
  97. data/test/sass/plugin_test.rb +184 -10
  98. data/test/sass/results/compact.css +1 -1
  99. data/test/sass/results/complex.css +5 -5
  100. data/test/sass/results/compressed.css +1 -1
  101. data/test/sass/results/expanded.css +1 -1
  102. data/test/sass/results/import.css +3 -1
  103. data/test/sass/results/mixins.css +12 -12
  104. data/test/sass/results/nested.css +1 -1
  105. data/test/sass/results/options.css +1 -0
  106. data/test/sass/results/parent_ref.css +4 -4
  107. data/test/sass/results/script.css +3 -3
  108. data/test/sass/results/scss_import.css +15 -0
  109. data/test/sass/results/scss_importee.css +2 -0
  110. data/test/sass/script_conversion_test.rb +153 -0
  111. data/test/sass/script_test.rb +137 -70
  112. data/test/sass/scss/css_test.rb +811 -0
  113. data/test/sass/scss/rx_test.rb +156 -0
  114. data/test/sass/scss/scss_test.rb +871 -0
  115. data/test/sass/scss/test_helper.rb +37 -0
  116. data/test/sass/templates/alt.sass +2 -2
  117. data/test/sass/templates/bork1.sass +2 -0
  118. data/test/sass/templates/bork3.sass +2 -0
  119. data/test/sass/templates/bork4.sass +2 -0
  120. data/test/sass/templates/import.sass +4 -4
  121. data/test/sass/templates/importee.sass +3 -3
  122. data/test/sass/templates/line_numbers.sass +1 -1
  123. data/test/sass/templates/mixin_bork.sass +5 -0
  124. data/test/sass/templates/mixins.sass +2 -2
  125. data/test/sass/templates/nested_bork1.sass +2 -0
  126. data/test/sass/templates/nested_bork2.sass +2 -0
  127. data/test/sass/templates/nested_bork3.sass +2 -0
  128. data/test/sass/templates/nested_bork4.sass +2 -0
  129. data/test/sass/templates/nested_mixin_bork.sass +6 -0
  130. data/test/sass/templates/options.sass +2 -0
  131. data/test/sass/templates/parent_ref.sass +2 -2
  132. data/test/sass/templates/script.sass +69 -69
  133. data/test/sass/templates/scss_import.scss +10 -0
  134. data/test/sass/templates/scss_importee.scss +1 -0
  135. data/test/sass/templates/units.sass +10 -10
  136. data/test/test_helper.rb +20 -8
  137. data/vendor/fssm/LICENSE +20 -0
  138. data/vendor/fssm/README.markdown +55 -0
  139. data/vendor/fssm/Rakefile +59 -0
  140. data/vendor/fssm/VERSION.yml +5 -0
  141. data/vendor/fssm/example.rb +9 -0
  142. data/vendor/fssm/fssm.gemspec +77 -0
  143. data/vendor/fssm/lib/fssm.rb +33 -0
  144. data/vendor/fssm/lib/fssm/backends/fsevents.rb +36 -0
  145. data/vendor/fssm/lib/fssm/backends/inotify.rb +26 -0
  146. data/vendor/fssm/lib/fssm/backends/polling.rb +25 -0
  147. data/vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb +131 -0
  148. data/vendor/fssm/lib/fssm/monitor.rb +26 -0
  149. data/vendor/fssm/lib/fssm/path.rb +91 -0
  150. data/vendor/fssm/lib/fssm/pathname.rb +502 -0
  151. data/vendor/fssm/lib/fssm/state/directory.rb +57 -0
  152. data/vendor/fssm/lib/fssm/state/file.rb +24 -0
  153. data/vendor/fssm/lib/fssm/support.rb +63 -0
  154. data/vendor/fssm/lib/fssm/tree.rb +176 -0
  155. data/vendor/fssm/profile/prof-cache.rb +40 -0
  156. data/vendor/fssm/profile/prof-fssm-pathname.html +1231 -0
  157. data/vendor/fssm/profile/prof-pathname.rb +68 -0
  158. data/vendor/fssm/profile/prof-plain-pathname.html +988 -0
  159. data/vendor/fssm/profile/prof.html +2379 -0
  160. data/vendor/fssm/spec/path_spec.rb +75 -0
  161. data/vendor/fssm/spec/root/duck/quack.txt +0 -0
  162. data/vendor/fssm/spec/root/file.css +0 -0
  163. data/vendor/fssm/spec/root/file.rb +0 -0
  164. data/vendor/fssm/spec/root/file.yml +0 -0
  165. data/vendor/fssm/spec/root/moo/cow.txt +0 -0
  166. data/vendor/fssm/spec/spec_helper.rb +14 -0
  167. metadata +94 -14
  168. data/test/sass/templates/bork.sass +0 -2
@@ -0,0 +1,37 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+ require 'sass/engine'
3
+
4
+ module ScssTestHelper
5
+ def assert_parses(scss)
6
+ assert_equal scss.rstrip, render(scss).rstrip
7
+ end
8
+
9
+ def assert_not_parses(expected, scss)
10
+ raise "Template must include <err> where an error is expected" unless scss.include?("<err>")
11
+
12
+ after, was = scss.split("<err>")
13
+ line = after.count("\n") + 1
14
+
15
+ after.gsub!(/\s*\n\s*$/, '')
16
+ after.gsub!(/.*\n/, '')
17
+ after = "..." + after[-15..-1] if after.size > 18
18
+
19
+ was.gsub!(/^\s*\n\s*/, '')
20
+ was.gsub!(/\n.*/, '')
21
+ was = was[0...15] + "..." if was.size > 18
22
+
23
+ to_render = scss.sub("<err>", "")
24
+ render(to_render)
25
+ assert(false, "Expected syntax error for:\n#{to_render}\n")
26
+ rescue Sass::SyntaxError => err
27
+ assert_equal("Invalid CSS after \"#{after}\": expected #{expected}, was \"#{was}\"",
28
+ err.message)
29
+ assert_equal line, err.sass_line
30
+ end
31
+
32
+ def render(scss, options = {})
33
+ options[:syntax] ||= :scss
34
+ munge_filename options
35
+ Sass::Engine.new(scss, options).render
36
+ end
37
+ end
@@ -12,5 +12,5 @@ h1
12
12
  color: red
13
13
  :background-color green
14
14
  const
15
- nosp= 1 + 2
16
- sp = 1 + 2
15
+ nosp: 1 + 2
16
+ sp : 1 + 2
@@ -0,0 +1,2 @@
1
+ bork
2
+ :bork $bork
@@ -0,0 +1,2 @@
1
+ bork
2
+ bork:
@@ -0,0 +1,2 @@
1
+
2
+ bork: blah
@@ -1,11 +1,11 @@
1
- !preconst = "hello"
1
+ $preconst: hello
2
2
 
3
3
  =premixin
4
4
  pre-mixin: here
5
5
 
6
- @import importee.sass, basic.sass, basic.css, ../results/complex.css, partial.sass
6
+ @import importee.sass, scss_importee, basic.sass, basic.css, ../results/complex.css, partial.sass
7
7
 
8
8
  nonimported
9
- :myconst = !preconst
10
- :otherconst = !postconst
9
+ :myconst $preconst
10
+ :otherconst $postconst
11
11
  +postmixin
@@ -1,11 +1,11 @@
1
- !postconst = "goodbye"
1
+ $postconst: goodbye
2
2
 
3
3
  =postmixin
4
4
  post-mixin: here
5
5
 
6
6
  imported
7
- :otherconst = !preconst
8
- :myconst = !postconst
7
+ :otherconst $preconst
8
+ :myconst $postconst
9
9
  +premixin
10
10
 
11
11
  @import basic
@@ -5,7 +5,7 @@ foo
5
5
  squggle
6
6
  blat: bang
7
7
 
8
- !preconst = 12
8
+ $preconst: 12
9
9
 
10
10
  @import importee
11
11
 
@@ -0,0 +1,5 @@
1
+ =outer-mixin
2
+ +error-mixin
3
+
4
+ foo
5
+ +outer-mixin
@@ -1,10 +1,10 @@
1
- !yellow = #fc0
1
+ $yellow: #fc0
2
2
 
3
3
  =bordered
4
4
  :border
5
5
  :top
6
6
  :width 2px
7
- :color = !yellow
7
+ :color $yellow
8
8
  :left
9
9
  :width 1px
10
10
  :color #000
@@ -0,0 +1,2 @@
1
+
2
+ @import bork1
@@ -0,0 +1,2 @@
1
+
2
+ @import bork2
@@ -0,0 +1,2 @@
1
+
2
+ @import bork3
@@ -0,0 +1,2 @@
1
+
2
+ @import bork4
@@ -0,0 +1,6 @@
1
+
2
+
3
+ =error-mixin
4
+ width: 1px * 1em
5
+
6
+ @import mixin_bork
@@ -0,0 +1,2 @@
1
+ foo
2
+ style: option("style")
@@ -15,9 +15,9 @@ p, div
15
15
  :style solid
16
16
  :width 2em
17
17
  .ie7 &, .ie6 &
18
- :content string(Totally not cool.)
18
+ :content string("Totally not cool.")
19
19
  .firefox &
20
- :content string(Quite cool.)
20
+ :content string("Quite cool.")
21
21
 
22
22
  .wow, .snazzy
23
23
  :font-family fantasy
@@ -1,101 +1,101 @@
1
- !width = 10em + 20
2
- !color = #00ff98
3
- !main_text = #ffa
4
- !num = 10
5
- !dec = 10.2
6
- !dec_0 = 99.0
7
- !neg = -10
8
- !esc= 10"+12"
9
- !str= "Hello!"
10
- !qstr= "Quo\"ted\"!"
11
- !hstr= "Hyph-en!"
12
- !concat = "#{5 + 4} hi there"
13
- !percent= 11%
14
- !complex = 1px/1em
1
+ $width: 10em + 20
2
+ $color: #00ff98
3
+ $main_text: #ffa
4
+ $num: 10
5
+ $dec: 10.2
6
+ $dec_0: 99.0
7
+ $neg: -10
8
+ $esc: 10\+12
9
+ $str: Hello\!
10
+ $qstr: "Quo\"ted\"!"
11
+ $hstr: Hyph-en\!
12
+ $concat: #{5 + 4} hi there
13
+ $percent: 11%
14
+ $complex: 1px/1em
15
15
 
16
16
  #main
17
- :content = !str
18
- :qstr = !qstr
19
- :hstr = !hstr
20
- :width = !width
17
+ :content $str
18
+ :qstr $qstr
19
+ :hstr $hstr
20
+ :width $width
21
21
  :background-color #000
22
- :color= !main_text
23
- :short-color= #123
24
- :named-color= olive
25
- :con= "foo" bar (!concat "boom")
26
- :con2= "noquo" "quo"
22
+ :color $main_text
23
+ :short-color #123
24
+ :named-color olive
25
+ :con "foo" bar ($concat "boom")
26
+ :con2 "noquo" quo
27
27
  #sidebar
28
- :background-color= !color
28
+ :background-color $color
29
29
  :num
30
- :normal= !num
31
- :dec= !dec
32
- :dec0= !dec_0
33
- :neg= !neg
34
- :esc= !esc
35
- :many= 1 + 2 + 3
36
- :order= 1 + 2 * 3
37
- :complex= ((1 + 2) + 15)+#3a8b9f + ("hi"+(1 +1+ 2)* 4)
30
+ :normal $num
31
+ :dec $dec
32
+ :dec0 $dec_0
33
+ :neg $neg
34
+ :esc $esc
35
+ :many 1 + 2 + 3
36
+ :order 1 + 2 * 3
37
+ :complex ((1 + 2) + 15)+#3a8b9f + (hi+(1 +1+ 2)* 4)
38
38
 
39
39
  #plus
40
40
  :num
41
- :num= 5+2
42
- :num-un= 10em + 15em
43
- :num-un2= 10 + 13em
44
- :num-neg= 10 + -.13
45
- :str= 100 * 1px
46
- :col= 13 + #aaa
47
- :perc = !percent + 20%
41
+ :num 5+2
42
+ :num-un 10em + 15em
43
+ :num-un2 10 + 13em
44
+ :num-neg 10 + -.13
45
+ :str 100 * 1px
46
+ :col 13 + #aaa
47
+ :perc $percent + 20%
48
48
  :str
49
- :str= "hi" + "\ there"
50
- :str2= "hi" + " there"
51
- :col= "14em solid " + #123
52
- :num= "times: " + 13
49
+ :str "hi" + "\ there"
50
+ :str2 "hi" + " there"
51
+ :col "14em solid " + #123
52
+ :num "times: " + 13
53
53
  :col
54
- :num= #f02 + 123.5
55
- :col= #12A + #405162
54
+ :num #f02 + 123.5
55
+ :col #12A + #405162
56
56
 
57
57
  #minus
58
58
  :num
59
- :num= 912 - 12
59
+ :num 912 - 12
60
60
  :col
61
- :num= #fffffa - 5.2
62
- :col= #abcdef - #fedcba
61
+ :num #fffffa - 5.2
62
+ :col #abcdef - #fedcba
63
63
  :unary
64
- :num= -1
65
- :const= -!neg
66
- :paren= -(5 + 6)
67
- :two= --12
68
- :many= --------12
69
- :crazy= -----(5 + ---!neg)
64
+ :num -1
65
+ :const -$neg
66
+ :paren -(5 + 6)
67
+ :two --12
68
+ :many --------12
69
+ :crazy -----(5 + ---$neg)
70
70
 
71
71
  #times
72
72
  :num
73
- :num= 2 * 3.5
74
- :col= 2 * #3a4b5c
73
+ :num 2 * 3.5
74
+ :col 2 * #3a4b5c
75
75
  :col
76
- :num= #12468a * 0.5
77
- :col= #121212 * #020304
76
+ :num #12468a * 0.5
77
+ :col #121212 * #020304
78
78
 
79
79
  #div
80
80
  :num
81
- :num= 10 / 3.0
82
- :num2= 10 / 3
81
+ :num (10 / 3.0)
82
+ :num2 (10 / 3)
83
83
  :col
84
- :num= #12468a / 2
85
- :col= #abcdef / #0f0f0f
86
- :comp = !complex * 1em
84
+ :num #12468a / 2
85
+ :col #abcdef / #0f0f0f
86
+ :comp $complex * 1em
87
87
 
88
88
  #mod
89
89
  :num
90
- :num= 17 % 3
90
+ :num 17 % 3
91
91
  :col
92
- :col= #5f6e7d % #10200a
93
- :num= #aaabac % 3
92
+ :col #5f6e7d % #10200a
93
+ :num #aaabac % 3
94
94
 
95
95
  #const
96
96
  :escaped
97
- :quote = "!foo"
98
- :default = !str !important
97
+ :quote \$foo \!bar
98
+ :default $str !important
99
99
 
100
100
  #regression
101
- :a= (3 + 2) - 1
101
+ :a (3 + 2) - 1
@@ -0,0 +1,10 @@
1
+ $preconst: hello;
2
+
3
+ @mixin premixin {pre-mixin: here}
4
+
5
+ @import "importee.sass";
6
+
7
+ nonimported {
8
+ myconst: $preconst;
9
+ otherconst: $postconst;
10
+ @include postmixin; }
@@ -0,0 +1 @@
1
+ scss {imported: yes}
@@ -1,11 +1,11 @@
1
1
  b
2
- :foo= 0.5 * 10px
3
- :bar= 10zzz * 12px / 5zzz
4
- :baz= percentage(12.0px / 18px)
5
- :many-units= 10.0zzz / 3yyy * 12px / 5zzz * 3yyy / 3px * 4em
6
- :mm= 5mm + 1cm
7
- :pc= 1pc + 12pt
8
- :pt= 72pt - 2in
9
- :inches= 1in + 2.54cm
10
- :more-inches= 1in + ((72pt * 2in) + (36pt * 1in)) / 2.54cm
11
- :mixed= (1 + (1em * 6px / 3in)) * 4in / 2em
2
+ :foo 0.5 * 10px
3
+ :bar 10zzz * 12px / 5zzz
4
+ :baz percentage(12.0px / 18px)
5
+ :many-units 10.0zzz / 3yyy * 12px / 5zzz * 3yyy / 3px * 4em
6
+ :mm 5mm + 1cm
7
+ :pc 1pc + 12pt
8
+ :pt 72pt - 2in
9
+ :inches 1in + 2.54cm
10
+ :more-inches 1in + ((72pt * 2in) + (36pt * 1in)) / 2.54cm
11
+ :mixed (1 + (1em * 6px / 3in)) * 4in / 2em
@@ -9,11 +9,28 @@ require 'sass'
9
9
 
10
10
  Sass::RAILS_LOADED = true unless defined?(Sass::RAILS_LOADED)
11
11
 
12
+ module Sass::Script::Functions
13
+ module UserFunctions; end
14
+ include UserFunctions
15
+
16
+ def option(name)
17
+ Sass::Script::String.new(@options[name.value.to_sym].to_s)
18
+ end
19
+ end
20
+
12
21
  class Test::Unit::TestCase
13
- def munge_filename(opts)
22
+ def munge_filename(opts = {})
14
23
  return if opts.has_key?(:filename)
15
- test_name = caller[1].gsub(/^.*`(?:\w+ )*(\w+)'.*$/, '\1')
16
- opts[:filename] = "#{test_name}_inline.sass"
24
+ opts[:filename] = filename_for_test(opts[:syntax] || :sass)
25
+ end
26
+
27
+ def filename_for_test(syntax = :sass)
28
+ test_name = caller.
29
+ map {|c| Haml::Util.caller_info(c)[2]}.
30
+ compact.
31
+ map {|c| c.sub(/^(block|rescue) in /, '')}.
32
+ find {|c| c =~ /^test_/}
33
+ "#{test_name}_inline.#{syntax}"
17
34
  end
18
35
 
19
36
  def clean_up_sassc
@@ -42,9 +59,4 @@ class Test::Unit::TestCase
42
59
  return '=' if Haml::Util.ap_geq_3?
43
60
  return '-'
44
61
  end
45
-
46
- def form_for_calling_convention(name)
47
- return "@#{name}, :as => :#{name}, :html => {:class => nil, :id => nil}" if Haml::Util.ap_geq_3_beta_3?
48
- return ":#{name}, @#{name}"
49
- end
50
62
  end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Travis Tilley
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.
@@ -0,0 +1,55 @@
1
+ Monitor API
2
+ ===========
3
+
4
+ There are three ways you can run the monitor.
5
+
6
+ 1. call monitor with a path parameter, and define callbacks in a block
7
+ 2. call monitor with a block to configure multiple paths and callbacks
8
+ 3. create a monitor object and run each step manually
9
+
10
+ Monitor with path
11
+ -----------------
12
+
13
+ This form watches one path, and enters the run loop automatically. The first parameter is the path to watch, and the second parameter is an optional glob pattern or array of glob patterns that a file must match in order to trigger a callback. The default glob, if ommitted, is `'**/*'`.
14
+
15
+ FSSM.monitor('/some/directory/', '**/*') do
16
+ update {|base, relative|}
17
+ delete {|base, relative|}
18
+ create {|base, relative|}
19
+ end
20
+
21
+ Monitor with block
22
+ ------------------
23
+
24
+ This form watches one or more paths, and enters the run loop automatically. The glob configuration call can be ommitted, and defaults to `'**/*'`.
25
+
26
+ FSSM.monitor do
27
+ path '/some/directory/' do
28
+ glob '**/*.yml'
29
+
30
+ update {|base, relative|}
31
+ delete {|base, relative|}
32
+ create {|base, relative|}
33
+ end
34
+
35
+ path '/some/other/directory/' do
36
+ update {|base, relative|}
37
+ delete {|base, relative|}
38
+ create {|base, relative|}
39
+ end
40
+ end
41
+
42
+ Monitor object
43
+ --------------
44
+
45
+ This form doesn't enter the run loop automatically.
46
+
47
+ monitor = FSSM::Monitor.new
48
+
49
+ monitor.path '/some/directory/' do
50
+ update {|base, relative|}
51
+ delete {|base, relative|}
52
+ create {|base, relative|}
53
+ end
54
+
55
+ monitor.run