manveru-ramaze 2009.04 → 2009.04.01

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. data/CHANGELOG +0 -405
  2. data/MANIFEST +16 -16
  3. data/Rakefile +4 -24
  4. data/bin/ramaze +52 -275
  5. data/doc/tutorial/todolist.html +5 -83
  6. data/doc/tutorial/todolist.txt +33 -85
  7. data/examples/app/auth/layout/{auth.xhtml → auth.nag} +0 -0
  8. data/examples/app/auth/view/{index.xhtml → index.nag} +0 -0
  9. data/examples/app/auth/view/{login.xhtml → login.nag} +0 -0
  10. data/examples/app/auth/view/{secret.xhtml → secret.nag} +0 -0
  11. data/examples/app/blog/app.rb +1 -1
  12. data/examples/app/blog/controller/comment.rb +1 -1
  13. data/examples/app/blog/controller/entry.rb +3 -12
  14. data/examples/app/blog/model/init.rb +0 -5
  15. data/examples/app/blog/model/tag.rb +2 -2
  16. data/examples/app/blog/start.rb +1 -1
  17. data/examples/app/blog/view/entry/index.nag +3 -3
  18. data/examples/app/blog/view/feed.atom.nag +1 -1
  19. data/examples/app/blog/view/feed.rss.nag +1 -1
  20. data/examples/app/blog/view/index.nag +1 -1
  21. data/examples/app/blog/view/tag/index.nag +1 -1
  22. data/examples/app/todolist/model/init.rb +0 -3
  23. data/examples/app/wikore/spec/wikore.rb +6 -4
  24. data/examples/app/wikore/src/controller.rb +11 -9
  25. data/examples/app/wikore/src/model.rb +10 -7
  26. data/examples/app/wikore/start.rb +1 -1
  27. data/examples/app/wikore/{view → template}/index.xhtml +0 -0
  28. data/examples/helpers/provide.rb +23 -0
  29. data/examples/misc/rapp.rb +17 -28
  30. data/examples/templates/template_redcloth.rb +2 -2
  31. data/examples/templates/template_xslt.rb +48 -0
  32. data/examples/templates/view/external.xsl +57 -0
  33. data/lib/proto/config.ru +5 -4
  34. data/lib/proto/controller/init.rb +2 -2
  35. data/lib/proto/layout/{default.xhtml → default.nag} +0 -0
  36. data/lib/proto/spec/main.rb +8 -7
  37. data/lib/proto/start.rb +10 -6
  38. data/lib/proto/view/{index.xhtml → index.nag} +0 -0
  39. data/lib/proto/view/page.nag +27 -0
  40. data/lib/ramaze/app.rb +5 -5
  41. data/lib/ramaze/cache.rb +2 -3
  42. data/lib/ramaze/contrib/email.rb +0 -2
  43. data/lib/ramaze/contrib/sequel/create_join.rb +0 -1
  44. data/lib/ramaze/contrib/sequel/fill.rb +12 -0
  45. data/lib/ramaze/contrib/sequel/form_field.rb +4 -4
  46. data/lib/ramaze/contrib/sequel/image.rb +11 -9
  47. data/lib/ramaze/contrib/sequel/relation.rb +3 -17
  48. data/lib/ramaze/controller/default.rb +0 -5
  49. data/lib/ramaze/helper/cache.rb +8 -22
  50. data/lib/ramaze/helper/formatting.rb +0 -2
  51. data/lib/ramaze/helper/httpdigest.rb +1 -1
  52. data/lib/ramaze/helper/link.rb +5 -2
  53. data/lib/ramaze/helper/localize.rb +3 -13
  54. data/lib/ramaze/helper/paginate.rb +0 -1
  55. data/lib/ramaze/helper/partial.rb +10 -85
  56. data/lib/ramaze/helper.rb +16 -6
  57. data/lib/ramaze/request.rb +1 -22
  58. data/lib/ramaze/snippets/ramaze/deprecated.rb +1 -0
  59. data/lib/ramaze/snippets/string/each.rb +19 -0
  60. data/lib/ramaze/spec.rb +2 -9
  61. data/lib/ramaze/version.rb +1 -1
  62. data/lib/ramaze/view/haml.rb +0 -1
  63. data/lib/ramaze/view/liquid.rb +11 -45
  64. data/lib/ramaze/view/nagoro/render_partial.rb +9 -9
  65. data/lib/ramaze/view.rb +0 -4
  66. data/lib/ramaze.rb +0 -2
  67. data/ramaze.gemspec +12 -12
  68. data/spec/contrib/sequel/fill.rb +47 -0
  69. data/spec/examples/helpers/httpdigest.rb +67 -42
  70. data/spec/examples/templates/template_markaby.rb +1 -1
  71. data/spec/examples/templates/template_xslt.rb +10 -0
  72. data/spec/ramaze/dispatcher/file.rb +20 -22
  73. data/spec/ramaze/error.rb +1 -1
  74. data/spec/ramaze/helper/auth.rb +40 -29
  75. data/spec/ramaze/helper/cache.rb +3 -43
  76. data/spec/ramaze/helper/flash.rb +14 -10
  77. data/spec/ramaze/helper/httpdigest.rb +65 -47
  78. data/spec/ramaze/helper/localize.rb +9 -9
  79. data/spec/ramaze/helper/partial.rb +40 -0
  80. data/spec/ramaze/helper/sequel_form.rb +1 -1
  81. data/spec/ramaze/helper/simple_captcha.rb +13 -9
  82. data/spec/ramaze/helper/stack.rb +39 -31
  83. data/spec/ramaze/helper/user.rb +13 -15
  84. data/spec/ramaze/request.rb +0 -12
  85. data/tasks/bacon.rake +21 -38
  86. data/tasks/release.rake +22 -4
  87. metadata +24 -22
  88. data/lib/proto/app.rb +0 -15
  89. data/lib/ramaze/cache/localmemcache.rb +0 -56
  90. data/lib/ramaze/contrib/app_graph.rb +0 -64
  91. data/lib/ramaze/tool/create.rb +0 -48
  92. data/lib/ramaze/tool/project_creator.rb +0 -111
  93. data/spec/ramaze/cache/localmemcache.rb +0 -49
  94. data/tasks/setup.rake +0 -24
@@ -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 :mock
26
+ behaves_like :session
27
27
 
28
28
  it 'displays a flashbox with one item' do
29
- get('/populate_one')
30
- get('/box')
31
- last_response.status.should == 200
32
- last_response.body.should == 'one : for starters'
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
- get('/populate_two')
37
- get('/box')
38
- last_response.status.should == 200
39
- last_response.body.split("\n").sort.should == ['one : this one', 'two : and this']
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(username)
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
- describe 'headers' do
52
- behaves_like :mock
51
+ behaves_like :mock, :session
53
52
 
54
- it 'sends out all the required header information' do
55
- get '/authenticate'
56
- www_authenticate = last_response.headers['WWW-Authenticate']
57
- authorization = Rack::Auth::Digest::Params.parse(www_authenticate)
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
- digest_authorize 'foo', 'oof'
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
- it 'fails to authenticate an incorrect password with a block' do
85
- digest_authorize 'foo', 'bar'
86
- get '/authenticate'
87
- last_response.status.should == 401
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
- describe 'Plaintext authentication' do
93
- behaves_like :mock
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
- it 'authenticates a user with the plaintext method' do
96
- get '/plaintext/authenticate'
97
- last_response.status.should == 401
98
- last_response.body.should == 'Unauthorized'
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
- authorize 'foo', 'oof'
101
- get '/plaintext/authenticate'
102
- last_response.status.should == 200
103
- last_response.body.should == "Hello foo"
104
- end
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
- it 'fails to authenticate an incorrect password with the plaintext method' do
107
- authorize 'foo', 'bar'
108
- get '/plaintext/authenticate'
109
- last_response.status.should == 401
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 /regexp/.respond_to?(:kcode)
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('/', :lang => :de).body.should == 'de'
38
+ get('/?lang=de').body.should == 'de'
39
39
  end
40
40
 
41
41
  should 'override language by cookie' do
42
- get('/', {}, :cookie => 'lang=ja').body.should == 'ja'
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('/', :lang => :foobar).body.should == 'foobar'
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', :lang => :en).body.should == 'one'
52
- get('/translate/one', :lang => :ja).body.should == '一'
53
- get('/translate/one', :lang => :de).body.should == 'eins'
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', :lang => :ja).body.should == 'two'
58
- get('/translate/three', :lang => :ja).body.should == '三'
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
@@ -32,7 +32,7 @@ class FormController < Ramaze::Controller
32
32
  end
33
33
 
34
34
  def edit(id)
35
- sequel_form(User[id]).to_s
35
+ sequel_form(User[id])
36
36
  end
37
37
 
38
38
  def edit_with_options(id)
@@ -25,21 +25,25 @@ class SpecCustomCaptcha < SpecSimpleCaptcha
25
25
  end
26
26
 
27
27
  describe Ramaze::Helper::SimpleCaptcha do
28
- behaves_like :mock
28
+ behaves_like :session
29
29
 
30
30
  should 'ask question' do
31
- get('/ask_question')
32
- question = last_response.body
33
- question.should =~ /^\d+ [+-] \d+$/
31
+ session do |mock|
32
+ question = mock.get('/ask_question').body
33
+ question.should =~ /^\d+ [+-] \d+$/
34
34
 
35
- lh, m, rh = question.split
36
- answer = lh.to_i.send(m, rh.to_i)
35
+ lh, m, rh = question.split
36
+ answer = lh.to_i.send(m, rh.to_i)
37
37
 
38
- get("/answer_question/#{answer}").body.should == 'correct'
38
+ mock.get("/answer_question/#{answer}").body.should == 'correct'
39
+ end
39
40
  end
40
41
 
41
42
  should 'ask custom question' do
42
- get('/fish/ask_question').body.should == 'the answer to everything'
43
- get('/fish/answer_question/42').body.should == 'correct'
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
@@ -39,48 +39,56 @@ class SpecStackHelper < Ramaze::Controller
39
39
  end
40
40
 
41
41
  describe Ramaze::Helper::Stack do
42
- behaves_like :mock
42
+ behaves_like :session
43
43
  @uri = 'http://example.org'
44
44
 
45
45
  should 'login directly' do
46
- get('/secure').body.should == 'please login'
46
+ session do |mock|
47
+ mock.get('/secure').body.should == 'please login'
47
48
 
48
- get('/login').status.should == 302
49
- last_response['Location'].should == "#@uri/secure"
49
+ got = mock.get('/login')
50
+ got.status.should == 302
51
+ got['Location'].should == "#@uri/secure"
50
52
 
51
- get('/secure').status.should == 200
52
- last_response.body.should == 'secret content'
53
+ got = mock.get('/secure')
54
+ got.status.should == 200
55
+ got.body.should == 'secret content'
53
56
 
54
- get('/secure').body.should == 'secret content'
55
- get('/logout')
56
- get('/secure').body.should == 'please login'
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
- get('/logged_in_page').status.should == 302
61
- last_response['Location'].should == 'http://example.org/login'
62
-
63
- get('/login').status.should == 302
64
- last_response['Location'].should == 'http://example.org/logged_in_page'
65
-
66
- get('/logged_in_page').status.should == 200
67
- last_response.body.should == 'the logged in page'
68
-
69
- get('/logout')
70
- get('/secure').body.should == 'please login'
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
- get('/logged_in_params?x=y').status.should == 302
75
- last_response['Location'].should == 'http://example.org/login'
76
-
77
- get('/login').status.should == 302
78
- last_response['Location'].should == 'http://example.org/logged_in_params?x=y'
79
-
80
- get('/logged_in_params?x=y').status.should == 200
81
- last_response.body.should == {'x' => 'y'}.inspect
82
-
83
- get('/logout')
84
- get('/secure').body.should == 'please login'
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
@@ -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 :mock
51
+ behaves_like :session
56
52
 
57
53
  should 'login' do
58
- get('/status').body.should == 'no'
59
- get('/login', :name => :arthur, :password => 42).body.should == 'logged in'
60
- get('/status').body.should == 'yes'
61
- get('/profile').body.should == MockSequelUser.new.profile
62
- get('/logout').status.should == 200
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
- get('/callback/status').body.should == 'no'
67
- get('/callback/login', :name => :arthur, :password => 42).body.should == 'logged in'
68
- get('/callback/status').body.should == 'yes'
69
- get('/callback/profile').body.should == MockSequelUser.new.profile
70
- get('/logout').status.should == 200
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
@@ -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
- specs_size = specs.size
9
+ total = specs.size
11
10
  len = specs.map{|s| s.size }.sort.last
12
- total_tests = total_assertions = total_failures = total_errors = 0
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, specs_size, spec])
18
+ print(left_format % [idx + 1, total, spec])
21
19
 
22
20
  Open3.popen3(RUBY, spec) do |sin, sout, serr|
23
- out = sout.read.strip
24
- err = serr.read.strip
21
+ out = sout.read
22
+ err = serr.read
25
23
 
26
- # this is conventional, see spec/innate/state/fiber.rb for usage
27
- if out =~ /^Bacon::Error: (needed .*)/
28
- puts(yellow % ("%6s %s" % ['', $1]))
29
- else
30
- total = nil
24
+ ran = false
31
25
 
32
- out.each_line do |line|
33
- scanned = line.scanf(spec_format)
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
- next unless scanned.size == 4
36
-
37
- total = Vector[*scanned]
38
- break
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
- some_failed = true
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
- total_color = some_failed ? red : green
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 => [:jquery, :reversion, :gemspec] do
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 => [:jquery, :reversion, :gemspec, :package] do
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} '#{version}' pkg/#{name}-#{version}.gem
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} '#{version}' '#{file}'"
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