sass 3.1.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (260) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTING +1 -1
  3. data/MIT-LICENSE +2 -2
  4. data/README.md +29 -17
  5. data/Rakefile +43 -9
  6. data/VERSION +1 -1
  7. data/VERSION_DATE +1 -0
  8. data/VERSION_NAME +1 -1
  9. data/bin/sass +6 -1
  10. data/bin/sass-convert +6 -1
  11. data/bin/scss +6 -1
  12. data/ext/mkrf_conf.rb +27 -0
  13. data/lib/sass/cache_stores/base.rb +7 -3
  14. data/lib/sass/cache_stores/chain.rb +3 -2
  15. data/lib/sass/cache_stores/filesystem.rb +5 -7
  16. data/lib/sass/cache_stores/memory.rb +1 -1
  17. data/lib/sass/cache_stores/null.rb +2 -2
  18. data/lib/sass/callbacks.rb +2 -1
  19. data/lib/sass/css.rb +168 -53
  20. data/lib/sass/engine.rb +502 -174
  21. data/lib/sass/environment.rb +151 -111
  22. data/lib/sass/error.rb +7 -7
  23. data/lib/sass/exec.rb +176 -60
  24. data/lib/sass/features.rb +40 -0
  25. data/lib/sass/importers/base.rb +46 -7
  26. data/lib/sass/importers/deprecated_path.rb +51 -0
  27. data/lib/sass/importers/filesystem.rb +113 -30
  28. data/lib/sass/importers.rb +1 -0
  29. data/lib/sass/logger/base.rb +30 -0
  30. data/lib/sass/logger/log_level.rb +45 -0
  31. data/lib/sass/logger.rb +12 -0
  32. data/lib/sass/media.rb +213 -0
  33. data/lib/sass/plugin/compiler.rb +194 -104
  34. data/lib/sass/plugin/configuration.rb +18 -25
  35. data/lib/sass/plugin/merb.rb +1 -1
  36. data/lib/sass/plugin/staleness_checker.rb +37 -11
  37. data/lib/sass/plugin.rb +10 -13
  38. data/lib/sass/railtie.rb +2 -1
  39. data/lib/sass/repl.rb +5 -6
  40. data/lib/sass/script/css_lexer.rb +8 -4
  41. data/lib/sass/script/css_parser.rb +5 -2
  42. data/lib/sass/script/functions.rb +1547 -618
  43. data/lib/sass/script/lexer.rb +122 -72
  44. data/lib/sass/script/parser.rb +304 -135
  45. data/lib/sass/script/tree/funcall.rb +306 -0
  46. data/lib/sass/script/{interpolation.rb → tree/interpolation.rb} +43 -13
  47. data/lib/sass/script/tree/list_literal.rb +77 -0
  48. data/lib/sass/script/tree/literal.rb +45 -0
  49. data/lib/sass/script/tree/map_literal.rb +64 -0
  50. data/lib/sass/script/{node.rb → tree/node.rb} +30 -12
  51. data/lib/sass/script/{operation.rb → tree/operation.rb} +33 -21
  52. data/lib/sass/script/{string_interpolation.rb → tree/string_interpolation.rb} +14 -4
  53. data/lib/sass/script/{unary_operation.rb → tree/unary_operation.rb} +21 -9
  54. data/lib/sass/script/tree/variable.rb +57 -0
  55. data/lib/sass/script/tree.rb +15 -0
  56. data/lib/sass/script/value/arg_list.rb +36 -0
  57. data/lib/sass/script/value/base.rb +238 -0
  58. data/lib/sass/script/value/bool.rb +40 -0
  59. data/lib/sass/script/{color.rb → value/color.rb} +256 -74
  60. data/lib/sass/script/value/deprecated_false.rb +55 -0
  61. data/lib/sass/script/value/helpers.rb +155 -0
  62. data/lib/sass/script/value/list.rb +128 -0
  63. data/lib/sass/script/value/map.rb +70 -0
  64. data/lib/sass/script/value/null.rb +49 -0
  65. data/lib/sass/script/{number.rb → value/number.rb} +115 -62
  66. data/lib/sass/script/{string.rb → value/string.rb} +9 -11
  67. data/lib/sass/script/value.rb +12 -0
  68. data/lib/sass/script.rb +35 -9
  69. data/lib/sass/scss/css_parser.rb +2 -12
  70. data/lib/sass/scss/parser.rb +657 -230
  71. data/lib/sass/scss/rx.rb +17 -12
  72. data/lib/sass/scss/static_parser.rb +37 -6
  73. data/lib/sass/scss.rb +0 -1
  74. data/lib/sass/selector/abstract_sequence.rb +35 -3
  75. data/lib/sass/selector/comma_sequence.rb +29 -14
  76. data/lib/sass/selector/sequence.rb +371 -74
  77. data/lib/sass/selector/simple.rb +28 -13
  78. data/lib/sass/selector/simple_sequence.rb +163 -36
  79. data/lib/sass/selector.rb +138 -36
  80. data/lib/sass/shared.rb +3 -5
  81. data/lib/sass/source/map.rb +196 -0
  82. data/lib/sass/source/position.rb +39 -0
  83. data/lib/sass/source/range.rb +41 -0
  84. data/lib/sass/stack.rb +126 -0
  85. data/lib/sass/supports.rb +228 -0
  86. data/lib/sass/tree/at_root_node.rb +82 -0
  87. data/lib/sass/tree/comment_node.rb +34 -29
  88. data/lib/sass/tree/content_node.rb +9 -0
  89. data/lib/sass/tree/css_import_node.rb +60 -0
  90. data/lib/sass/tree/debug_node.rb +3 -3
  91. data/lib/sass/tree/directive_node.rb +33 -3
  92. data/lib/sass/tree/each_node.rb +9 -9
  93. data/lib/sass/tree/extend_node.rb +20 -6
  94. data/lib/sass/tree/for_node.rb +6 -6
  95. data/lib/sass/tree/function_node.rb +12 -4
  96. data/lib/sass/tree/if_node.rb +2 -15
  97. data/lib/sass/tree/import_node.rb +11 -5
  98. data/lib/sass/tree/media_node.rb +27 -11
  99. data/lib/sass/tree/mixin_def_node.rb +15 -4
  100. data/lib/sass/tree/mixin_node.rb +27 -7
  101. data/lib/sass/tree/node.rb +69 -35
  102. data/lib/sass/tree/prop_node.rb +47 -31
  103. data/lib/sass/tree/return_node.rb +4 -3
  104. data/lib/sass/tree/root_node.rb +20 -4
  105. data/lib/sass/tree/rule_node.rb +37 -26
  106. data/lib/sass/tree/supports_node.rb +38 -0
  107. data/lib/sass/tree/trace_node.rb +33 -0
  108. data/lib/sass/tree/variable_node.rb +10 -4
  109. data/lib/sass/tree/visitors/base.rb +5 -8
  110. data/lib/sass/tree/visitors/check_nesting.rb +67 -52
  111. data/lib/sass/tree/visitors/convert.rb +134 -53
  112. data/lib/sass/tree/visitors/cssize.rb +245 -51
  113. data/lib/sass/tree/visitors/deep_copy.rb +102 -0
  114. data/lib/sass/tree/visitors/extend.rb +68 -0
  115. data/lib/sass/tree/visitors/perform.rb +331 -105
  116. data/lib/sass/tree/visitors/set_options.rb +125 -0
  117. data/lib/sass/tree/visitors/to_css.rb +259 -95
  118. data/lib/sass/tree/warn_node.rb +3 -3
  119. data/lib/sass/tree/while_node.rb +3 -3
  120. data/lib/sass/util/cross_platform_random.rb +19 -0
  121. data/lib/sass/util/multibyte_string_scanner.rb +157 -0
  122. data/lib/sass/util/normalized_map.rb +130 -0
  123. data/lib/sass/util/ordered_hash.rb +192 -0
  124. data/lib/sass/util/subset_map.rb +11 -2
  125. data/lib/sass/util/test.rb +9 -0
  126. data/lib/sass/util.rb +565 -39
  127. data/lib/sass/version.rb +27 -15
  128. data/lib/sass.rb +39 -4
  129. data/test/sass/cache_test.rb +15 -0
  130. data/test/sass/compiler_test.rb +223 -0
  131. data/test/sass/conversion_test.rb +901 -107
  132. data/test/sass/css2sass_test.rb +94 -0
  133. data/test/sass/engine_test.rb +1059 -164
  134. data/test/sass/exec_test.rb +86 -0
  135. data/test/sass/extend_test.rb +933 -837
  136. data/test/sass/fixtures/test_staleness_check_across_importers.css +1 -0
  137. data/test/sass/fixtures/test_staleness_check_across_importers.scss +1 -0
  138. data/test/sass/functions_test.rb +995 -136
  139. data/test/sass/importer_test.rb +338 -18
  140. data/test/sass/logger_test.rb +58 -0
  141. data/test/sass/more_results/more_import.css +2 -2
  142. data/test/sass/plugin_test.rb +114 -30
  143. data/test/sass/results/cached_import_option.css +3 -0
  144. data/test/sass/results/filename_fn.css +3 -0
  145. data/test/sass/results/import.css +2 -2
  146. data/test/sass/results/import_charset.css +1 -0
  147. data/test/sass/results/import_charset_1_8.css +1 -0
  148. data/test/sass/results/import_charset_ibm866.css +1 -0
  149. data/test/sass/results/import_content.css +1 -0
  150. data/test/sass/results/script.css +1 -1
  151. data/test/sass/results/scss_import.css +2 -2
  152. data/test/sass/results/units.css +2 -2
  153. data/test/sass/script_conversion_test.rb +43 -1
  154. data/test/sass/script_test.rb +380 -36
  155. data/test/sass/scss/css_test.rb +257 -75
  156. data/test/sass/scss/scss_test.rb +2322 -110
  157. data/test/sass/source_map_test.rb +887 -0
  158. data/test/sass/templates/_cached_import_option_partial.scss +1 -0
  159. data/test/sass/templates/_double_import_loop2.sass +1 -0
  160. data/test/sass/templates/_filename_fn_import.scss +11 -0
  161. data/test/sass/templates/_imported_content.sass +3 -0
  162. data/test/sass/templates/_same_name_different_partiality.scss +1 -0
  163. data/test/sass/templates/bork5.sass +3 -0
  164. data/test/sass/templates/cached_import_option.scss +3 -0
  165. data/test/sass/templates/double_import_loop1.sass +1 -0
  166. data/test/sass/templates/filename_fn.scss +18 -0
  167. data/test/sass/templates/import_charset.sass +2 -0
  168. data/test/sass/templates/import_charset_1_8.sass +2 -0
  169. data/test/sass/templates/import_charset_ibm866.sass +2 -0
  170. data/test/sass/templates/import_content.sass +4 -0
  171. data/test/sass/templates/same_name_different_ext.sass +2 -0
  172. data/test/sass/templates/same_name_different_ext.scss +1 -0
  173. data/test/sass/templates/same_name_different_partiality.scss +1 -0
  174. data/test/sass/templates/single_import_loop.sass +1 -0
  175. data/test/sass/templates/subdir/import_up1.scss +1 -0
  176. data/test/sass/templates/subdir/import_up2.scss +1 -0
  177. data/test/sass/test_helper.rb +1 -1
  178. data/test/sass/util/multibyte_string_scanner_test.rb +147 -0
  179. data/test/sass/util/normalized_map_test.rb +51 -0
  180. data/test/sass/util_test.rb +183 -0
  181. data/test/sass/value_helpers_test.rb +181 -0
  182. data/test/test_helper.rb +45 -5
  183. data/vendor/listen/CHANGELOG.md +228 -0
  184. data/vendor/listen/CONTRIBUTING.md +38 -0
  185. data/vendor/listen/Gemfile +30 -0
  186. data/vendor/listen/Guardfile +8 -0
  187. data/vendor/{fssm → listen}/LICENSE +1 -1
  188. data/vendor/listen/README.md +315 -0
  189. data/vendor/listen/Rakefile +47 -0
  190. data/vendor/listen/Vagrantfile +96 -0
  191. data/vendor/listen/lib/listen/adapter.rb +214 -0
  192. data/vendor/listen/lib/listen/adapters/bsd.rb +112 -0
  193. data/vendor/listen/lib/listen/adapters/darwin.rb +85 -0
  194. data/vendor/listen/lib/listen/adapters/linux.rb +113 -0
  195. data/vendor/listen/lib/listen/adapters/polling.rb +67 -0
  196. data/vendor/listen/lib/listen/adapters/windows.rb +87 -0
  197. data/vendor/listen/lib/listen/dependency_manager.rb +126 -0
  198. data/vendor/listen/lib/listen/directory_record.rb +371 -0
  199. data/vendor/listen/lib/listen/listener.rb +225 -0
  200. data/vendor/listen/lib/listen/multi_listener.rb +143 -0
  201. data/vendor/listen/lib/listen/turnstile.rb +28 -0
  202. data/vendor/listen/lib/listen/version.rb +3 -0
  203. data/vendor/listen/lib/listen.rb +40 -0
  204. data/vendor/listen/listen.gemspec +22 -0
  205. data/vendor/listen/spec/listen/adapter_spec.rb +183 -0
  206. data/vendor/listen/spec/listen/adapters/bsd_spec.rb +36 -0
  207. data/vendor/listen/spec/listen/adapters/darwin_spec.rb +37 -0
  208. data/vendor/listen/spec/listen/adapters/linux_spec.rb +47 -0
  209. data/vendor/listen/spec/listen/adapters/polling_spec.rb +68 -0
  210. data/vendor/listen/spec/listen/adapters/windows_spec.rb +30 -0
  211. data/vendor/listen/spec/listen/dependency_manager_spec.rb +107 -0
  212. data/vendor/listen/spec/listen/directory_record_spec.rb +1225 -0
  213. data/vendor/listen/spec/listen/listener_spec.rb +169 -0
  214. data/vendor/listen/spec/listen/multi_listener_spec.rb +174 -0
  215. data/vendor/listen/spec/listen/turnstile_spec.rb +56 -0
  216. data/vendor/listen/spec/listen_spec.rb +73 -0
  217. data/vendor/listen/spec/spec_helper.rb +21 -0
  218. data/vendor/listen/spec/support/adapter_helper.rb +629 -0
  219. data/vendor/listen/spec/support/directory_record_helper.rb +55 -0
  220. data/vendor/listen/spec/support/fixtures_helper.rb +29 -0
  221. data/vendor/listen/spec/support/listeners_helper.rb +156 -0
  222. data/vendor/listen/spec/support/platform_helper.rb +15 -0
  223. metadata +344 -271
  224. data/lib/sass/less.rb +0 -382
  225. data/lib/sass/script/bool.rb +0 -18
  226. data/lib/sass/script/funcall.rb +0 -162
  227. data/lib/sass/script/list.rb +0 -76
  228. data/lib/sass/script/literal.rb +0 -245
  229. data/lib/sass/script/variable.rb +0 -54
  230. data/lib/sass/scss/sass_parser.rb +0 -11
  231. data/test/sass/less_conversion_test.rb +0 -653
  232. data/vendor/fssm/README.markdown +0 -55
  233. data/vendor/fssm/Rakefile +0 -59
  234. data/vendor/fssm/VERSION.yml +0 -5
  235. data/vendor/fssm/example.rb +0 -9
  236. data/vendor/fssm/fssm.gemspec +0 -77
  237. data/vendor/fssm/lib/fssm/backends/fsevents.rb +0 -36
  238. data/vendor/fssm/lib/fssm/backends/inotify.rb +0 -26
  239. data/vendor/fssm/lib/fssm/backends/polling.rb +0 -25
  240. data/vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb +0 -131
  241. data/vendor/fssm/lib/fssm/monitor.rb +0 -26
  242. data/vendor/fssm/lib/fssm/path.rb +0 -91
  243. data/vendor/fssm/lib/fssm/pathname.rb +0 -502
  244. data/vendor/fssm/lib/fssm/state/directory.rb +0 -57
  245. data/vendor/fssm/lib/fssm/state/file.rb +0 -24
  246. data/vendor/fssm/lib/fssm/support.rb +0 -63
  247. data/vendor/fssm/lib/fssm/tree.rb +0 -176
  248. data/vendor/fssm/lib/fssm.rb +0 -33
  249. data/vendor/fssm/profile/prof-cache.rb +0 -40
  250. data/vendor/fssm/profile/prof-fssm-pathname.html +0 -1231
  251. data/vendor/fssm/profile/prof-pathname.rb +0 -68
  252. data/vendor/fssm/profile/prof-plain-pathname.html +0 -988
  253. data/vendor/fssm/profile/prof.html +0 -2379
  254. data/vendor/fssm/spec/path_spec.rb +0 -75
  255. data/vendor/fssm/spec/root/duck/quack.txt +0 -0
  256. data/vendor/fssm/spec/root/file.css +0 -0
  257. data/vendor/fssm/spec/root/file.rb +0 -0
  258. data/vendor/fssm/spec/root/file.yml +0 -0
  259. data/vendor/fssm/spec/root/moo/cow.txt +0 -0
  260. data/vendor/fssm/spec/spec_helper.rb +0 -14
@@ -1,502 +0,0 @@
1
- require 'fileutils'
2
- require 'find'
3
-
4
- module FSSM
5
- class Pathname < String
6
- SYMLOOP_MAX = 8
7
-
8
- ROOT = '/'.freeze
9
- DOT = '.'.freeze
10
- DOT_DOT = '..'.freeze
11
-
12
- class << self
13
- def for(path)
14
- path.is_a?(::FSSM::Pathname) ? path : new("#{path}")
15
- end
16
- end
17
-
18
- def initialize(path)
19
- raise ArgumentError, "path cannot contain ASCII NULLs" if path =~ %r{\0}
20
- super(path)
21
- end
22
-
23
- def <=>(other)
24
- self.tr('/', "\0").to_s <=> other.to_str.tr('/', "\0")
25
- rescue NoMethodError
26
- nil
27
- end
28
-
29
- def ==(other)
30
- left = self.cleanpath.tr('/', "\0").to_s
31
- right = self.class.for(other).cleanpath.tr('/', "\0").to_s
32
-
33
- left == right
34
- rescue NoMethodError
35
- false
36
- end
37
-
38
- def +(path)
39
- dup << path
40
- end
41
-
42
- def <<(path)
43
- replace( join(path).cleanpath! )
44
- end
45
-
46
- def absolute?
47
- self[0, 1].to_s == ROOT
48
- end
49
-
50
- def ascend
51
- parts = to_a
52
- parts.length.downto(1) do |i|
53
- yield self.class.join(parts[0, i])
54
- end
55
- end
56
-
57
- def children
58
- entries[2..-1]
59
- end
60
-
61
- def cleanpath!
62
- parts = to_a
63
- final = []
64
-
65
- parts.each do |part|
66
- case part
67
- when DOT then
68
- next
69
- when DOT_DOT then
70
- case final.last
71
- when ROOT then
72
- next
73
- when DOT_DOT then
74
- final.push(DOT_DOT)
75
- when nil then
76
- final.push(DOT_DOT)
77
- else
78
- final.pop
79
- end
80
- else
81
- final.push(part)
82
- end
83
- end
84
-
85
- replace(final.empty? ? DOT : self.class.join(*final))
86
- end
87
-
88
- def cleanpath
89
- dup.cleanpath!
90
- end
91
-
92
- def descend
93
- parts = to_a
94
- 1.upto(parts.length) { |i| yield self.class.join(parts[0, i]) }
95
- end
96
-
97
- def dot?
98
- self == DOT
99
- end
100
-
101
- def dot_dot?
102
- self == DOT_DOT
103
- end
104
-
105
- def each_filename(&blk)
106
- to_a.each(&blk)
107
- end
108
-
109
- def mountpoint?
110
- stat1 = self.lstat
111
- stat2 = self.parent.lstat
112
-
113
- stat1.dev != stat2.dev || stat1.ino == stat2.ino
114
- rescue Errno::ENOENT
115
- false
116
- end
117
-
118
- def parent
119
- self + '..'
120
- end
121
-
122
- def realpath
123
- path = self
124
-
125
- SYMLOOP_MAX.times do
126
- link = path.readlink
127
- link = path.dirname + link if link.relative?
128
- path = link
129
- end
130
-
131
- raise Errno::ELOOP, self
132
- rescue Errno::EINVAL
133
- path.expand_path
134
- end
135
-
136
- def relative?
137
- !absolute?
138
- end
139
-
140
- def relative_path_from(base)
141
- base = self.class.for(base)
142
-
143
- raise ArgumentError, 'no relative path between a relative and absolute' if self.absolute? != base.absolute?
144
-
145
- return self if base.dot?
146
- return self.class.new(DOT) if self == base
147
-
148
- base = base.cleanpath.to_a
149
- dest = self.cleanpath.to_a
150
-
151
- while !dest.empty? && !base.empty? && dest[0] == base[0]
152
- base.shift
153
- dest.shift
154
- end
155
-
156
- base.shift if base[0] == DOT
157
- dest.shift if dest[0] == DOT
158
-
159
- raise ArgumentError, "base directory may not contain '#{DOT_DOT}'" if base.include?(DOT_DOT)
160
-
161
- path = base.fill(DOT_DOT) + dest
162
- path = self.class.join(*path)
163
- path = self.class.new(DOT) if path.empty?
164
-
165
- path
166
- end
167
-
168
- def root?
169
- !!(self =~ %r{^#{ROOT}+$})
170
- end
171
-
172
- def to_a
173
- array = to_s.split(File::SEPARATOR)
174
- array.delete('')
175
- array.insert(0, ROOT) if absolute?
176
- array
177
- end
178
-
179
- alias segments to_a
180
-
181
- def to_path
182
- self
183
- end
184
-
185
- def to_s
186
- "#{self}"
187
- end
188
-
189
- alias to_str to_s
190
-
191
- def unlink
192
- Dir.unlink(self)
193
- true
194
- rescue Errno::ENOTDIR
195
- File.unlink(self)
196
- true
197
- end
198
- end
199
-
200
- class Pathname
201
- def self.[](pattern)
202
- Dir[pattern].map! {|d| FSSM::Pathname.new(d) }
203
- end
204
-
205
- def self.pwd
206
- FSSM::Pathname.new(Dir.pwd)
207
- end
208
-
209
- def entries
210
- Dir.entries(self).map! {|e| FSSM::Pathname.new(e) }
211
- end
212
-
213
- def mkdir(mode = 0777)
214
- Dir.mkdir(self, mode)
215
- end
216
-
217
- def opendir(&blk)
218
- Dir.open(self, &blk)
219
- end
220
-
221
- def rmdir
222
- Dir.rmdir(self)
223
- end
224
-
225
- def self.glob(pattern, flags = 0)
226
- dirs = Dir.glob(pattern, flags)
227
- dirs.map! {|path| FSSM::Pathname.new(path) }
228
-
229
- if block_given?
230
- dirs.each {|dir| yield dir }
231
- nil
232
- else
233
- dirs
234
- end
235
- end
236
-
237
- def glob(pattern, flags = 0, &block)
238
- patterns = [pattern].flatten
239
- patterns.map! {|p| self.class.glob(self.to_s + p, flags, &block) }
240
- patterns.flatten
241
- end
242
-
243
- def chdir
244
- blk = lambda { yield self } if block_given?
245
- Dir.chdir(self, &blk)
246
- end
247
- end
248
-
249
- class Pathname
250
- def blockdev?
251
- FileTest.blockdev?(self)
252
- end
253
-
254
- def chardev?
255
- FileTest.chardev?(self)
256
- end
257
-
258
- def directory?
259
- FileTest.directory?(self)
260
- end
261
-
262
- def executable?
263
- FileTest.executable?(self)
264
- end
265
-
266
- def executable_real?
267
- FileTest.executable_real?(self)
268
- end
269
-
270
- def exists?
271
- FileTest.exists?(self)
272
- end
273
-
274
- def file?
275
- FileTest.file?(self)
276
- end
277
-
278
- def grpowned?
279
- FileTest.grpowned?(self)
280
- end
281
-
282
- def owned?
283
- FileTest.owned?(self)
284
- end
285
-
286
- def pipe?
287
- FileTest.pipe?(self)
288
- end
289
-
290
- def readable?
291
- FileTest.readable?(self)
292
- end
293
-
294
- def readable_real?
295
- FileTest.readable_real?(self)
296
- end
297
-
298
- def setgid?
299
- FileTest.setgit?(self)
300
- end
301
-
302
- def setuid?
303
- FileTest.setuid?(self)
304
- end
305
-
306
- def socket?
307
- FileTest.socket?(self)
308
- end
309
-
310
- def sticky?
311
- FileTest.sticky?(self)
312
- end
313
-
314
- def symlink?
315
- FileTest.symlink?(self)
316
- end
317
-
318
- def world_readable?
319
- FileTest.world_readable?(self)
320
- end
321
-
322
- def world_writable?
323
- FileTest.world_writable?(self)
324
- end
325
-
326
- def writable?
327
- FileTest.writable?(self)
328
- end
329
-
330
- def writable_real?
331
- FileTest.writable_real?(self)
332
- end
333
-
334
- def zero?
335
- FileTest.zero?(self)
336
- end
337
- end
338
-
339
- class Pathname
340
- def atime
341
- File.atime(self)
342
- end
343
-
344
- def ctime
345
- File.ctime(self)
346
- end
347
-
348
- def ftype
349
- File.ftype(self)
350
- end
351
-
352
- def lstat
353
- File.lstat(self)
354
- end
355
-
356
- def mtime
357
- File.mtime(self)
358
- end
359
-
360
- def stat
361
- File.stat(self)
362
- end
363
-
364
- def utime(atime, mtime)
365
- File.utime(self, atime, mtime)
366
- end
367
- end
368
-
369
- class Pathname
370
- def self.join(*parts)
371
- last_part = FSSM::Pathname.new(parts.last)
372
- return last_part if last_part.absolute?
373
- FSSM::Pathname.new(File.join(*parts.reject {|p| p.empty? }))
374
- end
375
-
376
- def basename
377
- self.class.new(File.basename(self))
378
- end
379
-
380
- def chmod(mode)
381
- File.chmod(mode, self)
382
- end
383
-
384
- def chown(owner, group)
385
- File.chown(owner, group, self)
386
- end
387
-
388
- def dirname
389
- self.class.new(File.dirname(self))
390
- end
391
-
392
- def expand_path(from = nil)
393
- self.class.new(File.expand_path(self, from))
394
- end
395
-
396
- def extname
397
- File.extname(self)
398
- end
399
-
400
- def fnmatch?(pat, flags = 0)
401
- File.fnmatch(pat, self, flags)
402
- end
403
-
404
- def join(*parts)
405
- self.class.join(self, *parts)
406
- end
407
-
408
- def lchmod(mode)
409
- File.lchmod(mode, self)
410
- end
411
-
412
- def lchown(owner, group)
413
- File.lchown(owner, group, self)
414
- end
415
-
416
- def link(to)
417
- File.link(self, to)
418
- end
419
-
420
- def open(mode = 'r', perm = nil, &blk)
421
- File.open(self, mode, perm, &blk)
422
- end
423
-
424
- def readlink
425
- self.class.new(File.readlink(self))
426
- end
427
-
428
- def rename(to)
429
- File.rename(self, to)
430
- replace(to)
431
- end
432
-
433
- def size
434
- File.size(self)
435
- end
436
-
437
- def size?
438
- File.size?(self)
439
- end
440
-
441
- def split
442
- File.split(self).map {|part| FSSM::Pathname.new(part) }
443
- end
444
-
445
- def symlink(to)
446
- File.symlink(self, to)
447
- end
448
-
449
- def truncate
450
- File.truncate(self)
451
- end
452
- end
453
-
454
- class Pathname
455
- def mkpath
456
- self.class.new(FileUtils.mkpath(self))
457
- end
458
-
459
- def rmtree
460
- self.class.new(FileUtils.rmtree(self).first)
461
- end
462
-
463
- def touch
464
- self.class.new(FileUtils.touch(self).first)
465
- end
466
- end
467
-
468
- class Pathname
469
- def each_line(sep = $/, &blk)
470
- IO.foreach(self, sep, &blk)
471
- end
472
-
473
- def read(len = nil, off = 0)
474
- IO.read(self, len, off)
475
- end
476
-
477
- def readlines(sep = $/)
478
- IO.readlines(self, sep)
479
- end
480
-
481
- def sysopen(mode = 'r', perm = nil)
482
- IO.sysopen(self, mode, perm)
483
- end
484
- end
485
-
486
- class Pathname
487
- def find
488
- Find.find(self) {|path| yield FSSM::Pathname.new(path) }
489
- end
490
- end
491
-
492
- class Pathname
493
- class << self
494
- alias getwd pwd
495
- end
496
-
497
- alias absolute expand_path
498
- alias delete unlink
499
- alias exist? exists?
500
- alias fnmatch fnmatch?
501
- end
502
- end
@@ -1,57 +0,0 @@
1
- module FSSM::State
2
- class Directory
3
- attr_reader :path
4
-
5
- def initialize(path)
6
- @path = path
7
- @cache = FSSM::Tree::Cache.new
8
- end
9
-
10
- def refresh(base=nil, skip_callbacks=false)
11
- previous, current = recache(base || @path.to_pathname)
12
-
13
- unless skip_callbacks
14
- deleted(previous, current)
15
- created(previous, current)
16
- modified(previous, current)
17
- end
18
- end
19
-
20
- private
21
-
22
- def created(previous, current)
23
- (current.keys - previous.keys).each {|created| @path.create(created)}
24
- end
25
-
26
- def deleted(previous, current)
27
- (previous.keys - current.keys).each {|deleted| @path.delete(deleted)}
28
- end
29
-
30
- def modified(previous, current)
31
- (current.keys & previous.keys).each do |file|
32
- @path.update(file) if (current[file] <=> previous[file]) != 0
33
- end
34
- end
35
-
36
- def recache(base)
37
- base = FSSM::Pathname.for(base)
38
- previous = @cache.files
39
- snapshot(base)
40
- current = @cache.files
41
- [previous, current]
42
- end
43
-
44
- def snapshot(base)
45
- base = FSSM::Pathname.for(base)
46
- @cache.unset(base)
47
- @path.glob.each {|glob| add_glob(base, glob)}
48
- end
49
-
50
- def add_glob(base, glob)
51
- FSSM::Pathname.glob(base.join(glob).to_s).each do |fn|
52
- @cache.set(fn)
53
- end
54
- end
55
-
56
- end
57
- end
@@ -1,24 +0,0 @@
1
- module FSSM::State
2
- class File
3
- attr_reader :path
4
-
5
- def initialize(path)
6
- @path = path
7
- end
8
-
9
- def refresh(base=nil, skip_callbacks=false)
10
- base ||= @path.to_pathname
11
- used_to_exist, @exists = @exists, base.exists?
12
- # this handles bad symlinks without failing. why handle bad symlinks at
13
- # all? well, we could still be interested in their creation and deletion.
14
- old_mtime, @mtime = @mtime, base.symlink? ? Time.at(0) : base.mtime if @exists
15
-
16
- unless skip_callbacks
17
- @path.delete(@path.to_s) if used_to_exist && !@exists
18
- @path.create(@path.to_s) if !used_to_exist && @exists
19
- @path.update(@path.to_s) if used_to_exist && @exists && old_mtime != @mtime
20
- end
21
- end
22
-
23
- end
24
- end
@@ -1,63 +0,0 @@
1
- require 'rbconfig'
2
-
3
- module FSSM::Support
4
- class << self
5
- def backend
6
- @@backend ||= case
7
- when mac? && !jruby? && carbon_core?
8
- 'FSEvents'
9
- when linux? && rb_inotify?
10
- 'Inotify'
11
- else
12
- 'Polling'
13
- end
14
- end
15
-
16
- def jruby?
17
- defined?(JRUBY_VERSION)
18
- end
19
-
20
- def mac?
21
- Config::CONFIG['target_os'] =~ /darwin/i
22
- end
23
-
24
- def linux?
25
- Config::CONFIG['target_os'] =~ /linux/i
26
- end
27
-
28
- def carbon_core?
29
- begin
30
- require 'osx/foundation'
31
- OSX.require_framework '/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework'
32
- true
33
- rescue LoadError
34
- STDERR.puts("Warning: Unable to load CarbonCore. FSEvents will be unavailable.")
35
- false
36
- end
37
- end
38
-
39
- def rb_inotify?
40
- found = begin
41
- require 'rb-inotify'
42
- if defined?(INotify::VERSION)
43
- version = INotify::VERSION
44
- version[0] > 0 || version[1] >= 6
45
- end
46
- rescue LoadError
47
- false
48
- end
49
- STDERR.puts("Warning: Unable to load rb-inotify >= 0.5.1. Inotify will be unavailable.") unless found
50
- found
51
- end
52
-
53
- def use_block(context, block)
54
- return if block.nil?
55
- if block.arity == 1
56
- block.call(context)
57
- else
58
- context.instance_eval(&block)
59
- end
60
- end
61
-
62
- end
63
- end