middleman-core 3.0.0.alpha.7 → 3.0.0.alpha.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/features/preview_changes.feature +12 -1
  2. data/lib/middleman-core/base.rb +1 -1
  3. data/lib/middleman-core/cli/server.rb +1 -1
  4. data/lib/middleman-core/core_extensions/file_watcher.rb +2 -0
  5. data/lib/middleman-core/core_extensions/front_matter.rb +0 -1
  6. data/lib/middleman-core/core_extensions/rendering.rb +8 -1
  7. data/lib/middleman-core/renderers/erb.rb +10 -0
  8. data/lib/middleman-core/step_definitions/middleman_steps.rb +10 -8
  9. data/lib/middleman-core/step_definitions/server_steps.rb +4 -3
  10. data/lib/middleman-core/vendor/rb-fsevent-0.4.3.1/LICENSE +20 -0
  11. data/lib/middleman-core/vendor/rb-fsevent-0.4.3.1/README.rdoc +254 -0
  12. data/lib/middleman-core/vendor/rb-fsevent-0.4.3.1/ext/extconf.rb +61 -0
  13. data/lib/middleman-core/vendor/rb-fsevent-0.4.3.1/ext/fsevent/fsevent_watch.c +226 -0
  14. data/lib/middleman-core/vendor/rb-fsevent-0.4.3.1/lib/rb-fsevent/fsevent.rb +105 -0
  15. data/lib/middleman-core/vendor/rb-fsevent-0.4.3.1/lib/rb-fsevent/version.rb +3 -0
  16. data/lib/middleman-core/vendor/rb-fsevent-0.4.3.1/lib/rb-fsevent.rb +2 -0
  17. data/lib/middleman-core/vendor/rb-inotify-0.8.8/.yardopts +4 -0
  18. data/lib/middleman-core/vendor/rb-inotify-0.8.8/MIT-LICENSE +20 -0
  19. data/lib/middleman-core/vendor/rb-inotify-0.8.8/README.md +66 -0
  20. data/lib/middleman-core/vendor/rb-inotify-0.8.8/Rakefile +54 -0
  21. data/lib/middleman-core/vendor/rb-inotify-0.8.8/VERSION +1 -0
  22. data/lib/middleman-core/vendor/rb-inotify-0.8.8/lib/rb-inotify/event.rb +139 -0
  23. data/lib/middleman-core/vendor/rb-inotify-0.8.8/lib/rb-inotify/native/flags.rb +89 -0
  24. data/lib/middleman-core/vendor/rb-inotify-0.8.8/lib/rb-inotify/native.rb +31 -0
  25. data/lib/middleman-core/vendor/rb-inotify-0.8.8/lib/rb-inotify/notifier.rb +308 -0
  26. data/lib/middleman-core/vendor/rb-inotify-0.8.8/lib/rb-inotify/watcher.rb +83 -0
  27. data/lib/middleman-core/vendor/rb-inotify-0.8.8/lib/rb-inotify.rb +17 -0
  28. data/lib/middleman-core/vendor/rb-inotify-0.8.8/rb-inotify.gemspec +53 -0
  29. data/lib/middleman-core/version.rb +1 -1
  30. data/lib/middleman-core/{guard.rb → watcher.rb} +62 -58
  31. data/lib/middleman-core.rb +1 -1
  32. data/middleman-core.gemspec +1 -1
  33. metadata +29 -10
@@ -1,61 +1,67 @@
1
- # Guard watches the filesystem for changes
2
- require "guard"
3
- require "guard/guard"
1
+ # Inspect Ruby env
2
+ require "rbconfig"
3
+
4
+ # Watcher Library
5
+ require "fssm"
4
6
 
5
7
  # File changes are forwarded to the currently running app via HTTP
6
8
  require "net/http"
7
9
 
8
- # Support forking on Windows
9
- require "win32/process" if Middleman::WINDOWS
10
-
11
- # The Guard namespace
12
- module Middleman::Guard
13
-
14
- # Start guard
15
- # @param [Hash] options
16
- # @return [void]
17
- def self.start(options={})
18
- # Forward CLI options to Guard
19
- options_hash = options.map { |k,v| ", :#{k} => '#{v}'" }.join
20
-
21
- # Watch all files in project, even hidden ones.
22
- ::Guard.start({
23
- :guardfile_contents => %Q{
24
- guard 'middleman'#{options_hash} do
25
- watch(%r{(.*)})
26
- end
27
- },
28
- :watch_all_modifications => true,
29
- :no_interactions => true
30
- })
31
- end
32
- end
33
-
34
- # @private
35
- module Guard
36
-
37
- # Monkeypatch Guard into being quiet
38
- module UI
10
+ module Middleman
11
+ class Watcher
39
12
  class << self
40
- def info(message, options = { }); end
13
+ attr_accessor :singleton
14
+
15
+ def start(options)
16
+ self.singleton = new(options)
17
+ self.singleton.watch!
18
+ end
19
+
20
+ # What command is sent to kill instances
21
+ # @return [Symbol, Fixnum]
22
+ def kill_command
23
+ ::Middleman::WINDOWS ? 1 : :INT
24
+ end
25
+
26
+ def ignore_list
27
+ [
28
+ /\.sass-cache/,
29
+ /\.git/,
30
+ /\.DS_Store/
31
+ ]
32
+ end
41
33
  end
42
- end
43
-
44
- # Guards must be in the Guard module to be picked up
45
- class Middleman < Guard
46
34
 
47
- # Save the options for later
48
- def initialize(watchers = [], options = {})
49
- super
50
-
51
- # Save options
35
+ def initialize(options)
52
36
  @options = options
37
+
38
+ if RbConfig::CONFIG['target_os'] =~ /darwin/i
39
+ $LOAD_PATH << File.expand_path('../../middleman-core/vendor/rb-fsevent-0.4.3.1/lib', __FILE__)
40
+ require 'rb-fsevent'
41
+ elsif RbConfig::CONFIG['target_os'] =~ /linux/i
42
+ $LOAD_PATH << File.expand_path('../../middleman-core/vendor/rb-inotify-0.8.8/lib', __FILE__)
43
+ require 'rb-inotify'
44
+ end
45
+
46
+ start
47
+ end
48
+
49
+ def watch!
50
+ local = self
51
+ FSSM.monitor(Dir.pwd) do
52
+ create { |base, relative| local.run_on_change([relative]) }
53
+ update { |base, relative| local.run_on_change([relative]) }
54
+ delete { |base, relative| local.run_on_deletion([relative]) }
55
+ end
53
56
  end
54
57
 
55
58
  # Start Middleman in a fork
56
59
  # @return [void]
57
60
  def start
58
- @server_job = fork { bootup }
61
+ @server_job = fork {
62
+ Signal.trap(::Middleman::WINDOWS ? :KILL : :TERM) { exit! }
63
+ bootup
64
+ }
59
65
  end
60
66
 
61
67
  # Start an instance of Middleman::Base
@@ -92,7 +98,7 @@ module Guard
92
98
  stop
93
99
  start
94
100
  end
95
-
101
+
96
102
  # What to do on file change
97
103
  # @param [Array<String>] paths Array of paths that changed
98
104
  # @return [void]
@@ -101,7 +107,9 @@ module Guard
101
107
  return reload if needs_to_reload?(paths)
102
108
 
103
109
  # Otherwise forward to Middleman
104
- paths.each { |path| tell_server(:change => path) }
110
+ paths.each do |path|
111
+ tell_server(:change => path) unless self.class.ignore_list.any? { |r| path.match(r) }
112
+ end
105
113
  end
106
114
 
107
115
  # What to do on file deletion
@@ -112,13 +120,9 @@ module Guard
112
120
  return reload if needs_to_reload?(paths)
113
121
 
114
122
  # Otherwise forward to Middleman
115
- paths.each { |path| tell_server(:delete => path) }
116
- end
117
-
118
- # What command is sent to kill instances
119
- # @return [Symbol, Fixnum]
120
- def self.kill_command
121
- ::Middleman::WINDOWS ? 1 : :INT
123
+ paths.each do |path|
124
+ tell_server(:delete => path) unless self.class.ignore_list.any? { |r| path.match(r) }
125
+ end
122
126
  end
123
127
 
124
128
  private
@@ -141,8 +145,8 @@ module Guard
141
145
  end
142
146
  end
143
147
 
144
- # Trap the interupt signal and shut down Guard (and thus the server) smoothly
145
- trap(::Guard::Middleman.kill_command) do
146
- ::Guard.stop
147
- exit!(0)
148
+ # Trap the interupt signal and shut down FSSM (and thus the server) smoothly
149
+ trap(::Middleman::Watcher.kill_command) do
150
+ ::Middleman::Watcher.singleton.stop
151
+ exit(0)
148
152
  end
@@ -27,7 +27,7 @@ module Middleman
27
27
  autoload :Base, "middleman-core/base"
28
28
  autoload :Cache, "middleman-core/cache"
29
29
  autoload :Templates, "middleman-core/templates"
30
- autoload :Guard, "middleman-core/guard"
30
+ autoload :Watcher, "middleman-core/watcher"
31
31
 
32
32
  module Cli
33
33
  autoload :Base, "middleman-core/cli"
@@ -36,6 +36,6 @@ Gem::Specification.new do |s|
36
36
  s.add_dependency("activesupport", ["~> 3.1.0"])
37
37
 
38
38
  # Watcher
39
- s.add_dependency("guard", ["~> 0.9.4"])
39
+ s.add_dependency("fssm", ["~> 0.2.7"])
40
40
  end
41
41
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-core
3
3
  version: !ruby/object:Gem::Version
4
- hash: -3702664398
4
+ hash: -3702664404
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
9
  - 0
10
10
  - alpha
11
- - 7
12
- version: 3.0.0.alpha.7
11
+ - 8
12
+ version: 3.0.0.alpha.8
13
13
  platform: ruby
14
14
  authors:
15
15
  - Thomas Reynolds
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-12-29 00:00:00 -08:00
20
+ date: 2012-01-02 00:00:00 -08:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -108,13 +108,13 @@ dependencies:
108
108
  requirements:
109
109
  - - ~>
110
110
  - !ruby/object:Gem::Version
111
- hash: 51
111
+ hash: 25
112
112
  segments:
113
113
  - 0
114
- - 9
115
- - 4
116
- version: 0.9.4
117
- name: guard
114
+ - 2
115
+ - 7
116
+ version: 0.2.7
117
+ name: fssm
118
118
  version_requirements: *id006
119
119
  description: A static site generator based on Sinatra. Providing dozens of templating languages (Haml, Sass, Compass, Slim, CoffeeScript, and more). Makes minification, compression, cache busting, Yaml data (and more) an easy part of your development cycle.
120
120
  email:
@@ -390,7 +390,6 @@ files:
390
390
  - lib/middleman-core/extensions/automatic_image_sizes/fastimage.rb
391
391
  - lib/middleman-core/extensions/directory_indexes.rb
392
392
  - lib/middleman-core/extensions/lorem.rb
393
- - lib/middleman-core/guard.rb
394
393
  - lib/middleman-core/renderers/erb.rb
395
394
  - lib/middleman-core/sitemap/page.rb
396
395
  - lib/middleman-core/sitemap/store.rb
@@ -694,7 +693,27 @@ files:
694
693
  - lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_output_helpers.rb
695
694
  - lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_render_helpers.rb
696
695
  - lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_tag_helpers.rb
696
+ - lib/middleman-core/vendor/rb-fsevent-0.4.3.1/LICENSE
697
+ - lib/middleman-core/vendor/rb-fsevent-0.4.3.1/README.rdoc
698
+ - lib/middleman-core/vendor/rb-fsevent-0.4.3.1/ext/extconf.rb
699
+ - lib/middleman-core/vendor/rb-fsevent-0.4.3.1/ext/fsevent/fsevent_watch.c
700
+ - lib/middleman-core/vendor/rb-fsevent-0.4.3.1/lib/rb-fsevent.rb
701
+ - lib/middleman-core/vendor/rb-fsevent-0.4.3.1/lib/rb-fsevent/fsevent.rb
702
+ - lib/middleman-core/vendor/rb-fsevent-0.4.3.1/lib/rb-fsevent/version.rb
703
+ - lib/middleman-core/vendor/rb-inotify-0.8.8/.yardopts
704
+ - lib/middleman-core/vendor/rb-inotify-0.8.8/MIT-LICENSE
705
+ - lib/middleman-core/vendor/rb-inotify-0.8.8/README.md
706
+ - lib/middleman-core/vendor/rb-inotify-0.8.8/Rakefile
707
+ - lib/middleman-core/vendor/rb-inotify-0.8.8/VERSION
708
+ - lib/middleman-core/vendor/rb-inotify-0.8.8/lib/rb-inotify.rb
709
+ - lib/middleman-core/vendor/rb-inotify-0.8.8/lib/rb-inotify/event.rb
710
+ - lib/middleman-core/vendor/rb-inotify-0.8.8/lib/rb-inotify/native.rb
711
+ - lib/middleman-core/vendor/rb-inotify-0.8.8/lib/rb-inotify/native/flags.rb
712
+ - lib/middleman-core/vendor/rb-inotify-0.8.8/lib/rb-inotify/notifier.rb
713
+ - lib/middleman-core/vendor/rb-inotify-0.8.8/lib/rb-inotify/watcher.rb
714
+ - lib/middleman-core/vendor/rb-inotify-0.8.8/rb-inotify.gemspec
697
715
  - lib/middleman-core/version.rb
716
+ - lib/middleman-core/watcher.rb
698
717
  - middleman-core.gemspec
699
718
  has_rdoc: true
700
719
  homepage: http://middlemanapp.com