massimo 0.7.5 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/.document +5 -0
  2. data/.gitignore +6 -0
  3. data/Gemfile +2 -0
  4. data/Gemfile.lock +88 -0
  5. data/README.md +3 -1
  6. data/Rakefile +8 -0
  7. data/bin/massimo +1 -17
  8. data/lib/massimo/cli.rb +63 -0
  9. data/lib/massimo/config.rb +8 -5
  10. data/lib/massimo/javascript.rb +10 -2
  11. data/lib/massimo/reloader.rb +37 -0
  12. data/lib/massimo/site.rb +24 -21
  13. data/lib/massimo/templates/site/config.rb +18 -0
  14. data/lib/massimo/templates/site/javascripts/main.js +0 -0
  15. data/lib/massimo/templates/site/pages/index.erb +5 -0
  16. data/lib/massimo/templates/site/public/.empty_directory +0 -0
  17. data/lib/massimo/templates/site/stylesheets/main.scss +0 -0
  18. data/lib/massimo/templates/site/views/layouts/main.erb +12 -0
  19. data/lib/massimo/ui.rb +2 -2
  20. data/lib/massimo/version.rb +1 -1
  21. data/lib/massimo/watcher.rb +22 -7
  22. data/lib/massimo.rb +3 -11
  23. data/massimo.gemspec +40 -0
  24. data/spec/massimo/cli_spec.rb +254 -0
  25. data/spec/massimo/config_spec.rb +97 -0
  26. data/spec/massimo/helpers_spec.rb +26 -0
  27. data/spec/massimo/javascript_spec.rb +120 -0
  28. data/spec/massimo/massimo_spec.rb +23 -0
  29. data/spec/massimo/page_spec.rb +224 -0
  30. data/spec/massimo/reloader_spec.rb +135 -0
  31. data/spec/massimo/resource_spec.rb +208 -0
  32. data/spec/massimo/server_spec.rb +35 -0
  33. data/spec/massimo/site_spec.rb +299 -0
  34. data/spec/massimo/stylesheet_spec.rb +77 -0
  35. data/spec/massimo/ui_spec.rb +109 -0
  36. data/spec/massimo/view_spec.rb +46 -0
  37. data/spec/massimo/watcher_spec.rb +122 -0
  38. data/spec/spec_helper.rb +65 -0
  39. data/spec/support/matchers/be_a_directory_matcher.rb +5 -0
  40. data/spec/support/matchers/be_a_file_matcher.rb +26 -0
  41. metadata +74 -20
  42. data/lib/massimo/commands/base.rb +0 -85
  43. data/lib/massimo/commands/build.rb +0 -19
  44. data/lib/massimo/commands/generate.rb +0 -62
  45. data/lib/massimo/commands/help.rb +0 -34
  46. data/lib/massimo/commands/server.rb +0 -24
  47. data/lib/massimo/commands/version.rb +0 -9
  48. data/lib/massimo/commands/watch.rb +0 -16
@@ -0,0 +1,65 @@
1
+ lib = File.expand_path('../../lib', __FILE__)
2
+ $:.unshift(lib) unless $:.include?(lib)
3
+
4
+ require 'rubygems'
5
+ require 'rspec'
6
+ require 'rr'
7
+ require 'construct'
8
+ require 'rack/test'
9
+ require 'unindent'
10
+ require 'sass'
11
+ require 'less'
12
+ require 'coffee-script'
13
+ require 'sprockets'
14
+ require 'jsmin'
15
+ require 'packr'
16
+ require 'yui/compressor'
17
+ require 'closure-compiler'
18
+ require 'growl'
19
+ require 'massimo'
20
+
21
+ # Requires supporting files with custom matchers and macros, etc,
22
+ # in ./support/ and its subdirectories.
23
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
24
+
25
+ RSpec.configure do |config|
26
+ config.include Construct::Helpers
27
+ config.include Rack::Test::Methods
28
+ config.mock_with :rr
29
+
30
+ config.before :each do
31
+ stub($stdout).puts
32
+ stub(Growl).notify
33
+ end
34
+
35
+ config.after :each do
36
+ Massimo.site = nil
37
+ end
38
+
39
+ # Builds a construct with a single file in it.
40
+ def with_file(filename, content = nil)
41
+ within_construct do |construct|
42
+ construct.file filename, content
43
+ yield
44
+ end
45
+ end
46
+
47
+ # Captures the given stream and returns it:
48
+ #
49
+ # stream = capture(:stdout) { puts "Cool" }
50
+ # stream # => "Cool\n"
51
+ #
52
+ def capture(stream)
53
+ begin
54
+ stream = stream.to_s
55
+ eval "$#{stream} = StringIO.new"
56
+ yield
57
+ result = eval("$#{stream}").string
58
+ ensure
59
+ eval("$#{stream} = #{stream.upcase}")
60
+ end
61
+
62
+ result
63
+ end
64
+ alias :silence :capture
65
+ end
@@ -0,0 +1,5 @@
1
+ RSpec::Matchers.define :be_a_directory do
2
+ match do |path|
3
+ File.directory?(path.to_s)
4
+ end
5
+ end
@@ -0,0 +1,26 @@
1
+ RSpec::Matchers.define :be_a_file do
2
+ match do |path|
3
+ @path = path.to_s
4
+ file? && content_matches?
5
+ end
6
+
7
+ def with_content(content)
8
+ @content = content
9
+ self
10
+ end
11
+
12
+ def file?
13
+ File.file?(@path)
14
+ end
15
+
16
+ def content_matches?
17
+ case @content
18
+ when String
19
+ File.read(@path).strip == @content.strip
20
+ when Regexp
21
+ File.read(@path) =~ @content
22
+ else
23
+ true
24
+ end
25
+ end
26
+ end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 7
8
- - 5
9
- version: 0.7.5
7
+ - 8
8
+ - 0
9
+ version: 0.8.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-12-01 00:00:00 -06:00
17
+ date: 2011-01-25 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -102,9 +102,9 @@ dependencies:
102
102
  - !ruby/object:Gem::Version
103
103
  segments:
104
104
  - 1
105
- - 1
105
+ - 2
106
106
  - 0
107
- version: 1.1.0
107
+ version: 1.2.0
108
108
  type: :runtime
109
109
  version_requirements: *id006
110
110
  - !ruby/object:Gem::Dependency
@@ -132,9 +132,9 @@ dependencies:
132
132
  - !ruby/object:Gem::Version
133
133
  segments:
134
134
  - 2
135
+ - 4
135
136
  - 0
136
- - 0
137
- version: 2.0.0
137
+ version: 2.4.0
138
138
  type: :development
139
139
  version_requirements: *id008
140
140
  - !ruby/object:Gem::Dependency
@@ -288,9 +288,39 @@ dependencies:
288
288
  type: :development
289
289
  version_requirements: *id018
290
290
  - !ruby/object:Gem::Dependency
291
- name: growl
291
+ name: yui-compressor
292
292
  prerelease: false
293
293
  requirement: &id019 !ruby/object:Gem::Requirement
294
+ none: false
295
+ requirements:
296
+ - - ~>
297
+ - !ruby/object:Gem::Version
298
+ segments:
299
+ - 0
300
+ - 9
301
+ - 0
302
+ version: 0.9.0
303
+ type: :development
304
+ version_requirements: *id019
305
+ - !ruby/object:Gem::Dependency
306
+ name: closure-compiler
307
+ prerelease: false
308
+ requirement: &id020 !ruby/object:Gem::Requirement
309
+ none: false
310
+ requirements:
311
+ - - ~>
312
+ - !ruby/object:Gem::Version
313
+ segments:
314
+ - 0
315
+ - 3
316
+ - 0
317
+ version: 0.3.0
318
+ type: :development
319
+ version_requirements: *id020
320
+ - !ruby/object:Gem::Dependency
321
+ name: growl
322
+ prerelease: false
323
+ requirement: &id021 !ruby/object:Gem::Requirement
294
324
  none: false
295
325
  requirements:
296
326
  - - ~>
@@ -301,7 +331,7 @@ dependencies:
301
331
  - 0
302
332
  version: 1.0.0
303
333
  type: :development
304
- version_requirements: *id019
334
+ version_requirements: *id021
305
335
  description: Massimo builds HTML, Javascript, and CSS Files from your source.
306
336
  email: me@petebrowne.com
307
337
  executables:
@@ -311,29 +341,53 @@ extensions: []
311
341
  extra_rdoc_files: []
312
342
 
313
343
  files:
344
+ - .document
345
+ - .gitignore
346
+ - Gemfile
347
+ - Gemfile.lock
348
+ - LICENSE
349
+ - README.md
350
+ - Rakefile
314
351
  - bin/massimo
315
- - lib/massimo/commands/base.rb
316
- - lib/massimo/commands/build.rb
317
- - lib/massimo/commands/generate.rb
318
- - lib/massimo/commands/help.rb
319
- - lib/massimo/commands/server.rb
320
- - lib/massimo/commands/version.rb
321
- - lib/massimo/commands/watch.rb
352
+ - lib/massimo.rb
353
+ - lib/massimo/cli.rb
322
354
  - lib/massimo/config.rb
323
355
  - lib/massimo/helpers.rb
324
356
  - lib/massimo/javascript.rb
325
357
  - lib/massimo/page.rb
358
+ - lib/massimo/reloader.rb
326
359
  - lib/massimo/resource.rb
327
360
  - lib/massimo/server.rb
328
361
  - lib/massimo/site.rb
329
362
  - lib/massimo/stylesheet.rb
363
+ - lib/massimo/templates/site/config.rb
364
+ - lib/massimo/templates/site/javascripts/main.js
365
+ - lib/massimo/templates/site/pages/index.erb
366
+ - lib/massimo/templates/site/public/.empty_directory
367
+ - lib/massimo/templates/site/stylesheets/main.scss
368
+ - lib/massimo/templates/site/views/layouts/main.erb
330
369
  - lib/massimo/ui.rb
331
370
  - lib/massimo/version.rb
332
371
  - lib/massimo/view.rb
333
372
  - lib/massimo/watcher.rb
334
- - lib/massimo.rb
335
- - LICENSE
336
- - README.md
373
+ - massimo.gemspec
374
+ - spec/massimo/cli_spec.rb
375
+ - spec/massimo/config_spec.rb
376
+ - spec/massimo/helpers_spec.rb
377
+ - spec/massimo/javascript_spec.rb
378
+ - spec/massimo/massimo_spec.rb
379
+ - spec/massimo/page_spec.rb
380
+ - spec/massimo/reloader_spec.rb
381
+ - spec/massimo/resource_spec.rb
382
+ - spec/massimo/server_spec.rb
383
+ - spec/massimo/site_spec.rb
384
+ - spec/massimo/stylesheet_spec.rb
385
+ - spec/massimo/ui_spec.rb
386
+ - spec/massimo/view_spec.rb
387
+ - spec/massimo/watcher_spec.rb
388
+ - spec/spec_helper.rb
389
+ - spec/support/matchers/be_a_directory_matcher.rb
390
+ - spec/support/matchers/be_a_file_matcher.rb
337
391
  has_rdoc: true
338
392
  homepage: http://petebrowne.github.com/massimo/
339
393
  licenses: []
@@ -1,85 +0,0 @@
1
- require 'optparse'
2
- require 'thor/actions'
3
- require 'thor/shell'
4
-
5
- module Massimo
6
- module Commands
7
- class Base
8
- include Thor::Actions
9
- include Thor::Shell
10
-
11
- attr_reader :options, :parser
12
-
13
- def self.run
14
- command = self.new
15
- command.parse
16
- command.run
17
- end
18
-
19
- def initialize
20
- @options = {}
21
- @parser = OptionParser.new
22
-
23
- parser.banner = "#{banner}\n" if respond_to?(:banner)
24
- common_options
25
- add_options if respond_to?(:add_options)
26
-
27
- # needed for Thor::Actions to work
28
- self.destination_root = nil
29
- end
30
-
31
- def common_options
32
- parser.on('-c', '--config FILE', 'Path to the config file') do |config|
33
- options[:config] = config
34
- end
35
-
36
- parser.on('-s', '--source-path PATH', 'Path to the source dir') do |path|
37
- options[:source_path] = path
38
- end
39
-
40
- parser.on('-o', '--output-path PATH', 'Path to the output dir') do |path|
41
- options[:output_path] = path
42
- end
43
-
44
- parser.on('-e', '--environment ENV', 'Sets the Site environment') do |env|
45
- options[:environment] = env
46
- end
47
-
48
- parser.on('-p', '--production', "Sets the Site environment to 'production'") do |production|
49
- options[:environment] = 'production'
50
- end
51
- end
52
-
53
- def parse
54
- begin
55
- parser.parse(ARGV)
56
- rescue
57
- say parser
58
- exit
59
- end
60
- end
61
-
62
- def run
63
- end
64
-
65
- def site
66
- @site ||= Massimo::Site.new(config_file(:yml)).tap do |site|
67
- site.config.environment = options[:environment] if options[:environment]
68
- site.config.source_path = options[:source_path] if options[:source_path]
69
- site.config.output_path = options[:output_path] if options[:output_path]
70
- if config_rb = config_file(:rb)
71
- site.instance_eval File.read(config_rb)
72
- end
73
- end
74
- end
75
-
76
- def config_file(ext)
77
- if options[:config] && File.extname(options[:config]) == ".#{ext}"
78
- options[:config]
79
- elsif File.exist?("config.#{ext}")
80
- "config.#{ext}"
81
- end
82
- end
83
- end
84
- end
85
- end
@@ -1,19 +0,0 @@
1
- module Massimo
2
- module Commands
3
- class Build < Base
4
- def banner
5
- %{
6
- #{Massimo::UI.color('massimo build', :cyan)}
7
- Builds the site from the source files.
8
- }
9
- end
10
-
11
- def run
12
- exit Massimo::UI.report_errors {
13
- site.process
14
- Massimo::UI.say 'massimo has built your site', :growl => true
15
- }
16
- end
17
- end
18
- end
19
- end
@@ -1,62 +0,0 @@
1
- require 'active_support/core_ext/string/starts_ends_with'
2
- require 'active_support/inflector'
3
-
4
- module Massimo
5
- module Commands
6
- class Generate < Base
7
- def banner
8
- %{
9
- #{Massimo::UI.color('massimo generate SITE_OR_RESOURCE [FILE]', :cyan)}
10
- Generates a new site:
11
- massimo generate myblog
12
- Within a massimo project, you can generate a new resource file:
13
- massimo generate page contact.haml
14
- }
15
- end
16
-
17
- def add_options
18
- @site_or_resource = ARGV.shift
19
-
20
- if ARGV.first && !ARGV.first.starts_with?('-')
21
- @file = ARGV.shift
22
- end
23
-
24
- options.merge!(
25
- :page_ext => 'haml',
26
- :javascript_ext => 'js',
27
- :stylesheet_ext => 'sass'
28
- )
29
-
30
- parser.on('--page', '--page-ext EXT', 'The extension used for generated Pages and Views') do |ext|
31
- options[:page_ext] = ext
32
- end
33
-
34
- parser.on('--js', '--javascript-ext EXT', 'The extension used for generated Javascripts') do |ext|
35
- options[:javascript_ext] = ext
36
- end
37
-
38
- parser.on('--css', '--stylesheet-ext EXT', 'The extension used for generated Stylesheets') do |ext|
39
- options[:stylesheet_ext] = ext
40
- end
41
- end
42
-
43
- def run
44
- if @file
45
- create_file File.join(site.config.path_for(@site_or_resource.pluralize), @file)
46
- else
47
- empty_directory @site_or_resource
48
- inside @site_or_resource do
49
- site.resources.each do |resource|
50
- empty_directory(resource.path)
51
- end
52
- create_file File.join(Massimo::Page.path, "index.#{options[:page_ext]}")
53
- create_file File.join(Massimo::Javascript.path, "main.#{options[:javascript_ext]}")
54
- create_file File.join(Massimo::Stylesheet.path, "main.#{options[:stylesheet_ext]}")
55
- create_file File.join(Massimo::View.path, "layouts/main.#{options[:page_ext]}")
56
- empty_directory site.config.output_path
57
- end
58
- end
59
- end
60
- end
61
- end
62
- end
@@ -1,34 +0,0 @@
1
- require 'active_support/core_ext/string/conversions'
2
-
3
- module Massimo
4
- module Commands
5
- class Help < Base
6
- def add_options
7
- command_name = ARGV.shift
8
- unless command_name.nil? or %w( help version ).include?(command_name)
9
- @command = "Massimo::Commands::#{command_name.camelize}".constantize rescue nil
10
- end
11
- end
12
-
13
- def run
14
- if @command
15
- puts @command.new.parser
16
- else
17
- puts %{
18
- #{Massimo::UI.color('massimo', :cyan)}
19
- a static website builder
20
-
21
- Commands:
22
- massimo build # Builds the site
23
- massimo generate SITE_OR_RESOURCE [FILE] # Generates a new site
24
- Optionally generates a resource file
25
- massimo help [COMMAND] # Shows info about a specific command
26
- massimo server [PORT] # Runs a local web server
27
- massimo version # Displays current version
28
- massimo watch # Watches your files for changes
29
- }
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,24 +0,0 @@
1
- require 'active_support/core_ext/string/starts_ends_with'
2
-
3
- module Massimo
4
- module Commands
5
- class Server < Base
6
- def banner
7
- %{
8
- #{Massimo::UI.color('massimo server [PORT]', :cyan)}
9
- Runs a local Rack based web server on the given port.
10
- }
11
- end
12
-
13
- def add_options
14
- if ARGV.first && !ARGV.first.starts_with?('-')
15
- @port = ARGV.shift
16
- end
17
- end
18
-
19
- def run
20
- Massimo::Server.start(site, (@port || 3000).to_i)
21
- end
22
- end
23
- end
24
- end
@@ -1,9 +0,0 @@
1
- module Massimo
2
- module Commands
3
- class Version < Base
4
- def run
5
- puts Massimo::VERSION
6
- end
7
- end
8
- end
9
- end
@@ -1,16 +0,0 @@
1
- module Massimo
2
- module Commands
3
- class Watch < Base
4
- def banner
5
- %{
6
- #{Massimo::UI.color('massimo watch', :cyan)}
7
- Watches your files for changes and automatically builds the site.
8
- }
9
- end
10
-
11
- def run
12
- Massimo::Watcher.start(site)
13
- end
14
- end
15
- end
16
- end