engine_of_war 0.0.1

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.
data/spec/page_spec.rb ADDED
@@ -0,0 +1,129 @@
1
+ #!/bin/env rspec
2
+
3
+ require "spec_helper"
4
+
5
+ describe "Given a haml file without frontmatter, Page" do
6
+ before do
7
+ @path = "/file"
8
+ create_template("#{@path}.html.haml", "%h1 This is a post.")
9
+ @page = EngineOfWar::Page.new(@path)
10
+ end
11
+ subject { @page }
12
+
13
+ its(:engine) { should == :haml }
14
+ its(:meta) { should be_a(HashWithIndifferentAccess) }
15
+ its(:meta) { should be_empty }
16
+ its(:url) { should == "/file" }
17
+ end
18
+
19
+ describe "Given a textile file without frontmatter, Page" do
20
+ before do
21
+ @path = "/file"
22
+ create_template("#{@path}.html.textile", "h1. This is a post.")
23
+ @page = EngineOfWar::Page.new(@path)
24
+ end
25
+ subject { @page }
26
+
27
+ its(:engine) { should == :textile }
28
+ its(:github_edit_url) { should == "https://github.com/thunderboltlabs/thunderboltlabs/edit/master/views/file.html.textile" }
29
+ end
30
+
31
+ describe "Given a file with front matter" do
32
+ before do
33
+ @path = "file"
34
+ create_template("#{@path}.html.haml",
35
+ <<-EOF)
36
+ ---
37
+ title: "Title for this post."
38
+ date: 2011-01-10
39
+ ---
40
+ %h1 This is a post.
41
+ EOF
42
+ end
43
+
44
+ describe "Page.new(filename)" do
45
+ before { @page = EngineOfWar::Page.new(@path) }
46
+ subject { @page }
47
+
48
+ its(:meta) { should be_a(HashWithIndifferentAccess) }
49
+ its(:url) { should == "/file" }
50
+ its(:source) { should match("%h1 This is a post.") }
51
+ its(:source) { should_not match("Title for this post") }
52
+ its(:github_edit_url) { should == "https://github.com/thunderboltlabs/thunderboltlabs/edit/master/views/file.html.haml" }
53
+
54
+ describe "#meta" do
55
+ before { @out = @page.meta }
56
+
57
+ it "returns the title in the hash" do
58
+ @out[:title].should == "Title for this post."
59
+ end
60
+
61
+ it "returns the date as a Date object" do
62
+ @out[:date].should be_a Date
63
+ end
64
+ end
65
+ end
66
+
67
+ describe "Page.new(filename/)" do
68
+ before { @page = EngineOfWar::Page.new("file/") }
69
+ subject { @page }
70
+
71
+ its(:url) { should == "/file" }
72
+ its(:source) { should match("%h1 This is a post.") }
73
+ its(:source) { should_not match("Title for this post") }
74
+ its(:github_edit_url) { should == "https://github.com/thunderboltlabs/thunderboltlabs/edit/master/views/file.html.haml" }
75
+ end
76
+ end
77
+
78
+ describe "Page.new(foo) with meta specifying layout" do
79
+ before do
80
+ create_template("layouts/application.html.haml", "%h1 Layout\n= yield")
81
+ create_template("layouts/bar.html.haml", "%h1 Bar\n= yield")
82
+ @path = "foo"
83
+ create_template("#{@path}.html.haml",
84
+ <<-EOF)
85
+ ---
86
+ layout: bar
87
+ ---
88
+ %h1 This is a post.
89
+ EOF
90
+ @page = EngineOfWar::Page.new(@path)
91
+ end
92
+ subject { @page }
93
+
94
+ its(:layout) { should == "bar.html" }
95
+ end
96
+
97
+ describe "Page.new(directory/file)" do
98
+ before do
99
+ @path = "directory/file"
100
+ create_template("#{@path}.html.haml", "This is a post.")
101
+ @page = EngineOfWar::Page.new(@path)
102
+ end
103
+ subject { @page }
104
+
105
+ context "with a layout named application.html.haml" do
106
+ before do
107
+ create_template("layouts/application.html.haml", "%h1 Layout\n= yield")
108
+ end
109
+
110
+ its(:layout) { should == "application.html" }
111
+
112
+ context "and a layout named directory.html.haml" do
113
+ before do
114
+ create_template("layouts/directory.html.haml", "%h1 Directory\n= yield")
115
+ end
116
+
117
+ its(:layout) { should == "directory.html" }
118
+ end
119
+ end
120
+
121
+ describe "#url" do
122
+ before { @out = @page.url }
123
+
124
+ it "returns the path of the page" do
125
+ @out.should == "/directory/file"
126
+ end
127
+ end
128
+ end
129
+
@@ -0,0 +1,44 @@
1
+ #!/bin/env rspec
2
+
3
+ require "spec_helper"
4
+
5
+ describe "Recommendation.new(hash)" do
6
+ raw = {
7
+ :quote => "Great to work with, intelligent feedback, exceptional quality.",
8
+ :who => "Matt Todd",
9
+ :who_url => "http://www.workingwithrails.com/person/7298-matt-todd",
10
+ :where => "Working with Rails",
11
+ :where_url => "http://example.com/foo",
12
+ :position => "Developer",
13
+ :company => "GitHub",
14
+ :company_url => "http://github.com/",
15
+ :short_quote => "Short"
16
+ }
17
+
18
+ before { @recommendation = EngineOfWar::Recommendation.new(raw) }
19
+ subject { @recommendation }
20
+
21
+ raw.each do |k, v|
22
+ its(k) { should == v}
23
+ end
24
+ end
25
+
26
+ describe "Recommendation.random" do
27
+ before do
28
+ create_config("recommendations.json",
29
+ <<-EOF)
30
+ [{
31
+ "quote": "Great to work with, intelligent feedback, exceptional quality.",
32
+ "who": "Matt Todd",
33
+ "who_url": "http://www.workingwithrails.com/person/7298-matt-todd",
34
+ "where_url": "http://www.workingwithrails.com/recommendation/for/person/7844-tammer-saleh",
35
+ "position": "",
36
+ "company": "GitHub",
37
+ "company_url": "http://github.com/"
38
+ }]
39
+ EOF
40
+ @recommendation = EngineOfWar::Recommendation.random
41
+ end
42
+ subject { @recommendation }
43
+ it { should be_a(EngineOfWar::Recommendation) }
44
+ end
@@ -0,0 +1,49 @@
1
+ require "spec_helper"
2
+
3
+ describe "given a layout" do
4
+ before do
5
+ create_template("layouts/application.html.haml", "%h1 Layout\n= yield")
6
+ end
7
+
8
+ describe "and a haml template" do
9
+ before { create_template("bar.html.haml", "%h1 Haml") }
10
+
11
+ context "on GET to /bar" do
12
+ before { visit "/bar" }
13
+
14
+ it "renders the template" do
15
+ page.should have_selector('h1:contains("Haml")')
16
+ end
17
+
18
+ it "renders the layout" do
19
+ page.should have_selector('h1:contains("Layout")')
20
+ end
21
+ end
22
+ end
23
+
24
+ describe "and a nested haml template" do
25
+ before { create_template("foo/bar.html.haml", "%h2 Nested Page") }
26
+
27
+ context "on GET to /foo/bar" do
28
+ before { visit "/foo/bar" }
29
+
30
+ it "renders the template" do
31
+ page.should have_selector('h2:contains("Nested Page")')
32
+ end
33
+ end
34
+ end
35
+
36
+ describe "and a textile template" do
37
+ before { create_template("bar.html.textile", "h1. Textile") }
38
+
39
+ context "on GET to /bar" do
40
+ before { visit "/bar" }
41
+
42
+ it "renders the template" do
43
+ page.should have_selector('h1:contains("Textile")')
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+
data/spec/root_spec.rb ADDED
@@ -0,0 +1,25 @@
1
+ require "spec_helper"
2
+
3
+ describe "given a layout" do
4
+ before do
5
+ create_template("layouts/application.html.haml", "%h1 Layout\n= yield")
6
+ end
7
+
8
+ describe "and a haml template named index.html.haml" do
9
+ before { create_template("index.html.haml", "%h1 Haml") }
10
+
11
+ context "on GET to /" do
12
+ before { visit "/" }
13
+
14
+ it "renders the template" do
15
+ page.should have_selector('h1:contains("Haml")')
16
+ end
17
+
18
+ it "renders the layout" do
19
+ page.should have_selector('h1:contains("Layout")')
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+
@@ -0,0 +1,71 @@
1
+ require "bundler/setup"
2
+ require 'rspec'
3
+ require 'capybara/rspec'
4
+
5
+ require "engine_of_war.rb"
6
+
7
+ Capybara.app = EngineOfWar::App
8
+
9
+ EngineOfWar::App.set :views, "/tmp/engine-#{$$}/views"
10
+ EngineOfWar::App.set :public, "/tmp/engine-#{$$}/public"
11
+ EngineOfWar::App.set :config, "/tmp/engine-#{$$}/config"
12
+ EngineOfWar::App.enable :raise_errors
13
+ EngineOfWar::App.disable :show_exceptions
14
+
15
+ def create_template(path, content)
16
+ create_file "#{EngineOfWar::App.settings.views}/#{path}", content.unindent
17
+ end
18
+
19
+ def create_asset(path, content)
20
+ create_file "#{EngineOfWar::App.settings.public}/#{path}", content.unindent
21
+ end
22
+
23
+ def create_config(path, content)
24
+ create_file "#{EngineOfWar::App.settings.config}/#{path}", content.unindent
25
+ end
26
+
27
+ def create_file(path, content)
28
+ FileUtils.mkdir_p(File.dirname(path))
29
+ File.open(path, "w+") do |f|
30
+ f << content
31
+ end
32
+ end
33
+
34
+ def show_files
35
+ pp Dir[File.join(File.dirname(EngineOfWar::App.settings.views), "**", "*")]
36
+ end
37
+
38
+ def create_dirs
39
+ FileUtils.mkdir_p(EngineOfWar::App.settings.views)
40
+ FileUtils.mkdir_p(EngineOfWar::App.settings.public)
41
+ FileUtils.mkdir_p(EngineOfWar::App.settings.config)
42
+ end
43
+
44
+ def remove_dirs
45
+ FileUtils.rm_rf(EngineOfWar::App.settings.views)
46
+ FileUtils.rm_rf(EngineOfWar::App.settings.public)
47
+ FileUtils.rm_rf(EngineOfWar::App.settings.config)
48
+ end
49
+
50
+ RSpec.configure do |config|
51
+ config.include Capybara::DSL
52
+
53
+ config.before(:all) do
54
+ create_dirs
55
+ end
56
+
57
+ config.after(:all) do
58
+ remove_dirs
59
+ end
60
+
61
+ config.before(:each) do
62
+ remove_dirs
63
+ create_dirs
64
+ end
65
+
66
+ # config.after(:each) do
67
+ # remove_dirs
68
+ # create_dirs
69
+ # end
70
+ end
71
+
metadata ADDED
@@ -0,0 +1,246 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: engine_of_war
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Thunderbolt Labs
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: sinatra
16
+ requirement: &70332316779880 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70332316779880
25
+ - !ruby/object:Gem::Dependency
26
+ name: compass
27
+ requirement: &70332316779460 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70332316779460
36
+ - !ruby/object:Gem::Dependency
37
+ name: padrino
38
+ requirement: &70332316779040 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70332316779040
47
+ - !ruby/object:Gem::Dependency
48
+ name: active_support
49
+ requirement: &70332316778620 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *70332316778620
58
+ - !ruby/object:Gem::Dependency
59
+ name: builder
60
+ requirement: &70332316778180 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: *70332316778180
69
+ - !ruby/object:Gem::Dependency
70
+ name: haml
71
+ requirement: &70332316777760 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: *70332316777760
80
+ - !ruby/object:Gem::Dependency
81
+ name: sass
82
+ requirement: &70332316777260 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: 3.1.7
88
+ type: :runtime
89
+ prerelease: false
90
+ version_requirements: *70332316777260
91
+ - !ruby/object:Gem::Dependency
92
+ name: RedCloth
93
+ requirement: &70332316776840 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ type: :runtime
100
+ prerelease: false
101
+ version_requirements: *70332316776840
102
+ - !ruby/object:Gem::Dependency
103
+ name: coffee-script
104
+ requirement: &70332316776380 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: *70332316776380
113
+ - !ruby/object:Gem::Dependency
114
+ name: yard
115
+ requirement: &70332316775960 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ type: :development
122
+ prerelease: false
123
+ version_requirements: *70332316775960
124
+ - !ruby/object:Gem::Dependency
125
+ name: RedCloth
126
+ requirement: &70332316775540 !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: *70332316775540
135
+ - !ruby/object:Gem::Dependency
136
+ name: rake
137
+ requirement: &70332316775120 !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ type: :development
144
+ prerelease: false
145
+ version_requirements: *70332316775120
146
+ - !ruby/object:Gem::Dependency
147
+ name: rspec
148
+ requirement: &70332316774700 !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ type: :development
155
+ prerelease: false
156
+ version_requirements: *70332316774700
157
+ - !ruby/object:Gem::Dependency
158
+ name: capybara
159
+ requirement: &70332316774280 !ruby/object:Gem::Requirement
160
+ none: false
161
+ requirements:
162
+ - - ! '>='
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ type: :development
166
+ prerelease: false
167
+ version_requirements: *70332316774280
168
+ description: Semi-static site engine.
169
+ email:
170
+ - us@thunderboltlabs.com
171
+ executables: []
172
+ extensions: []
173
+ extra_rdoc_files: []
174
+ files:
175
+ - .gitignore
176
+ - .rbenv-version
177
+ - .yardopts
178
+ - Gemfile
179
+ - Rakefile
180
+ - Readme.textile
181
+ - engine_of_war.gemspec
182
+ - lib/engine_of_war.rb
183
+ - lib/engine_of_war/app.rb
184
+ - lib/engine_of_war/extensions/string.rb
185
+ - lib/engine_of_war/layout.rb
186
+ - lib/engine_of_war/my_red_cloth_template.rb
187
+ - lib/engine_of_war/page.rb
188
+ - lib/engine_of_war/page_collection.rb
189
+ - lib/engine_of_war/recommendation.rb
190
+ - lib/engine_of_war/version.rb
191
+ - spec/assets_spec.rb
192
+ - spec/atom_spec.rb
193
+ - spec/blog_spec.rb
194
+ - spec/code_filter_spec.rb
195
+ - spec/frontmatter_spec.rb
196
+ - spec/image_filter_spec.rb
197
+ - spec/page_collection_spec.rb
198
+ - spec/page_spec.rb
199
+ - spec/recommendations_spec.rb
200
+ - spec/rendering_spec.rb
201
+ - spec/root_spec.rb
202
+ - spec/spec_helper.rb
203
+ homepage: http://thunderboltlabs.com
204
+ licenses: []
205
+ post_install_message:
206
+ rdoc_options: []
207
+ require_paths:
208
+ - lib
209
+ required_ruby_version: !ruby/object:Gem::Requirement
210
+ none: false
211
+ requirements:
212
+ - - ! '>='
213
+ - !ruby/object:Gem::Version
214
+ version: '0'
215
+ segments:
216
+ - 0
217
+ hash: 2014848802530923412
218
+ required_rubygems_version: !ruby/object:Gem::Requirement
219
+ none: false
220
+ requirements:
221
+ - - ! '>='
222
+ - !ruby/object:Gem::Version
223
+ version: '0'
224
+ segments:
225
+ - 0
226
+ hash: 2014848802530923412
227
+ requirements: []
228
+ rubyforge_project:
229
+ rubygems_version: 1.8.11
230
+ signing_key:
231
+ specification_version: 3
232
+ summary: Semi-static site endine based on Padrino
233
+ test_files:
234
+ - spec/assets_spec.rb
235
+ - spec/atom_spec.rb
236
+ - spec/blog_spec.rb
237
+ - spec/code_filter_spec.rb
238
+ - spec/frontmatter_spec.rb
239
+ - spec/image_filter_spec.rb
240
+ - spec/page_collection_spec.rb
241
+ - spec/page_spec.rb
242
+ - spec/recommendations_spec.rb
243
+ - spec/rendering_spec.rb
244
+ - spec/root_spec.rb
245
+ - spec/spec_helper.rb
246
+ has_rdoc: