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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a8b7fa251ffb5faae0d07c460068da7b1462c69f
4
- data.tar.gz: 7ef60b41475e3763ac0b9cfc6c177d0556099ec7
3
+ metadata.gz: a0c699cab58ca0ec6248b17674081ac621137843
4
+ data.tar.gz: 6ac12538e8f294cefe7c1881ef5eef6a182917b2
5
5
  SHA512:
6
- metadata.gz: ab7e88e906675e7f39d5f736cf554719caaaf97eb5f6269b098b6371ac7f0fcdb3d7f9d8e7473325e8d412aa980b9c229e5dc3412c3ff9b5fe1f150274083020
7
- data.tar.gz: e7002eca788be88b22dd135506afad8cc14b76775c33e323ea170c1d33c0d6305a9f5de1a0731afeb82ae7393afb3bc333073bebf421d7666b887ab1f510001e
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
- ### [Routing GUIDE](DOCUMENTATION/GUIDE_ROUTING.md)
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 it to ``controllers/``.
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 "controllers"
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 not ARGV[1].to_s.match(/[\w_\-\.]+/)
66
- generate_controller("#{ARGV[1]}Controller", "src/#{ARGV[1]}.rb")
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 Route
2
+ module Router
3
3
 
4
4
  def self.add(what, verb)
5
- Nephos::Route::ALL << what.merge(verb: verb)
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::Route.check!(what)
68
- Nephos::Route.add_params!(what)
69
- Nephos::Route.add(what, verb)
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 "controllers/*.rb"].each do |f|
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 Route
7
+ module Router
8
8
 
9
- ALL = []
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 ALL.find{|e| e[:match] =~ route and e[:verb] == verb}
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)
@@ -1,10 +1,9 @@
1
1
  require_relative 'responder'
2
- require_relative '../routing/execute'
3
2
 
4
3
  module Nephos
5
4
  class Server
6
5
 
7
- SERVER = lambda {|env| return Route.execute(env)}
6
+ SERVER = lambda {|env| return Router.execute(env)}
8
7
 
9
8
  attr_accessor :port
10
9
 
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'
@@ -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/routing/execute.rb
19
- lib/nephos-server/routing/load.rb
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/routing.rb
29
+ test/router.rb
30
30
  test/params.rb
31
31
  test/controller.rb
32
32
  routes.rb
33
- controllers/dataset.rb
34
- controllers/image.jpg
35
- controllers/main.rb
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 test_initialize
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 TestNephosServerRouting < Test::Unit::TestCase
7
+ class TestNephosServerRouter < Test::Unit::TestCase
8
8
 
9
9
  # remove all seeds
10
- Nephos::Route::ALL = []
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
@@ -5,6 +5,6 @@ class TestNephosServer < Test::Unit::TestCase
5
5
  end
6
6
 
7
7
  require_relative 'responder'
8
- require_relative 'routing'
8
+ require_relative 'router'
9
9
  require_relative 'controller'
10
10
  require_relative 'params'
data/version CHANGED
@@ -1 +1 @@
1
- 0.2.3
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.3
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-27 00:00:00.000000000 Z
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/routing/execute.rb
66
- - lib/nephos-server/routing/load.rb
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/routing.rb
76
+ - test/router.rb
77
77
  - test/params.rb
78
78
  - test/controller.rb
79
79
  - routes.rb
80
- - controllers/dataset.rb
81
- - controllers/image.jpg
82
- - controllers/main.rb
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/routing/execute.rb
106
- - lib/nephos-server/routing/load.rb
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/routing.rb
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