serious 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ script: "bundle exec rake test"
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - ree
6
+ - 1.9.3
@@ -33,6 +33,9 @@ the processing chain to your liking, add custom ERb helpers and so on. See the d
33
33
  stupid_formatter (http://rdoc.info/projects/colszowka/stupid_formatter) to learn how to
34
34
  customize the formatting.
35
35
 
36
+ Articles with a date in the future will not appear on the site, thus allowing you to prepare article
37
+ that should be published later.
38
+
36
39
  == Getting started
37
40
 
38
41
  Install the gem:
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ end
11
11
 
12
12
  task :default => :test
13
13
 
14
- require 'rake/rdoctask'
14
+ require 'rdoc/task'
15
15
  Rake::RDocTask.new do |rdoc|
16
16
  rdoc.rdoc_dir = 'rdoc'
17
17
  rdoc.rdoc_files.include('README*')
@@ -18,6 +18,7 @@ class Serious < Sinatra::Base
18
18
  set :articles, Proc.new { File.join(Dir.getwd, 'articles') }
19
19
  set :pages, Proc.new { File.join(Dir.getwd, 'pages') }
20
20
  set :static, true # Required to serve static files, see http://www.sinatrarb.com/configuration.html
21
+ set :future, false
21
22
 
22
23
  not_found do
23
24
  erb :"404"
@@ -106,5 +107,4 @@ Serious.set :environment, :test
106
107
  Serious.set :date_format, "%B %o %Y"
107
108
  Serious.set :disqus, false
108
109
  Serious.set :google_analytics, false
109
- Serious.set :feed_url, '/atom.xml'
110
-
110
+ Serious.set :feed_url, '/atom.xml'
@@ -13,9 +13,15 @@ class Serious::Article
13
13
  #
14
14
  def all(options={})
15
15
  options = {:limit => 10000, :offset => 0}.merge(options)
16
- (article_paths[options[:offset]...options[:limit]+options[:offset]] || []).map {|article_path| new(article_path) }
16
+ now = DateTime.now
17
+ articles = article_paths.map do |article_path|
18
+ article = new(article_path)
19
+ article if article && (Serious.future || article.date <= now)
20
+ end.compact[options[:offset]...options[:limit]+options[:offset]]
21
+
22
+ articles || []
17
23
  end
18
-
24
+
19
25
  #
20
26
  # Retrieves the article(s) for the given arguments. The arguments must be part of the filename.
21
27
  # You can give any combination, but the arguments must appear in the same order as given in the
@@ -26,7 +32,11 @@ class Serious::Article
26
32
  def find(*args)
27
33
  # Reformat arguments (one-digit months and days should be converted to two-digit format)
28
34
  args = args.map {|a| a.to_s =~ /^\d{1}$/ ? "%02d" % a : a }
29
- articles = article_paths.select {|path| File.basename(path) =~ /#{args.join('-')}/i }.map {|path| new(path) }
35
+ now = DateTime.now
36
+ articles = article_paths.select {|path| File.basename(path) =~ /#{args.join('-')}/i }.map do |path|
37
+ article = new(path)
38
+ article if article && (Serious.future || article.date <= now)
39
+ end.compact
30
40
  end
31
41
 
32
42
  #
@@ -1,8 +1,11 @@
1
1
  # encoding: utf-8
2
2
 
3
- # Swallow the actual run method from config.ru
3
+ # Swallow the actual run and use methods from config.ru so config can be fetched
4
+ # without NoMethodError...
4
5
  def run(*args)
5
6
  end
7
+ def use(*args)
8
+ end
6
9
 
7
10
  begin
8
11
  config = File.read('config.ru')
@@ -2,4 +2,4 @@
2
2
  # Serious::VERSION since Serious is a class that inherits from Sinatra::Base
3
3
  # and we'd be getting Superclass mismatch errors here since Sinatra is
4
4
  # unavailable when evaluating this file standalone...
5
- SERIOUS_VERSION = '0.3.1'
5
+ SERIOUS_VERSION = '0.3.2'
@@ -16,7 +16,6 @@ Gem::Specification.new do |s|
16
16
 
17
17
  s.bindir = 'bin'
18
18
  s.executables = ['serious']
19
- s.default_executable = 'serious'
20
19
 
21
20
  s.add_dependency 'sinatra', ">= 1.0.0"
22
21
  s.add_dependency 'stupid_formatter', '>= 0.2.0'
@@ -25,10 +24,12 @@ Gem::Specification.new do |s|
25
24
  s.add_development_dependency "shoulda", "2.10.3"
26
25
  s.add_development_dependency "hpricot", ">= 0.8.0"
27
26
  s.add_development_dependency "rack-test", ">= 0.5.0"
27
+ s.add_development_dependency "rake", ">= 0.8.7"
28
+ s.add_development_dependency "rdoc"
28
29
  s.add_development_dependency 'simplecov'
29
30
 
30
31
  s.files = `git ls-files`.split("\n")
31
32
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
32
33
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
33
34
  s.require_paths = ["lib"]
34
- end
35
+ end
@@ -0,0 +1,3 @@
1
+ title: We come in peace!
2
+
3
+ We got tied of waiting so we came to say hello
@@ -100,7 +100,8 @@ class Test::Unit::TestCase
100
100
 
101
101
  def self.should_contain(expect, item)
102
102
  should "contain #{expect}" do
103
- assert_match(/#{expect}/, item)
103
+ # expect = Regex.new(expect) unless expect.kind_of(Regex)
104
+ assert_match(expect, item)
104
105
  end
105
106
  end
106
107
 
@@ -130,4 +131,16 @@ class Test::Unit::TestCase
130
131
  Dir.chdir('..')
131
132
  end
132
133
  end
134
+
135
+ def serious(site_name="", arguments="", cache=true)
136
+ if cache
137
+ @cache ||= {}
138
+ return @cache[site_name] if @cache[site_name]
139
+ end
140
+
141
+ executable = File.expand_path('../../bin/serious', __FILE__)
142
+ output = `#{executable} #{site_name} #{arguments}`
143
+ @cache[site_name] = output if cache
144
+ output
145
+ end
133
146
  end
@@ -9,20 +9,20 @@ class TestArticle < Test::Unit::TestCase
9
9
  setup do
10
10
  @articles = Serious::Article.all
11
11
  end
12
-
12
+
13
13
  should("return 4 articles") { assert_equal 4, @articles.length }
14
14
  should "have only instances of Serious::Article in the collection" do
15
15
  assert @articles.all? {|a| a.instance_of?(Serious::Article) }
16
16
  end
17
-
17
+
18
18
  should "return an existing path for all articles" do
19
19
  assert @articles.all? {|a| File.exist? a.path }
20
20
  end
21
-
21
+
22
22
  should "have 2009-12-24 as the first article's date" do
23
23
  assert_equal Date.new(2009, 12, 24), @articles.first.date
24
24
  end
25
-
25
+
26
26
  should "have 2000-01-01 as the last article's date" do
27
27
  assert_equal Date.new(2000, 1, 1), @articles.last.date
28
28
  end
@@ -14,7 +14,7 @@ class TestBin < Test::Unit::TestCase
14
14
  FileUtils.mkdir('tmp') if not File.exist?('tmp')
15
15
  Dir.chdir('tmp')
16
16
  end
17
-
17
+
18
18
  when_running_serious_with '' do
19
19
  should_print "Usage: serious DIRNAME"
20
20
  should_print "Only lowercase letters and dashes"
@@ -73,9 +73,9 @@ class TestBin < Test::Unit::TestCase
73
73
  should_not_have_path 'public-included/views'
74
74
  should_have_file 'public-included/Gemfile'
75
75
  should_have_file 'public-included/config.ru' do |file|
76
- should_contain "Serious.set :public, File.join(Dir.getwd, 'public')"
77
- should_not_contain ":views"
78
- should_not_contain ":root"
76
+ should_contain "Serious.set :public, File.join\(Dir.getwd, 'public'\)", file
77
+ should_not_contain ":views", file
78
+ should_not_contain ":root", file
79
79
  end
80
80
  should_have_file "public-included/public/css/serious.css"
81
81
  should_have_file "public-included/public/css/application.css"
@@ -86,9 +86,9 @@ class TestBin < Test::Unit::TestCase
86
86
  should_not_have_path 'views-included/public'
87
87
  should_have_file 'views-included/Gemfile'
88
88
  should_have_file 'views-included/config.ru' do |file|
89
- should_contain "Serious.set :views, File.join(Dir.getwd, 'views')"
90
- should_not_contain ":public"
91
- should_not_contain ":root"
89
+ should_contain "Serious.set :views, File.join\(Dir.getwd, 'views'\)", file
90
+ should_not_contain ":public", file
91
+ should_not_contain ":root", file
92
92
  end
93
93
  should_have_file "views-included/views/layout.erb"
94
94
  end
@@ -97,9 +97,9 @@ class TestBin < Test::Unit::TestCase
97
97
  should_have_dir 'views-and-public/articles'
98
98
  should_have_file 'views-and-public/Gemfile'
99
99
  should_have_file 'views-and-public/config.ru' do |file|
100
- should_contain "Serious.set :root, Dir.getwd"
101
- should_not_contain ":public"
102
- should_not_contain ":views"
100
+ should_contain "Serious.set :root, Dir.getwd", file
101
+ should_not_contain ":public", file
102
+ should_not_contain ":views", file
103
103
  end
104
104
  should_have_file "views-and-public/public/css/serious.css"
105
105
  should_have_file "views-and-public/public/css/application.css"
@@ -118,20 +118,8 @@ class TestBin < Test::Unit::TestCase
118
118
  # Run this only once...
119
119
  context "zzz" do
120
120
  should "remove tmp at the end" do
121
- FileUtils.rm_rf File.expand_path(File.join(File.dirname(__FILE__), 'tmp'))
122
- end
123
- end
124
-
125
- def serious(site_name="", arguments="", cache=true)
126
- if cache
127
- @cache ||= {}
128
- return @cache[site_name] if @cache[site_name]
121
+ FileUtils.rm_rf File.expand_path('../tmp', __FILE__)
129
122
  end
130
-
131
- executable = File.expand_path(File.join(File.dirname(__FILE__), '..', '../../bin/serious'))
132
- output = `#{executable} #{site_name} #{arguments}`
133
- @cache[site_name] = output if cache
134
- output
135
123
  end
136
124
 
137
125
  end
@@ -179,7 +179,31 @@ class TestSerious < Test::Unit::TestCase
179
179
  should_contain_text "The requested page could not be found!", "#container h2:first"
180
180
  should_not_contain_text "Well we were born within one hour of each other.", ".article .body"
181
181
  end
182
-
182
+
183
+ context "Get /3010/04/20/we-come-in-peace" do
184
+ setup do
185
+ app.set :future, false
186
+ get '/3010/04/20/we-come-in-peace'
187
+ end
188
+
189
+ should_respond_with 404
190
+ should_set_cache_control_to 300
191
+ should_contain_text "The requested page could not be found!", "#container h2:first"
192
+ should_not_contain_text "We got tied of waiting so we came to say hello", ".article .body"
193
+ end
194
+
195
+ context "Get /3010/04/20/we-come-in-peace" do
196
+ setup do
197
+ app.set :future, true
198
+ get '/3010/04/20/we-come-in-peace'
199
+ end
200
+
201
+ should_respond_with 200
202
+ should_set_cache_control_to 300
203
+ should_contain_text "We come in peace!", "#container h2:first"
204
+ should_contain_text "We got tied of waiting so we came to say hello", ".article .body"
205
+ end
206
+
183
207
  # ===================================================================
184
208
  # Tests for the public folder
185
209
  # ===================================================================
metadata CHANGED
@@ -1,146 +1,128 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: serious
3
- version: !ruby/object:Gem::Version
4
- hash: 17
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.2
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 3
9
- - 1
10
- version: 0.3.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Christoph Olszowka
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-02-09 00:00:00 +01:00
19
- default_executable: serious
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2011-08-06 00:00:00.000000000 +02:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
22
16
  name: sinatra
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &70321852676300 !ruby/object:Gem::Requirement
25
18
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 23
30
- segments:
31
- - 1
32
- - 0
33
- - 0
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
34
22
  version: 1.0.0
35
23
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: stupid_formatter
39
24
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *70321852676300
26
+ - !ruby/object:Gem::Dependency
27
+ name: stupid_formatter
28
+ requirement: &70321852675780 !ruby/object:Gem::Requirement
41
29
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 23
46
- segments:
47
- - 0
48
- - 2
49
- - 0
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
50
33
  version: 0.2.0
51
34
  type: :runtime
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: builder
55
35
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
36
+ version_requirements: *70321852675780
37
+ - !ruby/object:Gem::Dependency
38
+ name: builder
39
+ requirement: &70321852675300 !ruby/object:Gem::Requirement
57
40
  none: false
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- hash: 15
62
- segments:
63
- - 2
64
- - 1
65
- - 2
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
66
44
  version: 2.1.2
67
45
  type: :runtime
68
- version_requirements: *id003
69
- - !ruby/object:Gem::Dependency
70
- name: shoulda
71
46
  prerelease: false
72
- requirement: &id004 !ruby/object:Gem::Requirement
47
+ version_requirements: *70321852675300
48
+ - !ruby/object:Gem::Dependency
49
+ name: shoulda
50
+ requirement: &70321852674820 !ruby/object:Gem::Requirement
73
51
  none: false
74
- requirements:
75
- - - "="
76
- - !ruby/object:Gem::Version
77
- hash: 33
78
- segments:
79
- - 2
80
- - 10
81
- - 3
52
+ requirements:
53
+ - - =
54
+ - !ruby/object:Gem::Version
82
55
  version: 2.10.3
83
56
  type: :development
84
- version_requirements: *id004
85
- - !ruby/object:Gem::Dependency
86
- name: hpricot
87
57
  prerelease: false
88
- requirement: &id005 !ruby/object:Gem::Requirement
58
+ version_requirements: *70321852674820
59
+ - !ruby/object:Gem::Dependency
60
+ name: hpricot
61
+ requirement: &70321852674360 !ruby/object:Gem::Requirement
89
62
  none: false
90
- requirements:
91
- - - ">="
92
- - !ruby/object:Gem::Version
93
- hash: 63
94
- segments:
95
- - 0
96
- - 8
97
- - 0
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
98
66
  version: 0.8.0
99
67
  type: :development
100
- version_requirements: *id005
101
- - !ruby/object:Gem::Dependency
102
- name: rack-test
103
68
  prerelease: false
104
- requirement: &id006 !ruby/object:Gem::Requirement
69
+ version_requirements: *70321852674360
70
+ - !ruby/object:Gem::Dependency
71
+ name: rack-test
72
+ requirement: &70321852673900 !ruby/object:Gem::Requirement
105
73
  none: false
106
- requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- hash: 11
110
- segments:
111
- - 0
112
- - 5
113
- - 0
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
114
77
  version: 0.5.0
115
78
  type: :development
116
- version_requirements: *id006
117
- - !ruby/object:Gem::Dependency
118
- name: simplecov
119
79
  prerelease: false
120
- requirement: &id007 !ruby/object:Gem::Requirement
80
+ version_requirements: *70321852673900
81
+ - !ruby/object:Gem::Dependency
82
+ name: rake
83
+ requirement: &70321852673440 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: 0.8.7
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: *70321852673440
92
+ - !ruby/object:Gem::Dependency
93
+ name: rdoc
94
+ requirement: &70321852673020 !ruby/object:Gem::Requirement
121
95
  none: false
122
- requirements:
123
- - - ">="
124
- - !ruby/object:Gem::Version
125
- hash: 3
126
- segments:
127
- - 0
128
- version: "0"
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
129
100
  type: :development
130
- version_requirements: *id007
131
- description: Serious is a simple, file-driven blog engine inspired by toto and driven by sinatra with an emphasis on easy setup
132
- email:
101
+ prerelease: false
102
+ version_requirements: *70321852673020
103
+ - !ruby/object:Gem::Dependency
104
+ name: simplecov
105
+ requirement: &70321852672520 !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ type: :development
112
+ prerelease: false
113
+ version_requirements: *70321852672520
114
+ description: Serious is a simple, file-driven blog engine inspired by toto and driven
115
+ by sinatra with an emphasis on easy setup
116
+ email:
133
117
  - christoph at olszowka de
134
- executables:
118
+ executables:
135
119
  - serious
136
120
  extensions: []
137
-
138
121
  extra_rdoc_files: []
139
-
140
- files:
122
+ files:
141
123
  - .document
142
124
  - .gitignore
143
- - CHANGELOG.rdoc
125
+ - .travis.yml
144
126
  - Gemfile
145
127
  - LICENSE
146
128
  - README.rdoc
@@ -169,6 +151,7 @@ files:
169
151
  - test/articles/2009-04-01-foo-bar.txt
170
152
  - test/articles/2009-12-11-ruby-is-the-shit.txt
171
153
  - test/articles/2009-12-24-merry-christmas.txt
154
+ - test/articles/3010-04-20-we-come-in-peace.txt
172
155
  - test/helper.rb
173
156
  - test/pages/about.txt
174
157
  - test/pages/foo-bar.txt
@@ -180,42 +163,35 @@ files:
180
163
  has_rdoc: true
181
164
  homepage: https://github.com/colszowka/serious
182
165
  licenses: []
183
-
184
166
  post_install_message:
185
167
  rdoc_options: []
186
-
187
- require_paths:
168
+ require_paths:
188
169
  - lib
189
- required_ruby_version: !ruby/object:Gem::Requirement
170
+ required_ruby_version: !ruby/object:Gem::Requirement
190
171
  none: false
191
- requirements:
192
- - - ">="
193
- - !ruby/object:Gem::Version
194
- hash: 3
195
- segments:
196
- - 0
197
- version: "0"
198
- required_rubygems_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ! '>='
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ required_rubygems_version: !ruby/object:Gem::Requirement
199
177
  none: false
200
- requirements:
201
- - - ">="
202
- - !ruby/object:Gem::Version
203
- hash: 3
204
- segments:
205
- - 0
206
- version: "0"
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
207
182
  requirements: []
208
-
209
183
  rubyforge_project: serious
210
- rubygems_version: 1.4.1
184
+ rubygems_version: 1.6.2
211
185
  signing_key:
212
186
  specification_version: 3
213
- summary: Serious is a simple, file-driven blog engine inspired by toto and driven by sinatra with an emphasis on easy setup
214
- test_files:
187
+ summary: Serious is a simple, file-driven blog engine inspired by toto and driven
188
+ by sinatra with an emphasis on easy setup
189
+ test_files:
215
190
  - test/articles/2000-01-01-disco-2000.txt
216
191
  - test/articles/2009-04-01-foo-bar.txt
217
192
  - test/articles/2009-12-11-ruby-is-the-shit.txt
218
193
  - test/articles/2009-12-24-merry-christmas.txt
194
+ - test/articles/3010-04-20-we-come-in-peace.txt
219
195
  - test/helper.rb
220
196
  - test/pages/about.txt
221
197
  - test/pages/foo-bar.txt
@@ -1,10 +0,0 @@
1
- = Changelog for serious
2
- http://github.com/colszowka/serious
3
-
4
- == v0.3.0 (2010-08-17)
5
-
6
- * Fixed encoding issues with Ruby 1.9.1/1.9.2-rc2, added unit tests. Works on Heroku with Ruby 1.9.1 now (colszowka)
7
- * Made blog generator (serious command) use Heroku with Ruby 1.9.1 by default (when --heroku switch is active) (colszowka)
8
- * Use Bundler Gemfile instead of Heroku .gems file in blog generator (colszowka)
9
- * Use Bundler internally for easy development setup (git clone -> bundle install -> rake test) (colszowka)
10
- * Trailing slashes in article urls Regexp fixed (rb2k)