vanilla 1.17 → 1.17.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/Rakefile +21 -7
  2. data/bin/vanilla +2 -2
  3. data/lib/vanilla.rb +10 -7
  4. data/lib/vanilla/app.rb +57 -97
  5. data/lib/vanilla/config.rb +46 -0
  6. data/lib/vanilla/console.rb +1 -1
  7. data/lib/vanilla/renderers/base.rb +12 -2
  8. data/lib/vanilla/request.rb +9 -34
  9. data/lib/vanilla/routing.rb +34 -0
  10. data/lib/vanilla/test_helper.rb +10 -7
  11. data/pristine_app/Gemfile.lock +35 -0
  12. data/pristine_app/application.rb +2 -4
  13. data/pristine_app/public/vanilla.css +299 -9
  14. data/pristine_app/soups/base/layout.snip +11 -7
  15. data/pristine_app/soups/base/start.snip +15 -14
  16. data/pristine_app/soups/system/current_snip.rb +2 -2
  17. data/pristine_app/soups/system/feed.rb +30 -0
  18. data/pristine_app/soups/system/index.rb +3 -3
  19. data/pristine_app/soups/system/link_to.rb +5 -1
  20. data/pristine_app/soups/system/link_to_current_snip.rb +2 -3
  21. data/pristine_app/soups/tutorial/tutorial-layout.snip +9 -2
  22. data/pristine_app/soups/tutorial/tutorial-links.snip +2 -1
  23. data/pristine_app/soups/tutorial/tutorial-removing.snip.markdown +8 -0
  24. data/pristine_app/soups/tutorial/tutorial-renderers.snip.markdown +10 -4
  25. data/pristine_app/soups/tutorial/tutorial.snip.markdown +0 -1
  26. data/pristine_app/soups/tutorial/vanilla-rb.snip +4 -6
  27. data/pristine_app/tmp/restart.txt +0 -0
  28. data/test/core/configuration_test.rb +89 -0
  29. data/test/{dynasnip_test.rb → core/dynasnip_test.rb} +0 -0
  30. data/test/{renderers → core/renderers}/base_renderer_test.rb +37 -0
  31. data/test/{renderers → core/renderers}/erb_renderer_test.rb +0 -0
  32. data/test/{renderers → core/renderers}/haml_renderer_test.rb +0 -0
  33. data/test/{renderers → core/renderers}/markdown_renderer_test.rb +0 -0
  34. data/test/{renderers → core/renderers}/raw_renderer_test.rb +0 -0
  35. data/test/{renderers → core/renderers}/ruby_renderer_test.rb +0 -0
  36. data/test/core/routing_test.rb +30 -0
  37. data/test/{snip_inclusion_test.rb → core/snip_inclusion_test.rb} +0 -0
  38. data/test/{snip_reference_parser_test.rb → core/snip_reference_parser_test.rb} +0 -0
  39. data/test/{test_helper.rb → core/test_helper.rb} +5 -4
  40. data/test/core/vanilla_app_test.rb +51 -0
  41. data/test/{vanilla_presenting_test.rb → core/vanilla_presenting_test.rb} +15 -1
  42. data/test/{vanilla_request_test.rb → core/vanilla_request_test.rb} +0 -0
  43. data/test/pristine_app/current_snip_test.rb +46 -0
  44. data/test/pristine_app/feed_test.rb +47 -0
  45. data/test/pristine_app/index_test.rb +34 -0
  46. data/test/pristine_app/link_to_current_snip_test.rb +11 -0
  47. data/test/pristine_app/link_to_test.rb +27 -0
  48. data/test/pristine_app/page_title_test.rb +15 -0
  49. data/test/pristine_app/raw_test.rb +24 -0
  50. data/test/pristine_app/test_helper.rb +25 -0
  51. metadata +83 -42
  52. data/lib/vanilla/routes.rb +0 -18
  53. data/test/dynasnips/link_to_current_snip_test.rb +0 -19
  54. data/test/dynasnips/link_to_test.rb +0 -27
  55. data/test/dynasnips/page_title_test.rb +0 -19
  56. data/test/vanilla_app_test.rb +0 -111
@@ -1,18 +0,0 @@
1
- module Vanilla
2
- # Expects to be able to call 'soup' on whatever it is included into
3
- module Routes
4
- def link_to(link_text, snip_name=link_text, part=nil)
5
- if soup[snip_name]
6
- %{<a href="#{url_to(snip_name, part)}">#{link_text}</a>}
7
- else
8
- %{<a class="missing" href="#{url_to(snip_name, part)}">#{link_text}</a>}
9
- end
10
- end
11
-
12
- def url_to(snip_name, part=nil)
13
- url = "/#{snip_name.gsub(" ", "+")}"
14
- url += "/#{part}" if part
15
- url
16
- end
17
- end
18
- end
@@ -1,19 +0,0 @@
1
- require "test_helper"
2
- $LOAD_PATH.unshift File.expand_path("../../../pristine_app/soups/system", __FILE__)
3
- require "link_to_current_snip"
4
-
5
- context "The link_to_current_snip dynasnip" do
6
- setup do
7
- app.soup << LinkToCurrentSnip.snip_attributes
8
- create_snip :name => "test", :content => "test {link_to_current_snip}"
9
- end
10
-
11
- should "render a link to the snip that was requested" do
12
- assert_response_body %{test <a href="/test">test</a>}, "/test"
13
- end
14
-
15
- should "render a link to the snip that was requested even if it isn't the snip that included the dyna" do
16
- create_snip :name => "othertest", :content => "othertest {test}"
17
- assert_response_body %{othertest test <a href="/othertest">othertest</a>}, "/othertest"
18
- end
19
- end
@@ -1,27 +0,0 @@
1
- require "test_helper"
2
- $LOAD_PATH.unshift File.expand_path("../../../pristine_app/soups/system", __FILE__)
3
- require "link_to"
4
-
5
- context "The link_to dynasnip" do
6
- setup do
7
- create_snip :name => "start", :content => "hello"
8
- end
9
-
10
- should "render a link to a snip that exists" do
11
- assert_equal %{<a href="/start">start</a>}, render_dynasnip(LinkTo, "start")
12
- end
13
-
14
- should "allow specification of the link text" do
15
- assert_equal %{<a href="/start">the start snip</a>}, render_dynasnip(LinkTo, "start", "the start snip")
16
- end
17
-
18
- should "mark snips that are missing with a class" do
19
- assert_equal %{<a class="missing" href="/missing">missing</a>}, render_dynasnip(LinkTo, "missing")
20
- end
21
-
22
- private
23
-
24
- def render_dynasnip(klass, *args)
25
- klass.new(app).handle(*args)
26
- end
27
- end
@@ -1,19 +0,0 @@
1
- require "test_helper"
2
- $LOAD_PATH.unshift File.expand_path("../../../pristine_app/soups/system", __FILE__)
3
- require "page_title"
4
-
5
- context "The page_title dynasnip" do
6
- setup do
7
- app.soup << PageTitle.snip_attributes
8
- end
9
-
10
- should "render as the requested snip name if that snip has no title" do
11
- create_snip :name => "test", :content => "{page_title}"
12
- assert_response_body %{test}, "/test"
13
- end
14
-
15
- should "render as the requested snip's page_title when that attribute is present" do
16
- create_snip :name => "test", :content => "{page_title}", :page_title => "This is a test"
17
- assert_response_body %{This is a test}, "/test"
18
- end
19
- end
@@ -1,111 +0,0 @@
1
- require "test_helper"
2
- require "tmpdir"
3
-
4
- describe Vanilla::App do
5
- context "when behaving as a Rack application" do
6
- should "return a valid rack response" do
7
- create_snip(:name => "test", :content => "content")
8
- get "/test.text"
9
- assert_equal 200, last_response.status
10
- assert_kind_of Hash, last_response.headers
11
- assert_equal "content", last_response.body
12
- end
13
- end
14
-
15
- context "when being configured" do
16
- should "default the root snip to 'start'" do
17
- create_snip :name => "start", :content => "default"
18
- assert_response_body "default", "/"
19
- end
20
-
21
- should "allow a customised root snip" do
22
- create_snip :name => "start", :content => "default"
23
- create_snip :name => "custom", :content => "custom"
24
- app.config[:root_snip] = "custom"
25
- assert_response_body "custom", "/"
26
- end
27
-
28
- should "allow specification of the root directory to aide loading external soups" do
29
- soup_dir = File.join(Dir.tmpdir, "my_soup")
30
- FileUtils.mkdir_p(soup_dir)
31
- File.open(File.join(soup_dir, "blah.snip"), "w") { |f| f.write "Hello superfriends" }
32
-
33
- class TestApp < Vanilla::App
34
- configure do |c|
35
- c.root = Dir.tmpdir
36
- c.soups = ["my_soup"]
37
- end
38
- end
39
-
40
- app =
41
- assert_equal "Hello superfriends", TestApp.new.soup['blah'].content
42
- end
43
-
44
- should "allow configuration against the class" do
45
- class TestApp < Vanilla::App
46
- end
47
-
48
- TestApp.configure do |config|
49
- config.soups = ["blah", "monkey"]
50
- config.root = Dir.tmpdir
51
- end
52
-
53
- assert_equal ["blah", "monkey"], TestApp.new.config[:soups]
54
- end
55
- end
56
-
57
- context "when detecting the snip renderer" do
58
- should "return the constant refered to in the render_as property of the snip" do
59
- snip = create_snip(:name => "blah", :render_as => "Raw")
60
- assert_equal Vanilla::Renderers::Raw, app.renderer_for(snip)
61
- end
62
-
63
- context "using the snip extension" do
64
- {
65
- "markdown" => Vanilla::Renderers::Markdown,
66
- "textile" => Vanilla::Renderers::Textile,
67
- "erb" => Vanilla::Renderers::Erb,
68
- "rb" => Vanilla::Renderers::Ruby,
69
- "haml" => Vanilla::Renderers::Haml
70
- }.each do |extension, renderer|
71
- should "return the renderer #{renderer} when the snip has extension #{extension}" do
72
- snip = create_snip(:name => "blah", :extension => extension)
73
- assert_equal renderer, app.renderer_for(snip)
74
- end
75
- end
76
- end
77
-
78
- should "respect snip renderers passed in the config" do
79
- TestApp.configure do |c|
80
- c.renderers = {"markdown" => "Vanilla::Renderers::Bold"}
81
- end
82
- snip = create_snip(:name => "blah", :extension => "markdown")
83
- assert_equal Vanilla::Renderers::Bold, TestApp.new.renderer_for(snip)
84
- end
85
-
86
- should "return Vanilla::Renderers::Base if no render_as property exists" do
87
- snip = create_snip(:name => "blah")
88
- assert_equal Vanilla::Renderers::Base, app.renderer_for(snip)
89
- end
90
-
91
- should "return Vanilla::Renderers::Base if the render_as property is blank" do
92
- snip = create_snip(:name => "blah", :render_as => '')
93
- assert_equal Vanilla::Renderers::Base, app.renderer_for(snip)
94
- end
95
-
96
- should "raise an error if the specified renderer doesn't exist" do
97
- snip = create_snip(:name => "blah", :render_as => "NonExistentClass")
98
- assert_raises(NameError) { @app.renderer_for(snip) }
99
- end
100
-
101
- should "load constants presented as a string" do
102
- class ::MyRenderer
103
- end
104
- TestApp.configure do |c|
105
- c.renderers = {"my_renderer" => "MyRenderer"}
106
- end
107
- snip = create_snip(:name => "blah", :render_as => "my_renderer")
108
- assert_equal MyRenderer, TestApp.new.renderer_for(snip)
109
- end
110
- end
111
- end