nephos-server 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +4 -0
- data/bin/nephos-generator +1 -1
- data/lib/nephos-server/router/main.rb +15 -4
- data/test/generator.rb +7 -7
- data/version +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4514440bf54a350bfc10a1708dd59e62026c09a
|
4
|
+
data.tar.gz: 9b799b47b67cf952c673dff00d0f78372fdd19ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9c40078b0cd371e4d8a78ef260d8ba60077495c27b4b0dcc8608d439585c39102281d877906345776168351d3d2709a409cfe1a15b9ade138cb141835117786
|
7
|
+
data.tar.gz: 4d9d73d790941b6a0192525ed3c20374c683affc465d83ad761ac7a32e6a9268524205141d26dcd83d13e3ef1bdbe4f34fb4035cb8d5bcfdbb87849fa435c8cd
|
data/CHANGELOG
CHANGED
data/bin/nephos-generator
CHANGED
@@ -120,7 +120,7 @@ EOF
|
|
120
120
|
case opt[0]
|
121
121
|
when "c", "controller"
|
122
122
|
if opt[1].to_s.match(/[\w\-\.]+/)
|
123
|
-
Controller.generate!("#{opt[1].capitalize}Controller", "app/#{opt[1].downcase}.rb")
|
123
|
+
Controller.generate!("#{opt[1].capitalize}Controller", "app/#{opt[1].downcase}_controller.rb")
|
124
124
|
else
|
125
125
|
puts "error"
|
126
126
|
end
|
@@ -29,22 +29,33 @@ module Nephos
|
|
29
29
|
return {route: route, verb: verb, from: from, path: path, args: args}
|
30
30
|
end
|
31
31
|
|
32
|
+
def self.error(code, err=nil)
|
33
|
+
if ENV["ENVIRONMENT"].to_s.match(/prod(uction)?/)
|
34
|
+
return render(status: code)
|
35
|
+
elsif err
|
36
|
+
#TODO: improve this
|
37
|
+
return render(status: code, content: err.is_a?(String) ? err : err.message)
|
38
|
+
else
|
39
|
+
return render(status: code)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
32
43
|
def self.execute(env)
|
33
44
|
begin
|
34
45
|
route = URI.parse(env['REQUEST_URI'])
|
35
46
|
rescue => err
|
36
47
|
puts "uri err #{err.message}".red
|
37
|
-
return
|
48
|
+
return error(500, err)
|
38
49
|
end
|
39
50
|
parsed = parse_env(env, route)
|
40
51
|
puts "#{parsed[:from]} [#{parsed[:verb]}] \t ---> \t #{route}"
|
41
52
|
call = parse_path(parsed[:path], parsed[:verb])
|
42
|
-
return
|
53
|
+
return error(404, "404 not found \"#{route}\"") if call.nil?
|
43
54
|
begin
|
44
55
|
controller = Module.const_get(call[:controller]).new(env, parsed, call)
|
45
|
-
return render(controller.send(call[:method])
|
56
|
+
return render(controller.send(call[:method]))
|
46
57
|
rescue => err
|
47
|
-
return
|
58
|
+
return error(500, err)
|
48
59
|
end
|
49
60
|
end
|
50
61
|
|
data/test/generator.rb
CHANGED
@@ -7,17 +7,17 @@ class TestNephosServerGenerator < Test::Unit::TestCase
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def test_generator_controller
|
10
|
-
`rm -f app/
|
10
|
+
`rm -f app/test_controller.rb`
|
11
11
|
|
12
12
|
`nephos-generator --debug c test`
|
13
|
-
assert File.exists? "app/
|
14
|
-
assert_equal "class TestController < Nephos::Controller", File.read("app/
|
15
|
-
`rm -f app/
|
13
|
+
assert File.exists? "app/test_controller.rb"
|
14
|
+
assert_equal "class TestController < Nephos::Controller", File.read("app/test_controller.rb").split("\n").first
|
15
|
+
`rm -f app/test_controller.rb`
|
16
16
|
|
17
17
|
`nephos-generator c test --debug`
|
18
|
-
assert File.exists? "app/
|
19
|
-
assert_equal "class TestController < Nephos::Controller", File.read("app/
|
20
|
-
`rm -f app/
|
18
|
+
assert File.exists? "app/test_controller.rb"
|
19
|
+
assert_equal "class TestController < Nephos::Controller", File.read("app/test_controller.rb").split("\n").first
|
20
|
+
`rm -f app/test_controller.rb`
|
21
21
|
end
|
22
22
|
|
23
23
|
# test simple and rm
|
data/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.4
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nephos-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- poulet_a
|
@@ -148,6 +148,5 @@ rubyforge_project:
|
|
148
148
|
rubygems_version: 2.4.8
|
149
149
|
signing_key:
|
150
150
|
specification_version: 4
|
151
|
-
summary: "* improve
|
152
|
-
integer argument) * fix router helpers"
|
151
|
+
summary: "* improve errors * fix unitary tests about controller generator"
|
153
152
|
test_files: []
|