middleman 2.0.0.rc4 → 2.0.0.rc5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,6 +1,8 @@
1
1
  2.0.0
2
2
  =====
3
3
 
4
+ - Guard-powered auto-reloading of config.rb
5
+ - Guard LiveReload
4
6
  - Sprockets JS
5
7
  - Refactored Dynamically Reloadable Core
6
8
  - Combine views/ and public/ into a single source/ folder.
@@ -4,6 +4,4 @@ ENV['MM_ENV'] = "build"
4
4
 
5
5
  # Require app
6
6
  require File.join(File.dirname(__FILE__), "..", "lib", "middleman")
7
-
8
- require 'middleman'
9
7
  Middleman::Builder.start
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ `mv public source`
4
+ `ditto views source`
5
+ `rm -rf views`
@@ -1,75 +1,45 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'optparse'
3
+ require "thor"
4
+ require "thor/group"
4
5
 
5
6
  # Require Middleman
6
7
  require File.join(File.dirname(__FILE__), '..', 'lib', 'middleman')
7
8
 
8
- sandboxed_server = Middleman.server
9
-
10
- env = ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development'
11
- options = { :Port => 4567, :AccessLog => [] }
12
-
13
- # TODO: Switch to Thor
14
- OptionParser.new { |opts|
15
- opts.banner = "Usage: mm-server [rack options]"
16
- opts.separator ""
17
- opts.separator "Rack options:"
18
- opts.on("-p", "--port PORT", "use PORT (default: 4567)") { |port|
19
- options[:Port] = port
20
- }
21
- opts.on("-E", "--env ENVIRONMENT", "use ENVIRONMENT for defaults (default: development)") { |e|
22
- env = e
23
- }
24
- opts.on("--debug", "Debug mode") {
25
- sandboxed_server.set :logging, true
26
- }
27
-
28
- opts.parse! ARGV
29
- }
30
-
31
- ENV['RACK_ENV'] = env
32
-
33
- @current_path = Dir.pwd
34
- @path_parts = @current_path.split("/")
35
- @found_root = false
36
-
37
- while (!@found_root && (@path_parts.length > 0))
38
- @current_path = File.join(*@path_parts)
39
-
40
- source_folder = File.join(@current_path, "source")
41
-
42
- if File.exists?(source_folder)
43
- @found_root = true
44
- next
9
+ module Middleman
10
+ class GuardServer < ::Thor::Group
11
+ include Thor::Actions
12
+
13
+ class_option :environment, :aliases => "-e", :default => ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development'
14
+
15
+ class_option :port, :aliases => "-p", :default => "4567"
16
+ class_option :"livereload-port", :default => "35729"
17
+ class_option :"livereload", :default => true, :type => :boolean
18
+
19
+ def start_guard
20
+ if !File.exists?("config.rb")
21
+ $stderr.puts "== Error: Could not find a Middleman project config, perhaps you are in the wrong folder?"
22
+ return
23
+ end
24
+
25
+ # If the old directories exists, use it, but issue warning
26
+ if File.exists?("views") || File.exists?("public")
27
+ $stderr.puts "== Error: The views and public folders are have been combined. Create a new 'source' folder, add the contents of views and public to it and then remove the empty views and public folders."
28
+ return
29
+ end
30
+
31
+ ENV['RACK_ENV'] = options[:environment]
32
+
33
+ livereload_options = {
34
+ :port => options[:"livereload-port"]
35
+ }
36
+ livereload_options = nil unless options[:"livereload"]
37
+
38
+ ::Middleman::Guard.start({
39
+ :port => options[:port],
40
+ }, livereload_options)
41
+ end
45
42
  end
46
-
47
- @path_parts.pop
48
43
  end
49
44
 
50
- if !@found_root
51
- $stderr.puts "== Error: Could not find a Middleman project structure, perhaps you are in the wrong folder?"
52
- exit
53
- end
54
-
55
- # If the old init.rb exists, issue warning
56
- old_config = File.join(@current_path, "init.rb")
57
- if File.exists? old_config
58
- $stderr.puts "== Error: The init.rb file (deprecated) needs to be be renamed to config.rb"
59
- exit
60
- end
61
-
62
- # If the old directories exists, use it, but issue warning
63
- old_views = File.join(@current_path, "views")
64
- old_public = File.join(@current_path, "public")
65
- if File.exists?(old_views) || File.exists?(old_public)
66
- $stderr.puts "== Error: The views and public folders are have been combined. Create a new 'source' folder, add the contents of views and public to it and then remove the empty views and public folders."
67
- exit
68
- end
69
-
70
- sandboxed_server.set :root, @current_path
71
- options[:app] = sandboxed_server.new
72
- # options[:server] = 'webrick'
73
-
74
- puts "== The Middleman is standing watch on port #{options[:Port]}"
75
- Rack::Server.new(options).start
45
+ Middleman::GuardServer.start
@@ -66,6 +66,7 @@ module Middleman
66
66
  # Auto-load modules on-demand
67
67
  autoload :Base, "middleman/base"
68
68
  autoload :Builder, "middleman/builder"
69
+ autoload :Guard, "middleman/guard"
69
70
 
70
71
  # Custom Renderers
71
72
  module Renderers
@@ -143,6 +144,9 @@ module Middleman
143
144
 
144
145
  # Proxy web services requests in dev mode only
145
146
  autoload :Proxy, "middleman/features/proxy"
147
+
148
+ # guard-livereload
149
+ autoload :LiveReload, "middleman/features/live_reload"
146
150
 
147
151
  # Automatically resize images for mobile devises
148
152
  # autoload :TinySrc, "middleman/features/tiny_src"
@@ -0,0 +1,71 @@
1
+ require "guard"
2
+ require "guard/guard"
3
+ require "guard/livereload"
4
+
5
+ module Middleman::Guard
6
+ def self.start(options={}, livereload={})
7
+ options_hash = ""
8
+ options.each do |k,v|
9
+ options_hash << ", :#{k} => '#{v}'"
10
+ end
11
+
12
+ guardfile_contents = %Q{
13
+ guard 'middleman'#{options_hash} do
14
+ watch("config.rb")
15
+ end
16
+ }
17
+
18
+ if livereload
19
+ livereload_options_hash = ""
20
+ livereload.each do |k,v|
21
+ livereload_options_hash << ", :#{k} => '#{v}'"
22
+ end
23
+
24
+ guardfile_contents << %Q{
25
+ guard 'livereload'#{livereload_options_hash} do
26
+ watch(%r{^source/(.*)$})
27
+ end
28
+ }
29
+ end
30
+
31
+ ::Guard.start({ :guardfile_contents => guardfile_contents })
32
+ end
33
+ end
34
+
35
+ module Guard
36
+ class Middleman < Guard
37
+ def initialize(watchers = [], options = {})
38
+ super
39
+ @options = {
40
+ :port => '4567'
41
+ }.update(options)
42
+ end
43
+
44
+ def start
45
+ server_start
46
+ end
47
+
48
+ def run_on_change(paths)
49
+ server_stop
50
+ server_start
51
+ end
52
+
53
+ private
54
+ def server_start
55
+ puts "== The Middleman is standing watch on port #{@options[:port]}"
56
+ @server_options = { :Port => @options[:port], :AccessLog => [] }
57
+ @server_job = fork do
58
+ @server_options[:app] = ::Middleman.server.new
59
+ ::Rack::Server.new(@server_options).start
60
+ end
61
+ end
62
+
63
+ def server_stop
64
+ puts "== The Middleman is shutting down"
65
+ Process.kill("KILL", @server_job)
66
+ Process.wait @server_job
67
+ @server_job = nil
68
+ @server_options[:app] = nil
69
+ end
70
+ end
71
+ end
@@ -1,3 +1,3 @@
1
1
  module Middleman
2
- VERSION = "2.0.0.rc4"
2
+ VERSION = "2.0.0.rc5"
3
3
  end
@@ -34,6 +34,8 @@ Gem::Specification.new do |s|
34
34
  s.add_runtime_dependency("compass", ["~> 0.11.3"])
35
35
  s.add_runtime_dependency("sprockets", ["2.0.0.beta.10"])
36
36
  s.add_runtime_dependency("httparty", ["~> 0.7.0"])
37
+ s.add_runtime_dependency("guard", [">= 0"])
38
+ s.add_runtime_dependency("guard-livereload", [">= 0"])
37
39
  s.add_development_dependency("coffee-filter", ["~> 0.1.1"])
38
40
  s.add_development_dependency("cucumber", ["~> 0.10.0"])
39
41
  s.add_development_dependency("rake", ["0.8.7"])
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: middleman
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 2.0.0.rc4
5
+ version: 2.0.0.rc5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Thomas Reynolds
@@ -190,66 +190,89 @@ dependencies:
190
190
  type: :runtime
191
191
  version_requirements: *id016
192
192
  - !ruby/object:Gem::Dependency
193
- name: coffee-filter
193
+ name: guard
194
194
  prerelease: false
195
195
  requirement: &id017 !ruby/object:Gem::Requirement
196
+ none: false
197
+ requirements:
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ version: "0"
201
+ type: :runtime
202
+ version_requirements: *id017
203
+ - !ruby/object:Gem::Dependency
204
+ name: guard-livereload
205
+ prerelease: false
206
+ requirement: &id018 !ruby/object:Gem::Requirement
207
+ none: false
208
+ requirements:
209
+ - - ">="
210
+ - !ruby/object:Gem::Version
211
+ version: "0"
212
+ type: :runtime
213
+ version_requirements: *id018
214
+ - !ruby/object:Gem::Dependency
215
+ name: coffee-filter
216
+ prerelease: false
217
+ requirement: &id019 !ruby/object:Gem::Requirement
196
218
  none: false
197
219
  requirements:
198
220
  - - ~>
199
221
  - !ruby/object:Gem::Version
200
222
  version: 0.1.1
201
223
  type: :development
202
- version_requirements: *id017
224
+ version_requirements: *id019
203
225
  - !ruby/object:Gem::Dependency
204
226
  name: cucumber
205
227
  prerelease: false
206
- requirement: &id018 !ruby/object:Gem::Requirement
228
+ requirement: &id020 !ruby/object:Gem::Requirement
207
229
  none: false
208
230
  requirements:
209
231
  - - ~>
210
232
  - !ruby/object:Gem::Version
211
233
  version: 0.10.0
212
234
  type: :development
213
- version_requirements: *id018
235
+ version_requirements: *id020
214
236
  - !ruby/object:Gem::Dependency
215
237
  name: rake
216
238
  prerelease: false
217
- requirement: &id019 !ruby/object:Gem::Requirement
239
+ requirement: &id021 !ruby/object:Gem::Requirement
218
240
  none: false
219
241
  requirements:
220
242
  - - "="
221
243
  - !ruby/object:Gem::Version
222
244
  version: 0.8.7
223
245
  type: :development
224
- version_requirements: *id019
246
+ version_requirements: *id021
225
247
  - !ruby/object:Gem::Dependency
226
248
  name: rspec
227
249
  prerelease: false
228
- requirement: &id020 !ruby/object:Gem::Requirement
250
+ requirement: &id022 !ruby/object:Gem::Requirement
229
251
  none: false
230
252
  requirements:
231
253
  - - ">="
232
254
  - !ruby/object:Gem::Version
233
255
  version: "0"
234
256
  type: :development
235
- version_requirements: *id020
257
+ version_requirements: *id022
236
258
  - !ruby/object:Gem::Dependency
237
259
  name: rocco
238
260
  prerelease: false
239
- requirement: &id021 !ruby/object:Gem::Requirement
261
+ requirement: &id023 !ruby/object:Gem::Requirement
240
262
  none: false
241
263
  requirements:
242
264
  - - ">="
243
265
  - !ruby/object:Gem::Version
244
266
  version: "0"
245
267
  type: :development
246
- version_requirements: *id021
268
+ version_requirements: *id023
247
269
  description:
248
270
  email:
249
271
  - tdreyno@gmail.com
250
272
  executables:
251
273
  - mm-build
252
274
  - mm-init
275
+ - mm-migrate
253
276
  - mm-server
254
277
  extensions: []
255
278
 
@@ -267,6 +290,7 @@ files:
267
290
  - Rakefile
268
291
  - bin/mm-build
269
292
  - bin/mm-init
293
+ - bin/mm-migrate
270
294
  - bin/mm-server
271
295
  - features/asset_host.feature
272
296
  - features/automatic_image_sizes.feature
@@ -370,6 +394,7 @@ files:
370
394
  - lib/middleman/features/proxy.rb
371
395
  - lib/middleman/features/relative_assets.rb
372
396
  - lib/middleman/features/tiny_src.rb
397
+ - lib/middleman/guard.rb
373
398
  - lib/middleman/renderers/coffee_script.rb
374
399
  - lib/middleman/renderers/haml.rb
375
400
  - lib/middleman/renderers/markdown.rb