Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding some footer magic in

  • Loading branch information...
commit 359b52a3bc80e1e33e3b0b23e1fce2f7fe19014c 1 parent 535f57e
@qrush qrush authored
View
9 lib/report_card/index.rb
@@ -1,16 +1,19 @@
module ReportCard
class Index
+ attr_reader :projects, :footer
+
TEMPLATE_PATH = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "template", "index.html.erb"))
def self.create(projects, site)
- new(projects.select { |p| p.public }, site)
- new(projects.select { |p| ! p.public }, File.join(site, 'private'))
+ new(projects.select { |p| p.public }, site, "<a href='/private'>TOP SECRET PROJECTS</a>")
+ new(projects.select { |p| ! p.public }, File.join(site, 'private'), "<a href='/'>NORMAL BORING PROJECTS</a>")
end
- def initialize(projects, path)
+ def initialize(projects, path, footer)
return if projects.empty?
@projects = projects
+ @footer = footer
erb = File.read(TEMPLATE_PATH)
html = ERB.new(erb).result(binding)
View
2  template/index.html.erb
@@ -27,7 +27,7 @@
</ul>
</div>
<div id="footer">
- <a href="/private">TOP SECRET PROJECTS</a>
+ <%= @footer %>
</div>
</body>
</html>
View
10 test/index_test.rb
@@ -12,8 +12,8 @@ class IndexTest < Test::Unit::TestCase
end
should "split up public and private projects" do
- mock(ReportCard::Index).new([@public_project1, @public_project2], @site)
- mock(ReportCard::Index).new([@private_project], File.join(@site, "private"))
+ mock(ReportCard::Index).new([@public_project1, @public_project2], @site, anything)
+ mock(ReportCard::Index).new([@private_project], File.join(@site, "private"), anything)
ReportCard::Index.create(@projects, @site)
end
@@ -28,14 +28,16 @@ class IndexTest < Test::Unit::TestCase
mock(ERB).new(erb).mock!.result(anything) { html }
mock(File).open(File.join(@site, "index.html"), "w").yields(io)
- ReportCard::Index.new([@private_project], @site)
+ index = ReportCard::Index.new([@private_project], @site, "footer")
+ assert_equal [@private_project], index.projects
+ assert_equal "footer", index.footer
end
should "not write out anything if there's no projects" do
mock(File).read(anything).never
mock(ERB).new(anything).never
mock(File).open(anything, "w").never
- ReportCard::Index.new([], @site)
+ ReportCard::Index.new([], @site, "footer")
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.