ruby_slippers 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/.rvmrc +2 -0
  2. data/Gemfile +16 -0
  3. data/Gemfile.lock +45 -0
  4. data/Guardfile +16 -0
  5. data/LICENSE +20 -0
  6. data/README.md +122 -0
  7. data/Rakefile +5 -0
  8. data/TODO +32 -0
  9. data/VERSION +1 -0
  10. data/lib/ext/ext.rb +164 -0
  11. data/lib/ruby_slippers.rb +28 -0
  12. data/lib/ruby_slippers/app.rb +47 -0
  13. data/lib/ruby_slippers/archives.rb +22 -0
  14. data/lib/ruby_slippers/article.rb +104 -0
  15. data/lib/ruby_slippers/config.rb +37 -0
  16. data/lib/ruby_slippers/context.rb +38 -0
  17. data/lib/ruby_slippers/engine.rb +21 -0
  18. data/lib/ruby_slippers/repo.rb +21 -0
  19. data/lib/ruby_slippers/site.rb +115 -0
  20. data/lib/ruby_slippers/template.rb +28 -0
  21. data/lib/tasks/gemspec.rake +24 -0
  22. data/lib/tasks/test.rake +17 -0
  23. data/test/fixtures/articles/2010-05-17-the-wonderful-wizard-of-oz.txt +6 -0
  24. data/test/fixtures/articles/2010-05-18-the-marvelous-land-of-oz.txt +7 -0
  25. data/test/fixtures/articles/2010-05-20-dorothy-and-the-wizard-of-oz.txt +6 -0
  26. data/test/fixtures/articles/2011-05-18-ozma-of-oz.txt +10 -0
  27. data/test/fixtures/images/ozma.png +0 -0
  28. data/test/fixtures/pages/about.html.erb +1 -0
  29. data/test/fixtures/pages/archives.html.erb +23 -0
  30. data/test/fixtures/pages/article.html.erb +28 -0
  31. data/test/fixtures/pages/index.html.erb +27 -0
  32. data/test/fixtures/pages/sitemap.html.erb +0 -0
  33. data/test/fixtures/pages/tagged.html.erb +9 -0
  34. data/test/fixtures/templates/index.builder +21 -0
  35. data/test/fixtures/templates/layout.html.erb +4 -0
  36. data/test/fixtures/templates/repo.html.erb +1 -0
  37. data/test/fixtures/templates/sitemap.builder +25 -0
  38. data/test/integration/about_test.rb +23 -0
  39. data/test/integration/archives_test.rb +34 -0
  40. data/test/integration/articles_test.rb +56 -0
  41. data/test/integration/atom_test.rb +24 -0
  42. data/test/integration/invalid_route_test.rb +31 -0
  43. data/test/integration/tags_test.rb +24 -0
  44. data/test/support/test_helper.rb +47 -0
  45. data/test/unit/app_test.rb +14 -0
  46. data/test/unit/archives_test.rb +10 -0
  47. data/test/unit/article_test.rb +145 -0
  48. data/test/unit/date_patch_test.rb +10 -0
  49. data/test/unit/engine_test.rb +71 -0
  50. data/test/unit/site_test.rb +52 -0
  51. metadata +270 -0
@@ -0,0 +1,14 @@
1
+ require 'support/test_helper'
2
+ module RubySlippers::Engine
3
+ context "Site" do
4
+ context "instance" do
5
+ setup do
6
+ App.new.site
7
+ end
8
+
9
+ should("be the same as the singleton") {
10
+ topic == App.site
11
+ }
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,10 @@
1
+ require 'support/test_helper'
2
+
3
+ module RubySlippers::Engine
4
+ context "Archives" do
5
+ setup do
6
+ @config = Config.new(:markdown => true, :author => AUTHOR, :url => URL)
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,145 @@
1
+ require 'support/test_helper'
2
+
3
+ module RubySlippers::Engine
4
+ context "Article" do
5
+ setup do
6
+ @config = Config.new(:markdown => true, :author => AUTHOR, :url => URL)
7
+ @config[:markdown] = true
8
+ @config[:date] = lambda {|t| "the time is #{t.strftime("%Y/%m/%d %H:%M")}" }
9
+ @config[:summary] = {:length => 50}
10
+ @config[:tag_separator] = ", "
11
+ Site.new(@config)
12
+ end
13
+
14
+ context "article finders" do
15
+
16
+ context "by_title(regex)" do
17
+
18
+ end
19
+
20
+ context "by_title(string)" do
21
+
22
+ end
23
+
24
+ context "limit(num)" do
25
+
26
+ end
27
+ end
28
+
29
+ context "without a body (summary == body)" do
30
+ setup do
31
+ Article.new({
32
+ :title => "Dorothy & The Wizard of Oz.",
33
+ :body => "#Chapter I\nhello, *stranger*. ~"
34
+ }, @config)
35
+ end
36
+ should("not end in ...") { topic.summary !~ /&hellip;<\/p>/ }
37
+ end
38
+
39
+ context "with the bare essentials" do
40
+ setup do
41
+ Article.new({
42
+ :title => "Dorothy & The Wizard of Oz.",
43
+ :body => "#Chapter I\nhello, *stranger*."
44
+ }, @config)
45
+ end
46
+
47
+ should("have a title") { topic.title }.equals "Dorothy & The Wizard of Oz."
48
+ should("parse the body as markdown") { topic.body }.equals "<h1>Chapter I</h1>\n\n<p>hello, <em>stranger</em>.</p>\n"
49
+ should("create an appropriate slug") { topic.slug }.equals "dorothy-and-the-wizard-of-oz"
50
+ should("set the date") { topic.date }.equals "the time is #{Date.today.strftime("%Y/%m/%d %H:%M")}"
51
+ should("create a summary") { topic.summary == topic.body }
52
+ should("have an author") { topic.author }.equals AUTHOR
53
+ should("have a path") { topic.path }.equals Date.today.strftime("/%Y/%m/%d/dorothy-and-the-wizard-of-oz/")
54
+ should("have a url") { topic.url }.equals Date.today.strftime("#{URL}/%Y/%m/%d/dorothy-and-the-wizard-of-oz/")
55
+ end
56
+
57
+ context "with a user-defined summary" do
58
+ setup do
59
+ Article.new({
60
+ :title => "Dorothy & The Wizard of Oz.",
61
+ :body => "Well,\nhello ~\n, *stranger*."
62
+ }, @config.merge(:markdown => false, :summary => {:max => 150, :delim => /~\n/}))
63
+ end
64
+
65
+ should("split the article at the delimiter") { topic.summary }.equals "Well,\nhello"
66
+ should("not have the delimiter in the body") { topic.body !~ /~/ }
67
+ end
68
+
69
+ context "with everything specified" do
70
+ setup do
71
+ Article.new({
72
+ :title => "The Wizard of Oz",
73
+ :body => ("a little bit of text." * 5) + "\n" + "filler" * 10,
74
+ :date => "19/10/1976",
75
+ :slug => "wizard-of-oz",
76
+ :author => "toetoe",
77
+ :tags => "wizards, oz",
78
+ :image => "ozma.png"
79
+ }, @config)
80
+ end
81
+
82
+ should("parse the date") { [topic[:date].month, topic[:date].year] }.equals [10, 1976]
83
+ should("use the slug") { topic.slug }.equals "wizard-of-oz"
84
+ should("use the author") { topic.author }.equals "toetoe"
85
+ should("have tags") { topic.tags }.equals "wizards, oz"
86
+ should("have tag links") { topic.tag_links }.equals "<a href=\"/tagged/wizards\">wizards</a>, <a href=\"/tagged/oz\">oz</a>"
87
+ should("have an image") { topic.image_src }.equals "/img/articles/1976/october/ozma.png"
88
+ should("end in ...") { topic.summary =~ /&hellip;<\/p>/ }
89
+
90
+ context "and long first paragraph" do
91
+ should("create a valid summary") { topic.summary }.equals "<p>" + ("a little bit of text." * 5).chop + "&hellip;</p>\n"
92
+ end
93
+
94
+ context "and a short first paragraph" do
95
+ setup do
96
+ @config[:markdown] = false
97
+ Article.new({:body => "there ain't such thing as a free lunch\n" * 10}, @config)
98
+ end
99
+
100
+ should("create a valid summary") { topic.summary.size }.within 75..80
101
+ end
102
+ end
103
+
104
+ context "in a subdirectory" do
105
+ context "with implicit leading forward slash" do
106
+ setup do
107
+ conf = Config.new({})
108
+ conf.set(:prefix, "blog")
109
+ Article.new({
110
+ :title => "Dorothy & The Wizard of Oz.",
111
+ :body => "#Chapter I\nhello, *stranger*."
112
+ }, conf)
113
+ end
114
+
115
+ should("be in the directory") { topic.path }.equals Date.today.strftime("/blog/%Y/%m/%d/dorothy-and-the-wizard-of-oz/")
116
+ end
117
+
118
+ context "with explicit leading forward slash" do
119
+ setup do
120
+ conf = Config.new({})
121
+ conf.set(:prefix, "/blog")
122
+ Article.new({
123
+ :title => "Dorothy & The Wizard of Oz.",
124
+ :body => "#Chapter I\nhello, *stranger*."
125
+ }, conf)
126
+ end
127
+
128
+ should("be in the directory") { topic.path }.equals Date.today.strftime("/blog/%Y/%m/%d/dorothy-and-the-wizard-of-oz/")
129
+ end
130
+
131
+ context "with explicit trailing forward slash" do
132
+ setup do
133
+ conf = Config.new({})
134
+ conf.set(:prefix, "blog/")
135
+ Article.new({
136
+ :title => "Dorothy & The Wizard of Oz.",
137
+ :body => "#Chapter I\nhello, *stranger*."
138
+ }, conf)
139
+ end
140
+
141
+ should("be in the directory") { topic.path }.equals Date.today.strftime("/blog/%Y/%m/%d/dorothy-and-the-wizard-of-oz/")
142
+ end
143
+ end
144
+ end
145
+ end
@@ -0,0 +1,10 @@
1
+ require 'support/test_helper'
2
+
3
+ module RubySlippers::Engine
4
+ context "RubySlippers" do
5
+ context "extends Ruby lib date" do
6
+ should("respond to iso8601") { Date.today }.respond_to?(:iso8601)
7
+ end
8
+ end
9
+ end
10
+
@@ -0,0 +1,71 @@
1
+ require 'support/test_helper'
2
+ require 'date'
3
+
4
+ module RubySlippers::Engine
5
+ context "Engine" do
6
+ setup do
7
+ @config = Config.new(:markdown => true, :author => AUTHOR, :url => URL)
8
+ @ruby_slippers = Rack::MockRequest.new(App.new(@config))
9
+ Paths[:articles] = "test/fixtures/articles"
10
+ Paths[:pages] = "test/fixtures/pages"
11
+ Paths[:templates] = "test/fixtures/templates"
12
+ end
13
+
14
+ context "GET to a repo name" do
15
+ setup do
16
+ class Repo
17
+ def readme() "#{self[:name]}'s README" end
18
+ end
19
+ end
20
+
21
+ context "when the repo is in the :repos array" do
22
+ setup do
23
+ @config[:github] = {:user => "dreamr", :repos => ['repo']}
24
+ @ruby_slippers.get('/repo')
25
+ end
26
+ should("return repo's README") { topic.body }.includes("repo's README")
27
+ end
28
+
29
+ context "when the repo is not in the :repos array" do
30
+ setup do
31
+ @config[:github] = {:user => "dreamr", :repos => []}
32
+ @ruby_slippers.get('/repo')
33
+ end
34
+ should("return a 404") { topic.status }.equals 404
35
+ end
36
+ end
37
+
38
+ context "using Config#set with a hash" do
39
+ setup do
40
+ conf = Config.new({})
41
+ conf.set(:summary, {:delim => /%/})
42
+ conf
43
+ end
44
+
45
+ should("set summary[:delim] to /%/") { topic[:summary][:delim].source }.equals "%"
46
+ should("leave the :max intact") { topic[:summary][:max] }.equals 150
47
+ end
48
+
49
+ context "using Config#set with a block" do
50
+ setup do
51
+ conf = Config.new({})
52
+ conf.set(:to_html) {|path, p, _| path + p }
53
+ conf
54
+ end
55
+
56
+ should("set the value to a proc") { topic[:to_html] }.respond_to :call
57
+ end
58
+
59
+ context "testing individual configuration parameters" do
60
+ context "generate error pages" do
61
+ setup do
62
+ conf = Config.new({})
63
+ conf.set(:error) {|code| "error code #{code}" }
64
+ conf
65
+ end
66
+
67
+ should("create an error page") { topic[:error].call(400) }.equals "error code 400"
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,52 @@
1
+ require 'support/test_helper'
2
+
3
+ module RubySlippers::Engine
4
+ context "Site" do
5
+ setup do
6
+ @config = Config.new(:markdown => true, :author => AUTHOR, :url => URL)
7
+ end
8
+
9
+ context "articles" do
10
+ setup do
11
+ Site.new(@config).articles
12
+ end
13
+ should("returns a size of 4") {
14
+ topic.size
15
+ }.equals 4
16
+
17
+ should("returns a articles in array") {
18
+ topic.class
19
+ }.equals Array
20
+ end
21
+
22
+ context "sitemap(type)" do
23
+
24
+ end
25
+
26
+ context "index(type)" do
27
+
28
+ end
29
+
30
+ context "archives(filter)" do
31
+
32
+ end
33
+
34
+ context "article(route)" do
35
+
36
+ end
37
+
38
+ context "tagged(tag)" do
39
+
40
+ end
41
+
42
+ context "go(route, env, type)" do
43
+
44
+ end
45
+
46
+ context "privates" do
47
+ context "http(code)" do
48
+
49
+ end
50
+ end
51
+ end
52
+ end
metadata ADDED
@@ -0,0 +1,270 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby_slippers
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.2.0
6
+ platform: ruby
7
+ authors:
8
+ - dreamr
9
+ - cloudhead
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+
14
+ date: 2011-06-29 00:00:00 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rake
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: rack
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: hpricot
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: builder
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: rdiscount
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: maruku
73
+ requirement: &id006 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ type: :runtime
80
+ prerelease: false
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: guard
84
+ requirement: &id007 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: "0"
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: *id007
93
+ - !ruby/object:Gem::Dependency
94
+ name: guard-bundler
95
+ requirement: &id008 !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: "0"
101
+ type: :development
102
+ prerelease: false
103
+ version_requirements: *id008
104
+ - !ruby/object:Gem::Dependency
105
+ name: guard-test
106
+ requirement: &id009 !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: "0"
112
+ type: :development
113
+ prerelease: false
114
+ version_requirements: *id009
115
+ - !ruby/object:Gem::Dependency
116
+ name: riot
117
+ requirement: &id010 !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: "0"
123
+ type: :development
124
+ prerelease: false
125
+ version_requirements: *id010
126
+ - !ruby/object:Gem::Dependency
127
+ name: jeweler
128
+ requirement: &id011 !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: "0"
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: *id011
137
+ - !ruby/object:Gem::Dependency
138
+ name: riot
139
+ requirement: &id012 !ruby/object:Gem::Requirement
140
+ none: false
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: "0"
145
+ type: :development
146
+ prerelease: false
147
+ version_requirements: *id012
148
+ - !ruby/object:Gem::Dependency
149
+ name: builder
150
+ requirement: &id013 !ruby/object:Gem::Requirement
151
+ none: false
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: "0"
156
+ type: :runtime
157
+ prerelease: false
158
+ version_requirements: *id013
159
+ - !ruby/object:Gem::Dependency
160
+ name: rack
161
+ requirement: &id014 !ruby/object:Gem::Requirement
162
+ none: false
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: "0"
167
+ type: :runtime
168
+ prerelease: false
169
+ version_requirements: *id014
170
+ - !ruby/object:Gem::Dependency
171
+ name: rdiscount
172
+ requirement: &id015 !ruby/object:Gem::Requirement
173
+ none: false
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: "0"
178
+ type: :runtime
179
+ prerelease: false
180
+ version_requirements: *id015
181
+ description: A ruby and rack based blog engine for heroku
182
+ email: james@rubyloves.me
183
+ executables: []
184
+
185
+ extensions: []
186
+
187
+ extra_rdoc_files:
188
+ - LICENSE
189
+ - README.md
190
+ - TODO
191
+ files:
192
+ - .rvmrc
193
+ - Gemfile
194
+ - Gemfile.lock
195
+ - Guardfile
196
+ - LICENSE
197
+ - README.md
198
+ - Rakefile
199
+ - VERSION
200
+ - lib/ext/ext.rb
201
+ - lib/ruby_slippers.rb
202
+ - lib/ruby_slippers/app.rb
203
+ - lib/ruby_slippers/archives.rb
204
+ - lib/ruby_slippers/article.rb
205
+ - lib/ruby_slippers/config.rb
206
+ - lib/ruby_slippers/context.rb
207
+ - lib/ruby_slippers/engine.rb
208
+ - lib/ruby_slippers/repo.rb
209
+ - lib/ruby_slippers/site.rb
210
+ - lib/ruby_slippers/template.rb
211
+ - lib/tasks/gemspec.rake
212
+ - lib/tasks/test.rake
213
+ - test/fixtures/articles/2010-05-17-the-wonderful-wizard-of-oz.txt
214
+ - test/fixtures/articles/2010-05-18-the-marvelous-land-of-oz.txt
215
+ - test/fixtures/articles/2010-05-20-dorothy-and-the-wizard-of-oz.txt
216
+ - test/fixtures/articles/2011-05-18-ozma-of-oz.txt
217
+ - test/fixtures/images/ozma.png
218
+ - test/fixtures/pages/about.html.erb
219
+ - test/fixtures/pages/archives.html.erb
220
+ - test/fixtures/pages/article.html.erb
221
+ - test/fixtures/pages/index.html.erb
222
+ - test/fixtures/pages/sitemap.html.erb
223
+ - test/fixtures/pages/tagged.html.erb
224
+ - test/fixtures/templates/index.builder
225
+ - test/fixtures/templates/layout.html.erb
226
+ - test/fixtures/templates/repo.html.erb
227
+ - test/fixtures/templates/sitemap.builder
228
+ - test/integration/about_test.rb
229
+ - test/integration/archives_test.rb
230
+ - test/integration/articles_test.rb
231
+ - test/integration/atom_test.rb
232
+ - test/integration/invalid_route_test.rb
233
+ - test/integration/tags_test.rb
234
+ - test/support/test_helper.rb
235
+ - test/unit/app_test.rb
236
+ - test/unit/archives_test.rb
237
+ - test/unit/article_test.rb
238
+ - test/unit/date_patch_test.rb
239
+ - test/unit/engine_test.rb
240
+ - test/unit/site_test.rb
241
+ - TODO
242
+ homepage: http://github.com/dreamr/ruby_slippers
243
+ licenses: []
244
+
245
+ post_install_message:
246
+ rdoc_options: []
247
+
248
+ require_paths:
249
+ - lib
250
+ required_ruby_version: !ruby/object:Gem::Requirement
251
+ none: false
252
+ requirements:
253
+ - - ">="
254
+ - !ruby/object:Gem::Version
255
+ version: "0"
256
+ required_rubygems_version: !ruby/object:Gem::Requirement
257
+ none: false
258
+ requirements:
259
+ - - ">="
260
+ - !ruby/object:Gem::Version
261
+ version: "0"
262
+ requirements: []
263
+
264
+ rubyforge_project:
265
+ rubygems_version: 1.7.2
266
+ signing_key:
267
+ specification_version: 3
268
+ summary: the smartest blog-engine in all of Oz
269
+ test_files: []
270
+