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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88dc123fd7778e73c4170a998c38f2a29bf63ad4
4
- data.tar.gz: 0831153c3949c6c869212c28fc98ee7c03046b23
3
+ metadata.gz: d4514440bf54a350bfc10a1708dd59e62026c09a
4
+ data.tar.gz: 9b799b47b67cf952c673dff00d0f78372fdd19ab
5
5
  SHA512:
6
- metadata.gz: 1164950bbde121ac27a0e779bbe3e8db88c1832d6b18021355382c698bc7604c8c9877fe9721ab31f9aa059c88ffd2c85b4c43ea63c90141134a4dc5c4117b8d
7
- data.tar.gz: ebf578920edd66b5171670b3675b37dd988c04855350eb0a6434c1e1ff6e9316909a2a73aa32dd7869b3ccc738fc14c0a86bd08c461167fc26b315c445ca1409
6
+ metadata.gz: e9c40078b0cd371e4d8a78ef260d8ba60077495c27b4b0dcc8608d439585c39102281d877906345776168351d3d2709a409cfe1a15b9ade138cb141835117786
7
+ data.tar.gz: 4d9d73d790941b6a0192525ed3c20374c683affc465d83ad761ac7a32e6a9268524205141d26dcd83d13e3ef1bdbe4f34fb4035cb8d5bcfdbb87849fa435c8cd
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ v0.4.4
2
+ * improve errors
3
+ * fix unitary tests about controller generator
4
+
1
5
  v0.4.3
2
6
  * improve gemspec changelog
3
7
  * improve generator
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 render(status: 500)
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 render(status: 404) if call.nil?
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]) || {status: 500})
56
+ return render(controller.send(call[:method]))
46
57
  rescue => err
47
- return render(status: 500)
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/test.rb`
10
+ `rm -f app/test_controller.rb`
11
11
 
12
12
  `nephos-generator --debug c test`
13
- assert File.exists? "app/test.rb"
14
- assert_equal "class TestController < Nephos::Controller", File.read("app/test.rb").split("\n").first
15
- `rm -f app/test.rb`
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/test.rb"
19
- assert_equal "class TestController < Nephos::Controller", File.read("app/test.rb").split("\n").first
20
- `rm -f app/test.rb`
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.3
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.3
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 gemspec changelog * improve generator * improve responder (with
152
- integer argument) * fix router helpers"
151
+ summary: "* improve errors * fix unitary tests about controller generator"
153
152
  test_files: []