nephos-server 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -4
- data/bin/nephos-generator +8 -3
- data/lib/nephos-server/{routing → router}/load.rb +5 -5
- data/lib/nephos-server/{routing/execute.rb → router/main.rb} +4 -4
- data/lib/nephos-server/server/main.rb +1 -2
- data/lib/nephos-server.rb +3 -0
- data/nephos-server.gemspec +6 -6
- data/test/controller.rb +11 -1
- data/test/{routing.rb → router.rb} +2 -2
- data/test/test.rb +1 -1
- data/version +1 -1
- metadata +14 -14
- /data/{controllers → app}/dataset.rb +0 -0
- /data/{controllers → app}/image.jpg +0 -0
- /data/{controllers → app}/main.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: a0c699cab58ca0ec6248b17674081ac621137843
|
4
|
+
data.tar.gz: 6ac12538e8f294cefe7c1881ef5eef6a182917b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ff2cd7da5ee44559e590165c79c0530fdb3bf55b78a27c00f896e4c58e6106165db0d9be62669c33c6466607ff36288aef85a0ba4b191b19eb6103635d69077
|
7
|
+
data.tar.gz: 12f799ef408edcc5b8ef980999a62f35d0cd3277f22af71c6c0770945e4fa23cda3b871b465e84db69832ba87773fb511b9698b5effb9a9ca25ce4096fc53d68
|
data/README.md
CHANGED
@@ -29,13 +29,13 @@ nephos-server -p 8080 # port is not required
|
|
29
29
|
## Guides
|
30
30
|
|
31
31
|
### [Render API](DOCUMENTATION/API_RENDER.md)
|
32
|
-
### [
|
32
|
+
### [Router GUIDE](DOCUMENTATION/GUIDE_ROUTER.md)
|
33
33
|
|
34
34
|
## Examples
|
35
35
|
|
36
36
|
### Controller
|
37
37
|
|
38
|
-
To create a controller, simply add
|
38
|
+
To create a controller, simply add a ruby code file to ``app/``, with a class inherited by ``Nephos::Controller``
|
39
39
|
The basic code of a controller can be generated via ``nephos-generator controller NAME``.
|
40
40
|
|
41
41
|
```ruby
|
@@ -85,8 +85,6 @@ end
|
|
85
85
|
## TODO v0.3
|
86
86
|
- Improve documentation (fix english, increase coverage, ...)
|
87
87
|
- Improve unitary test coverage
|
88
|
-
- Improve syntax coherence (router/render, file position, ...)
|
89
|
-
- Directory app instead of controllers
|
90
88
|
|
91
89
|
## TODO v1
|
92
90
|
- Improved Routing (more helper options)
|
data/bin/nephos-generator
CHANGED
@@ -26,6 +26,7 @@ class #{name} < Nephos::Controller
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
EOF
|
29
|
+
puts "Controller \"#{name}\" created at location \"#{file}\""
|
29
30
|
end
|
30
31
|
|
31
32
|
def create_application_dir dir
|
@@ -41,7 +42,7 @@ def initialize_application
|
|
41
42
|
raise "Not an empty dir" unless Dir[File.expand_path "*"].empty?
|
42
43
|
File.write "routes.rb", ROUTE_RB
|
43
44
|
File.write "Gemfile", GEMFILE
|
44
|
-
Dir.mkdir "
|
45
|
+
Dir.mkdir "app"
|
45
46
|
begin
|
46
47
|
`git init .`
|
47
48
|
puts "Git repository initialized"
|
@@ -62,8 +63,10 @@ begin
|
|
62
63
|
|
63
64
|
case ARGV[0]
|
64
65
|
when "c", "controller"
|
65
|
-
if
|
66
|
-
generate_controller("#{ARGV[1]}Controller", "
|
66
|
+
if ARGV[1].to_s.match(/[\w_\-\.]+/)
|
67
|
+
generate_controller("#{ARGV[1].capitalize}Controller", "app/#{ARGV[1].downcase}.rb")
|
68
|
+
else
|
69
|
+
puts "error"
|
67
70
|
end
|
68
71
|
when "a", "appli", "application"
|
69
72
|
if not ARGV[1].to_s.empty?
|
@@ -73,6 +76,8 @@ begin
|
|
73
76
|
end
|
74
77
|
initialize_application
|
75
78
|
puts "Application initialized"
|
79
|
+
else
|
80
|
+
puts "\"#{ARGV[0]}\" not recognized has a command"
|
76
81
|
end
|
77
82
|
|
78
83
|
rescue => err
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Nephos
|
2
|
-
module
|
2
|
+
module Router
|
3
3
|
|
4
4
|
def self.add(what, verb)
|
5
|
-
Nephos::
|
5
|
+
Nephos::Router::ROUTES << what.merge(verb: verb)
|
6
6
|
display = "[#{verb}] #{what[:url]} \t ---> \t #{what[:controller]}##{what[:method]}"
|
7
7
|
puts display unless what[:silent]
|
8
8
|
return display
|
@@ -64,9 +64,9 @@ end
|
|
64
64
|
def add_route(what, verb)
|
65
65
|
raise InvalidRoute unless what.is_a? Hash
|
66
66
|
what[:url] = File.expand_path File.join(route_prefix, what[:url])
|
67
|
-
Nephos::
|
68
|
-
Nephos::
|
69
|
-
Nephos::
|
67
|
+
Nephos::Router.check!(what)
|
68
|
+
Nephos::Router.add_params!(what)
|
69
|
+
Nephos::Router.add(what, verb)
|
70
70
|
end
|
71
71
|
|
72
72
|
# @param what [Hash]
|
@@ -1,12 +1,12 @@
|
|
1
|
-
Dir[File.expand_path "
|
1
|
+
Dir[File.expand_path "app/*.rb"].each do |f|
|
2
2
|
load(f) and puts "#{f} loaded"
|
3
3
|
end
|
4
4
|
puts
|
5
5
|
|
6
6
|
module Nephos
|
7
|
-
module
|
7
|
+
module Router
|
8
8
|
|
9
|
-
|
9
|
+
ROUTES = []
|
10
10
|
|
11
11
|
# @param arg [Hash or Symbol]
|
12
12
|
# shortcut to #{Nephos::Responder.render}
|
@@ -18,7 +18,7 @@ module Nephos
|
|
18
18
|
# find the right route to use from the url
|
19
19
|
def self.parse_path path, verb
|
20
20
|
route = File.join(["/"] + path)
|
21
|
-
return
|
21
|
+
return ROUTES.find{|e| e[:match] =~ route and e[:verb] == verb}
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.parse_env(env, route)
|
data/lib/nephos-server.rb
CHANGED
@@ -6,7 +6,10 @@ require 'open-uri'
|
|
6
6
|
require 'rack'
|
7
7
|
require 'colorize'
|
8
8
|
|
9
|
+
# lib
|
9
10
|
require_relative 'nephos-server/basic_errors'
|
10
11
|
require_relative 'nephos-server/params'
|
11
12
|
require_relative 'nephos-server/controller'
|
13
|
+
require_relative 'nephos-server/router/main'
|
14
|
+
# server
|
12
15
|
require_relative 'nephos-server/server/main'
|
data/nephos-server.gemspec
CHANGED
@@ -15,8 +15,8 @@ lib/nephos-server/params.rb
|
|
15
15
|
lib/nephos-server/controller.rb
|
16
16
|
lib/nephos-server/server/main.rb
|
17
17
|
lib/nephos-server/server/responder.rb
|
18
|
-
lib/nephos-server/
|
19
|
-
lib/nephos-server/
|
18
|
+
lib/nephos-server/router/main.rb
|
19
|
+
lib/nephos-server/router/load.rb
|
20
20
|
README.md
|
21
21
|
Rakefile
|
22
22
|
Procfile
|
@@ -26,13 +26,13 @@ nephos-server.gemspec
|
|
26
26
|
version
|
27
27
|
test/test.rb
|
28
28
|
test/responder.rb
|
29
|
-
test/
|
29
|
+
test/router.rb
|
30
30
|
test/params.rb
|
31
31
|
test/controller.rb
|
32
32
|
routes.rb
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
app/dataset.rb
|
34
|
+
app/image.jpg
|
35
|
+
app/main.rb
|
36
36
|
bin/nephos-server
|
37
37
|
bin/nephos-generator
|
38
38
|
)
|
data/test/controller.rb
CHANGED
@@ -1,9 +1,19 @@
|
|
1
1
|
class TestNephosServerController < Test::Unit::TestCase
|
2
2
|
|
3
|
-
def
|
3
|
+
def test_initialize_success
|
4
4
|
assert Nephos::Controller.new()
|
5
5
|
assert Nephos::Controller.new(env={}, {path: [], args: {}}, {params: []})
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_initialize_failure
|
6
9
|
assert_raise do Nephos::Controller.new({}, {}, {}) end
|
10
|
+
assert_raise do Nephos::Controller.new({}, {path: nil}, {}) end
|
11
|
+
assert_raise do Nephos::Controller.new({}, {path: []}, {}) end
|
12
|
+
assert_raise do Nephos::Controller.new({}, {path: [], args: {}}, {}) end
|
13
|
+
assert_raise do Nephos::Controller.new({}, {path: [], args: {}}, {params: nil}) end
|
14
|
+
assert_raise do Nephos::Controller.new({}, {path: nil, args: nil}, params: nil) end
|
15
|
+
assert_raise do Nephos::Controller.new({}, {path: nil, args: {}}, {params: {}}) end
|
16
|
+
assert_raise do Nephos::Controller.new({}, {path: [], args: nil}, {params: {}}) end
|
7
17
|
end
|
8
18
|
|
9
19
|
end
|
@@ -4,10 +4,10 @@ class TestController < Nephos::Controller
|
|
4
4
|
end
|
5
5
|
end
|
6
6
|
|
7
|
-
class
|
7
|
+
class TestNephosServerRouter < Test::Unit::TestCase
|
8
8
|
|
9
9
|
# remove all seeds
|
10
|
-
Nephos::
|
10
|
+
Nephos::Router::ROUTES = []
|
11
11
|
|
12
12
|
def test_valid_routes
|
13
13
|
get url: "/", controller: "TestController", method: "method", silent: true
|
data/test/test.rb
CHANGED
data/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.4
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nephos-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- poulet_a
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nomorebeer
|
@@ -62,8 +62,8 @@ email:
|
|
62
62
|
- lib/nephos-server/controller.rb
|
63
63
|
- lib/nephos-server/server/main.rb
|
64
64
|
- lib/nephos-server/server/responder.rb
|
65
|
-
- lib/nephos-server/
|
66
|
-
- lib/nephos-server/
|
65
|
+
- lib/nephos-server/router/main.rb
|
66
|
+
- lib/nephos-server/router/load.rb
|
67
67
|
- README.md
|
68
68
|
- Rakefile
|
69
69
|
- Procfile
|
@@ -73,13 +73,13 @@ email:
|
|
73
73
|
- version
|
74
74
|
- test/test.rb
|
75
75
|
- test/responder.rb
|
76
|
-
- test/
|
76
|
+
- test/router.rb
|
77
77
|
- test/params.rb
|
78
78
|
- test/controller.rb
|
79
79
|
- routes.rb
|
80
|
-
-
|
81
|
-
-
|
82
|
-
-
|
80
|
+
- app/dataset.rb
|
81
|
+
- app/image.jpg
|
82
|
+
- app/main.rb
|
83
83
|
- bin/nephos-server
|
84
84
|
- bin/nephos-generator
|
85
85
|
executables:
|
@@ -93,17 +93,17 @@ files:
|
|
93
93
|
- Procfile
|
94
94
|
- README.md
|
95
95
|
- Rakefile
|
96
|
+
- app/dataset.rb
|
97
|
+
- app/image.jpg
|
98
|
+
- app/main.rb
|
96
99
|
- bin/nephos-generator
|
97
100
|
- bin/nephos-server
|
98
|
-
- controllers/dataset.rb
|
99
|
-
- controllers/image.jpg
|
100
|
-
- controllers/main.rb
|
101
101
|
- lib/nephos-server.rb
|
102
102
|
- lib/nephos-server/basic_errors.rb
|
103
103
|
- lib/nephos-server/controller.rb
|
104
104
|
- lib/nephos-server/params.rb
|
105
|
-
- lib/nephos-server/
|
106
|
-
- lib/nephos-server/
|
105
|
+
- lib/nephos-server/router/load.rb
|
106
|
+
- lib/nephos-server/router/main.rb
|
107
107
|
- lib/nephos-server/server/main.rb
|
108
108
|
- lib/nephos-server/server/responder.rb
|
109
109
|
- nephos-server.gemspec
|
@@ -111,7 +111,7 @@ files:
|
|
111
111
|
- test/controller.rb
|
112
112
|
- test/params.rb
|
113
113
|
- test/responder.rb
|
114
|
-
- test/
|
114
|
+
- test/router.rb
|
115
115
|
- test/test.rb
|
116
116
|
- version
|
117
117
|
homepage: https://github.com/pouleta/NephosRubyServer
|
File without changes
|
File without changes
|
File without changes
|