lucie-lib 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lucie/app.rb +30 -16
- data/lib/lucie/controller/base.rb +1 -7
- data/lib/lucie/version.rb +1 -1
- data/test/functional/app_test.rb +11 -1
- data/test/test_app/app/controllers/fake_controller.rb +2 -0
- data/test/test_app/app/controllers/inheritance_controller.rb +5 -0
- data/test/test_helper.rb +1 -0
- metadata +10 -6
- /data/test/{helpers → fixtures}/before_filter_controller.rb +0 -0
- /data/test/{helpers → fixtures}/test_app.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f509d04638ba165b1e444061f66d60870e6936c
|
4
|
+
data.tar.gz: 261d15e0851a26c5449972fd075ee754b7fd28e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc15a34df4977c1f297f8f1b823253593286c65d1ea267f4a314236d4641b59afebd5ececc829f0fe7f57f1cd27ebcb858506241329a338c1632b6725ec01728
|
7
|
+
data.tar.gz: 0c5087237ad1a707e766c435d98985082fff2019de84dabc2bf21509cf5dfbf44e59e3cdb787a193ff7b4213eb2f3fb8fbe36ce9c1974fd2a64f588bdca5ced8
|
data/lib/lucie/app.rb
CHANGED
@@ -58,6 +58,7 @@ module Lucie
|
|
58
58
|
private
|
59
59
|
|
60
60
|
def call_method_invoking_process
|
61
|
+
autoload_controllers
|
61
62
|
apply_validators
|
62
63
|
pair_parameters
|
63
64
|
call_action_on_controller
|
@@ -87,25 +88,38 @@ private
|
|
87
88
|
end
|
88
89
|
|
89
90
|
def controller_class
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
91
|
+
controller_class = begin
|
92
|
+
if task
|
93
|
+
[task.split("_").map{|i| i.capitalize}.join, "Controller"].join
|
94
|
+
else
|
95
|
+
@action = :help
|
96
|
+
"ApplicationController"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
begin
|
101
|
+
Object.const_get(controller_class.to_sym)
|
102
|
+
rescue NameError
|
103
|
+
self.exit_value = 255
|
104
|
+
raise ControllerNotFound.new task
|
98
105
|
end
|
99
|
-
rescue NameError
|
100
|
-
include_controller_for(task)
|
101
|
-
Object.const_get(@controller_class.to_sym)
|
102
106
|
end
|
103
107
|
|
104
|
-
def
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
108
|
+
def autoload_controllers
|
109
|
+
base_path = File.join([root, "app/controllers"])
|
110
|
+
$LOAD_PATH << base_path
|
111
|
+
Dir.glob(File.join([base_path, "*_controller.rb"])).each do |path|
|
112
|
+
filename = File.basename(path)
|
113
|
+
controller_name = filename.split(".rb").first
|
114
|
+
if controller_name.to_s.length > 0
|
115
|
+
const_name = controller_name.split("_").map!{|x| x.capitalize!}.join
|
116
|
+
|
117
|
+
# place the constant to the root namespace
|
118
|
+
Object.class_eval do
|
119
|
+
autoload const_name.to_sym, controller_name
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
109
123
|
end
|
110
124
|
|
111
125
|
def call_action_on_controller
|
@@ -72,14 +72,8 @@ module Lucie
|
|
72
72
|
|
73
73
|
def apply_action(action)
|
74
74
|
if has_action? action
|
75
|
-
|
76
75
|
self.apply_before_filters
|
77
|
-
|
78
|
-
begin
|
79
|
-
return self.send(action)
|
80
|
-
rescue NameError
|
81
|
-
raise ActionNotFound.new(action, nil)
|
82
|
-
end
|
76
|
+
return self.send(action)
|
83
77
|
else
|
84
78
|
raise ActionNotFound.new(action, nil)
|
85
79
|
end
|
data/lib/lucie/version.rb
CHANGED
data/test/functional/app_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
require "stringio"
|
3
|
-
require "
|
3
|
+
require "fixtures/test_app"
|
4
4
|
require "fixtures/command_parser_fixtures"
|
5
5
|
|
6
6
|
describe App do
|
@@ -111,4 +111,14 @@ describe App do
|
|
111
111
|
should "store the ENV" do
|
112
112
|
assert_equal ENV["PWD"], TestApp.init([], "").env["PWD"]
|
113
113
|
end
|
114
|
+
|
115
|
+
should "find other controllers as well in controllers directory without require statement" do
|
116
|
+
if defined?(FakeController)
|
117
|
+
Object.send(:remove_const, :FakeController)
|
118
|
+
end
|
119
|
+
|
120
|
+
assert_output "ok", "" do
|
121
|
+
TestApp.run "inheritance index", File.expand_path("../../test_app/", __FILE__)
|
122
|
+
end
|
123
|
+
end
|
114
124
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lucie-lib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nucc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -88,13 +88,15 @@ files:
|
|
88
88
|
- lib/lucie/validators/optional.rb
|
89
89
|
- lib/lucie/version.rb
|
90
90
|
- lucie-lib.gemspec
|
91
|
+
- test/fixtures/before_filter_controller.rb
|
91
92
|
- test/fixtures/command_parser_fixtures.rb
|
92
93
|
- test/fixtures/template_snippet_fixtures.rb
|
94
|
+
- test/fixtures/test_app.rb
|
93
95
|
- test/functional/app_test.rb
|
94
96
|
- test/functional/template_snippet_test.rb
|
95
|
-
- test/helpers/before_filter_controller.rb
|
96
|
-
- test/helpers/test_app.rb
|
97
97
|
- test/test_app/app/controllers/application_controller.rb
|
98
|
+
- test/test_app/app/controllers/fake_controller.rb
|
99
|
+
- test/test_app/app/controllers/inheritance_controller.rb
|
98
100
|
- test/test_helper.rb
|
99
101
|
- test/unit/command_line_parser_test.rb
|
100
102
|
- test/unit/command_line_slicer_test.rb
|
@@ -124,13 +126,15 @@ specification_version: 4
|
|
124
126
|
summary: Library part of Lucie framework. Use only this gem, if you don't need project
|
125
127
|
generator.
|
126
128
|
test_files:
|
129
|
+
- test/fixtures/before_filter_controller.rb
|
127
130
|
- test/fixtures/command_parser_fixtures.rb
|
128
131
|
- test/fixtures/template_snippet_fixtures.rb
|
132
|
+
- test/fixtures/test_app.rb
|
129
133
|
- test/functional/app_test.rb
|
130
134
|
- test/functional/template_snippet_test.rb
|
131
|
-
- test/helpers/before_filter_controller.rb
|
132
|
-
- test/helpers/test_app.rb
|
133
135
|
- test/test_app/app/controllers/application_controller.rb
|
136
|
+
- test/test_app/app/controllers/fake_controller.rb
|
137
|
+
- test/test_app/app/controllers/inheritance_controller.rb
|
134
138
|
- test/test_helper.rb
|
135
139
|
- test/unit/command_line_parser_test.rb
|
136
140
|
- test/unit/command_line_slicer_test.rb
|
File without changes
|
File without changes
|