massimo 0.3.9 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/test/test_site.rb CHANGED
@@ -2,39 +2,33 @@ require File.join(File.dirname(__FILE__), "helper")
2
2
 
3
3
  class TestSite < Test::Unit::TestCase
4
4
 
5
- def source_page_paths
6
- @source_page_paths ||= Pathname.glob(source_dir("pages", "**", "*")).
7
- reject { |p| p.basename.to_s =~ /^_/ || File.directory?(p) }.
8
- collect { |p| p.basename }
9
- end
10
-
11
5
  should "store configuration options" do
12
6
  @site = Massimo::Site(
13
- :source => "./source",
14
- :output => "./output"
7
+ :source => source_dir,
8
+ :output => output_dir
15
9
  )
16
- assert_equal "./source", @site.options[:source]
17
- assert_equal "./output", @site.options[:output]
10
+ assert_equal source_dir, @site.options[:source]
11
+ assert_equal output_dir, @site.options[:output]
18
12
  end
19
13
 
20
14
  should "use default options unless specified" do
21
- @site = Massimo::Site(:output => "./output")
22
- assert_equal Massimo::Site::DEFAULT_OPTIONS[:source], @site.options[:source]
23
- assert_equal "./output", @site.options[:output]
15
+ @site = Massimo::Site(:source => source_dir)
16
+ assert_equal source_dir, @site.options[:source]
17
+ assert_equal Massimo::Site::DEFAULT_OPTIONS[:output], @site.options[:output]
24
18
  end
25
19
 
26
20
  should "have refresh the configuration if new options are set" do
27
- Massimo::Site(:souce => "/some/strange/dir", :output => "/the/wrong/dir")
28
- @site = Massimo::Site(:output => "/the/wrong/dir")
29
- assert_equal Massimo::Site::DEFAULT_OPTIONS[:source], @site.options[:source]
21
+ Massimo::Site(:source => source_dir, :output => "/the/wrong/dir")
22
+ @site = Massimo::Site(:source => source_dir)
23
+ assert_equal Massimo::Site::DEFAULT_OPTIONS[:output], @site.options[:output]
30
24
  end
31
25
 
32
26
  should "have methods for determining the environment" do
33
- @site = Massimo::Site()
27
+ @site = Massimo::Site(:source => source_dir)
34
28
  assert @site.development?
35
- @site = Massimo::Site(:environment => :development)
29
+ @site = Massimo::Site(:source => source_dir, :environment => :development)
36
30
  assert @site.development?
37
- @site = Massimo::Site(:environment => :production)
31
+ @site = Massimo::Site(:source => source_dir, :environment => :production)
38
32
  assert @site.production?
39
33
  end
40
34
 
@@ -45,12 +39,12 @@ class TestSite < Test::Unit::TestCase
45
39
  assert_equal source_dir("some", "path"), @site.source_dir("some", "path")
46
40
  end
47
41
 
48
- should "have a directory shortcut methods" do
49
- assert_equal source_dir("pages", "some", "file.txt"), @site.pages_dir("some", "file.txt")
50
- assert_equal source_dir("views", "some", "file.txt"), @site.views_dir("some", "file.txt")
51
- assert_equal source_dir("stylesheets", "some", "file.txt"), @site.stylesheets_dir("some", "file.txt")
52
- assert_equal source_dir("javascripts", "some", "file.txt"), @site.javascripts_dir("some", "file.txt")
53
- end
42
+ # should "have a directory shortcut methods" do
43
+ # assert_equal source_dir("pages", "some", "file.txt"), @site.pages_dir("some", "file.txt")
44
+ # assert_equal source_dir("views", "some", "file.txt"), @site.views_dir("some", "file.txt")
45
+ # assert_equal source_dir("stylesheets", "some", "file.txt"), @site.stylesheets_dir("some", "file.txt")
46
+ # assert_equal source_dir("javascripts", "some", "file.txt"), @site.javascripts_dir("some", "file.txt")
47
+ # end
54
48
 
55
49
  should "have a output_dir method" do
56
50
  assert_equal output_dir("some", "path"), @site.output_dir("some", "path")
@@ -95,32 +89,5 @@ class TestSite < Test::Unit::TestCase
95
89
  teardown { clear_output }
96
90
  end
97
91
  end
98
-
99
- should "find only the pages set in the :pages option" do
100
- only_pages = %w{about_us.erb feed.haml index.erb}
101
- page_paths = Massimo::Site(:source => source_dir, :pages => only_pages).pages(true).collect { |page| page.source_path.basename }
102
- assert_equal_arrays only_pages, page_paths
103
- end
104
-
105
- should "skip pages set in the :skip_pages option (as an Array)" do
106
- skip_pages = %w{about_us.erb erb.erb erb_with_layout.erb feed.haml posts/first-post.haml haml.haml html.html index.erb markdown.markdown}
107
- page_paths = Massimo::Site(:source => source_dir, :skip_pages => skip_pages).pages(true).collect { |page| page.source_path.basename }
108
- assert_equal_arrays [
109
- "with_extension.haml",
110
- "with_meta_data.haml",
111
- "with_title.haml",
112
- "with_url.haml",
113
- "without_extension.haml",
114
- "without_meta_data.haml",
115
- "without_title.haml",
116
- "without_url.haml"
117
- ], page_paths
118
- end
119
-
120
- should "skip pages set in the :skip_pages option (as a Proc)" do
121
- site_options = { :source => source_dir, :skip_pages => lambda { |file| file.include?("with") } }
122
- page_paths = Massimo::Site(site_options).pages(true).collect { |page| page.source_path.basename }
123
- assert_equal_arrays %w{about_us.erb erb.erb feed.haml first-post.haml haml.haml html.html index.erb markdown.markdown}, page_paths
124
- end
125
92
 
126
93
  end
data/test/test_view.rb CHANGED
@@ -42,5 +42,9 @@ class TestView < Test::Unit::TestCase
42
42
  @view.new_data = "test"
43
43
  assert_equal "test", @view.new_data
44
44
  end
45
+
46
+ should "still raise NoMethodError when accessing non-existent meta_data properties" do
47
+ assert_raise(::NoMethodError) { @view.non_existent_prop }
48
+ end
45
49
  end
46
50
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: massimo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.9
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Browne
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-24 00:00:00 -06:00
12
+ date: 2010-01-09 00:00:00 -06:00
13
13
  default_executable: massimo
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: 0.3.26
53
+ version: 0.3.29
54
54
  version:
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: directory_watcher
@@ -83,7 +83,7 @@ dependencies:
83
83
  version: 1.0.1
84
84
  version:
85
85
  description: Massimo builds HTML, Javascript, and CSS Files from your source.
86
- email: peter@peterbrowne.net
86
+ email: me@petebrowne.com
87
87
  executables:
88
88
  - massimo
89
89
  extensions: []
@@ -104,7 +104,9 @@ files:
104
104
  - lib/massimo/helpers.rb
105
105
  - lib/massimo/javascript.rb
106
106
  - lib/massimo/page.rb
107
- - lib/massimo/resource.rb
107
+ - lib/massimo/resource/base.rb
108
+ - lib/massimo/resource/collection.rb
109
+ - lib/massimo/resource/processing.rb
108
110
  - lib/massimo/site.rb
109
111
  - lib/massimo/stylesheet.rb
110
112
  - lib/massimo/templates.rb
@@ -144,6 +146,7 @@ files:
144
146
  - test/source/views/with_helper.haml
145
147
  - test/source/views/with_locals.haml
146
148
  - test/source/views/without_locals.haml
149
+ - test/test_helpers.rb
147
150
  - test/test_javascript.rb
148
151
  - test/test_page.rb
149
152
  - test/test_resource.rb
@@ -183,6 +186,7 @@ test_files:
183
186
  - test/helper.rb
184
187
  - test/source/helpers/test_helper.rb
185
188
  - test/source/lib/site.rb
189
+ - test/test_helpers.rb
186
190
  - test/test_javascript.rb
187
191
  - test/test_page.rb
188
192
  - test/test_resource.rb
@@ -1,52 +0,0 @@
1
- module Massimo
2
- class Resource
3
- attr_reader :source_path, :body
4
-
5
- # Creates a new page associated with the given file path.
6
- def initialize(source_path)
7
- @source_path = ::Pathname.new(source_path)
8
- # read and parse the source file
9
- self.read_source!
10
- end
11
-
12
- # Renders the page using the registered filters.
13
- def render(locals = {})
14
- @body
15
- end
16
-
17
- # Gets the resource's file name.
18
- def file_name
19
- @source_path.basename.to_s
20
- end
21
-
22
- # Gets the resource type, based on the file's extension
23
- def resource_type
24
- @source_path.extname.to_s[1..-1]
25
- end
26
-
27
- # Gets the site instance
28
- def site
29
- ::Massimo::Site()
30
- end
31
-
32
- protected
33
-
34
- # Reads the source page file, and populates the meta_data and
35
- # body attributes.
36
- def read_source!
37
- raise ::Massimo::MissingResource unless @source_path.exist?
38
- # try to read it now
39
- begin
40
- @line = 1
41
- @body = @source_path.read
42
- rescue
43
- raise ::Massimo::InvalidResource
44
- end
45
- end
46
-
47
- # Get the options from the Site's config for the current resource type.
48
- def options_for_resource_type
49
- self.site.options[self.resource_type.to_sym]
50
- end
51
- end
52
- end