compass-edge 0.9.5.0 → 0.10.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) hide show
  1. data/CHANGELOG.markdown +0 -153
  2. data/README.markdown +2 -12
  3. data/REVISION +1 -1
  4. data/Rakefile +2 -37
  5. data/VERSION.yml +1 -1
  6. data/examples/blueprint_default/index.html.haml +3 -3
  7. data/examples/blueprint_default/parts/forms.html.haml +0 -2
  8. data/examples/blueprint_default/src/screen.sass +1 -1
  9. data/examples/blueprint_plugins/index.html.haml +6 -6
  10. data/examples/blueprint_plugins/src/buttons.sass +2 -2
  11. data/examples/blueprint_plugins/src/link_icons.sass +1 -1
  12. data/examples/blueprint_plugins/src/rtl_screen.sass +3 -3
  13. data/examples/blueprint_plugins/src/screen.sass +2 -2
  14. data/examples/blueprint_semantic/src/liquid.sass +4 -4
  15. data/examples/blueprint_semantic/src/screen.sass +3 -3
  16. data/examples/compass/src/utilities.sass +2 -2
  17. data/examples/downloader.rb +2 -2
  18. data/lib/compass/app_integration.rb +0 -21
  19. data/lib/compass/app_integration/rails.rb +0 -18
  20. data/lib/compass/app_integration/rails/configuration_defaults.rb +0 -16
  21. data/lib/compass/app_integration/rails/installer.rb +6 -6
  22. data/lib/compass/app_integration/stand_alone.rb +1 -20
  23. data/lib/compass/app_integration/stand_alone/configuration_defaults.rb +1 -5
  24. data/lib/compass/app_integration/stand_alone/installer.rb +17 -29
  25. data/lib/compass/commands.rb +2 -2
  26. data/lib/compass/commands/create_project.rb +1 -10
  27. data/lib/compass/commands/generate_grid_background.rb +1 -1
  28. data/lib/compass/commands/help.rb +7 -34
  29. data/lib/compass/commands/installer_command.rb +11 -15
  30. data/lib/compass/commands/project_base.rb +2 -2
  31. data/lib/compass/commands/update_project.rb +1 -51
  32. data/lib/compass/commands/validate_project.rb +3 -59
  33. data/lib/compass/commands/watch_project.rb +2 -4
  34. data/lib/compass/commands/write_configuration.rb +3 -84
  35. data/lib/compass/compiler.rb +4 -13
  36. data/lib/compass/configuration.rb +18 -23
  37. data/lib/compass/configuration/adapters.rb +1 -1
  38. data/lib/compass/configuration/data.rb +2 -5
  39. data/lib/compass/configuration/defaults.rb +1 -32
  40. data/lib/compass/configuration/helpers.rb +10 -47
  41. data/lib/compass/configuration/inheritance.rb +1 -1
  42. data/lib/compass/configuration/serialization.rb +2 -2
  43. data/lib/compass/errors.rb +1 -4
  44. data/lib/compass/exec.rb +0 -1
  45. data/lib/compass/exec/project_options_parser.rb +0 -4
  46. data/lib/compass/frameworks.rb +1 -40
  47. data/lib/compass/frameworks/blueprint/stylesheets/_blueprint.sass +1 -29
  48. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/_ie.sass +2 -2
  49. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/_print.sass +4 -1
  50. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/_reset.sass +2 -57
  51. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/_screen.sass +29 -2
  52. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/modules/_buttons.sass +84 -2
  53. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/modules/_colors.sass +33 -2
  54. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/modules/_debug.sass +9 -2
  55. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/modules/_fancy_type.sass +82 -2
  56. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/modules/_form.sass +55 -2
  57. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/modules/_grid.sass +178 -2
  58. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/modules/_interaction.sass +58 -2
  59. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/modules/_link_icons.sass +44 -2
  60. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/modules/_liquid.sass +140 -2
  61. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/modules/_reset.sass +56 -2
  62. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/modules/_rtl.sass +122 -2
  63. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/modules/_scaffolding.sass +47 -2
  64. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/modules/_typography.sass +160 -2
  65. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/modules/_utilities.sass +37 -2
  66. data/lib/compass/frameworks/blueprint/templates/buttons/buttons.sass +2 -2
  67. data/lib/compass/frameworks/blueprint/templates/buttons/manifest.rb +0 -12
  68. data/lib/compass/frameworks/blueprint/templates/link_icons/link_icons.sass +1 -1
  69. data/lib/compass/frameworks/blueprint/templates/link_icons/manifest.rb +0 -13
  70. data/lib/compass/frameworks/blueprint/templates/project/manifest.rb +0 -24
  71. data/lib/compass/frameworks/blueprint/templates/project/screen.sass +7 -1
  72. data/lib/compass/frameworks/blueprint/templates/project/welcome.html.haml +1 -9
  73. data/lib/compass/frameworks/compass/stylesheets/_compass.sass +1 -2
  74. data/lib/compass/frameworks/compass/stylesheets/compass/_utilities.sass +1 -0
  75. data/lib/compass/frameworks/compass/stylesheets/compass/utilities/_css3.sass +6 -0
  76. data/lib/compass/frameworks/compass/stylesheets/compass/{css3 → utilities/css3}/_border_radius.sass +0 -0
  77. data/lib/compass/frameworks/compass/stylesheets/compass/utilities/css3/_box_shadow.sass +12 -0
  78. data/lib/compass/frameworks/compass/stylesheets/compass/{css3 → utilities/css3}/_box_sizing.sass +0 -0
  79. data/lib/compass/frameworks/compass/stylesheets/compass/{css3 → utilities/css3}/_columns.sass +0 -0
  80. data/lib/compass/frameworks/compass/stylesheets/compass/{css3 → utilities/css3}/_inline_block.sass +0 -0
  81. data/lib/compass/frameworks/compass/stylesheets/compass/{css3 → utilities/css3}/_opacity.sass +0 -0
  82. data/lib/compass/frameworks/compass/stylesheets/compass/utilities/general/_reset.sass +2 -2
  83. data/lib/compass/frameworks/compass/templates/ellipsis/manifest.rb +1 -26
  84. data/lib/compass/frameworks/compass/templates/extension/manifest.rb +2 -16
  85. data/lib/compass/frameworks/compass/templates/project/manifest.rb +0 -1
  86. data/lib/compass/grid_builder.rb +1 -1
  87. data/lib/compass/installers.rb +1 -1
  88. data/lib/compass/installers/base.rb +52 -13
  89. data/lib/compass/installers/manifest.rb +1 -33
  90. data/lib/compass/logger.rb +2 -28
  91. data/lib/compass/sass_extensions/functions.rb +1 -3
  92. data/lib/compass/sass_extensions/functions/enumerate.rb +2 -2
  93. data/lib/compass/sass_extensions/functions/inline_image.rb +1 -22
  94. data/lib/compass/sass_extensions/functions/urls.rb +0 -20
  95. data/lib/compass/sass_extensions/monkey_patches.rb +2 -2
  96. data/lib/compass/validator.rb +3 -2
  97. data/lib/vendor/fssm.rb +6 -19
  98. data/lib/vendor/fssm/backends/fsevents.rb +60 -19
  99. data/lib/vendor/fssm/backends/polling.rb +18 -20
  100. data/lib/vendor/fssm/ext.rb +0 -30
  101. data/lib/vendor/fssm/monitor.rb +6 -10
  102. data/lib/vendor/fssm/path.rb +21 -24
  103. data/lib/vendor/fssm/state.rb +29 -37
  104. data/lib/vendor/fssm/support.rb +7 -3
  105. data/test/command_line_helper.rb +4 -12
  106. data/test/command_line_test.rb +2 -2
  107. data/test/compass_test.rb +4 -14
  108. data/test/configuration_test.rb +5 -5
  109. data/test/fixtures/stylesheets/blueprint/css/typography.css +3 -5
  110. data/test/fixtures/stylesheets/blueprint/sass/screen.sass +1 -1
  111. data/test/fixtures/stylesheets/blueprint/sass/typography.sass +2 -2
  112. data/test/fixtures/stylesheets/compass/css/print.css +8 -2
  113. data/test/fixtures/stylesheets/compass/css/reset.css +1 -1
  114. data/test/fixtures/stylesheets/image_urls/css/screen.css +0 -2
  115. data/test/io_helper.rb +1 -18
  116. data/test/rails_integration_test.rb +41 -3
  117. data/test/sass_extensions_test.rb +2 -2
  118. data/test/test_helper.rb +0 -1
  119. metadata +9 -124
  120. data/examples/compass/bootstrap.rb +0 -3
  121. data/examples/compass/extensions/yui/stylesheets/_yui.sass +0 -7
  122. data/examples/compass/extensions/yui/stylesheets/yui/modules/_base.sass +0 -70
  123. data/examples/compass/extensions/yui/stylesheets/yui/modules/_fonts.sass +0 -45
  124. data/examples/compass/extensions/yui/stylesheets/yui/modules/_grids.sass +0 -385
  125. data/examples/compass/extensions/yui/stylesheets/yui/modules/_reset.sass +0 -61
  126. data/examples/compass/extensions/yui/templates/project/manifest.rb +0 -1
  127. data/examples/compass/extensions/yui/templates/project/screen.sass +0 -4
  128. data/examples/css3/config.rb +0 -6
  129. data/examples/css3/extensions/fancy-fonts/templates/project/Vtks Revolt.ttf +0 -0
  130. data/examples/css3/extensions/fancy-fonts/templates/project/angelina.ttf +0 -0
  131. data/examples/css3/extensions/fancy-fonts/templates/project/fancy-fonts.sass +0 -7
  132. data/examples/css3/extensions/fancy-fonts/templates/project/manifest.rb +0 -5
  133. data/examples/css3/images/fresh-peas.jpg +0 -0
  134. data/examples/css3/index.html.haml +0 -55
  135. data/examples/css3/src/_base.sass +0 -14
  136. data/examples/css3/src/fancy-fonts.sass +0 -7
  137. data/examples/css3/src/gradient.sass +0 -10
  138. data/examples/css3/src/main.sass +0 -80
  139. data/examples/css3/stylesheets/fonts/Vtks Revolt.ttf +0 -0
  140. data/examples/css3/stylesheets/fonts/angelina.ttf +0 -0
  141. data/examples/susy/bootstrap.rb +0 -3
  142. data/examples/susy/config.rb +0 -9
  143. data/examples/susy/extensions/susy/LICENSE.txt +0 -28
  144. data/examples/susy/extensions/susy/README.mkdn +0 -235
  145. data/examples/susy/extensions/susy/compass-susy-plugin.gemspec +0 -35
  146. data/examples/susy/extensions/susy/docs/tutorial/build.sh +0 -141
  147. data/examples/susy/extensions/susy/docs/tutorial/code/01_target/src/_defaults.sass +0 -100
  148. data/examples/susy/extensions/susy/docs/tutorial/code/01_target/src/screen.sass +0 -98
  149. data/examples/susy/extensions/susy/docs/tutorial/code/02_container/src/_defaults.sass +0 -147
  150. data/examples/susy/extensions/susy/docs/tutorial/code/02_container/src/screen.sass +0 -19
  151. data/examples/susy/extensions/susy/docs/tutorial/code/03_structure/src/_defaults.sass +0 -147
  152. data/examples/susy/extensions/susy/docs/tutorial/code/03_structure/src/screen.sass +0 -48
  153. data/examples/susy/extensions/susy/docs/tutorial/code/_common/config.rb +0 -14
  154. data/examples/susy/extensions/susy/docs/tutorial/code/_common/images/grid.png +0 -0
  155. data/examples/susy/extensions/susy/docs/tutorial/code/_common/images/susy_logo.png +0 -0
  156. data/examples/susy/extensions/susy/docs/tutorial/code/_common/src/_base.sass +0 -63
  157. data/examples/susy/extensions/susy/docs/tutorial/code/_tools/Markdown.pl +0 -1450
  158. data/examples/susy/extensions/susy/docs/tutorial/code/site/src/_defaults.sass +0 -100
  159. data/examples/susy/extensions/susy/docs/tutorial/code/site/src/screen.sass +0 -91
  160. data/examples/susy/extensions/susy/docs/tutorial/figures/susy_element.png +0 -0
  161. data/examples/susy/extensions/susy/docs/tutorial/figures/susy_grid.png +0 -0
  162. data/examples/susy/extensions/susy/docs/tutorial/index.mkdn +0 -301
  163. data/examples/susy/extensions/susy/lib/susy.rb +0 -2
  164. data/examples/susy/extensions/susy/lib/susy/compass_plugin.rb +0 -5
  165. data/examples/susy/extensions/susy/lib/susy/sass_extensions.rb +0 -79
  166. data/examples/susy/extensions/susy/sass/susy/_grid.sass +0 -128
  167. data/examples/susy/extensions/susy/sass/susy/_reset.sass +0 -7
  168. data/examples/susy/extensions/susy/sass/susy/_susy.sass +0 -23
  169. data/examples/susy/extensions/susy/sass/susy/_text.sass +0 -15
  170. data/examples/susy/extensions/susy/sass/susy/_utils.sass +0 -81
  171. data/examples/susy/extensions/susy/templates/project/_base.sass +0 -62
  172. data/examples/susy/extensions/susy/templates/project/_defaults.sass +0 -147
  173. data/examples/susy/extensions/susy/templates/project/ie.sass +0 -9
  174. data/examples/susy/extensions/susy/templates/project/manifest.rb +0 -5
  175. data/examples/susy/extensions/susy/templates/project/print.sass +0 -7
  176. data/examples/susy/extensions/susy/templates/project/screen.sass +0 -44
  177. data/examples/susy/src/_base.sass +0 -62
  178. data/examples/susy/src/_defaults.sass +0 -148
  179. data/examples/susy/src/screen.sass +0 -114
  180. data/features/command_line.feature +0 -226
  181. data/features/extensions.feature +0 -20
  182. data/features/step_definitions/command_line_steps.rb +0 -223
  183. data/features/step_definitions/extension_steps.rb +0 -13
  184. data/lib/compass/commands/interactive.rb +0 -61
  185. data/lib/compass/commands/project_stats.rb +0 -162
  186. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/_buttons.sass +0 -84
  187. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/_colors.sass +0 -33
  188. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/_debug.sass +0 -9
  189. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/_fancy_type.sass +0 -82
  190. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/_form.sass +0 -56
  191. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/_grid.sass +0 -179
  192. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/_interaction.sass +0 -58
  193. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/_link_icons.sass +0 -44
  194. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/_liquid.sass +0 -141
  195. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/_rtl.sass +0 -123
  196. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/_scaffolding.sass +0 -49
  197. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/_typography.sass +0 -162
  198. data/lib/compass/frameworks/blueprint/stylesheets/blueprint/_utilities.sass +0 -37
  199. data/lib/compass/frameworks/compass/stylesheets/compass/_css3.sass +0 -14
  200. data/lib/compass/frameworks/compass/stylesheets/compass/css3/_background_clip.sass +0 -16
  201. data/lib/compass/frameworks/compass/stylesheets/compass/css3/_background_origin.sass +0 -18
  202. data/lib/compass/frameworks/compass/stylesheets/compass/css3/_background_size.sass +0 -14
  203. data/lib/compass/frameworks/compass/stylesheets/compass/css3/_box_shadow.sass +0 -20
  204. data/lib/compass/frameworks/compass/stylesheets/compass/css3/_font_face.sass +0 -31
  205. data/lib/compass/frameworks/compass/stylesheets/compass/css3/_gradient.sass +0 -40
  206. data/lib/compass/frameworks/compass/stylesheets/compass/css3/_text_shadow.sass +0 -15
  207. data/lib/compass/frameworks/compass/stylesheets/compass/css3/_transform.sass +0 -60
  208. data/lib/compass/frameworks/compass/stylesheets/compass/css3/_transition.sass +0 -57
  209. data/lib/compass/frameworks/compass/templates/project/USAGE.markdown +0 -32
  210. data/lib/compass/installers/bare_installer.rb +0 -58
  211. data/lib/compass/installers/manifest_installer.rb +0 -59
  212. data/lib/compass/sass_extensions/functions/color_stop.rb +0 -10
  213. data/lib/compass/sass_extensions/functions/font_files.rb +0 -11
  214. data/lib/compass/sass_extensions/monkey_patches/traversal.rb +0 -23
  215. data/lib/compass/stats.rb +0 -92
  216. data/lib/vendor/fssm/cache.rb +0 -193
  217. data/lib/vendor/fssm/fsevents.rb +0 -129
  218. data/lib/vendor/fssm/tree.rb +0 -176
  219. data/test/fixtures/stylesheets/relative/assets/images/testing.png +0 -0
  220. data/test/fixtures/stylesheets/relative/config.rb +0 -9
  221. data/test/fixtures/stylesheets/relative/css/ie.css +0 -1
  222. data/test/fixtures/stylesheets/relative/css/print.css +0 -1
  223. data/test/fixtures/stylesheets/relative/css/screen.css +0 -1
  224. data/test/fixtures/stylesheets/relative/sass/ie.sass +0 -6
  225. data/test/fixtures/stylesheets/relative/sass/print.sass +0 -6
  226. data/test/fixtures/stylesheets/relative/sass/screen.sass +0 -3
  227. data/test/rails_helper.rb +0 -40
@@ -1,10 +0,0 @@
1
- module Compass::SassExtensions::Functions::ColorStop
2
- def color_stop(*args)
3
- raise Sass::SyntaxError, "An even number of arguments must be passed to color-stop()" unless args.size % 2 == 0
4
- stops = []
5
- while args.size > 0
6
- stops << "color-stop(#{args.shift}, #{args.shift})"
7
- end
8
- Sass::Script::String.new(stops.join(", "))
9
- end
10
- end
@@ -1,11 +0,0 @@
1
- module Compass::SassExtensions::Functions::FontFiles
2
- def font_files(*args)
3
- raise Sass::SyntaxError, "An even number of arguments must be passed to font_files()" unless args.size % 2 == 0
4
- files = []
5
- while args.size > 0
6
- files << "#{font_url(args.shift)} format('#{args.shift}')"
7
- end
8
- Sass::Script::String.new(files.join(", "))
9
- end
10
-
11
- end
@@ -1,23 +0,0 @@
1
- module Sass
2
- module Tree
3
- class Node
4
- unless method_defined?(:visit_depth_first)
5
- def visit_depth_first(visitor)
6
- visitor.visit(self)
7
- visitor.down(self) if children.any? and visitor.respond_to?(:down)
8
- if is_a?(ImportNode) && visitor.import?(self)
9
- root = Sass::Files.tree_for(import, @options)
10
- imported_children = root.children
11
- end
12
-
13
- (imported_children || children).each do |child|
14
- break if visitor.respond_to?(:stop?) && visitor.stop?
15
- child.visit_depth_first(visitor)
16
- end
17
- visitor.up(self) if children.any?
18
- end
19
- end
20
- end
21
- end
22
- end
23
-
@@ -1,92 +0,0 @@
1
- module Compass
2
- module Stats
3
- class StatsVisitor
4
- attr_accessor :rule_count, :prop_count, :mixin_def_count, :mixin_count
5
- def initialize
6
- self.rule_count = 0
7
- self.prop_count = 0
8
- self.mixin_def_count = 0
9
- self.mixin_count = 0
10
- end
11
- def visit(node)
12
- self.prop_count += 1 if node.is_a?(Sass::Tree::PropNode) && !node.children.any?
13
- if node.is_a?(Sass::Tree::RuleNode)
14
- self.rule_count += node.rules.map{|r| r.split(/,/)}.flatten.compact.size
15
- end
16
- self.mixin_def_count += 1 if node.is_a?(Sass::Tree::MixinDefNode)
17
- self.mixin_count += 1 if node.is_a?(Sass::Tree::MixinNode)
18
- end
19
- def up(node)
20
- end
21
- def down(node)
22
- end
23
- def import?(node)
24
- return false
25
- full_filename = node.send(:import)
26
- full_filename != Compass.deprojectize(full_filename)
27
- end
28
- end
29
- class CssFile
30
- attr_accessor :path, :css
31
- attr_accessor :selector_count, :prop_count
32
- def initialize(path)
33
- require 'css_parser'
34
- self.path = path
35
- self.css = CssParser::Parser.new
36
- self.css.add_block!(contents)
37
- self.selector_count = 0
38
- self.prop_count = 0
39
- end
40
- def contents
41
- @contents ||= File.read(path)
42
- end
43
- def lines
44
- contents.inject(0){|m,c| m + 1 }
45
- end
46
- def analyze!
47
- css.each_selector do |selector, declarations, specificity|
48
- sels = selector.split(/,/).size
49
- props = declarations.split(/;/).size
50
- self.selector_count += sels
51
- self.prop_count += props
52
- end
53
- end
54
- end
55
- class SassFile
56
- attr_accessor :path
57
- attr_reader :visitor
58
- def initialize(path)
59
- self.path = path
60
- end
61
- def contents
62
- @contents ||= File.read(path)
63
- end
64
- def tree
65
- @tree = Sass::Engine.new(contents, Compass.configuration.to_sass_engine_options).to_tree
66
- end
67
- def visit_tree!
68
- @visitor = StatsVisitor.new
69
- tree.visit_depth_first(@visitor)
70
- @visitor
71
- end
72
- def analyze!
73
- visit_tree!
74
- end
75
- def lines
76
- contents.inject(0){|m,c| m + 1 }
77
- end
78
- def rule_count
79
- visitor.rule_count
80
- end
81
- def prop_count
82
- visitor.prop_count
83
- end
84
- def mixin_def_count
85
- visitor.mixin_def_count
86
- end
87
- def mixin_count
88
- visitor.mixin_count
89
- end
90
- end
91
- end
92
- end
@@ -1,193 +0,0 @@
1
- class FSSM::Cache
2
- module Common
3
- include Enumerable
4
-
5
- def initialize
6
- @children = Hash.new
7
- end
8
-
9
- def each(prefix='./', &block)
10
- @children.each do |segment, node|
11
- cprefix = Pathname.for(prefix.dup).join(segment)
12
- block.call(cprefix, node)
13
- node.each(cprefix, &block)
14
- end
15
- end
16
-
17
- protected
18
-
19
- def with_lock
20
- @mutex.lock
21
- yield
22
- @mutex.unlock
23
- end
24
-
25
- def descendant(path)
26
- recurse_on_key(path, false)
27
- end
28
-
29
- def descendant!(path)
30
- recurse_on_key(path, true)
31
- end
32
-
33
- def child(segment)
34
- has_child?(segment) ? @children["#{segment}"] : nil
35
- end
36
-
37
- def child!(segment)
38
- (@children["#{segment}"] ||= Node.new)
39
- end
40
-
41
- def has_child?(segment)
42
- @children.include?("#{segment}")
43
- end
44
-
45
- def remove_child(segment)
46
- @children.delete("#{segment}")
47
- end
48
-
49
- def remove_children
50
- @children.clear
51
- end
52
-
53
- def recurse_on_key(key, create)
54
- key = sanitize_key(key)
55
- node = self
56
-
57
- until key.empty?
58
- segment = key.shift
59
- node = create ? node.child!(segment) : node.child(segment)
60
- return nil unless node
61
- end
62
-
63
- node
64
- end
65
-
66
- def key_for_path(path)
67
- Pathname.for(path).names
68
- end
69
-
70
- def relative_path(path)
71
- sanitize_path(path, false)
72
- end
73
-
74
- def absolute_path(path)
75
- sanitize_path(path, true)
76
- end
77
-
78
- def sanitize_path(path, absolute)
79
- if path.is_a?(Array)
80
- first = absolute ? '/' : path.shift
81
- path = path.inject(Pathname.new("#{first}")) do |pathname, segment|
82
- pathname.join("#{segment}")
83
- end
84
- path
85
- else
86
- path = Pathname.for(path)
87
- absolute ? path.expand_path : path
88
- end
89
- end
90
- end
91
-
92
- class Node
93
- include Common
94
-
95
- attr_accessor :mtime
96
- attr_accessor :ftype
97
-
98
- def <=>(other)
99
- self.mtime <=> other.mtime
100
- end
101
-
102
- def from_path(path)
103
- path = absolute_path(path)
104
- @mtime = path.mtime
105
- @ftype = path.ftype
106
- end
107
-
108
- protected
109
-
110
- def sanitize_key(key)
111
- key_for_path(relative_path(key))
112
- end
113
- end
114
-
115
- include Common
116
-
117
- def initialize
118
- @mutex = Mutex.new
119
- super
120
- end
121
-
122
- def clear
123
- @mutex.lock
124
- @children.clear
125
- @mutex.unlock
126
- end
127
-
128
- def set(path)
129
- unset(path)
130
- node = descendant!(path)
131
- node.from_path(path)
132
- node.mtime
133
- end
134
-
135
- def unset(path='/')
136
- key = sanitize_key(path)
137
-
138
- if key.empty?
139
- self.clear
140
- return nil
141
- end
142
-
143
- segment = key.pop
144
- node = descendant(key)
145
-
146
- return unless node
147
-
148
- @mutex.lock
149
- node.remove_child(segment)
150
- @mutex.unlock
151
-
152
- nil
153
- end
154
-
155
- def files
156
- ftype('file')
157
- end
158
-
159
- def directories
160
- ftype('directory')
161
- end
162
-
163
- protected
164
-
165
- def each(&block)
166
- prefix='/'
167
- super(prefix, &block)
168
- end
169
-
170
- def ftype(ft)
171
- inject({}) do |hash, entry|
172
- path, node = entry
173
- hash["#{path}"] = node.mtime if node.ftype == ft
174
- hash
175
- end
176
- end
177
-
178
- def descendant(path)
179
- node = recurse_on_key(path, false)
180
- node
181
- end
182
-
183
- def descendant!(path)
184
- @mutex.lock
185
- node = recurse_on_key(path, true)
186
- @mutex.unlock
187
- node
188
- end
189
-
190
- def sanitize_key(key)
191
- key_for_path(absolute_path(key))
192
- end
193
- end
@@ -1,129 +0,0 @@
1
- OSX.require_framework '/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework'
2
-
3
- module Rucola
4
- class FSEvents
5
- class FSEvent
6
- attr_reader :fsevents_object
7
- attr_reader :id
8
- attr_reader :path
9
- def initialize(fsevents_object, id, path)
10
- @fsevents_object, @id, @path = fsevents_object, id, path
11
- end
12
-
13
- # Returns an array of the files/dirs in the path that the event occurred in.
14
- # The files are sorted by the modification time, the first entry is the last modified file.
15
- def files
16
- Dir.glob("#{File.expand_path(path)}/*").sort_by {|f| File.mtime(f) }.reverse
17
- end
18
-
19
- # Returns the last modified file in the path that the event occurred in.
20
- def last_modified_file
21
- files.first
22
- end
23
- end
24
-
25
- class StreamError < StandardError; end
26
-
27
- attr_reader :paths
28
- attr_reader :stream
29
-
30
- attr_accessor :allocator
31
- attr_accessor :context
32
- attr_accessor :since
33
- attr_accessor :latency
34
- attr_accessor :flags
35
-
36
- # Initializes a new FSEvents `watchdog` object and starts watching the directories you specify for events. The
37
- # block is used as a handler for events, which are passed as the block's argument. This method is the easiest
38
- # way to start watching some directories if you don't care about the details of setting up the event stream.
39
- #
40
- # Rucola::FSEvents.start_watching('/tmp') do |events|
41
- # events.each { |event| log.debug("#{event.files.inspect} were changed.") }
42
- # end
43
- #
44
- # Rucola::FSEvents.start_watching('/var/log/system.log', '/var/log/secure.log', :since => last_id, :latency => 5) do
45
- # Growl.notify("Something was added to your log files!")
46
- # end
47
- #
48
- # Note that the method also returns the FSEvents object. This enables you to control the event stream if you want to.
49
- #
50
- # fsevents = Rucola::FSEvents.start_watching('/Volumes') do |events|
51
- # events.each { |event| Growl.notify("Volume changes: #{event.files.to_sentence}") }
52
- # end
53
- # fsevents.stop
54
- def self.start_watching(*params, &block)
55
- fsevents = new(*params, &block)
56
- fsevents.create_stream
57
- fsevents.start
58
- fsevents
59
- end
60
-
61
- # Creates a new FSEvents `watchdog` object. You can specify a list of paths to watch and options to control the
62
- # behaviour of the watchdog. The block you pass serves as a callback when an event is generated on one of the
63
- # specified paths.
64
- #
65
- # fsevents = FSEvents.new('/etc/passwd') { Mailer.send_mail("Someone touched the password file!") }
66
- # fsevents.create_stream
67
- # fsevents.start
68
- #
69
- # fsevents = FSEvents.new('/home/upload', :since => UploadWatcher.last_event_id) do |events|
70
- # events.each do |event|
71
- # UploadWatcher.last_event_id = event.id
72
- # event.files.each do |file|
73
- # UploadWatcher.logfile.append("#{file} was changed")
74
- # end
75
- # end
76
- # end
77
- #
78
- # *:since: The service will report events that have happened after the supplied event ID. Never use 0 because that
79
- # will cause every fsevent since the "beginning of time" to be reported. Use OSX::KFSEventStreamEventIdSinceNow
80
- # if you want to receive events that have happened after this call. (Default: OSX::KFSEventStreamEventIdSinceNow).
81
- # You can find the ID's passed with :since in the events passed to your block.
82
- # *:latency: Number of seconds to wait until an FSEvent is reported, this allows the service to bundle events. (Default: 0.0)
83
- #
84
- # Please refer to the Cocoa documentation for the rest of the options.
85
- def initialize(*params, &block)
86
- raise ArgumentError, 'No callback block was specified.' unless block_given?
87
-
88
- options = params.last.kind_of?(Hash) ? params.pop : {}
89
- @paths = params.flatten
90
-
91
- paths.each { |path| raise ArgumentError, "The specified path (#{path}) does not exist." unless File.exist?(path) }
92
-
93
- @allocator = options[:allocator] || OSX::KCFAllocatorDefault
94
- @context = options[:context] || nil
95
- @since = options[:since] || OSX::KFSEventStreamEventIdSinceNow
96
- @latency = options[:latency] || 0.0
97
- @flags = options[:flags] || 0
98
- @stream = options[:stream] || nil
99
-
100
- @user_callback = block
101
- @callback = Proc.new do |stream, client_callback_info, number_of_events, paths_pointer, event_flags, event_ids|
102
- paths_pointer.regard_as('*')
103
- events = []
104
- number_of_events.times {|i| events << Rucola::FSEvents::FSEvent.new(self, event_ids[i], paths_pointer[i]) }
105
- @user_callback.call(events)
106
- end
107
- end
108
-
109
- # Create the stream.
110
- # Raises a Rucola::FSEvents::StreamError if the stream could not be created.
111
- def create_stream
112
- @stream = OSX.FSEventStreamCreate(@allocator, @callback, @context, @paths, @since, @latency, @flags)
113
- raise(StreamError, 'Unable to create FSEvents stream.') unless @stream
114
- OSX.FSEventStreamScheduleWithRunLoop(@stream, OSX.CFRunLoopGetCurrent, OSX::KCFRunLoopDefaultMode)
115
- end
116
-
117
- # Start the stream.
118
- # Raises a Rucola::FSEvents::StreamError if the stream could not be started.
119
- def start
120
- raise(StreamError, 'Unable to start FSEvents stream.') unless OSX.FSEventStreamStart(@stream)
121
- end
122
-
123
- # Stop the stream.
124
- # You can resume it by calling `start` again.
125
- def stop
126
- OSX.FSEventStreamStop(@stream)
127
- end
128
- end
129
- end