hackety_sling 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 148a5cee29c169c17d8a2c85a2171273e27d885af0354dd72dda8f07b9168ae8
4
+ data.tar.gz: f67df9aa1312ac1738b73e3c77d9a8c6a806bf8d27b48c37ea071de0bd415a08
5
+ SHA512:
6
+ metadata.gz: 0b5fd361da1b5191af6f9d779736ffa9044ab5517a1f7fe1173aa9eb055218f285267017fa7f2c14db63cc95e91ff784f4261307b699ba32c9982560b5049df9
7
+ data.tar.gz: da9aa15e248076a4fdee6f1ccf9c213e815a846ae5af49eece3aefa9c1031bc599f680d82343b5449538f3626697aee745b7823b10f7fe06d8808f21b1439174
data/.travis.yml CHANGED
@@ -1,3 +1,4 @@
1
1
  script: "bundle exec rake"
2
2
  rvm:
3
3
  - 1.9.2
4
+ - 1.9.3
data/README.md CHANGED
@@ -24,7 +24,7 @@ class MySuperBlog < Sinatra::Base
24
24
 
25
25
 
26
26
  # Optional
27
- set :hackety_sling_posts_on_index
27
+ set :hackety_sling_posts_on_index, 2
28
28
 
29
29
  get '/other-sinatra-page/' do
30
30
  erubis :other_sinatra_page
@@ -16,7 +16,6 @@ Gem::Specification.new do |s|
16
16
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
17
  s.require_paths = ['lib']
18
18
  s.add_dependency 'document_mapper'
19
- s.add_dependency 'erubis'
20
19
  s.add_dependency 'sinatra'
21
20
  s.add_dependency 'ratom'
22
21
  s.add_development_dependency 'rack-test'
@@ -1,5 +1,5 @@
1
1
  module Sinatra
2
2
  module HacketySling
3
- VERSION = '0.0.4'
3
+ VERSION = '0.1.0'
4
4
  end
5
5
  end
@@ -16,13 +16,13 @@ module Sinatra
16
16
  erb :index
17
17
  end
18
18
 
19
- app.get '/archive/' do
20
- @posts = Post.order_by(:date => :asc).all
19
+ app.get '/archive/?' do
20
+ @posts = Post.order_by(:date => :desc).all
21
21
  erb :post_list
22
22
  end
23
23
 
24
24
  %w(tags author).each do |attribute|
25
- app.get "/#{attribute}/:value/" do |value|
25
+ app.get "/#{attribute}/:value/?" do |value|
26
26
  @posts = Post.order_by(:date => :desc)
27
27
  @posts = @posts.where(attribute.to_sym.include => value).all
28
28
  erb :posts
@@ -30,18 +30,18 @@ module Sinatra
30
30
  end
31
31
 
32
32
  Post.all.each do |post|
33
- app.get post.permalink do
33
+ app.get "#{post.permalink}?" do
34
34
  @post = post
35
35
  erb :post
36
36
  end
37
- base_name = post.file_name_without_extension.sub(/^\d{4}-\d{2}-\d{2}-/, '')
38
- app.get "/#{base_name}/" do
37
+ base_name = post.file_name_without_extension.sub(/\d{4}-\d{2}-\d{2}-/, '')
38
+ app.get "/#{base_name}/?" do
39
39
  redirect post.permalink, 301
40
40
  end
41
41
  end
42
42
 
43
43
  ymd = [:year, :month, :day]
44
- app.get %r{^/(\d{4}/)(\d{2}/)?(\d{2}/)?$} do
44
+ app.get %r{/(\d{4}/?)(\d{2}/?)?(\d{2}/?)?} do
45
45
  selector_hash = {}
46
46
  params[:captures].each_with_index do |date_part, index|
47
47
  selector_hash[ymd[index]] = date_part.to_i unless date_part.nil?
@@ -23,95 +23,72 @@ describe TestApp do
23
23
  end
24
24
 
25
25
  describe 'when requesting the index path' do
26
- it 'should request the 2 most current posts by default' do
26
+ it 'displays the 2 most current posts by default' do
27
27
  get '/'
28
28
  assert last_response.ok?
29
- refute last_response.body.include? @post_titles[0]
30
- refute last_response.body.include? @post_titles[1]
31
- assert last_response.body.include? @post_titles[2]
32
- assert last_response.body.include? @post_titles[3]
29
+ assert_equal ['Test post 4', 'Test post 3'], post_titles
33
30
  end
34
31
 
35
- it 'the number of posts should be configurable' do
32
+ it 'the number of posts is configurable' do
36
33
  app.set :hackety_sling_posts_on_index, 3
37
34
  get '/'
35
+ app.set :hackety_sling_posts_on_index, 2 # set back to original value
38
36
  assert last_response.ok?
39
- refute last_response.body.include? @post_titles[0]
40
- assert last_response.body.include? @post_titles[1]
41
- assert last_response.body.include? @post_titles[2]
42
- assert last_response.body.include? @post_titles[3]
37
+ assert_equal ['Test post 4', 'Test post 3', 'Test post 2'], post_titles
43
38
  end
44
39
  end
45
40
 
46
41
  describe 'when requesting posts by time' do
47
- it 'should show all posts of one year' do
42
+ it 'shows all posts of one year' do
48
43
  get '/2010/'
49
44
  assert last_response.ok?
50
- assert last_response.body.include? @post_titles[0]
51
- assert last_response.body.include? @post_titles[1]
52
- assert last_response.body.include? @post_titles[2]
53
- refute last_response.body.include? @post_titles[3]
45
+ assert_equal ['Test post 3', 'Test post 2', 'Test post 1'], post_titles
54
46
  end
55
47
 
56
- it 'should show all posts of one month' do
48
+ it 'shows all posts of one month' do
57
49
  get '/2010/11/'
58
50
  assert last_response.ok?
59
- refute last_response.body.include? @post_titles[0]
60
- refute last_response.body.include? @post_titles[1]
61
- assert last_response.body.include? @post_titles[2]
62
- refute last_response.body.include? @post_titles[3]
51
+ assert_equal ['Test post 3'], post_titles
63
52
  end
64
53
 
65
- it 'should show all posts of one day' do
54
+ it 'shows all posts of one day' do
66
55
  get '/2010/08/10/'
67
56
  assert last_response.ok?
68
- refute last_response.body.include? @post_titles[0]
69
- assert last_response.body.include? @post_titles[1]
70
- refute last_response.body.include? @post_titles[2]
71
- refute last_response.body.include? @post_titles[3]
57
+ assert_equal ['Test post 2'], post_titles
72
58
  end
73
59
  end
74
60
 
75
61
  describe 'when requesting a certain blog post' do
76
- it 'should show the blog post' do
62
+ it 'shows the blog post' do
77
63
  get '/2010/11/13/test-post-3/'
78
64
  assert last_response.ok?
79
- refute last_response.body.include? @post_titles[0]
80
- refute last_response.body.include? @post_titles[1]
81
- assert last_response.body.include? @post_titles[2]
82
- refute last_response.body.include? @post_titles[3]
65
+ assert_equal ['Test post 3'], post_titles
83
66
  end
84
67
 
85
- it 'should redirect to the url with date if only the slug was given' do
68
+ it 'redirects to the url with date if only the slug was given' do
86
69
  get '/test-post-2/'
87
70
  assert_redirected_to '/2010/08/10/test-post-2/', 301
88
71
  end
89
72
  end
90
73
 
91
74
  describe 'when requesting posts by tag' do
92
- it 'should show all posts with a certain tag' do
75
+ it 'shows all posts with a certain tag' do
93
76
  get '/tags/ruby/'
94
77
  assert last_response.ok?
95
- assert last_response.body.include? @post_titles[0]
96
- assert last_response.body.include? @post_titles[1]
97
- refute last_response.body.include? @post_titles[2]
98
- refute last_response.body.include? @post_titles[3]
78
+ assert_equal ['Test post 2', 'Test post 1'], post_titles
99
79
  end
100
80
  end
101
81
 
102
82
  describe 'when requesting posts by author' do
103
- it 'should show all posts with a certain author' do
83
+ it 'shows all posts with a certain author' do
104
84
  get '/author/ralph/'
105
85
  assert last_response.ok?
106
- refute last_response.body.include? @post_titles[0]
107
- refute last_response.body.include? @post_titles[1]
108
- assert last_response.body.include? @post_titles[2]
109
- refute last_response.body.include? @post_titles[3]
86
+ assert_equal ['Test post 3'], post_titles
110
87
  end
111
88
  end
112
89
 
113
90
  describe 'when requesting the archive page' do
114
- it 'should respond to the archive path' do
91
+ it 'responds to the archive path' do
115
92
  get '/archive/'
116
93
  assert last_response.ok?
117
94
  @post_titles.each do |post_title|
@@ -121,7 +98,7 @@ describe TestApp do
121
98
  end
122
99
 
123
100
  describe 'the atom feed' do
124
- it 'should be generated ok' do
101
+ it 'is generated ok' do
125
102
  get '/atom.xml'
126
103
  assert last_response.ok?
127
104
  end
@@ -138,5 +115,8 @@ describe TestApp do
138
115
  assert status == last_response.status, status_msg
139
116
  assert (path == redirect_url || url(path) == redirect_url), location_msg
140
117
  end
141
- end
142
118
 
119
+ def post_titles
120
+ last_response.body.scan(/Test post \d/)
121
+ end
122
+ end
data/test/post_test.rb CHANGED
@@ -9,11 +9,11 @@ require 'sinatra/hackety_sling/post'
9
9
  include Sinatra::HacketySling
10
10
 
11
11
  describe Post do
12
- it 'should return the correct date permalink' do
12
+ it 'returns the correct date permalink' do
13
13
  assert_equal '/2010/08/09/', Post.order_by(:title => :asc).first.date_permalink
14
14
  end
15
15
 
16
- it 'should return the correct permalink' do
16
+ it 'returns the correct permalink' do
17
17
  assert_equal '/2010/08/09/test-post-1/', Post.order_by(:title => :asc).first.permalink
18
18
  end
19
19
  end
metadata CHANGED
@@ -1,82 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hackety_sling
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
5
- prerelease:
4
+ version: 0.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ralph von der Heyden
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2011-10-20 00:00:00.000000000Z
11
+ date: 2022-07-28 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: document_mapper
16
- requirement: &70301858857940 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *70301858857940
25
- - !ruby/object:Gem::Dependency
26
- name: erubis
27
- requirement: &70301858857080 !ruby/object:Gem::Requirement
28
- none: false
22
+ version_requirements: !ruby/object:Gem::Requirement
29
23
  requirements:
30
- - - ! '>='
24
+ - - ">="
31
25
  - !ruby/object:Gem::Version
32
26
  version: '0'
33
- type: :runtime
34
- prerelease: false
35
- version_requirements: *70301858857080
36
27
  - !ruby/object:Gem::Dependency
37
28
  name: sinatra
38
- requirement: &70301858855940 !ruby/object:Gem::Requirement
39
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
40
30
  requirements:
41
- - - ! '>='
31
+ - - ">="
42
32
  - !ruby/object:Gem::Version
43
33
  version: '0'
44
34
  type: :runtime
45
35
  prerelease: false
46
- version_requirements: *70301858855940
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: ratom
49
- requirement: &70301858854820 !ruby/object:Gem::Requirement
50
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
51
44
  requirements:
52
- - - ! '>='
45
+ - - ">="
53
46
  - !ruby/object:Gem::Version
54
47
  version: '0'
55
48
  type: :runtime
56
49
  prerelease: false
57
- version_requirements: *70301858854820
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
58
55
  - !ruby/object:Gem::Dependency
59
56
  name: rack-test
60
- requirement: &70301858852940 !ruby/object:Gem::Requirement
61
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
62
58
  requirements:
63
- - - ! '>='
59
+ - - ">="
64
60
  - !ruby/object:Gem::Version
65
61
  version: '0'
66
62
  type: :development
67
63
  prerelease: false
68
- version_requirements: *70301858852940
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: RedCloth
71
- requirement: &70301858851920 !ruby/object:Gem::Requirement
72
- none: false
71
+ requirement: !ruby/object:Gem::Requirement
73
72
  requirements:
74
- - - ! '>='
73
+ - - ">="
75
74
  - !ruby/object:Gem::Version
76
75
  version: '0'
77
76
  type: :development
78
77
  prerelease: false
79
- version_requirements: *70301858851920
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
80
83
  description: A simple blog engine based on Sinatra and document_mapper
81
84
  email:
82
85
  - ralph@rvdh.de
@@ -84,8 +87,8 @@ executables: []
84
87
  extensions: []
85
88
  extra_rdoc_files: []
86
89
  files:
87
- - .gitignore
88
- - .travis.yml
90
+ - ".gitignore"
91
+ - ".travis.yml"
89
92
  - Gemfile
90
93
  - README.md
91
94
  - Rakefile
@@ -106,33 +109,25 @@ files:
106
109
  - views/posts.erb
107
110
  homepage: http://rvdh.de
108
111
  licenses: []
112
+ metadata: {}
109
113
  post_install_message:
110
114
  rdoc_options: []
111
115
  require_paths:
112
116
  - lib
113
117
  required_ruby_version: !ruby/object:Gem::Requirement
114
- none: false
115
118
  requirements:
116
- - - ! '>='
119
+ - - ">="
117
120
  - !ruby/object:Gem::Version
118
121
  version: '0'
119
- segments:
120
- - 0
121
- hash: -4069875926690539564
122
122
  required_rubygems_version: !ruby/object:Gem::Requirement
123
- none: false
124
123
  requirements:
125
- - - ! '>='
124
+ - - ">="
126
125
  - !ruby/object:Gem::Version
127
126
  version: '0'
128
- segments:
129
- - 0
130
- hash: -4069875926690539564
131
127
  requirements: []
132
- rubyforge_project:
133
- rubygems_version: 1.8.10
128
+ rubygems_version: 3.1.6
134
129
  signing_key:
135
- specification_version: 3
130
+ specification_version: 4
136
131
  summary: A simple blog engine based on Sinatra and document_mapper
137
132
  test_files:
138
133
  - test/hackety_sling_test.rb