massimo 0.5.6 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/massimo/cli.rb +6 -12
- data/lib/massimo/page.rb +4 -9
- data/lib/massimo/server.rb +1 -0
- data/lib/massimo/ui.rb +70 -0
- data/lib/massimo/view.rb +1 -1
- data/lib/massimo/watcher.rb +12 -10
- data/lib/massimo.rb +1 -0
- metadata +26 -11
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
data/lib/massimo/cli.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'optparse'
|
2
|
-
require 'ostruct'
|
3
1
|
require 'thor'
|
4
2
|
|
5
3
|
module Massimo
|
@@ -13,25 +11,21 @@ module Massimo
|
|
13
11
|
|
14
12
|
desc 'build', 'Builds the site'
|
15
13
|
def build
|
16
|
-
|
17
|
-
|
14
|
+
Massimo::UI.report_errors do
|
15
|
+
site.process
|
16
|
+
Massimo::UI.say 'massimo has built your site', :growl => true
|
17
|
+
end
|
18
18
|
end
|
19
19
|
map 'b' => :build
|
20
20
|
|
21
21
|
desc 'watch', 'Watches your files for changes and rebuilds'
|
22
22
|
def watch
|
23
|
-
|
24
|
-
say 'massimo is watching your files for changes'
|
25
|
-
Massimo::Watcher.start(site)
|
26
|
-
rescue Interrupt
|
27
|
-
exit
|
28
|
-
end
|
23
|
+
Massimo::Watcher.start(site)
|
29
24
|
end
|
30
25
|
map 'w' => :watch
|
31
26
|
|
32
27
|
desc 'server [PORT]', 'Runs a local web server and processes the site on save'
|
33
28
|
def server(port = 3000)
|
34
|
-
say "massimo is serving your site at http://localhost:#{port}"
|
35
29
|
Massimo::Server.start(site, port.to_i)
|
36
30
|
end
|
37
31
|
map 's' => :server
|
@@ -72,7 +66,7 @@ module Massimo
|
|
72
66
|
|
73
67
|
desc 'version', 'Displays current version'
|
74
68
|
def version
|
75
|
-
say Massimo::VERSION
|
69
|
+
Massimo::UI.say Massimo::VERSION
|
76
70
|
end
|
77
71
|
map %w( -v --version ) => :version
|
78
72
|
|
data/lib/massimo/page.rb
CHANGED
@@ -9,8 +9,8 @@ module Massimo
|
|
9
9
|
def render
|
10
10
|
output = content
|
11
11
|
|
12
|
-
if template_type = Tilt[
|
13
|
-
template = template_type.new(
|
12
|
+
if template_type = Tilt[filename]
|
13
|
+
template = template_type.new(source_path.to_s, @line || 1) { output }
|
14
14
|
meta_data = @meta_data.merge(self.class.resource_name.singularize.to_sym => self)
|
15
15
|
output = template.render(Massimo.site.template_scope, meta_data)
|
16
16
|
end
|
@@ -23,7 +23,7 @@ module Massimo
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def title
|
26
|
-
@meta_data[:title] ||=
|
26
|
+
@meta_data[:title] ||= filename.chomp(source_path.extname.to_s).titleize
|
27
27
|
end
|
28
28
|
|
29
29
|
def extension
|
@@ -31,12 +31,7 @@ module Massimo
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def url
|
34
|
-
@meta_data[:url] ||=
|
35
|
-
url = super
|
36
|
-
url.chomp!('index.html')
|
37
|
-
url.sub!(/\.html$/, '/')
|
38
|
-
url
|
39
|
-
end
|
34
|
+
@meta_data[:url] ||= super.chomp('index.html').sub(/\.html$/, '/')
|
40
35
|
end
|
41
36
|
|
42
37
|
def layout
|
data/lib/massimo/server.rb
CHANGED
data/lib/massimo/ui.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'active_support/core_ext/array/extract_options'
|
2
|
+
|
3
|
+
module Massimo
|
4
|
+
module UI
|
5
|
+
extend self
|
6
|
+
|
7
|
+
COLOR_CODES = {
|
8
|
+
:black => 30,
|
9
|
+
:red => 31,
|
10
|
+
:green => 32,
|
11
|
+
:yellow => 33,
|
12
|
+
:blue => 34,
|
13
|
+
:magenta => 35,
|
14
|
+
:cyan => 36
|
15
|
+
}.freeze
|
16
|
+
|
17
|
+
# Say (print) something to the user.
|
18
|
+
def say(message, *args)
|
19
|
+
options = args.extract_options!
|
20
|
+
color = args.first
|
21
|
+
|
22
|
+
growl(message) if options[:growl]
|
23
|
+
message = (' ' * padding) + message.to_s
|
24
|
+
message = self.color(message, color) if color
|
25
|
+
|
26
|
+
$stdout.puts(message)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Color the given message with the given color
|
30
|
+
def color(message, color)
|
31
|
+
"\e[#{COLOR_CODES[color.to_sym]}m#{message}\e[0m"
|
32
|
+
end
|
33
|
+
|
34
|
+
# Run the given block and cleanly report any errors
|
35
|
+
def report_errors
|
36
|
+
begin
|
37
|
+
yield
|
38
|
+
rescue Exception => error
|
39
|
+
say 'massimo had a problem', :red
|
40
|
+
indent do
|
41
|
+
say error.message, :magenta
|
42
|
+
say error.backtrace.first, :magenta
|
43
|
+
end
|
44
|
+
growl "#{error.message}\n#{error.backtrace.first}", 'massimo problem'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Indents the messages within the block by the given amount.
|
49
|
+
def indent(amount = 2)
|
50
|
+
self.padding += amount
|
51
|
+
yield
|
52
|
+
self.padding -= amount
|
53
|
+
end
|
54
|
+
|
55
|
+
protected
|
56
|
+
|
57
|
+
def growl(message, title = 'massimo')
|
58
|
+
Growl.notify(message, :title => title) if defined?(Growl)
|
59
|
+
end
|
60
|
+
|
61
|
+
def padding
|
62
|
+
@padding ||= 0
|
63
|
+
end
|
64
|
+
|
65
|
+
def padding=(value)
|
66
|
+
@padding = [ 0, value.to_i ].max
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
data/lib/massimo/view.rb
CHANGED
data/lib/massimo/watcher.rb
CHANGED
@@ -2,6 +2,7 @@ module Massimo
|
|
2
2
|
class Watcher
|
3
3
|
class << self
|
4
4
|
def start(site)
|
5
|
+
Massimo::UI.say 'massimo is watching your files for changes', :growl => true
|
5
6
|
self.new(site).run
|
6
7
|
end
|
7
8
|
end
|
@@ -11,24 +12,25 @@ module Massimo
|
|
11
12
|
@files = []
|
12
13
|
end
|
13
14
|
|
14
|
-
# Runs a loop, processing the whenever files have changed.
|
15
|
+
# Runs a loop, processing the Site whenever files have changed.
|
15
16
|
def run
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
begin
|
18
|
+
loop do
|
19
|
+
process
|
20
|
+
sleep 0.5
|
21
|
+
end
|
22
|
+
rescue Interrupt
|
23
|
+
exit
|
19
24
|
end
|
20
25
|
end
|
21
26
|
|
22
27
|
# Processes the Site if any of the files have changed.
|
23
28
|
def process
|
24
29
|
if changed?
|
25
|
-
|
26
|
-
|
30
|
+
Massimo::UI.report_errors do
|
31
|
+
Massimo::UI.say 'massimo has noticed a change'
|
27
32
|
@site.process
|
28
|
-
|
29
|
-
rescue Exception => e
|
30
|
-
puts e.message
|
31
|
-
puts e.backtrace
|
33
|
+
Massimo::UI.say 'massimo has built your site', :growl => true
|
32
34
|
end
|
33
35
|
end
|
34
36
|
end
|
data/lib/massimo.rb
CHANGED
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
- 5
|
8
7
|
- 6
|
9
|
-
|
8
|
+
- 0
|
9
|
+
version: 0.6.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Pete Browne
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-30 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -229,6 +229,20 @@ dependencies:
|
|
229
229
|
version: 0.9.0
|
230
230
|
type: :development
|
231
231
|
version_requirements: *id015
|
232
|
+
- !ruby/object:Gem::Dependency
|
233
|
+
name: growl
|
234
|
+
prerelease: false
|
235
|
+
requirement: &id016 !ruby/object:Gem::Requirement
|
236
|
+
requirements:
|
237
|
+
- - ~>
|
238
|
+
- !ruby/object:Gem::Version
|
239
|
+
segments:
|
240
|
+
- 1
|
241
|
+
- 0
|
242
|
+
- 0
|
243
|
+
version: 1.0.0
|
244
|
+
type: :development
|
245
|
+
version_requirements: *id016
|
232
246
|
description: Massimo builds HTML, Javascript, and CSS Files from your source.
|
233
247
|
email: me@petebrowne.com
|
234
248
|
executables:
|
@@ -239,17 +253,18 @@ extra_rdoc_files: []
|
|
239
253
|
|
240
254
|
files:
|
241
255
|
- bin/massimo
|
242
|
-
- lib/massimo/stylesheet.rb
|
243
|
-
- lib/massimo/server.rb
|
244
|
-
- lib/massimo/view.rb
|
245
|
-
- lib/massimo/page.rb
|
246
|
-
- lib/massimo/resource.rb
|
247
256
|
- lib/massimo/cli.rb
|
248
257
|
- lib/massimo/config.rb
|
249
|
-
- lib/massimo/watcher.rb
|
250
|
-
- lib/massimo/site.rb
|
251
|
-
- lib/massimo/javascript.rb
|
252
258
|
- lib/massimo/helpers.rb
|
259
|
+
- lib/massimo/javascript.rb
|
260
|
+
- lib/massimo/page.rb
|
261
|
+
- lib/massimo/resource.rb
|
262
|
+
- lib/massimo/server.rb
|
263
|
+
- lib/massimo/site.rb
|
264
|
+
- lib/massimo/stylesheet.rb
|
265
|
+
- lib/massimo/ui.rb
|
266
|
+
- lib/massimo/view.rb
|
267
|
+
- lib/massimo/watcher.rb
|
253
268
|
- lib/massimo.rb
|
254
269
|
- LICENSE
|
255
270
|
- README.md
|