schreihals 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,41 @@
1
+ require_relative 'test_helper'
2
+
3
+ context Schreihals::Document do
4
+ helper(:test_document_directory) { File.expand_path('../files/', __FILE__) }
5
+ helper(:test_document_filename) { File.join(test_document_directory, 'simple_document.md') }
6
+ helper(:test_document_contents) { open(test_document_filename).read }
7
+
8
+ setup { Schreihals::Document }
9
+
10
+ context "#from_string" do
11
+ setup { topic.from_string open(test_document_filename).read }
12
+
13
+ asserts(:class).equals Schreihals::Document
14
+ asserts(:body).equals "This is the body."
15
+ asserts(:title).equals "This is the title"
16
+ asserts("automatically converts dates into Date objects") { topic.date.kind_of? Date }
17
+ asserts("automatically converts datetimes into Time objects") { topic.datetime.kind_of? Time }
18
+ end
19
+
20
+ asserts "#from_file should call #from_string with the contents of the file" do
21
+ mock.proxy(topic).from_string(test_document_contents, { 'file_name' => 'simple_document.md' })
22
+ topic.from_file(test_document_filename)
23
+ end.kind_of?(Schreihals::Document)
24
+
25
+ context "#from_file" do
26
+ setup { topic.from_file(test_document_filename) }
27
+
28
+ asserts(:file_name).equals "simple_document.md"
29
+ asserts(:file_name_without_extension).equals "simple_document"
30
+ asserts(:file_extension).equals "md"
31
+ end
32
+
33
+ context "#load_from_directory" do
34
+ should "call #from_file for each file contained in the directory" do
35
+ Dir[File.join(test_document_directory, "*")].each do |f|
36
+ mock.proxy(topic).from_file(f)
37
+ end
38
+ topic.load_from_directory(test_document_directory)
39
+ end.kind_of?(Array)
40
+ end
41
+ end
@@ -0,0 +1,7 @@
1
+ ---
2
+ title: This is the title
3
+ date: 2011-12-24
4
+ datetime: 2011-12-24 12:22:01
5
+ ---
6
+
7
+ This is the body.
@@ -0,0 +1,8 @@
1
+ ---
2
+ title: First Post.
3
+ tags: [test]
4
+ summary: "This is the first post."
5
+ read_more: "Read more!"
6
+ ---
7
+
8
+ This is the body of the first post. Amazing, isn't it?
@@ -0,0 +1,8 @@
1
+ ---
2
+ title: Second Post.
3
+ tags: [test]
4
+ summary: "This is the second post."
5
+ read_more: "Read even more!"
6
+ ---
7
+
8
+ This is the body of the second post. You can't stop me.
@@ -0,0 +1,5 @@
1
+ ---
2
+ title: A Static Page.
3
+ ---
4
+
5
+ This is a static page. It has no date.
@@ -0,0 +1,63 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'riot'
4
+ require 'riot/rr'
5
+ require 'nokogiri'
6
+ require 'awesome_print'
7
+
8
+ $:.unshift File.dirname(__FILE__)
9
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
10
+
11
+ require 'schreihals'
12
+
13
+ require 'rack/test'
14
+ set :environment, :test
15
+
16
+ module Riot
17
+ class PresentMacro < Riot::AssertionMacro
18
+ register :present
19
+
20
+ def evaluate(thing)
21
+ thing.present? ? pass("is present") : fail("expected to be present")
22
+ end
23
+
24
+ def devaluate(thing)
25
+ thing.present? ? fail("expected to not be present") : pass("is not present")
26
+ end
27
+ end
28
+
29
+ class IncludesHTMLMacro < Riot::AssertionMacro
30
+ register :includes_html
31
+
32
+ def evaluate(actual, expected)
33
+ doc = Nokogiri::HTML(actual)
34
+ expected = expected.to_a.flatten
35
+
36
+ if (doc/expected.first).empty?
37
+ fail("expected #{actual} to contain a [#{expected.first}]")
38
+ elsif !(doc/expected.first).inner_html.match(expected.last)
39
+ fail("expected [#{expected.first}] to contain #{expected.last}")
40
+ else
41
+ pass "contains [#{expected.first}] with \"#{expected.last}\""
42
+ end
43
+ end
44
+ end
45
+
46
+ class IncludesElementsMacro < Riot::AssertionMacro
47
+ register :includes_elements
48
+
49
+ def evaluate(actual, selector, count)
50
+ doc = Nokogiri::HTML(actual)
51
+ (doc/selector).size == count ? pass("contains #{count} instance#{"s" unless count == 1} of [#{selector}]") :
52
+ fail("expected #{actual} to contain #{count} #{selector}(s)")
53
+ end
54
+ end
55
+
56
+ # class WithinMacro < Riot::AssertionMacro
57
+ # register :within
58
+
59
+ # def evaluate(actual, expected)
60
+ # expected.include?(actual) ? pass : fail("expected #{actual} to be within #{expected}")
61
+ # end
62
+ # end
63
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schreihals
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,33 +9,44 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-24 00:00:00.000000000 Z
12
+ date: 2012-01-09 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rack
16
+ requirement: &70360914055160 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.4.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70360914055160
14
25
  - !ruby/object:Gem::Dependency
15
26
  name: sinatra
16
- requirement: &70220324705880 !ruby/object:Gem::Requirement
27
+ requirement: &70360914054280 !ruby/object:Gem::Requirement
17
28
  none: false
18
29
  requirements:
19
- - - ! '>='
30
+ - - ~>
20
31
  - !ruby/object:Gem::Version
21
- version: '0'
32
+ version: 1.3.2
22
33
  type: :runtime
23
34
  prerelease: false
24
- version_requirements: *70220324705880
35
+ version_requirements: *70360914054280
25
36
  - !ruby/object:Gem::Dependency
26
37
  name: activesupport
27
- requirement: &70220324704580 !ruby/object:Gem::Requirement
38
+ requirement: &70360914053660 !ruby/object:Gem::Requirement
28
39
  none: false
29
40
  requirements:
30
- - - ! '>='
41
+ - - ~>
31
42
  - !ruby/object:Gem::Version
32
- version: '0'
43
+ version: 3.1.0
33
44
  type: :runtime
34
45
  prerelease: false
35
- version_requirements: *70220324704580
46
+ version_requirements: *70360914053660
36
47
  - !ruby/object:Gem::Dependency
37
48
  name: shotgun
38
- requirement: &70220324702440 !ruby/object:Gem::Requirement
49
+ requirement: &70360914052360 !ruby/object:Gem::Requirement
39
50
  none: false
40
51
  requirements:
41
52
  - - ! '>='
@@ -43,10 +54,10 @@ dependencies:
43
54
  version: '0'
44
55
  type: :runtime
45
56
  prerelease: false
46
- version_requirements: *70220324702440
57
+ version_requirements: *70360914052360
47
58
  - !ruby/object:Gem::Dependency
48
59
  name: haml
49
- requirement: &70220324701320 !ruby/object:Gem::Requirement
60
+ requirement: &70360914050460 !ruby/object:Gem::Requirement
50
61
  none: false
51
62
  requirements:
52
63
  - - ! '>='
@@ -54,10 +65,10 @@ dependencies:
54
65
  version: '0'
55
66
  type: :runtime
56
67
  prerelease: false
57
- version_requirements: *70220324701320
68
+ version_requirements: *70360914050460
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: sass
60
- requirement: &70220324700620 !ruby/object:Gem::Requirement
71
+ requirement: &70360914049220 !ruby/object:Gem::Requirement
61
72
  none: false
62
73
  requirements:
63
74
  - - ! '>='
@@ -65,10 +76,10 @@ dependencies:
65
76
  version: '0'
66
77
  type: :runtime
67
78
  prerelease: false
68
- version_requirements: *70220324700620
79
+ version_requirements: *70360914049220
69
80
  - !ruby/object:Gem::Dependency
70
- name: document_mapper
71
- requirement: &70220324699420 !ruby/object:Gem::Requirement
81
+ name: coderay
82
+ requirement: &70360914048400 !ruby/object:Gem::Requirement
72
83
  none: false
73
84
  requirements:
74
85
  - - ! '>='
@@ -76,10 +87,10 @@ dependencies:
76
87
  version: '0'
77
88
  type: :runtime
78
89
  prerelease: false
79
- version_requirements: *70220324699420
90
+ version_requirements: *70360914048400
80
91
  - !ruby/object:Gem::Dependency
81
- name: coderay
82
- requirement: &70220324698340 !ruby/object:Gem::Requirement
92
+ name: redcarpet
93
+ requirement: &70360914047760 !ruby/object:Gem::Requirement
83
94
  none: false
84
95
  requirements:
85
96
  - - ! '>='
@@ -87,10 +98,10 @@ dependencies:
87
98
  version: '0'
88
99
  type: :runtime
89
100
  prerelease: false
90
- version_requirements: *70220324698340
101
+ version_requirements: *70360914047760
91
102
  - !ruby/object:Gem::Dependency
92
- name: redcarpet
93
- requirement: &70220324697560 !ruby/object:Gem::Requirement
103
+ name: rack-cache
104
+ requirement: &70360914047100 !ruby/object:Gem::Requirement
94
105
  none: false
95
106
  requirements:
96
107
  - - ! '>='
@@ -98,10 +109,10 @@ dependencies:
98
109
  version: '0'
99
110
  type: :runtime
100
111
  prerelease: false
101
- version_requirements: *70220324697560
112
+ version_requirements: *70360914047100
102
113
  - !ruby/object:Gem::Dependency
103
- name: rack-cache
104
- requirement: &70220324696600 !ruby/object:Gem::Requirement
114
+ name: rack-codehighlighter
115
+ requirement: &70360914044680 !ruby/object:Gem::Requirement
105
116
  none: false
106
117
  requirements:
107
118
  - - ! '>='
@@ -109,10 +120,21 @@ dependencies:
109
120
  version: '0'
110
121
  type: :runtime
111
122
  prerelease: false
112
- version_requirements: *70220324696600
123
+ version_requirements: *70360914044680
113
124
  - !ruby/object:Gem::Dependency
114
- name: rack-codehighlighter
115
- requirement: &70220324695840 !ruby/object:Gem::Requirement
125
+ name: schnitzelstyle
126
+ requirement: &70360914043620 !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: 0.0.2
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: *70360914043620
135
+ - !ruby/object:Gem::Dependency
136
+ name: nokogiri
137
+ requirement: &70360914042680 !ruby/object:Gem::Requirement
116
138
  none: false
117
139
  requirements:
118
140
  - - ! '>='
@@ -120,42 +142,121 @@ dependencies:
120
142
  version: '0'
121
143
  type: :runtime
122
144
  prerelease: false
123
- version_requirements: *70220324695840
145
+ version_requirements: *70360914042680
124
146
  - !ruby/object:Gem::Dependency
125
- name: schnitzelstyle
126
- requirement: &70220324695100 !ruby/object:Gem::Requirement
147
+ name: thor
148
+ requirement: &70360914040900 !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ type: :runtime
155
+ prerelease: false
156
+ version_requirements: *70360914040900
157
+ - !ruby/object:Gem::Dependency
158
+ name: psych
159
+ requirement: &70360914039880 !ruby/object:Gem::Requirement
160
+ none: false
161
+ requirements:
162
+ - - ! '>='
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ type: :runtime
166
+ prerelease: false
167
+ version_requirements: *70360914039880
168
+ - !ruby/object:Gem::Dependency
169
+ name: i18n
170
+ requirement: &70360914039120 !ruby/object:Gem::Requirement
127
171
  none: false
128
172
  requirements:
129
173
  - - ! '>='
130
174
  - !ruby/object:Gem::Version
131
- version: 0.0.1
175
+ version: '0'
132
176
  type: :runtime
133
177
  prerelease: false
134
- version_requirements: *70220324695100
178
+ version_requirements: *70360914039120
135
179
  - !ruby/object:Gem::Dependency
136
- name: rspec
137
- requirement: &70220324694080 !ruby/object:Gem::Requirement
180
+ name: tilt
181
+ requirement: &70360914038380 !ruby/object:Gem::Requirement
182
+ none: false
183
+ requirements:
184
+ - - ~>
185
+ - !ruby/object:Gem::Version
186
+ version: 1.3.0
187
+ type: :runtime
188
+ prerelease: false
189
+ version_requirements: *70360914038380
190
+ - !ruby/object:Gem::Dependency
191
+ name: rake
192
+ requirement: &70360914037380 !ruby/object:Gem::Requirement
138
193
  none: false
139
194
  requirements:
140
195
  - - ! '>='
141
196
  - !ruby/object:Gem::Version
142
- version: 2.0.0
197
+ version: '0'
198
+ type: :development
199
+ prerelease: false
200
+ version_requirements: *70360914037380
201
+ - !ruby/object:Gem::Dependency
202
+ name: riot
203
+ requirement: &70360914035900 !ruby/object:Gem::Requirement
204
+ none: false
205
+ requirements:
206
+ - - ! '>='
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ type: :development
210
+ prerelease: false
211
+ version_requirements: *70360914035900
212
+ - !ruby/object:Gem::Dependency
213
+ name: rack-test
214
+ requirement: &70360914034700 !ruby/object:Gem::Requirement
215
+ none: false
216
+ requirements:
217
+ - - ! '>='
218
+ - !ruby/object:Gem::Version
219
+ version: '0'
220
+ type: :development
221
+ prerelease: false
222
+ version_requirements: *70360914034700
223
+ - !ruby/object:Gem::Dependency
224
+ name: watchr
225
+ requirement: &70360914033060 !ruby/object:Gem::Requirement
226
+ none: false
227
+ requirements:
228
+ - - ! '>='
229
+ - !ruby/object:Gem::Version
230
+ version: '0'
231
+ type: :development
232
+ prerelease: false
233
+ version_requirements: *70360914033060
234
+ - !ruby/object:Gem::Dependency
235
+ name: awesome_print
236
+ requirement: &70360914031420 !ruby/object:Gem::Requirement
237
+ none: false
238
+ requirements:
239
+ - - ! '>='
240
+ - !ruby/object:Gem::Version
241
+ version: '0'
143
242
  type: :development
144
243
  prerelease: false
145
- version_requirements: *70220324694080
244
+ version_requirements: *70360914031420
146
245
  description: A simple blog engine for hackers.
147
246
  email:
148
247
  - hendrik@mans.de
149
- executables: []
248
+ executables:
249
+ - schreihals
150
250
  extensions: []
151
251
  extra_rdoc_files: []
152
252
  files:
153
253
  - .gitignore
154
- - .rspec
254
+ - .watchr
155
255
  - Gemfile
156
256
  - LICENSE
157
257
  - README.md
158
258
  - Rakefile
259
+ - bin/schreihals
159
260
  - example/Gemfile
160
261
  - example/config.ru
161
262
  - example/posts/2010-06-17-pythton-is-great.md
@@ -164,18 +265,40 @@ files:
164
265
  - lib/public/.gitkeep
165
266
  - lib/public/favicon.ico
166
267
  - lib/schreihals.rb
268
+ - lib/schreihals/actions.rb
269
+ - lib/schreihals/app.rb
270
+ - lib/schreihals/cli.rb
271
+ - lib/schreihals/document.rb
272
+ - lib/schreihals/helpers.rb
273
+ - lib/schreihals/post.rb
274
+ - lib/schreihals/static.rb
167
275
  - lib/schreihals/version.rb
276
+ - lib/templates/first-post.md.tt
277
+ - lib/templates/new-post.md.tt
278
+ - lib/templates/new_blog/.gitignore
279
+ - lib/templates/new_blog/Gemfile
280
+ - lib/templates/new_blog/config.ru.tt
281
+ - lib/templates/new_blog/posts/.gitkeep
282
+ - lib/templates/new_blog/public/media/.gitkeep
168
283
  - lib/views/404.haml
169
284
  - lib/views/atom.haml
285
+ - lib/views/blog.scss
170
286
  - lib/views/index.haml
171
287
  - lib/views/layout.haml
172
288
  - lib/views/partials/_disqus.haml
289
+ - lib/views/partials/_gauges.haml
173
290
  - lib/views/partials/_google_analytics.haml
174
291
  - lib/views/partials/_post.haml
175
292
  - lib/views/post.haml
176
293
  - lib/views/schreihals.scss
177
294
  - schreihals.gemspec
178
- - spec/spec_helper.rb
295
+ - test/app_test.rb
296
+ - test/document_test.rb
297
+ - test/files/simple_document.md
298
+ - test/posts/2011-12-23-first-post.md
299
+ - test/posts/2011-12-24-second-post.md
300
+ - test/posts/static-page.md
301
+ - test/test_helper.rb
179
302
  homepage: http://hmans.net
180
303
  licenses: []
181
304
  post_install_message:
@@ -201,4 +324,10 @@ signing_key:
201
324
  specification_version: 3
202
325
  summary: A simple blog engine for hackers.
203
326
  test_files:
204
- - spec/spec_helper.rb
327
+ - test/app_test.rb
328
+ - test/document_test.rb
329
+ - test/files/simple_document.md
330
+ - test/posts/2011-12-23-first-post.md
331
+ - test/posts/2011-12-24-second-post.md
332
+ - test/posts/static-page.md
333
+ - test/test_helper.rb