massimo 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/massimo/commands/base.rb +2 -4
- data/lib/massimo/javascript.rb +27 -27
- data/lib/massimo/page.rb +32 -32
- data/lib/massimo/resource.rb +3 -3
- data/lib/massimo/site.rb +28 -30
- data/lib/massimo/ui.rb +9 -9
- data/lib/massimo/version.rb +1 -1
- data/lib/massimo/watcher.rb +10 -10
- metadata +3 -3
@@ -16,7 +16,7 @@ module Massimo
|
|
16
16
|
command.run
|
17
17
|
end
|
18
18
|
|
19
|
-
def initialize
|
19
|
+
def initialize
|
20
20
|
@options = {}
|
21
21
|
@parser = OptionParser.new
|
22
22
|
|
@@ -63,15 +63,13 @@ module Massimo
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def site
|
66
|
-
@site ||=
|
67
|
-
site = Massimo::Site.new config_file(:yml)
|
66
|
+
@site ||= Massimo::Site.new(config_file(:yml)).tap do |site|
|
68
67
|
site.config.environment = options[:environment] if options[:environment]
|
69
68
|
site.config.source_path = options[:source_path] if options[:source_path]
|
70
69
|
site.config.output_path = options[:output_path] if options[:output_path]
|
71
70
|
if config_rb = config_file(:rb)
|
72
71
|
site.instance_eval File.read(config_rb)
|
73
72
|
end
|
74
|
-
site
|
75
73
|
end
|
76
74
|
end
|
77
75
|
|
data/lib/massimo/javascript.rb
CHANGED
@@ -10,35 +10,35 @@ module Massimo
|
|
10
10
|
|
11
11
|
protected
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
13
|
+
def compile
|
14
|
+
case source_path.extname
|
15
|
+
when '.coffee'
|
16
|
+
require 'coffee-script' unless defined?(CoffeeScript)
|
17
|
+
CoffeeScript.compile(content, Massimo.config.options_for(:coffee_script))
|
18
|
+
else
|
19
|
+
require 'sprockets' unless defined?(Sprockets)
|
20
|
+
options = Massimo.config.options_for(:sprockets).merge(
|
21
|
+
:assert_root => Massimo.config.output_path,
|
22
|
+
:source_files => [ source_path.to_s ]
|
23
|
+
)
|
24
|
+
secretary = Sprockets::Secretary.new(options)
|
25
|
+
secretary.install_assets
|
26
|
+
secretary.concatenation.to_s
|
27
|
+
end
|
27
28
|
end
|
28
|
-
end
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
30
|
+
def compress(javascript)
|
31
|
+
case Massimo.config.javascripts_compressor.to_s
|
32
|
+
when 'min', 'jsmin'
|
33
|
+
require 'jsmin' unless defined?(JSMin)
|
34
|
+
JSMin.minify(javascript).strip
|
35
|
+
when 'pack', 'packr'
|
36
|
+
require 'packr' unless defined?(Packr)
|
37
|
+
options = { :shrink_vars => true }.merge Massimo.config.options_for(:packr)
|
38
|
+
Packr.pack(javascript, options)
|
39
|
+
else
|
40
|
+
javascript
|
41
|
+
end
|
41
42
|
end
|
42
|
-
end
|
43
43
|
end
|
44
44
|
end
|
data/lib/massimo/page.rb
CHANGED
@@ -43,54 +43,54 @@ module Massimo
|
|
43
43
|
def output_path
|
44
44
|
@output_path ||= begin
|
45
45
|
output_path = super.to_s
|
46
|
-
output_path <<
|
46
|
+
output_path << 'index.html' if output_path.ends_with? '/'
|
47
47
|
Pathname.new output_path
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
protected
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
53
|
+
def read_source
|
54
|
+
case source_path.extname
|
55
|
+
when '.yml', '.yaml'
|
56
|
+
@meta_data = (YAML.load(source_path.read) || {}).symbolize_keys
|
57
|
+
@content = @meta_data[:content] || ''
|
58
|
+
else
|
59
|
+
@line = nil
|
60
|
+
@content = ''
|
61
|
+
front_matter = false
|
62
|
+
meta_data = ''
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
else
|
69
|
-
if front_matter
|
70
|
-
meta_data << line
|
64
|
+
source_path.open do |file|
|
65
|
+
file.each do |line|
|
66
|
+
if line =~ /\A---\s*\Z/
|
67
|
+
front_matter = !front_matter
|
71
68
|
else
|
72
|
-
|
73
|
-
|
69
|
+
if front_matter
|
70
|
+
meta_data << line
|
71
|
+
else
|
72
|
+
@line ||= file.lineno
|
73
|
+
@content << line
|
74
|
+
end
|
74
75
|
end
|
75
76
|
end
|
76
77
|
end
|
77
|
-
end
|
78
78
|
|
79
|
-
|
79
|
+
@meta_data = (YAML.load(meta_data) || {}).symbolize_keys
|
80
|
+
end
|
80
81
|
end
|
81
|
-
end
|
82
82
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
83
|
+
def method_missing(method, *args, &block)
|
84
|
+
if args.length == 0
|
85
|
+
method_name = method.to_s
|
86
|
+
if method_name.chomp! '?'
|
87
|
+
!!@meta_data[method_name.to_sym]
|
88
|
+
else
|
89
|
+
@meta_data[method_name.to_sym]
|
90
|
+
end
|
88
91
|
else
|
89
|
-
|
92
|
+
super
|
90
93
|
end
|
91
|
-
else
|
92
|
-
super
|
93
94
|
end
|
94
|
-
end
|
95
95
|
end
|
96
96
|
end
|
data/lib/massimo/resource.rb
CHANGED
data/lib/massimo/site.rb
CHANGED
@@ -39,12 +39,10 @@ module Massimo
|
|
39
39
|
# The scope used for templating. It includes helpers from Massimo::Helpers along
|
40
40
|
# with any custom helpers.
|
41
41
|
def template_scope
|
42
|
-
|
43
|
-
scope = Object.new.extend(Massimo::Helpers, Tilt::CompileSite)
|
42
|
+
Object.new.extend(Massimo::Helpers, Tilt::CompileSite).tap do |scope|
|
44
43
|
add_template_scope_blocks(scope)
|
45
44
|
add_template_scope_extensions(scope)
|
46
45
|
add_template_scope_helpers(scope)
|
47
|
-
scope
|
48
46
|
end
|
49
47
|
end
|
50
48
|
|
@@ -67,43 +65,43 @@ module Massimo
|
|
67
65
|
|
68
66
|
protected
|
69
67
|
|
70
|
-
|
71
|
-
|
72
|
-
|
68
|
+
def add_template_scope_blocks(scope)
|
69
|
+
@template_scope_blocks.each do |block|
|
70
|
+
scope.instance_eval(&block)
|
71
|
+
end
|
73
72
|
end
|
74
|
-
end
|
75
73
|
|
76
|
-
|
77
|
-
|
78
|
-
|
74
|
+
def add_template_scope_extensions(scope)
|
75
|
+
@template_scope_extensions.each do |extension|
|
76
|
+
scope.extend(extension)
|
77
|
+
end
|
79
78
|
end
|
80
|
-
end
|
81
79
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
80
|
+
def add_template_scope_helpers(scope)
|
81
|
+
config.files_in(:helpers, :rb).each do |file|
|
82
|
+
load(file)
|
83
|
+
if helper = (class_name_of_file(file).constantize rescue nil)
|
84
|
+
scope.extend(helper)
|
85
|
+
end
|
87
86
|
end
|
88
87
|
end
|
89
|
-
end
|
90
88
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
89
|
+
def reload_libs
|
90
|
+
if defined? @previous_libs
|
91
|
+
@previous_libs.each do |lib|
|
92
|
+
class_name = class_name_of_file(lib)
|
93
|
+
Object.class_eval do
|
94
|
+
remove_const(class_name) if const_defined?(class_name)
|
95
|
+
end
|
97
96
|
end
|
98
97
|
end
|
98
|
+
@previous_libs = config.files_in(:lib, :rb).each do |file|
|
99
|
+
load(file)
|
100
|
+
end
|
99
101
|
end
|
100
|
-
@previous_libs = config.files_in(:lib, :rb).each do |file|
|
101
|
-
load(file)
|
102
|
-
end
|
103
|
-
end
|
104
102
|
|
105
|
-
|
106
|
-
|
107
|
-
|
103
|
+
def class_name_of_file(file)
|
104
|
+
File.basename(file).sub(/\.[^\.]+$/, '').classify
|
105
|
+
end
|
108
106
|
end
|
109
107
|
end
|
data/lib/massimo/ui.rb
CHANGED
@@ -54,16 +54,16 @@ module Massimo
|
|
54
54
|
|
55
55
|
protected
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
def growl(message, title = 'massimo')
|
58
|
+
Growl.notify(message, :title => title) if defined?(Growl)
|
59
|
+
end
|
60
60
|
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
def padding
|
62
|
+
@padding ||= 0
|
63
|
+
end
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
65
|
+
def padding=(value)
|
66
|
+
@padding = [ 0, value.to_i ].max
|
67
|
+
end
|
68
68
|
end
|
69
69
|
end
|
data/lib/massimo/version.rb
CHANGED
data/lib/massimo/watcher.rb
CHANGED
@@ -42,16 +42,16 @@ module Massimo
|
|
42
42
|
|
43
43
|
protected
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
def files
|
46
|
+
@files = Dir[*glob].map { |file| File.mtime(file) }
|
47
|
+
end
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
49
|
+
def glob
|
50
|
+
glob = @site.resources.map(&:path)
|
51
|
+
glob << @site.config.path_for(:lib)
|
52
|
+
glob << @site.config.path_for(:helpers)
|
53
|
+
glob.map! { |path| File.join(path, '**/*.*') }
|
54
|
+
glob
|
55
|
+
end
|
56
56
|
end
|
57
57
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 7
|
8
|
-
-
|
9
|
-
version: 0.7.
|
8
|
+
- 4
|
9
|
+
version: 0.7.4
|
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-11-
|
17
|
+
date: 2010-11-27 00:00:00 -06:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|