massimo 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+
data/Gemfile CHANGED
File without changes
data/README.md CHANGED
@@ -1,30 +1,42 @@
1
- # Massimo
1
+ Massimo
2
+ =======
2
3
 
3
4
  Massimo is a static website builder that allows you to use dynamic technologies such as Haml & Sass for rapid development.
4
5
 
5
6
  *Massimo's code is inspired by other website generators like [Jekyll](http://github.com/mojombo/jekyll) and [Webby](http://webby.rubyforge.org/).*
6
7
 
7
- ## Features
8
+ Features
9
+ --------
8
10
 
9
11
  * Renders templates and views using [Tilt](http://github.com/rtomayko/tilt)
10
12
  * Uses familiar helper methods from [Padrino::Helpers](http://github.com/padrino/padrino-framework)
11
13
  * Supports custom helper methods like [Rails](http://rubyonrails.org/) and [Sinatra](http://www.sinatrarb.com/)
12
14
  * Concats javascripts using [Sprockets](http://getsprockets.org/)
13
- and then minifies them using [JSMin](http://github.com/rgrove/jsmin)
15
+ and then compresses them using whichever library you want.
14
16
  * Renders stylesheets using either [Sass](http://sass-lang.com/) or [Less](http://lesscss.org/)
15
17
  * Automatically creates pretty URLs
16
18
 
17
- ## Getting Started
19
+ Installation
20
+ -----------
21
+
22
+ ``` bash
23
+ $ gem install massimo
24
+ ```
25
+
26
+ Getting Started
27
+ ---------------
18
28
 
19
- gem install massimo
20
- massimo generate my-site
21
- cd my-site
22
- massimo build
29
+ ``` bash
30
+ $ massimo new my-site
31
+ $ cd my-site
32
+ $ massimo build
33
+ ```
23
34
 
24
35
  For more information, visit [http://massimo.petebrowne.com/](http://massimo.petebrowne.com/).
25
36
 
26
37
  For an example of a site built by massimo, visit [http://github.com/petebrowne/massimo-site](http://github.com/petebrowne/massimo-site).
27
38
 
28
- ## Copyright
39
+ Copyright
40
+ ---------
29
41
 
30
- Copyright (c) 2009 [Peter Browne](http://petebrowne.com). See LICENSE for details.
42
+ Copyright (c) 2011 [Peter Browne](http://petebrowne.com). See LICENSE for details.
data/Rakefile CHANGED
@@ -5,4 +5,4 @@ Bundler::GemHelper.install_tasks
5
5
 
6
6
  require 'rspec/core'
7
7
  require 'rspec/core/rake_task'
8
- RSpec::Core::RakeTask.new
8
+ RSpec::Core::RakeTask.new
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'bundler/setup' if File.exist?('./Gemfile')
3
4
  require 'massimo'
4
5
  Massimo::CLI.start
@@ -24,11 +24,11 @@ module Massimo
24
24
  end
25
25
  map 'b' => :build
26
26
 
27
- desc 'generate SITE_NAME', 'Generates a new site with the give name'
28
- def generate(site_name)
27
+ desc 'new SITE_NAME', 'Generates a new site with the give name'
28
+ def new(site_name)
29
29
  directory 'site', site_name
30
30
  end
31
- map 'g' => :generate
31
+ map %w(n generate g) => :new
32
32
 
33
33
  desc 'server [PORT]', 'Runs a local Rack based web server on the given port'
34
34
  def server(port = 3000)
@@ -1,6 +1,8 @@
1
1
  require 'active_support/core_ext/hash/keys'
2
2
  require 'active_support/string_inquirer'
3
+ require 'crush'
3
4
  require 'ostruct'
5
+ require 'tilt'
4
6
  require 'yaml'
5
7
 
6
8
  module Massimo
@@ -17,6 +19,20 @@ module Massimo
17
19
  :stylesheets_url => '/stylesheets'
18
20
  }.freeze
19
21
 
22
+ JS_COMPRESSORS = {
23
+ :jsmin => Crush::JSMin,
24
+ :packr => Crush::Packr,
25
+ :yui => Crush::YUI::JavaScriptCompressor,
26
+ :closure => Crush::Closure::Compiler,
27
+ :uglifier => Crush::Uglifier
28
+ }
29
+
30
+ CSS_COMPRESSORS = {
31
+ :cssmin => Crush::CSSMin,
32
+ :rainpress => Crush::Rainpress,
33
+ :yui => Crush::YUI::CssCompressor
34
+ }
35
+
20
36
  # Creates a new configuration. Takes either a hash of options
21
37
  # or a file path to a .yaml file.
22
38
  def initialize(options = nil)
@@ -46,6 +62,69 @@ module Massimo
46
62
  ActiveSupport::StringInquirer.new(super)
47
63
  end
48
64
 
65
+ # Sets up Massimo to compress both JavaScript and CSS files.
66
+ #
67
+ # @param [Boolean] compress Wether or not to compress.
68
+ def compress=(compress)
69
+ Crush.register if compress
70
+ end
71
+
72
+ # Sets up Massimo to compress JavaScript files. By default,
73
+ # whichever JavaScript compression library is available, is used.
74
+ # To set the one you want to use see #js_compressor=.
75
+ #
76
+ # @param [Boolean] compress Wether or not to compress.
77
+ def compress_js=(compress)
78
+ Crush.register_js if compress
79
+ end
80
+
81
+ # Sets the JavaScript compressor to use. The compressor can
82
+ # be either a symbol mapping to the recognized Crush::Engines
83
+ # (see JS_COMPRESSORS) or any Tilt::Template.
84
+ #
85
+ # @param [Tilt::Template, Symbol] compressor The compressor to use.
86
+ def js_compressor=(compressor)
87
+ if compressor.respond_to?(:to_sym)
88
+ compressor = JS_COMPRESSORS[compressor.to_sym]
89
+ end
90
+ Tilt.prefer compressor, 'js'
91
+ end
92
+
93
+ # Sets the options used by the JavaScript compressor.
94
+ #
95
+ # @param [Hash] options The hash of options to use.
96
+ def js_compressor_options=(options)
97
+ self.js = options
98
+ end
99
+
100
+ # Sets up Massimo to compress CSS files. By default,
101
+ # whichever CSS compression library is available, is used.
102
+ # To set the one you want to use see #css_compressor=.
103
+ #
104
+ # @param [Boolean] compress Wether or not to compress.
105
+ def compress_css=(compress)
106
+ Crush.register_css if compress
107
+ end
108
+
109
+ # Sets the CSS compressor to use. The compressor can
110
+ # be either a symbol mapping to the recognized Crush::Engines
111
+ # (see CSS_COMPRESSORS) or any Tilt::Template.
112
+ #
113
+ # @param [Tilt::Template, Symbol] compressor The compressor to use.
114
+ def css_compressor=(compressor)
115
+ if compressor.respond_to?(:to_sym)
116
+ compressor = CSS_COMPRESSORS[compressor.to_sym]
117
+ end
118
+ Tilt.prefer compressor, 'css'
119
+ end
120
+
121
+ # Sets the options used by the CSS compressor.
122
+ #
123
+ # @param [Hash] options The hash of options to use.
124
+ def css_compressor_options=(options)
125
+ self.css = options
126
+ end
127
+
49
128
  # Get a full, expanded path for the given resource name. This is either set
50
129
  # in the configuration or determined dynamically based on the name.
51
130
  def path_for(resource_name)
@@ -70,6 +149,7 @@ module Massimo
70
149
  # Convience method for getting options for a given library name. For instance,
71
150
  # this is how we get the options set for Haml or Sass during processing.
72
151
  def options_for(lib_name)
152
+ return options_for("sass") if lib_name == "scss"
73
153
  send(lib_name) || {}
74
154
  end
75
155
  end
@@ -1,4 +1,5 @@
1
1
  require 'sprockets'
2
+ require 'tilt'
2
3
 
3
4
  module Massimo
4
5
  class Javascript < Massimo::Resource
@@ -11,42 +12,16 @@ module Massimo
11
12
  end
12
13
 
13
14
  def render
14
- output = if source_path.extname == '.js'
15
- options = Massimo.config.options_for(:sprockets).merge(
16
- :assert_root => Massimo.config.output_path,
17
- :source_files => [ source_path.to_s ]
18
- )
19
- secretary = Sprockets::Secretary.new(options)
20
- secretary.install_assets
21
- secretary.concatenation.to_s
22
- else
23
- super
24
- end
25
- compress(output)
26
- end
27
-
28
- protected
29
-
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)
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
- when 'yui', 'yui-compressor', 'yui/compressor'
40
- require 'yui/compressor' unless defined?(YUI)
41
- options = { :munge => true }.merge Massimo.config.options_for(:yui)
42
- YUI::JavaScriptCompressor.new(options).compress(javascript)
43
- when 'closure', 'closure-compiler', 'closure/compiler'
44
- require 'closure-compiler' unless defined?(Closure)
45
- options = Massimo.config.options_for(:closure)
46
- Closure::Compiler.new(options).compile(javascript)
47
- else
48
- javascript
49
- end.strip
15
+ if source_path.extname == '.js'
16
+ options = Massimo.config.options_for(:sprockets).merge(
17
+ :assert_root => Massimo.config.output_path,
18
+ :source_files => [ source_path.to_s ]
19
+ )
20
+ secretary = Sprockets::Secretary.new(options)
21
+ secretary.install_assets
22
+ @content = secretary.concatenation.to_s
50
23
  end
24
+ super
25
+ end
51
26
  end
52
27
  end
@@ -17,7 +17,7 @@ module Massimo
17
17
  end
18
18
 
19
19
  def title
20
- @meta_data[:title] ||= filename.chomp(source_path.extname).titleize
20
+ @meta_data[:title] ||= filename.gsub(/\.[^.]+/, '').titleize
21
21
  end
22
22
 
23
23
  def extension
@@ -17,6 +17,8 @@ module Massimo
17
17
  @template_scope_extensions = []
18
18
  Massimo.site = self
19
19
 
20
+ setup_bundle unless bundled?
21
+
20
22
  Massimo::Reloader.reload(:config) do
21
23
  instance_eval File.read(config.config_path) if File.exist?(config.config_path)
22
24
  instance_eval(&block) if block_given?
@@ -45,7 +47,7 @@ module Massimo
45
47
  # The scope used for templating. It includes helpers from Massimo::Helpers along
46
48
  # with any custom helpers.
47
49
  def template_scope
48
- Object.new.extend(Massimo::Helpers, Tilt::CompileSite).tap do |scope|
50
+ Object.new.extend(Massimo::Helpers).tap do |scope|
49
51
  add_template_scope_blocks(scope)
50
52
  add_template_scope_extensions(scope)
51
53
  add_template_scope_helpers(scope)
@@ -71,6 +73,15 @@ module Massimo
71
73
 
72
74
  protected
73
75
 
76
+ def bundled?
77
+ !!@bundled
78
+ end
79
+
80
+ def setup_bundle
81
+ Bundler.require(:default, config.environment.to_sym) if defined?(Bundler)
82
+ @bundled = true
83
+ end
84
+
74
85
  def add_template_scope_blocks(scope)
75
86
  @template_scope_blocks.each do |block|
76
87
  scope.instance_eval(&block)
@@ -1,3 +1,5 @@
1
+ require 'tilt'
2
+
1
3
  module Massimo
2
4
  class Stylesheet < Massimo::Resource
3
5
  def extension
@@ -8,4 +10,4 @@ module Massimo
8
10
  end
9
11
  end
10
12
  end
11
- end
13
+ end
@@ -0,0 +1,8 @@
1
+ source :rubygems
2
+
3
+ gem "massimo", "<%= Massimo::VERSION %>"
4
+ gem "sass", "~> 3.1"
5
+
6
+ group :production do
7
+ gem "uglifier", "~> 1.0"
8
+ end
@@ -1,16 +1,10 @@
1
- require 'sass'
2
- require 'sprockets'
3
-
4
1
  # This is an example configuration File
5
2
  # Look here for all the available options:
6
3
  # http://massimo.petebrowne.com/configuration/
7
4
 
8
5
  if config.environment.production?
9
- # Use JSMin for javascript compression
10
- # config.javascripts_compressor = :min
11
-
12
- # Compress the output of Sass stylesheets
13
- # config.sass = { :style => :compressed }
6
+ # Compress javascripts and stylesheets
7
+ config.compress = true
14
8
  end
15
9
 
16
10
  helpers do
@@ -1,2 +1,2 @@
1
- require 'massimo'
1
+ require "massimo"
2
2
  run Massimo::Server.new
@@ -3,8 +3,8 @@
3
3
  <head lang="en">
4
4
  <meta charset="utf-8">
5
5
  <title><%= page.title %></title>
6
- <%= stylesheet_link_tag 'main' %>
7
- <%= javascript_include_tag 'main' %>
6
+ <%= stylesheet_link_tag "main" %>
7
+ <%= javascript_include_tag "main" %>
8
8
  </head>
9
9
  <body>
10
10
  <%= yield %>
@@ -1,3 +1,3 @@
1
1
  module Massimo
2
- VERSION = '0.9.0'
2
+ VERSION = '0.10.0'
3
3
  end
@@ -7,33 +7,29 @@ Gem::Specification.new do |s|
7
7
  s.summary = 'Massimo is a static website builder.'
8
8
  s.description = 'Massimo builds HTML, Javascript, and CSS Files from your source.'
9
9
 
10
- s.authors = 'Pete Browne'
11
- s.email = 'me@petebrowne.com'
10
+ s.authors = ['Pete Browne']
11
+ s.email = ['me@petebrowne.com']
12
12
  s.homepage = 'http://massimo.petebrowne.com/'
13
13
  s.rubyforge_project = 'massimo'
14
14
 
15
- s.add_dependency 'activesupport', '~> 3.0.0'
16
- s.add_dependency 'i18n', '~> 0.4.0'
17
- s.add_dependency 'rack', '~> 1.2.0'
18
- s.add_dependency 'padrino-helpers', '~> 0.9.0'
19
- s.add_dependency 'thor', '~> 0.14.0'
20
- s.add_dependency 'tilt', '~> 1.3.1'
21
- s.add_dependency 'tzinfo', '~> 0.3.0'
22
- s.add_dependency 'sprockets', '~> 1.0.0'
23
- s.add_development_dependency 'rspec', '~> 2.5.0'
24
- s.add_development_dependency 'rr', '~> 1.0.0'
25
- s.add_development_dependency 'test-construct', '~> 1.2.0'
26
- s.add_development_dependency 'rack-test', '~> 0.5.0'
27
- s.add_development_dependency 'unindent', '~> 0.9.0'
28
- s.add_development_dependency 'haml', '~> 3.1.0'
29
- s.add_development_dependency 'sass', '~> 3.1.0'
30
- s.add_development_dependency 'less', '~> 1.2.0'
31
- s.add_development_dependency 'coffee-script', '~> 2.2.0'
32
- s.add_development_dependency 'jsmin', '~> 1.0.0'
33
- s.add_development_dependency 'packr', '~> 3.1.0'
34
- s.add_development_dependency 'yui-compressor', '~> 0.9.0'
35
- s.add_development_dependency 'closure-compiler', '~> 0.3.0'
36
- s.add_development_dependency 'growl', '~> 1.0.0'
15
+ s.add_dependency 'activesupport', '~> 3.0'
16
+ s.add_dependency 'i18n', '~> 0.4'
17
+ s.add_dependency 'rack', '~> 1.1'
18
+ s.add_dependency 'padrino-helpers', '~> 0.9'
19
+ s.add_dependency 'thor', '~> 0.14'
20
+ s.add_dependency 'tilt', '~> 1.3'
21
+ s.add_dependency 'crush', '~> 0.3'
22
+ s.add_dependency 'tzinfo', '~> 0.3'
23
+ s.add_dependency 'sprockets', '~> 1.0'
24
+ s.add_development_dependency 'rake', '>= 0.8.7'
25
+ s.add_development_dependency 'rspec', '~> 2.6'
26
+ s.add_development_dependency 'rr', '~> 1.0'
27
+ s.add_development_dependency 'test-construct', '~> 1.2'
28
+ s.add_development_dependency 'rack-test', '~> 0.5'
29
+ s.add_development_dependency 'unindent', '~> 0.9'
30
+ s.add_development_dependency 'haml', '~> 3.1'
31
+ s.add_development_dependency 'sass', '~> 3.1'
32
+ s.add_development_dependency 'less', '~> 1.2'
37
33
 
38
34
  s.files = `git ls-files`.split("\n")
39
35
  s.executables = `git ls-files`.split("\n").map{ |f| f =~ /^bin\/(.*)/ ? $1 : nil }.compact
@@ -78,17 +78,17 @@ describe Massimo::CLI do
78
78
  end
79
79
  end
80
80
 
81
- describe '#generate' do
81
+ describe '#new' do
82
82
  it 'creates a massimo site directory' do
83
83
  within_construct do |c|
84
- massimo 'generate my_site'
84
+ massimo 'new my_site'
85
85
  'my_site'.should be_a_directory
86
86
  end
87
87
  end
88
88
 
89
89
  it 'creates resource directories' do
90
90
  within_construct do |c|
91
- massimo 'generate my_site'
91
+ massimo 'new my_site'
92
92
  'my_site/pages'.should be_a_directory
93
93
  'my_site/views'.should be_a_directory
94
94
  'my_site/javascripts'.should be_a_directory
@@ -98,14 +98,14 @@ describe Massimo::CLI do
98
98
 
99
99
  it 'creates an output path' do
100
100
  within_construct do |c|
101
- massimo 'generate my_site'
101
+ massimo 'new my_site'
102
102
  'my_site/public'.should be_a_directory
103
103
  end
104
104
  end
105
105
 
106
106
  it 'creates an default index page' do
107
107
  within_construct do |c|
108
- massimo 'generate my_site'
108
+ massimo 'new my_site'
109
109
  content = <<-EOS.unindent
110
110
  ---
111
111
  title: Home Page
@@ -113,64 +113,75 @@ describe Massimo::CLI do
113
113
  <h1><%= title %></h1>
114
114
  <p>Find me in pages/index.erb</p>
115
115
  EOS
116
- 'my_site/pages/index.erb'.should be_a_file.with_content(content)
116
+ 'my_site/pages/index.html.erb'.should be_a_file.with_content(content)
117
117
  end
118
118
  end
119
119
 
120
120
  it 'creates a default layout' do
121
121
  within_construct do |c|
122
- massimo 'generate my_site'
122
+ massimo 'new my_site'
123
123
  content = <<-EOS.unindent
124
124
  <!doctype html>
125
125
  <html>
126
126
  <head lang="en">
127
127
  <meta charset="utf-8">
128
128
  <title><%= page.title %></title>
129
- <%= stylesheet_link_tag 'main' %>
130
- <%= javascript_include_tag 'main' %>
129
+ <%= stylesheet_link_tag "main" %>
130
+ <%= javascript_include_tag "main" %>
131
131
  </head>
132
132
  <body>
133
133
  <%= yield %>
134
134
  </body>
135
135
  </html>
136
136
  EOS
137
- 'my_site/views/layouts/main.erb'.should be_a_file.with_content(content)
137
+ 'my_site/views/layouts/main.html.erb'.should be_a_file.with_content(content)
138
138
  end
139
139
  end
140
140
 
141
141
  it 'creates a default javascript file' do
142
142
  within_construct do |c|
143
- massimo 'generate my_site'
143
+ massimo 'new my_site'
144
144
  'my_site/javascripts/main.js'.should be_a_file
145
145
  end
146
146
  end
147
147
 
148
148
  it 'creates a default stylesheet file' do
149
149
  within_construct do |c|
150
- massimo 'generate my_site'
151
- 'my_site/stylesheets/main.scss'.should be_a_file
150
+ massimo 'new my_site'
151
+ 'my_site/stylesheets/main.css.scss'.should be_a_file
152
+ end
153
+ end
154
+
155
+ it 'creates a default Gemfile' do
156
+ within_construct do |c|
157
+ massimo 'new my_site'
158
+ content = <<-EOS.unindent
159
+ source :rubygems
160
+
161
+ gem "massimo", "#{Massimo::VERSION}"
162
+ gem "sass", "~> 3.1"
163
+
164
+ group :production do
165
+ gem "uglifier", "~> 1.0"
166
+ end
167
+ EOS
168
+ 'my_site/Gemfile'.should be_a_file.with_content(content)
152
169
  end
153
170
  end
154
171
 
155
172
  it 'creates a default config file' do
156
173
  within_construct do |c|
157
- massimo 'generate my_site'
174
+ massimo 'new my_site'
158
175
  content = <<-EOS.unindent
159
- require 'sass'
160
- require 'sprockets'
161
-
162
176
  # This is an example configuration File
163
177
  # Look here for all the available options:
164
178
  # http://massimo.petebrowne.com/configuration/
165
-
179
+
166
180
  if config.environment.production?
167
- # Use JSMin for javascript compression
168
- # config.javascripts_compressor = :min
169
-
170
- # Compress the output of Sass stylesheets
171
- # config.sass = { :style => :compressed }
181
+ # Compress javascripts and stylesheets
182
+ config.compress = true
172
183
  end
173
-
184
+
174
185
  helpers do
175
186
  # Define helper methods here
176
187
  end
@@ -181,9 +192,9 @@ describe Massimo::CLI do
181
192
 
182
193
  it 'creates a default rackup file' do
183
194
  within_construct do |c|
184
- massimo 'generate my_site'
195
+ massimo 'new my_site'
185
196
  content = <<-EOS.unindent
186
- require 'massimo'
197
+ require "massimo"
187
198
  run Massimo::Server.new
188
199
  EOS
189
200
  'my_site/config.ru'.should be_a_file.with_content(content)
@@ -194,7 +205,7 @@ describe Massimo::CLI do
194
205
  it 'creates a massimo site directory' do
195
206
  within_construct do |c|
196
207
  silence(:stdout) do
197
- massimo 'g my_site'
208
+ massimo 'n my_site'
198
209
  'my_site'.should be_a_directory
199
210
  end
200
211
  end