manveru-ramaze 2009.04 → 2009.04.01
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +0 -405
- data/MANIFEST +16 -16
- data/Rakefile +4 -24
- data/bin/ramaze +52 -275
- data/doc/tutorial/todolist.html +5 -83
- data/doc/tutorial/todolist.txt +33 -85
- data/examples/app/auth/layout/{auth.xhtml → auth.nag} +0 -0
- data/examples/app/auth/view/{index.xhtml → index.nag} +0 -0
- data/examples/app/auth/view/{login.xhtml → login.nag} +0 -0
- data/examples/app/auth/view/{secret.xhtml → secret.nag} +0 -0
- data/examples/app/blog/app.rb +1 -1
- data/examples/app/blog/controller/comment.rb +1 -1
- data/examples/app/blog/controller/entry.rb +3 -12
- data/examples/app/blog/model/init.rb +0 -5
- data/examples/app/blog/model/tag.rb +2 -2
- data/examples/app/blog/start.rb +1 -1
- data/examples/app/blog/view/entry/index.nag +3 -3
- data/examples/app/blog/view/feed.atom.nag +1 -1
- data/examples/app/blog/view/feed.rss.nag +1 -1
- data/examples/app/blog/view/index.nag +1 -1
- data/examples/app/blog/view/tag/index.nag +1 -1
- data/examples/app/todolist/model/init.rb +0 -3
- data/examples/app/wikore/spec/wikore.rb +6 -4
- data/examples/app/wikore/src/controller.rb +11 -9
- data/examples/app/wikore/src/model.rb +10 -7
- data/examples/app/wikore/start.rb +1 -1
- data/examples/app/wikore/{view → template}/index.xhtml +0 -0
- data/examples/helpers/provide.rb +23 -0
- data/examples/misc/rapp.rb +17 -28
- data/examples/templates/template_redcloth.rb +2 -2
- data/examples/templates/template_xslt.rb +48 -0
- data/examples/templates/view/external.xsl +57 -0
- data/lib/proto/config.ru +5 -4
- data/lib/proto/controller/init.rb +2 -2
- data/lib/proto/layout/{default.xhtml → default.nag} +0 -0
- data/lib/proto/spec/main.rb +8 -7
- data/lib/proto/start.rb +10 -6
- data/lib/proto/view/{index.xhtml → index.nag} +0 -0
- data/lib/proto/view/page.nag +27 -0
- data/lib/ramaze/app.rb +5 -5
- data/lib/ramaze/cache.rb +2 -3
- data/lib/ramaze/contrib/email.rb +0 -2
- data/lib/ramaze/contrib/sequel/create_join.rb +0 -1
- data/lib/ramaze/contrib/sequel/fill.rb +12 -0
- data/lib/ramaze/contrib/sequel/form_field.rb +4 -4
- data/lib/ramaze/contrib/sequel/image.rb +11 -9
- data/lib/ramaze/contrib/sequel/relation.rb +3 -17
- data/lib/ramaze/controller/default.rb +0 -5
- data/lib/ramaze/helper/cache.rb +8 -22
- data/lib/ramaze/helper/formatting.rb +0 -2
- data/lib/ramaze/helper/httpdigest.rb +1 -1
- data/lib/ramaze/helper/link.rb +5 -2
- data/lib/ramaze/helper/localize.rb +3 -13
- data/lib/ramaze/helper/paginate.rb +0 -1
- data/lib/ramaze/helper/partial.rb +10 -85
- data/lib/ramaze/helper.rb +16 -6
- data/lib/ramaze/request.rb +1 -22
- data/lib/ramaze/snippets/ramaze/deprecated.rb +1 -0
- data/lib/ramaze/snippets/string/each.rb +19 -0
- data/lib/ramaze/spec.rb +2 -9
- data/lib/ramaze/version.rb +1 -1
- data/lib/ramaze/view/haml.rb +0 -1
- data/lib/ramaze/view/liquid.rb +11 -45
- data/lib/ramaze/view/nagoro/render_partial.rb +9 -9
- data/lib/ramaze/view.rb +0 -4
- data/lib/ramaze.rb +0 -2
- data/ramaze.gemspec +12 -12
- data/spec/contrib/sequel/fill.rb +47 -0
- data/spec/examples/helpers/httpdigest.rb +67 -42
- data/spec/examples/templates/template_markaby.rb +1 -1
- data/spec/examples/templates/template_xslt.rb +10 -0
- data/spec/ramaze/dispatcher/file.rb +20 -22
- data/spec/ramaze/error.rb +1 -1
- data/spec/ramaze/helper/auth.rb +40 -29
- data/spec/ramaze/helper/cache.rb +3 -43
- data/spec/ramaze/helper/flash.rb +14 -10
- data/spec/ramaze/helper/httpdigest.rb +65 -47
- data/spec/ramaze/helper/localize.rb +9 -9
- data/spec/ramaze/helper/partial.rb +40 -0
- data/spec/ramaze/helper/sequel_form.rb +1 -1
- data/spec/ramaze/helper/simple_captcha.rb +13 -9
- data/spec/ramaze/helper/stack.rb +39 -31
- data/spec/ramaze/helper/user.rb +13 -15
- data/spec/ramaze/request.rb +0 -12
- data/tasks/bacon.rake +21 -38
- data/tasks/release.rake +22 -4
- metadata +24 -22
- data/lib/proto/app.rb +0 -15
- data/lib/ramaze/cache/localmemcache.rb +0 -56
- data/lib/ramaze/contrib/app_graph.rb +0 -64
- data/lib/ramaze/tool/create.rb +0 -48
- data/lib/ramaze/tool/project_creator.rb +0 -111
- data/spec/ramaze/cache/localmemcache.rb +0 -49
- data/tasks/setup.rake +0 -24
data/spec/ramaze/helper/flash.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
require 'spec/helper'
|
5
5
|
|
6
6
|
class SpecHelperFlash < Ramaze::Controller
|
7
|
-
map
|
7
|
+
map :/
|
8
8
|
helper :flash
|
9
9
|
trait :flashbox => "%key : %value"
|
10
10
|
|
@@ -23,19 +23,23 @@ class SpecHelperFlash < Ramaze::Controller
|
|
23
23
|
end
|
24
24
|
|
25
25
|
describe Ramaze::Helper::Flash do
|
26
|
-
behaves_like :
|
26
|
+
behaves_like :session
|
27
27
|
|
28
28
|
it 'displays a flashbox with one item' do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
session do |mock|
|
30
|
+
mock.get('/populate_one')
|
31
|
+
got = mock.get('/box')
|
32
|
+
got.status.should == 200
|
33
|
+
got.body.should == 'one : for starters'
|
34
|
+
end
|
33
35
|
end
|
34
36
|
|
35
37
|
it 'displays a flashbox with two items' do
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
session do |mock|
|
39
|
+
mock.get('/populate_two')
|
40
|
+
got = mock.get('/box')
|
41
|
+
got.status.should == 200
|
42
|
+
got.body.split("\n").sort.should == ['one : this one', 'two : and this']
|
43
|
+
end
|
40
44
|
end
|
41
45
|
end
|
@@ -26,7 +26,7 @@ class PlainTextController < Ramaze::Controller
|
|
26
26
|
|
27
27
|
protected
|
28
28
|
|
29
|
-
def httpdigest_lookup_plaintext_password
|
29
|
+
def httpdigest_lookup_plaintext_password username
|
30
30
|
username.reverse
|
31
31
|
end
|
32
32
|
end
|
@@ -48,67 +48,85 @@ class PasswordLookupController < Ramaze::Controller
|
|
48
48
|
end
|
49
49
|
|
50
50
|
describe Ramaze::Helper::HttpDigest do
|
51
|
-
|
52
|
-
behaves_like :mock
|
51
|
+
behaves_like :mock, :session
|
53
52
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
53
|
+
def auth_for(got, uri, username, password, qop_type = "auth")
|
54
|
+
authorization = Rack::Auth::Digest::Params.parse(got.headers['WWW-Authenticate'])
|
55
|
+
|
56
|
+
cnonce = Digest::MD5.hexdigest(rand.to_s)
|
57
|
+
nc = 1
|
58
|
+
nonce = authorization['nonce']
|
59
|
+
|
60
|
+
authorization['cnonce'] = cnonce
|
61
|
+
authorization['nc'] = nc
|
62
|
+
authorization['uri'] = uri
|
63
|
+
authorization['username'] = username
|
64
|
+
authorization['qop'] = qop_type
|
65
|
+
|
66
|
+
ha1 = Digest::MD5.hexdigest([username, REALM, password].join(':'))
|
67
|
+
a2 = ['GET',uri]
|
68
|
+
a2 << Digest::MD5.hexdigest('') if qop_type == "auth-int"
|
69
|
+
ha2 = Digest::MD5.hexdigest( a2.join(':') )
|
70
|
+
|
71
|
+
authorization['response'] = Digest::MD5.hexdigest([ha1, nonce, nc, cnonce, qop_type, ha2].join(':'))
|
72
|
+
|
73
|
+
"Digest #{authorization}"
|
74
|
+
end
|
75
|
+
|
76
|
+
def get_auth( uri, username, password, qop_type = "auth" )
|
77
|
+
got = nil
|
78
|
+
session do |mock|
|
79
|
+
got = mock.get( uri )
|
80
|
+
got.status.should == 401
|
81
|
+
got.body.should == 'Unauthorized'
|
82
|
+
got = mock.get( uri , 'HTTP_AUTHORIZATION' => auth_for(got, uri, username, password, qop_type ) )
|
83
|
+
end
|
84
|
+
got
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'sends out all the required header information' do
|
88
|
+
session do |mock|
|
89
|
+
got = mock.get('/authenticate')
|
90
|
+
authorization = Rack::Auth::Digest::Params.parse(got.headers['WWW-Authenticate'])
|
58
91
|
authorization["opaque"].should.not.be.empty
|
59
92
|
authorization["nonce"].should.not.be.empty
|
60
93
|
authorization["realm"].should == REALM
|
61
94
|
authorization["qop"].should == "auth,auth-int"
|
62
|
-
|
63
|
-
|
64
|
-
get '/authenticate'
|
65
|
-
last_response.headers.should.satisfy do |headers|
|
95
|
+
got = mock.get( '/authenticate' , 'HTTP_AUTHORIZATION' => auth_for(got, '/authenticate', 'foo', 'oof' ) )
|
96
|
+
got.headers.should.satisfy do |headers|
|
66
97
|
!headers.has_key?( "WWW-Authenticate" )
|
67
98
|
end
|
68
99
|
end
|
69
100
|
end
|
70
|
-
end
|
71
|
-
|
72
|
-
__END__
|
73
|
-
|
74
|
-
describe 'Digest authentication' do
|
75
|
-
behaves_like :mock
|
76
|
-
|
77
|
-
it 'authenticates a user with a block' do
|
78
|
-
digest_authorize 'foo', 'oof'
|
79
|
-
get '/authenticate'
|
80
|
-
last_response.status.should == 200
|
81
|
-
last_response.body.should == "Hello foo"
|
82
|
-
end
|
83
101
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
last_response.body.should == "Unauthorized"
|
89
|
-
end
|
102
|
+
it 'authenticates a user with a block' do
|
103
|
+
got = get_auth( '/authenticate', 'foo', 'oof' )
|
104
|
+
got.status.should == 200
|
105
|
+
got.body.should == "Hello foo"
|
90
106
|
end
|
91
107
|
|
92
|
-
|
93
|
-
|
108
|
+
it 'fails to authenticate an incorrect password with a block' do
|
109
|
+
got = get_auth( '/authenticate', 'foo', 'bar' )
|
110
|
+
got.status.should == 401
|
111
|
+
got.body.should == "Unauthorized"
|
112
|
+
end
|
94
113
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
114
|
+
it 'authenticates a user with a block using auth for a random given' do
|
115
|
+
got = get_auth( '/authenticate', 'foo', 'oof', 'some-random-non-existant-auth-type' )
|
116
|
+
got.status.should == 200
|
117
|
+
got.body.should == "Hello foo"
|
118
|
+
end
|
99
119
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
120
|
+
it 'authenticates a user with the plaintext method' do
|
121
|
+
got = get_auth( '/plaintext/authenticate', 'foo', 'oof' )
|
122
|
+
got.status.should == 200
|
123
|
+
got.body.should == "Hello foo"
|
124
|
+
end
|
105
125
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
last_response.body.should == "Unauthorized"
|
111
|
-
end
|
126
|
+
it 'fails to authenticate an incorrect password with the plaintext method' do
|
127
|
+
got = get_auth( '/plaintext/authenticate', 'foo', 'bar' )
|
128
|
+
got.status.should == 401
|
129
|
+
got.body.should == "Unauthorized"
|
112
130
|
end
|
113
131
|
|
114
132
|
it 'authenticates a user with the password lookup method' do
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# * Encoding: UTF-8
|
2
|
-
$KCODE = 'u' if
|
2
|
+
$KCODE = 'u' if //.respond_to?(:kcode)
|
3
3
|
require 'spec/helper'
|
4
4
|
spec_requires 'locale/tag', 'locale'
|
5
5
|
|
@@ -35,26 +35,26 @@ describe Ramaze::Helper::Localize do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
should 'override language by ?lang' do
|
38
|
-
get('
|
38
|
+
get('/?lang=de').body.should == 'de'
|
39
39
|
end
|
40
40
|
|
41
41
|
should 'override language by cookie' do
|
42
|
-
get('/',
|
42
|
+
get('/', 'HTTP_COOKIE' => 'lang=ja').body.should == 'ja'
|
43
43
|
end
|
44
44
|
|
45
45
|
should 'not fail if language is invalid' do
|
46
|
-
get('
|
46
|
+
get('/?lang=foobar').body.should == 'foobar'
|
47
47
|
end
|
48
48
|
|
49
49
|
should 'use dictionary to translate' do
|
50
50
|
get('/translate/one').body.should == 'one'
|
51
|
-
get('/translate/one
|
52
|
-
get('/translate/one
|
53
|
-
get('/translate/one
|
51
|
+
get('/translate/one?lang=en').body.should == 'one'
|
52
|
+
get('/translate/one?lang=ja').body.should == '一'
|
53
|
+
get('/translate/one?lang=de').body.should == 'eins'
|
54
54
|
end
|
55
55
|
|
56
56
|
it "falls back to default language if string wasn't found in dictionary" do
|
57
|
-
get('/translate/two
|
58
|
-
get('/translate/three
|
57
|
+
get('/translate/two?lang=ja').body.should == 'two'
|
58
|
+
get('/translate/three?lang=ja').body.should == '三'
|
59
59
|
end
|
60
60
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec/helper'
|
2
|
+
require 'ramaze/helper/partial'
|
3
|
+
|
4
|
+
class SpecHelperPartialMain < Ramaze::Controller
|
5
|
+
layout :layout
|
6
|
+
helper :partial
|
7
|
+
engine :Ezamar
|
8
|
+
map '/'
|
9
|
+
|
10
|
+
def layout
|
11
|
+
'[ #{@content} ]'
|
12
|
+
end
|
13
|
+
|
14
|
+
def entries
|
15
|
+
@entries = ['Hello', 'World']
|
16
|
+
|
17
|
+
'<?r @entries.each do |entry| ?>
|
18
|
+
#{SpecHelperPartialSub.partial_content(:entry, :entry => entry).inspect}
|
19
|
+
<?r end ?>'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class SpecHelperPartialSub < SpecHelperPartialMain
|
24
|
+
map '/sub'
|
25
|
+
|
26
|
+
def entry
|
27
|
+
@entry ||= 'Hello'
|
28
|
+
|
29
|
+
'Entry: #{@entry}'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'Ramaze::Helper::Partial' do
|
34
|
+
behaves_like :mock
|
35
|
+
|
36
|
+
it 'renders partial content' do
|
37
|
+
SpecHelperPartialSub.partial_content(:entry).should == 'Entry: Hello'
|
38
|
+
SpecHelperPartialSub.partial_content(:entry, :entry => 'foo').should == 'Entry: foo'
|
39
|
+
end
|
40
|
+
end
|
@@ -25,21 +25,25 @@ class SpecCustomCaptcha < SpecSimpleCaptcha
|
|
25
25
|
end
|
26
26
|
|
27
27
|
describe Ramaze::Helper::SimpleCaptcha do
|
28
|
-
behaves_like :
|
28
|
+
behaves_like :session
|
29
29
|
|
30
30
|
should 'ask question' do
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
session do |mock|
|
32
|
+
question = mock.get('/ask_question').body
|
33
|
+
question.should =~ /^\d+ [+-] \d+$/
|
34
34
|
|
35
|
-
|
36
|
-
|
35
|
+
lh, m, rh = question.split
|
36
|
+
answer = lh.to_i.send(m, rh.to_i)
|
37
37
|
|
38
|
-
|
38
|
+
mock.get("/answer_question/#{answer}").body.should == 'correct'
|
39
|
+
end
|
39
40
|
end
|
40
41
|
|
41
42
|
should 'ask custom question' do
|
42
|
-
|
43
|
-
|
43
|
+
session do |mock|
|
44
|
+
question = mock.get('/fish/ask_question')
|
45
|
+
question.body.should == 'the answer to everything'
|
46
|
+
mock.get('/fish/answer_question/42').body.should == 'correct'
|
47
|
+
end
|
44
48
|
end
|
45
49
|
end
|
data/spec/ramaze/helper/stack.rb
CHANGED
@@ -39,48 +39,56 @@ class SpecStackHelper < Ramaze::Controller
|
|
39
39
|
end
|
40
40
|
|
41
41
|
describe Ramaze::Helper::Stack do
|
42
|
-
behaves_like :
|
42
|
+
behaves_like :session
|
43
43
|
@uri = 'http://example.org'
|
44
44
|
|
45
45
|
should 'login directly' do
|
46
|
-
|
46
|
+
session do |mock|
|
47
|
+
mock.get('/secure').body.should == 'please login'
|
47
48
|
|
48
|
-
|
49
|
-
|
49
|
+
got = mock.get('/login')
|
50
|
+
got.status.should == 302
|
51
|
+
got['Location'].should == "#@uri/secure"
|
50
52
|
|
51
|
-
|
52
|
-
|
53
|
+
got = mock.get('/secure')
|
54
|
+
got.status.should == 200
|
55
|
+
got.body.should == 'secret content'
|
53
56
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
+
mock.get('/secure').body.should == 'secret content'
|
58
|
+
mock.get('/logout')
|
59
|
+
mock.get('/secure').body.should == 'please login'
|
60
|
+
end
|
57
61
|
end
|
58
62
|
|
59
63
|
should 'login via redirects' do
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
64
|
+
session do |mock|
|
65
|
+
got = mock.get('/logged_in_page')
|
66
|
+
got.status.should == 302
|
67
|
+
got['Location'].should == 'http://example.org/login'
|
68
|
+
|
69
|
+
got = mock.get('/login')
|
70
|
+
got.status.should == 302
|
71
|
+
got['Location'].should == 'http://example.org/logged_in_page'
|
72
|
+
|
73
|
+
got = mock.get('/logged_in_page')
|
74
|
+
got.status.should == 200
|
75
|
+
got.body.should == 'the logged in page'
|
76
|
+
end
|
71
77
|
end
|
72
78
|
|
73
79
|
should 'login with params via redirects' do
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
80
|
+
session do |mock|
|
81
|
+
got = mock.get('/logged_in_params?x=y')
|
82
|
+
got.status.should == 302
|
83
|
+
got['Location'].should == 'http://example.org/login'
|
84
|
+
|
85
|
+
got = mock.get('/login')
|
86
|
+
got.status.should == 302
|
87
|
+
got['Location'].should == 'http://example.org/logged_in_params?x=y'
|
88
|
+
|
89
|
+
got = mock.get('/logged_in_params?x=y')
|
90
|
+
got.status.should == 200
|
91
|
+
got.body.should == {'x' => 'y'}.inspect
|
92
|
+
end
|
85
93
|
end
|
86
94
|
end
|
data/spec/ramaze/helper/user.rb
CHANGED
@@ -23,10 +23,6 @@ class SpecUserHelper < Ramaze::Controller
|
|
23
23
|
user_login ? 'logged in' : 'failed login'
|
24
24
|
end
|
25
25
|
|
26
|
-
def logout
|
27
|
-
user_logout
|
28
|
-
end
|
29
|
-
|
30
26
|
def profile
|
31
27
|
user.profile
|
32
28
|
end
|
@@ -52,21 +48,23 @@ class SpecUserHelperCallback < SpecUserHelper
|
|
52
48
|
end
|
53
49
|
|
54
50
|
describe Ramaze::Helper::User do
|
55
|
-
behaves_like :
|
51
|
+
behaves_like :session
|
56
52
|
|
57
53
|
should 'login' do
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
54
|
+
session do |mock|
|
55
|
+
mock.get('/status').body.should == 'no'
|
56
|
+
mock.get('/login?name=arthur&password=42').body.should == 'logged in'
|
57
|
+
mock.get('/status').body.should == 'yes'
|
58
|
+
mock.get('/profile').body.should == MockSequelUser.new.profile
|
59
|
+
end
|
63
60
|
end
|
64
61
|
|
65
62
|
should 'login via the callback' do
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
63
|
+
session do |mock|
|
64
|
+
mock.get('/callback/status').body.should == 'no'
|
65
|
+
mock.get('/callback/login?name=arthur&password=42').body.should == 'logged in'
|
66
|
+
mock.get('/callback/status').body.should == 'yes'
|
67
|
+
mock.get('/callback/profile').body.should == MockSequelUser.new.profile
|
68
|
+
end
|
71
69
|
end
|
72
70
|
end
|
data/spec/ramaze/request.rb
CHANGED
@@ -46,16 +46,4 @@ describe 'Ramaze::Request' do
|
|
46
46
|
should 'provide #accept_charset' do
|
47
47
|
request(@env).accept_charset.should == 'UTF-8'
|
48
48
|
end
|
49
|
-
|
50
|
-
should 'properly parse requested locale' do
|
51
|
-
header = { "HTTP_ACCEPT_LANGUAGE" => "sv-se,sv;q=0.8,en-us;q=0.5,en;q=0.3" }
|
52
|
-
request(@env.merge(header)).accept_language_with_weight.should == [
|
53
|
-
['sv-se', 1.0], ['sv', 0.8], ['en-us', 0.5], ['en', 0.3]
|
54
|
-
]
|
55
|
-
|
56
|
-
header = { "HTTP_ACCEPT_LANGUAGE" => "nl-nl" }
|
57
|
-
request(@env.merge(header)).accept_language_with_weight.should == [
|
58
|
-
['nl-nl', 1.0]
|
59
|
-
]
|
60
|
-
end
|
61
49
|
end
|
data/tasks/bacon.rake
CHANGED
@@ -2,65 +2,48 @@ desc 'Run all bacon specs with pretty output'
|
|
2
2
|
task :bacon => :install_dependencies do
|
3
3
|
require 'open3'
|
4
4
|
require 'scanf'
|
5
|
-
require 'matrix'
|
6
5
|
|
7
6
|
specs = PROJECT_SPECS
|
8
7
|
|
9
8
|
some_failed = false
|
10
|
-
|
9
|
+
total = specs.size
|
11
10
|
len = specs.map{|s| s.size }.sort.last
|
12
|
-
|
13
|
-
totals = Vector[0, 0, 0, 0]
|
11
|
+
tt = ta = tf = te = 0
|
14
12
|
|
15
13
|
red, yellow, green = "\e[31m%s\e[0m", "\e[33m%s\e[0m", "\e[32m%s\e[0m"
|
16
14
|
left_format = "%4d/%d: %-#{len + 11}s"
|
17
15
|
spec_format = "%d specifications (%d requirements), %d failures, %d errors"
|
18
16
|
|
19
17
|
specs.each_with_index do |spec, idx|
|
20
|
-
print(left_format % [idx + 1,
|
18
|
+
print(left_format % [idx + 1, total, spec])
|
21
19
|
|
22
20
|
Open3.popen3(RUBY, spec) do |sin, sout, serr|
|
23
|
-
out = sout.read
|
24
|
-
err = serr.read
|
21
|
+
out = sout.read
|
22
|
+
err = serr.read
|
25
23
|
|
26
|
-
|
27
|
-
if out =~ /^Bacon::Error: (needed .*)/
|
28
|
-
puts(yellow % ("%6s %s" % ['', $1]))
|
29
|
-
else
|
30
|
-
total = nil
|
24
|
+
ran = false
|
31
25
|
|
32
|
-
|
33
|
-
|
26
|
+
out.each_line do |line|
|
27
|
+
tests, assertions, failures, errors = all = line.scanf(spec_format)
|
28
|
+
next unless all.any?
|
29
|
+
ran = true
|
30
|
+
tt += tests; ta += assertions; tf += failures; te += errors
|
34
31
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
if total
|
42
|
-
totals += total
|
43
|
-
tests, assertions, failures, errors = total_array = total.to_a
|
44
|
-
|
45
|
-
if tests > 0 && failures + errors == 0
|
46
|
-
puts((green % "%6d passed") % tests)
|
47
|
-
else
|
48
|
-
some_failed = true
|
49
|
-
puts(red % " failed")
|
50
|
-
puts out unless out.empty?
|
51
|
-
puts err unless err.empty?
|
52
|
-
end
|
32
|
+
if tests == 0 || failures + errors > 0
|
33
|
+
puts((red % spec_format) % all)
|
34
|
+
puts out
|
35
|
+
puts err
|
53
36
|
else
|
54
|
-
|
55
|
-
puts(red % " failed")
|
56
|
-
puts out unless out.empty?
|
57
|
-
puts err unless err.empty?
|
37
|
+
puts((green % "%6d passed") % tests)
|
58
38
|
end
|
39
|
+
|
40
|
+
break
|
59
41
|
end
|
42
|
+
|
43
|
+
puts(yellow % " skipped") unless ran
|
60
44
|
end
|
61
45
|
end
|
62
46
|
|
63
|
-
|
64
|
-
puts(total_color % (spec_format % totals.to_a))
|
47
|
+
puts(spec_format % [tt, ta, tf, te])
|
65
48
|
exit 1 if some_failed
|
66
49
|
end
|
data/tasks/release.rake
CHANGED
@@ -2,7 +2,7 @@ namespace :release do
|
|
2
2
|
task :all => [:release_github, :release_rubyforge]
|
3
3
|
|
4
4
|
desc 'Display instructions to release on github'
|
5
|
-
task :github => [:
|
5
|
+
task :github => [:reversion, :gemspec] do
|
6
6
|
name, version = GEMSPEC.name, GEMSPEC.version
|
7
7
|
|
8
8
|
puts <<INSTRUCTIONS
|
@@ -22,14 +22,14 @@ INSTRUCTIONS
|
|
22
22
|
|
23
23
|
# TODO: Not tested
|
24
24
|
desc 'Display instructions to release on rubyforge'
|
25
|
-
task :rubyforge => [:
|
25
|
+
task :rubyforge => [:reversion, :gemspec, :package] do
|
26
26
|
name, version = GEMSPEC.name, GEMSPEC.version
|
27
27
|
|
28
28
|
puts <<INSTRUCTIONS
|
29
29
|
To publish to rubyforge do following:
|
30
30
|
|
31
31
|
rubyforge login
|
32
|
-
rubyforge add_release #{name}
|
32
|
+
rubyforge add_release #{name} #{version} pkg/#{name}-#{version}.gem
|
33
33
|
|
34
34
|
After you have done these steps, see:
|
35
35
|
|
@@ -40,12 +40,30 @@ INSTRUCTIONS
|
|
40
40
|
|
41
41
|
desc 'Display instructions to add archives after release:rubyforge'
|
42
42
|
task :rubyforge_archives do
|
43
|
+
release_id = latest_release_id
|
44
|
+
|
43
45
|
puts "Adding archives for distro packagers is:", ""
|
44
46
|
|
45
47
|
Dir["pkg/#{name}-#{version}.{gz,zip}"].each do |file|
|
46
|
-
puts "rubyforge add_file #{name} #{name}
|
48
|
+
puts "rubyforge add_file #{name} #{name} #{release_id} '#{file}'"
|
47
49
|
end
|
48
50
|
|
49
51
|
puts
|
50
52
|
end
|
51
53
|
end
|
54
|
+
|
55
|
+
# Use URI and proper XPATH, something along these lines:
|
56
|
+
#
|
57
|
+
# a = doc.at('a[@href=~"release_id"]')[:href]
|
58
|
+
# release_id = URI(a).query[/release_id=(\w+)/, 1]
|
59
|
+
def latest_release_id
|
60
|
+
require 'open-uri'
|
61
|
+
require 'hpricot'
|
62
|
+
|
63
|
+
url = "http://rubyforge.org/frs/?group_id=#{PROJECT_RUBYFORGE_GROUP_ID}"
|
64
|
+
doc = Hpricot(open(url))
|
65
|
+
a = (doc/:a).find{|a| a[:href] =~ /release_id/}
|
66
|
+
|
67
|
+
version = a.inner_html
|
68
|
+
release_id = Hash[*a[:href].split('?').last.split('=').flatten]['release_id']
|
69
|
+
end
|