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,7 +1,7 @@
1
1
  module Compass::SassExtensions::Functions
2
2
  end
3
3
 
4
- %w(selectors enumerate urls display inline_image color_stop font_files).each do |func|
4
+ %w(selectors enumerate urls display inline_image).each do |func|
5
5
  require "compass/sass_extensions/functions/#{func}"
6
6
  end
7
7
 
@@ -11,8 +11,6 @@ module Sass::Script::Functions
11
11
  include Compass::SassExtensions::Functions::Urls
12
12
  include Compass::SassExtensions::Functions::Display
13
13
  include Compass::SassExtensions::Functions::InlineImage
14
- include Compass::SassExtensions::Functions::ColorStop
15
- include Compass::SassExtensions::Functions::FontFiles
16
14
  end
17
15
 
18
16
  # Wierd that this has to be re-included to pick up sub-modules. Ruby bug?
@@ -1,6 +1,6 @@
1
1
  module Compass::SassExtensions::Functions::Enumerate
2
- def enumerate(prefix, from, through, separator = "-")
3
- selectors = (from.value..through.value).map{|i| "#{prefix.value}#{separator}#{i}"}.join(", ")
2
+ def enumerate(prefix, from, through)
3
+ selectors = (from.value..through.value).map{|i| "#{prefix.value}-#{i}"}.join(", ")
4
4
  Sass::Script::String.new(selectors)
5
5
  end
6
6
  end
@@ -3,24 +3,11 @@ module Compass::SassExtensions::Functions::InlineImage
3
3
 
4
4
  def inline_image(path, mime_type = nil)
5
5
  path = path.value
6
- real_path = File.join(Compass.configuration.images_path, path)
6
+ real_path = File.join(Compass.configuration.project_path, Compass.configuration.images_dir, path)
7
7
  url = "url('data:#{compute_mime_type(path,mime_type)};base64,#{data(real_path)}')"
8
8
  Sass::Script::String.new(url)
9
9
  end
10
10
 
11
- def inline_font_files(*args)
12
- raise Sass::SyntaxError, "An even number of arguments must be passed to font_files()" unless args.size % 2 == 0
13
- path = path.value
14
- files = []
15
- while args.size > 0
16
- path = args.shift.value
17
- real_path = File.join(Compass.configuration.fonts_path, path)
18
- url = "url('data:#{compute_mime_type(path,mime_type)};base64,#{data(real_path)}')"
19
- files << "#{url} format('#{args.shift}')"
20
- end
21
- Sass::Script::String.new(files.join(", "))
22
- end
23
-
24
11
  private
25
12
  def compute_mime_type(path, mime_type)
26
13
  return mime_type if mime_type
@@ -31,14 +18,6 @@ private
31
18
  'image/jpeg'
32
19
  when /\.gif$/i
33
20
  'image/gif'
34
- when /\.otf$/i
35
- 'font/opentype'
36
- when /\.ttf$/i
37
- 'font/truetype'
38
- when /\.woff$/i
39
- 'font/woff'
40
- when /\.off$/i
41
- 'font/openfont'
42
21
  when /\.([a-zA-Z]+)$/
43
22
  "image/#{Regexp.last_match(1).downcase}"
44
23
  else
@@ -14,28 +14,8 @@ module Compass::SassExtensions::Functions::Urls
14
14
  url("#{http_stylesheets_path}/#{path}")
15
15
  end
16
16
 
17
- def font_url(path)
18
- path = path.value # get to the string value of the literal.
19
-
20
- # Short curcuit if they have provided an absolute url.
21
- if absolute_path?(path)
22
- return Sass::Script::String.new("url(#{path})")
23
- end
24
-
25
- # Compute the path to the font file, either root relative or stylesheet relative
26
- # or nil if the http_fonts_path cannot be determined from the configuration.
27
- http_fonts_path = if relative?
28
- compute_relative_path(Compass.configuration.fonts_dir)
29
- else
30
- Compass.configuration.http_fonts_path
31
- end
32
-
33
- url("#{http_fonts_path}/#{path}")
34
- end
35
-
36
17
  def image_url(path)
37
18
  path = path.value # get to the string value of the literal.
38
-
39
19
  # Short curcuit if they have provided an absolute url.
40
20
  if absolute_path?(path)
41
21
  return Sass::Script::String.new("url(#{path})")
@@ -1,3 +1,3 @@
1
- %w(stylesheet_updating traversal).each do |patch|
1
+ %w(stylesheet_updating).each do |patch|
2
2
  require "compass/sass_extensions/monkey_patches/#{patch}"
3
- end
3
+ end
@@ -2,8 +2,9 @@ begin
2
2
  require 'rubygems'
3
3
  require 'compass-validator'
4
4
  rescue LoadError
5
- raise Compass::MissingDependency, %Q{The Compass CSS Validator could not be loaded. Please install it:
5
+ puts %Q{The Compass CSS Validator could not be loaded. Please install it:
6
6
 
7
7
  sudo gem install chriseppstein-compass-validator --source http://gems.github.com/
8
8
  }
9
- end
9
+ exit(1)
10
+ end
@@ -1,41 +1,28 @@
1
- dir = File.dirname(__FILE__)
2
- $LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
3
-
4
1
  module FSSM
5
2
  FileNotFoundError = Class.new(StandardError)
6
3
  CallbackError = Class.new(StandardError)
7
4
 
8
5
  class << self
9
- def dbg(msg=nil)
10
- STDERR.puts(msg)
11
- end
12
-
13
- def monitor(*args, &block)
6
+ def monitor(*args, &block)
14
7
  monitor = FSSM::Monitor.new
15
8
  context = args.empty? ? monitor : monitor.path(*args)
16
-
17
- if block_given?
18
- if block.arity == 1
19
- block.call(context)
20
- else
21
- context.instance_eval(&block)
22
- end
9
+ if block && block.arity == 0
10
+ context.instance_eval(&block)
11
+ elsif block && block.arity == 1
12
+ block.call(context)
23
13
  end
24
-
25
14
  monitor.run
26
15
  end
27
16
  end
28
17
  end
29
18
 
30
- require 'thread'
31
19
  require 'pathname'
32
-
33
20
  require 'fssm/ext'
34
21
  require 'fssm/support'
35
- require 'fssm/tree'
36
22
  require 'fssm/path'
37
23
  require 'fssm/state'
38
24
  require 'fssm/monitor'
39
25
 
40
26
  require "fssm/backends/#{FSSM::Support.backend.downcase}"
41
27
  FSSM::Backends::Default = FSSM::Backends.const_get(FSSM::Support.backend)
28
+
@@ -1,37 +1,78 @@
1
- require 'fssm/fsevents'
2
-
3
1
  module FSSM::Backends
4
- class FSEvents
5
- def initialize
6
- @handlers = {}
7
- @fsevents = []
2
+ class FSEvents
3
+ def initialize(options={})
4
+ @streams = []
5
+ @handlers = {}
6
+ @allocator = options[:allocator] || OSX::KCFAllocatorDefault
7
+ @context = options[:context] || nil
8
+ @since = options[:since] || OSX::KFSEventStreamEventIdSinceNow
9
+ @latency = options[:latency] || 0.0
10
+ @flags = options[:flags] || 0
8
11
  end
9
12
 
10
13
  def add_path(path, preload=true)
11
- handler = FSSM::State.new(path)
12
- @handlers["#{path}"] = handler
14
+ @handlers["#{path}"] = FSSM::State.new(path, preload)
13
15
 
14
- fsevent = Rucola::FSEvents.new("#{path}", {:latency => 0.5}) do |events|
15
- events.each do |event|
16
- handler.refresh(event.path)
17
- end
16
+ cb = lambda do |stream, context, number, paths, flags, ids|
17
+ paths.regard_as('*')
18
+ watched = OSX.FSEventStreamCopyPathsBeingWatched(stream).first
19
+ @handlers["#{watched}"].refresh
20
+ # TODO: support this level of granularity
21
+ # number.times do |n|
22
+ # @handlers["#{watched}"].refresh_path(paths[n])
23
+ # end
18
24
  end
19
25
 
20
- fsevent.create_stream
21
- handler.refresh(path.to_pathname, true) if preload
22
- fsevent.start
23
- @fsevents << fsevent
26
+ @streams << create_stream(cb, "#{path}")
24
27
  end
25
28
 
26
29
  def run
30
+ @streams.each do |stream|
31
+ schedule_stream(stream)
32
+ start_stream(stream)
33
+ end
34
+
27
35
  begin
28
36
  OSX.CFRunLoopRun
29
37
  rescue Interrupt
30
- @fsevents.each do |fsev|
31
- fsev.stop
38
+ @streams.each do |stream|
39
+ stop_stream(stream)
40
+ invalidate_stream(stream)
41
+ release_stream(stream)
32
42
  end
33
43
  end
44
+
45
+ end
46
+
47
+ private
48
+
49
+ def create_stream(callback, paths)
50
+ paths = [paths] unless paths.is_a?(Array)
51
+ OSX.FSEventStreamCreate(@allocator, callback, @context, paths, @since, @latency, @flags)
52
+ end
53
+
54
+ def schedule_stream(stream, options={})
55
+ run_loop = options[:run_loop] || OSX.CFRunLoopGetCurrent
56
+ loop_mode = options[:loop_mode] || OSX::KCFRunLoopDefaultMode
57
+
58
+ OSX.FSEventStreamScheduleWithRunLoop(stream, run_loop, loop_mode)
34
59
  end
35
-
60
+
61
+ def start_stream(stream)
62
+ OSX.FSEventStreamStart(stream)
63
+ end
64
+
65
+ def stop_stream(stream)
66
+ OSX.FSEventStreamStop(stream)
67
+ end
68
+
69
+ def invalidate_stream(stream)
70
+ OSX.FSEventStreamInvalidate(stream)
71
+ end
72
+
73
+ def release_stream(stream)
74
+ OSX.FSEventStreamRelease(stream)
75
+ end
76
+
36
77
  end
37
78
  end
@@ -1,26 +1,24 @@
1
1
  module FSSM::Backends
2
2
  class Polling
3
- def initialize(options={})
4
- @handlers = []
5
- @latency = options[:latency] || 1
6
- end
7
-
8
- def add_path(path, preload=true)
9
- handler = FSSM::State.new(path)
10
- handler.refresh(path.to_pathname, true) if preload
11
- @handlers << handler
12
- end
13
-
14
- def run
15
- begin
16
- loop do
17
- start = Time.now.to_f
18
- @handlers.each {|handler| handler.refresh}
19
- nap_time = @latency - (Time.now.to_f - start)
20
- sleep nap_time if nap_time > 0
21
- end
22
- rescue Interrupt
3
+ def initialize(options={})
4
+ @handlers = []
5
+ @latency = options[:latency] || 1
6
+ end
7
+
8
+ def add_path(path, preload=true)
9
+ @handlers << FSSM::State.new(path, preload)
10
+ end
11
+
12
+ def run
13
+ begin
14
+ loop do
15
+ start = Time.now.to_f
16
+ @handlers.each {|handler| handler.refresh}
17
+ nap_time = @latency - (Time.now.to_f - start)
18
+ sleep nap_time if nap_time > 0
23
19
  end
20
+ rescue Interrupt
24
21
  end
25
22
  end
26
23
  end
24
+ end
@@ -4,34 +4,4 @@ class Pathname
4
4
  path.is_a?(Pathname) ? path : new(path)
5
5
  end
6
6
  end
7
-
8
- # before overwriting chop_basename:
9
- # %total - 29.50%
10
- # %self - 20.50%
11
- # after overwriting chop_basename:
12
- # %total - 24.36%
13
- # %self - 15.47%
14
- CHOP_PAT = /\A#{SEPARATOR_PAT}?\z/
15
- def chop_basename(path)
16
- base = File.basename(path)
17
- # the original version of this method recalculates this regexp
18
- # each run, despite the pattern never changing.
19
- if CHOP_PAT =~ base
20
- return nil
21
- else
22
- return path[0, path.rindex(base)], base
23
- end
24
- end
25
-
26
- def segments
27
- prefix, names = split_names(@path)
28
- names.unshift(prefix) unless prefix.empty?
29
- names.shift if names[0] == '.'
30
- names
31
- end
32
-
33
- def names
34
- prefix, names = split_names(@path)
35
- names
36
- end
37
7
  end
@@ -3,22 +3,18 @@ class FSSM::Monitor
3
3
  @options = options
4
4
  @backend = FSSM::Backends::Default.new
5
5
  end
6
-
6
+
7
7
  def path(*args, &block)
8
8
  path = FSSM::Path.new(*args)
9
-
10
- if block_given?
11
- if block.arity == 1
12
- block.call(path)
13
- else
14
- path.instance_eval(&block)
15
- end
9
+ if block && block.arity == 0
10
+ path.instance_eval(&block)
11
+ elsif block && block.arity == 1
12
+ block.call(path)
16
13
  end
17
-
18
14
  @backend.add_path(path)
19
15
  path
20
16
  end
21
-
17
+
22
18
  def run
23
19
  @backend.run
24
20
  end
@@ -3,48 +3,45 @@ class FSSM::Path
3
3
  set_path(path || '.')
4
4
  set_glob(glob || '**/*')
5
5
  init_callbacks
6
-
7
- if block_given?
8
- if block.arity == 1
9
- block.call(self)
10
- else
11
- self.instance_eval(&block)
12
- end
6
+ if block && block.arity == 0
7
+ self.instance_eval(&block)
8
+ elsif block && block.arity == 1
9
+ block.call(self)
13
10
  end
14
11
  end
15
-
12
+
16
13
  def to_s
17
14
  @path.to_s
18
15
  end
19
-
16
+
20
17
  def to_pathname
21
18
  @path
22
19
  end
23
-
20
+
24
21
  def glob(value=nil)
25
22
  return @glob if value.nil?
26
23
  set_glob(value)
27
24
  end
28
-
25
+
29
26
  def create(callback_or_path=nil, &block)
30
27
  callback_action(:create, (block_given? ? block : callback_or_path))
31
28
  end
32
-
29
+
33
30
  def update(callback_or_path=nil, &block)
34
31
  callback_action(:update, (block_given? ? block : callback_or_path))
35
32
  end
36
-
33
+
37
34
  def delete(callback_or_path=nil, &block)
38
35
  callback_action(:delete, (block_given? ? block : callback_or_path))
39
36
  end
40
-
37
+
41
38
  private
42
-
39
+
43
40
  def init_callbacks
44
41
  do_nothing = lambda {|base, relative|}
45
42
  @callbacks = Hash.new(do_nothing)
46
43
  end
47
-
44
+
48
45
  def callback_action(type, arg=nil)
49
46
  if arg.is_a?(Proc)
50
47
  set_callback(type, arg)
@@ -54,37 +51,37 @@ class FSSM::Path
54
51
  run_callback(type, arg)
55
52
  end
56
53
  end
57
-
54
+
58
55
  def set_callback(type, arg)
59
56
  raise ArgumentError, "Proc expected" unless arg.is_a?(Proc)
60
57
  @callbacks[type] = arg
61
58
  end
62
-
59
+
63
60
  def get_callback(type)
64
61
  @callbacks[type]
65
62
  end
66
-
63
+
67
64
  def run_callback(type, arg)
68
65
  base, relative = split_path(arg)
69
-
66
+
70
67
  begin
71
68
  @callbacks[type].call(base, relative)
72
69
  rescue Exception => e
73
70
  raise FSSM::CallbackError, "#{type} - #{base.join(relative)}: #{e.message}", e.backtrace
74
71
  end
75
72
  end
76
-
73
+
77
74
  def split_path(path)
78
75
  path = Pathname.for(path)
79
- [@path, (path.relative? ? path : path.relative_path_from(@path))]
76
+ [@path, (path.relative? ? path : path.relative_path_from(@path))]
80
77
  end
81
-
78
+
82
79
  def set_path(path)
83
80
  path = Pathname.for(path)
84
81
  raise FSSM::FileNotFoundError, "#{path}" unless path.exist?
85
82
  @path = path.realpath
86
83
  end
87
-
84
+
88
85
  def set_glob(glob)
89
86
  @glob = glob.is_a?(Array) ? glob : [glob]
90
87
  end