engine_of_war 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -25,6 +25,7 @@ Gem::Specification.new do |gem|
25
25
  gem.add_dependency "RedCloth"
26
26
  gem.add_dependency "rdiscount"
27
27
  gem.add_dependency "coffee-script"
28
+ gem.add_dependency "rack-google-analytics"
28
29
 
29
30
  gem.add_development_dependency "yard"
30
31
  gem.add_development_dependency "rake"
@@ -8,18 +8,37 @@ class EngineOfWar::App < Sinatra::Base
8
8
  end
9
9
 
10
10
  disable :show_exceptions
11
- set :haml, format: :html5
12
- set :scss, Compass.sass_engine_options
13
- set :github_info, nil
14
- set :site_title, nil
11
+ set :haml, format: :html5
12
+ set :scss, Compass.sass_engine_options
13
+ set :github_info, nil
14
+ set :site_title, nil
15
+ set :google_analytics_key, nil
16
+
15
17
  set :config do
16
18
  File.expand_path(root + '/config/')
17
19
  end
18
20
 
21
+ def self.google_analytics_key=(key)
22
+ use Rack::GoogleAnalytics, :tracker => key
23
+ end
24
+
19
25
  def render_page_with_layout(page)
20
26
  render_page(page, layout: "layouts/#{page.layout}", layout_engine: :haml)
21
27
  end
22
28
 
29
+ helpers do
30
+ def render_page(page, opts = {})
31
+ opts[:locals] ||= {}
32
+ opts[:locals][:meta] = page.meta
33
+ opts[:locals][:page] = page
34
+ send(page.engine, page.source, opts)
35
+ end
36
+
37
+ def collection(dir)
38
+ EngineOfWar::PageCollection.new(dir)
39
+ end
40
+ end
41
+
23
42
  error(500) { haml :"500" }
24
43
  error(404) { haml :"404" }
25
44
 
@@ -62,17 +81,4 @@ class EngineOfWar::App < Sinatra::Base
62
81
  content_type ext
63
82
  render :"#{name}", :layout => false
64
83
  end
65
-
66
- helpers do
67
- def render_page(page, opts = {})
68
- opts[:locals] ||= {}
69
- opts[:locals][:meta] = page.meta
70
- opts[:locals][:page] = page
71
- send(page.engine, page.source, opts)
72
- end
73
-
74
- def collection(dir)
75
- EngineOfWar::PageCollection.new(dir)
76
- end
77
- end
78
84
  end
@@ -1,3 +1,3 @@
1
1
  module EngineOfWar
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.0"
3
3
  end
data/lib/engine_of_war.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'sinatra'
2
+ require 'rack/google-analytics'
2
3
  require 'compass'
3
4
  require "builder"
4
5
  require 'haml'
data/spec/atom_spec.rb CHANGED
@@ -4,7 +4,7 @@ require "spec_helper"
4
4
 
5
5
  describe "Given some blog posts" do
6
6
  before do
7
- Capybara.app.settings.site_title = "The Great Bambino"
7
+ Capybara.app.site_title = "The Great Bambino"
8
8
  create_template("posts/a_post.html.haml",
9
9
  <<-EOF)
10
10
  ---
@@ -1,8 +1,15 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe "when not raising errors" do
4
- before { Capybara.app.disable :raise_errors }
5
- after { Capybara.app.enable :raise_errors }
4
+ before do
5
+ Capybara.app.disable :raise_errors
6
+ Capybara.app.disable :show_exceptions
7
+ end
8
+
9
+ after do
10
+ Capybara.app.enable :raise_errors
11
+ Capybara.app.enable :show_exceptions
12
+ end
6
13
 
7
14
  describe "given a /public/500.html page" do
8
15
  before { create_template("500.haml", "Bam") }
data/spec/page_spec.rb CHANGED
@@ -27,14 +27,14 @@ describe "Given a textile file without frontmatter, Page" do
27
27
  its(:engine) { should == :textile }
28
28
 
29
29
  context "when github is configured" do
30
- before { EngineOfWar::App.set :github_info, "foo/bar" }
30
+ before { Capybara.app.github_info = "foo/bar" }
31
31
  its(:github_edit_url) do
32
32
  should == "https://github.com/foo/bar/edit/master/views/file.html.textile"
33
33
  end
34
34
  end
35
35
 
36
36
  context "when github is not configured" do
37
- before { EngineOfWar::App.set :github_info, nil }
37
+ before { Capybara.app.github_info = nil }
38
38
  it ".github_edit_url should raise" do
39
39
  lambda { subject.github_edit_url }.should raise_error
40
40
  end
@@ -84,7 +84,7 @@ describe "Given a file with front matter" do
84
84
  its(:source) { should match("%h1 This is a post.") }
85
85
  its(:source) { should_not match("Title for this post") }
86
86
  context "when github is configured" do
87
- before { EngineOfWar::App.set :github_info, "foo/bar" }
87
+ before { Capybara.app.github_info = "foo/bar" }
88
88
  its(:github_edit_url) do
89
89
  should == "https://github.com/foo/bar/edit/master/views/file.html.haml"
90
90
  end
data/spec/root_spec.rb CHANGED
@@ -2,7 +2,14 @@ require "spec_helper"
2
2
 
3
3
  describe "given a layout" do
4
4
  before do
5
- create_template("layouts/application.html.haml", "%h1 Layout\n= yield")
5
+ create_template("layouts/application.html.haml", <<-EOP)
6
+ %html
7
+ %head
8
+ %body
9
+ %h1 Layout
10
+ = yield
11
+ EOP
12
+
6
13
  end
7
14
 
8
15
  describe "and a haml template named index.html.haml" do
@@ -19,6 +26,19 @@ describe "given a layout" do
19
26
  page.should have_selector('h1:contains("Layout")')
20
27
  end
21
28
  end
29
+
30
+ context "with google analytics configured" do
31
+ before { Capybara.app.google_analytics_key = "UA-xxxxxx-x" }
32
+
33
+ context "on GET to /" do
34
+ before { visit "/" }
35
+
36
+ it "renders the google analytics JS" do
37
+ page.should have_selector('script[type="text/javascript"]:contains("google-analytics.com")')
38
+ page.should have_selector('script[type="text/javascript"]:contains("UA-xxxxxx-x")')
39
+ end
40
+ end
41
+ end
22
42
  end
23
43
  end
24
44
 
data/spec/spec_helper.rb CHANGED
@@ -5,21 +5,18 @@ require 'capybara/rspec'
5
5
  require "engine_of_war.rb"
6
6
 
7
7
  Capybara.app = EngineOfWar::App
8
-
9
- EngineOfWar::App.set :root, "/tmp/engine-#{$$}"
10
- EngineOfWar::App.enable :raise_errors
11
- EngineOfWar::App.disable :show_exceptions
8
+ Capybara.app.set :root, "/tmp/engine-#{$$}"
12
9
 
13
10
  def create_template(path, content)
14
- create_file "#{EngineOfWar::App.settings.views}/#{path}", content.unindent
11
+ create_file "#{Capybara.app.settings.views}/#{path}", content.unindent
15
12
  end
16
13
 
17
14
  def create_asset(path, content)
18
- create_file "#{EngineOfWar::App.settings.public_folder}/#{path}", content.unindent
15
+ create_file "#{Capybara.app.settings.public_folder}/#{path}", content.unindent
19
16
  end
20
17
 
21
18
  def create_config(path, content)
22
- create_file "#{EngineOfWar::App.settings.config}/#{path}", content.unindent
19
+ create_file "#{Capybara.app.settings.config}/#{path}", content.unindent
23
20
  end
24
21
 
25
22
  def create_file(path, content)
@@ -30,19 +27,19 @@ def create_file(path, content)
30
27
  end
31
28
 
32
29
  def show_files
33
- pp Dir[File.join(File.dirname(EngineOfWar::App.settings.views), "**", "*")]
30
+ pp Dir[File.join(File.dirname(Capybara.app.settings.views), "**", "*")]
34
31
  end
35
32
 
36
33
  def create_dirs
37
- FileUtils.mkdir_p(EngineOfWar::App.settings.views)
38
- FileUtils.mkdir_p(EngineOfWar::App.settings.public_folder)
39
- FileUtils.mkdir_p(EngineOfWar::App.settings.config)
34
+ FileUtils.mkdir_p(Capybara.app.settings.views)
35
+ FileUtils.mkdir_p(Capybara.app.settings.public_folder)
36
+ FileUtils.mkdir_p(Capybara.app.settings.config)
40
37
  end
41
38
 
42
39
  def remove_dirs
43
- FileUtils.rm_rf(EngineOfWar::App.settings.views)
44
- FileUtils.rm_rf(EngineOfWar::App.settings.public_folder)
45
- FileUtils.rm_rf(EngineOfWar::App.settings.config)
40
+ FileUtils.rm_rf(Capybara.app.settings.views)
41
+ FileUtils.rm_rf(Capybara.app.settings.public_folder)
42
+ FileUtils.rm_rf(Capybara.app.settings.config)
46
43
  end
47
44
 
48
45
  RSpec.configure do |config|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: engine_of_war
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-23 00:00:00.000000000 Z
12
+ date: 2012-01-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
16
- requirement: &70287796203920 !ruby/object:Gem::Requirement
16
+ requirement: &70269693381840 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.3'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70287796203920
24
+ version_requirements: *70269693381840
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: compass
27
- requirement: &70287796203500 !ruby/object:Gem::Requirement
27
+ requirement: &70269693381420 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70287796203500
35
+ version_requirements: *70269693381420
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: padrino
38
- requirement: &70287796203040 !ruby/object:Gem::Requirement
38
+ requirement: &70269693380960 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70287796203040
46
+ version_requirements: *70269693380960
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: active_support
49
- requirement: &70287796202620 !ruby/object:Gem::Requirement
49
+ requirement: &70269693380540 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70287796202620
57
+ version_requirements: *70269693380540
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: builder
60
- requirement: &70287796202200 !ruby/object:Gem::Requirement
60
+ requirement: &70269693380120 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70287796202200
68
+ version_requirements: *70269693380120
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: haml
71
- requirement: &70287796201780 !ruby/object:Gem::Requirement
71
+ requirement: &70269693379700 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70287796201780
79
+ version_requirements: *70269693379700
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: sass
82
- requirement: &70287796201280 !ruby/object:Gem::Requirement
82
+ requirement: &70269693379200 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 3.1.7
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *70287796201280
90
+ version_requirements: *70269693379200
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: RedCloth
93
- requirement: &70287796200860 !ruby/object:Gem::Requirement
93
+ requirement: &70269693378780 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *70287796200860
101
+ version_requirements: *70269693378780
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rdiscount
104
- requirement: &70287796200400 !ruby/object:Gem::Requirement
104
+ requirement: &70269693378320 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :runtime
111
111
  prerelease: false
112
- version_requirements: *70287796200400
112
+ version_requirements: *70269693378320
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: coffee-script
115
- requirement: &70287796199980 !ruby/object:Gem::Requirement
115
+ requirement: &70269693377900 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,21 @@ dependencies:
120
120
  version: '0'
121
121
  type: :runtime
122
122
  prerelease: false
123
- version_requirements: *70287796199980
123
+ version_requirements: *70269693377900
124
+ - !ruby/object:Gem::Dependency
125
+ name: rack-google-analytics
126
+ requirement: &70269693377480 !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: *70269693377480
124
135
  - !ruby/object:Gem::Dependency
125
136
  name: yard
126
- requirement: &70287796199560 !ruby/object:Gem::Requirement
137
+ requirement: &70269693377060 !ruby/object:Gem::Requirement
127
138
  none: false
128
139
  requirements:
129
140
  - - ! '>='
@@ -131,10 +142,10 @@ dependencies:
131
142
  version: '0'
132
143
  type: :development
133
144
  prerelease: false
134
- version_requirements: *70287796199560
145
+ version_requirements: *70269693377060
135
146
  - !ruby/object:Gem::Dependency
136
147
  name: rake
137
- requirement: &70287796199120 !ruby/object:Gem::Requirement
148
+ requirement: &70269693376640 !ruby/object:Gem::Requirement
138
149
  none: false
139
150
  requirements:
140
151
  - - ! '>='
@@ -142,10 +153,10 @@ dependencies:
142
153
  version: '0'
143
154
  type: :development
144
155
  prerelease: false
145
- version_requirements: *70287796199120
156
+ version_requirements: *70269693376640
146
157
  - !ruby/object:Gem::Dependency
147
158
  name: rspec
148
- requirement: &70287796198700 !ruby/object:Gem::Requirement
159
+ requirement: &70269693376220 !ruby/object:Gem::Requirement
149
160
  none: false
150
161
  requirements:
151
162
  - - ! '>='
@@ -153,10 +164,10 @@ dependencies:
153
164
  version: '0'
154
165
  type: :development
155
166
  prerelease: false
156
- version_requirements: *70287796198700
167
+ version_requirements: *70269693376220
157
168
  - !ruby/object:Gem::Dependency
158
169
  name: capybara
159
- requirement: &70287796198280 !ruby/object:Gem::Requirement
170
+ requirement: &70269693375800 !ruby/object:Gem::Requirement
160
171
  none: false
161
172
  requirements:
162
173
  - - ! '>='
@@ -164,10 +175,10 @@ dependencies:
164
175
  version: '0'
165
176
  type: :development
166
177
  prerelease: false
167
- version_requirements: *70287796198280
178
+ version_requirements: *70269693375800
168
179
  - !ruby/object:Gem::Dependency
169
180
  name: guard-rspec
170
- requirement: &70287796197860 !ruby/object:Gem::Requirement
181
+ requirement: &70269693375380 !ruby/object:Gem::Requirement
171
182
  none: false
172
183
  requirements:
173
184
  - - ! '>='
@@ -175,10 +186,10 @@ dependencies:
175
186
  version: '0'
176
187
  type: :development
177
188
  prerelease: false
178
- version_requirements: *70287796197860
189
+ version_requirements: *70269693375380
179
190
  - !ruby/object:Gem::Dependency
180
191
  name: guard-bundler
181
- requirement: &70287796197440 !ruby/object:Gem::Requirement
192
+ requirement: &70269693374960 !ruby/object:Gem::Requirement
182
193
  none: false
183
194
  requirements:
184
195
  - - ! '>='
@@ -186,10 +197,10 @@ dependencies:
186
197
  version: '0'
187
198
  type: :development
188
199
  prerelease: false
189
- version_requirements: *70287796197440
200
+ version_requirements: *70269693374960
190
201
  - !ruby/object:Gem::Dependency
191
202
  name: ruby_gntp
192
- requirement: &70287796197020 !ruby/object:Gem::Requirement
203
+ requirement: &70269693374540 !ruby/object:Gem::Requirement
193
204
  none: false
194
205
  requirements:
195
206
  - - ! '>='
@@ -197,7 +208,7 @@ dependencies:
197
208
  version: '0'
198
209
  type: :development
199
210
  prerelease: false
200
- version_requirements: *70287796197020
211
+ version_requirements: *70269693374540
201
212
  description: Semi-static site engine.
202
213
  email:
203
214
  - us@thunderboltlabs.com
@@ -252,7 +263,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
252
263
  version: '0'
253
264
  segments:
254
265
  - 0
255
- hash: -1331396465721998580
266
+ hash: -3177996844443617288
256
267
  required_rubygems_version: !ruby/object:Gem::Requirement
257
268
  none: false
258
269
  requirements:
@@ -261,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
261
272
  version: '0'
262
273
  segments:
263
274
  - 0
264
- hash: -1331396465721998580
275
+ hash: -3177996844443617288
265
276
  requirements: []
266
277
  rubyforge_project:
267
278
  rubygems_version: 1.8.11