sinatra-trails 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -240,6 +240,13 @@ module Sinatra
240
240
  Route.new(path, action.to_s, ancestors, self)
241
241
  end
242
242
 
243
+ def map action
244
+ ancestors = [*self.ancestors, plural_name, action]
245
+
246
+ ancestors[0, ancestors.size - 2] = ancestors[0..-3].reject{ |ancestor| Resource === ancestor } if opts[:shallow]
247
+ Route.new([plural_name, action], action.to_s, ancestors, self)
248
+ end
249
+
243
250
  private
244
251
  def define_routes
245
252
  collection(:index) and collection(:new)
@@ -1,5 +1,5 @@
1
1
  module Sinatra
2
2
  module Trails
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
@@ -155,12 +155,21 @@ describe 'trails' do
155
155
  describe 'basic' do
156
156
  before :all do
157
157
  app.resources :users, 'posts' do
158
- # map :flag
159
158
  end
160
159
  end
161
160
  it_should_behave_like 'generates routes for users'
162
161
  it_should_behave_like 'generates routes for posts'
163
- # it { app.route_for(:flag).should == '/flag' }
162
+ end
163
+
164
+ describe 'as namespace' do
165
+ before :all do
166
+ app.resources :users do
167
+ map(:confirm)
168
+ end
169
+ puts app.print_routes
170
+ end
171
+ it_should_behave_like 'generates routes for users'
172
+ it { app.route_for(:users_confirm).should == '/users/confirm' }
164
173
  end
165
174
 
166
175
  describe 'nested with block' do
@@ -495,7 +504,6 @@ describe 'trails' do
495
504
  app.instance_eval do
496
505
  resources :users do
497
506
  before(user) do
498
- # puts params
499
507
  @user = params[:id]
500
508
  end
501
509
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-trails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-04 00:00:00.000000000Z
12
+ date: 2011-10-05 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
16
- requirement: &2166677580 !ruby/object:Gem::Requirement
16
+ requirement: &2156534160 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2166677580
24
+ version_requirements: *2156534160
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: i18n
27
- requirement: &2166677160 !ruby/object:Gem::Requirement
27
+ requirement: &2156533740 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2166677160
35
+ version_requirements: *2156533740
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: activesupport
38
- requirement: &2166676660 !ruby/object:Gem::Requirement
38
+ requirement: &2156533240 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '3.0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2166676660
46
+ version_requirements: *2156533240
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
- requirement: &2166676240 !ruby/object:Gem::Requirement
49
+ requirement: &2156532820 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2166676240
57
+ version_requirements: *2156532820
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec
60
- requirement: &2166675780 !ruby/object:Gem::Requirement
60
+ requirement: &2156532360 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2166675780
68
+ version_requirements: *2156532360
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rack-test
71
- requirement: &2166675360 !ruby/object:Gem::Requirement
71
+ requirement: &2156555720 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2166675360
79
+ version_requirements: *2156555720
80
80
  description: A named routes Sinatra DSL inspired by Rails routing
81
81
  email:
82
82
  - macarui@gmail.com