happy 0.1.0.pre27 → 0.1.0.pre28
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +1 -1
- data/lib/happy/controller.rb +37 -2
- data/lib/happy/version.rb +1 -1
- metadata +20 -23
- data/lib/happy/controller/cascadable.rb +0 -17
- data/spec/controller/cascadable_spec.rb +0 -43
data/.yardopts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
--
|
1
|
+
--private --protected lib/**/*.rb - README.md TUTORIAL.md LICENSE
|
data/lib/happy/controller.rb
CHANGED
@@ -5,7 +5,6 @@ require 'happy/controller/routing'
|
|
5
5
|
require 'happy/controller/actions'
|
6
6
|
require 'happy/controller/rackable'
|
7
7
|
require 'happy/controller/configurable'
|
8
|
-
require 'happy/controller/cascadable'
|
9
8
|
require 'happy/controller/permissions'
|
10
9
|
|
11
10
|
module Happy
|
@@ -19,7 +18,6 @@ module Happy
|
|
19
18
|
include Actions
|
20
19
|
include Rackable
|
21
20
|
include Configurable
|
22
|
-
include Cascadable
|
23
21
|
include Permissions
|
24
22
|
include Happy::Helpers
|
25
23
|
|
@@ -82,8 +80,45 @@ module Happy
|
|
82
80
|
url_for(@root_url, extras)
|
83
81
|
end
|
84
82
|
|
83
|
+
# Returns the application controller (ie, the root controller running this
|
84
|
+
# application.)
|
85
|
+
#
|
86
|
+
def app
|
87
|
+
@parent_controller ? @parent_controller.app : self
|
88
|
+
end
|
89
|
+
|
85
90
|
private
|
86
91
|
|
92
|
+
# Adds helper methods to the base class for all controllers. Use this
|
93
|
+
# to define application-level helper methods that you want to have available
|
94
|
+
# in all views, even if they're begin rendered by a controller different from
|
95
|
+
# your application controller.
|
96
|
+
#
|
97
|
+
# Modules passed to this method will be included into the base controller class.
|
98
|
+
# Example:
|
99
|
+
#
|
100
|
+
# helpers MyApp::Helpers
|
101
|
+
#
|
102
|
+
# Alternatively, you can specify a block that will be executed against the
|
103
|
+
# base controller class like this:
|
104
|
+
#
|
105
|
+
# helpers do
|
106
|
+
# def my_little_helper
|
107
|
+
# "something useful"
|
108
|
+
# end
|
109
|
+
# end
|
110
|
+
#
|
111
|
+
def self.helpers(*args, &blk)
|
112
|
+
args.flatten.each do |arg|
|
113
|
+
case arg
|
114
|
+
when Module then Happy::Controller.send(:include, arg)
|
115
|
+
else raise "Invalid helper specified."
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
Happy::Controller.class_exec(&blk) if blk
|
120
|
+
end
|
121
|
+
|
87
122
|
def current_url(*extras)
|
88
123
|
url_for(processed_path, extras)
|
89
124
|
end
|
data/lib/happy/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: happy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.pre28
|
5
5
|
prerelease: 6
|
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: 2012-06-
|
12
|
+
date: 2012-06-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &70101332488280 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.1'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70101332488280
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rack
|
27
|
-
requirement: &
|
27
|
+
requirement: &70101332487780 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '1.4'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70101332487780
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: allowance
|
38
|
-
requirement: &
|
38
|
+
requirement: &70101332487320 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.1.1
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70101332487320
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: tilt
|
49
|
-
requirement: &
|
49
|
+
requirement: &70101332486860 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '1.3'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70101332486860
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rake
|
60
|
-
requirement: &
|
60
|
+
requirement: &70101345428800 !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: *
|
68
|
+
version_requirements: *70101345428800
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
|
-
requirement: &
|
71
|
+
requirement: &70101345428260 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '2.8'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70101345428260
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rspec-html-matchers
|
82
|
-
requirement: &
|
82
|
+
requirement: &70101345427840 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70101345427840
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: rack-test
|
93
|
-
requirement: &
|
93
|
+
requirement: &70101345427380 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70101345427380
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: watchr
|
104
|
-
requirement: &
|
104
|
+
requirement: &70101345426960 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70101345426960
|
113
113
|
description: A happy little toolkit for writing web applications.
|
114
114
|
email:
|
115
115
|
- hendrik@mans.de
|
@@ -136,7 +136,6 @@ files:
|
|
136
136
|
- lib/happy.rb
|
137
137
|
- lib/happy/controller.rb
|
138
138
|
- lib/happy/controller/actions.rb
|
139
|
-
- lib/happy/controller/cascadable.rb
|
140
139
|
- lib/happy/controller/configurable.rb
|
141
140
|
- lib/happy/controller/permissions.rb
|
142
141
|
- lib/happy/controller/rackable.rb
|
@@ -158,7 +157,6 @@ files:
|
|
158
157
|
- lib/happy/response.rb
|
159
158
|
- lib/happy/version.rb
|
160
159
|
- spec/controller/actions_spec.rb
|
161
|
-
- spec/controller/cascadable_spec.rb
|
162
160
|
- spec/controller/configurable_spec.rb
|
163
161
|
- spec/controller/routing_spec.rb
|
164
162
|
- spec/controller_spec.rb
|
@@ -192,7 +190,6 @@ specification_version: 3
|
|
192
190
|
summary: A happy little toolkit for writing web applications.
|
193
191
|
test_files:
|
194
192
|
- spec/controller/actions_spec.rb
|
195
|
-
- spec/controller/cascadable_spec.rb
|
196
193
|
- spec/controller/configurable_spec.rb
|
197
194
|
- spec/controller/routing_spec.rb
|
198
195
|
- spec/controller_spec.rb
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Happy
|
2
|
-
class Controller
|
3
|
-
module Cascadable
|
4
|
-
def method_missing(name, *args, &blk)
|
5
|
-
if @parent_controller && @parent_controller.respond_to?(name)
|
6
|
-
@parent_controller.send(name, *args, &blk)
|
7
|
-
else
|
8
|
-
super
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def respond_to?(name)
|
13
|
-
super || @parent_controller.try(:respond_to?, name)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Happy
|
4
|
-
describe Controller::Cascadable do
|
5
|
-
|
6
|
-
describe '#method_missing' do
|
7
|
-
it "passes on all method calls to a parent if there is one" do
|
8
|
-
class Inner < Controller
|
9
|
-
def route
|
10
|
-
on 'one' do
|
11
|
-
some_helper
|
12
|
-
end
|
13
|
-
|
14
|
-
on 'two' do
|
15
|
-
some_unknown_helper
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class Middle < Controller
|
21
|
-
def route
|
22
|
-
run Inner
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
class Outer < Controller
|
27
|
-
def some_helper; 'some_information'; end
|
28
|
-
def route
|
29
|
-
run Middle
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def app
|
34
|
-
Outer
|
35
|
-
end
|
36
|
-
|
37
|
-
response_for { get '/one' }.body.should == 'some_information'
|
38
|
-
response_for { get '/two' }.status.should == 500
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
end
|