fasta 0.2.4 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fasta/cli.rb +5 -0
- data/lib/fasta/services/router.rb +23 -0
- data/lib/fasta/services/routes_mapper.rb +16 -0
- data/lib/fasta/version.rb +1 -1
- data/templates/boot.ru +1 -1
- data/templates/config/routes.rb +13 -16
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccc6ea929c578f89d0a6ed2b86698e9ec3b9c49059f85a56ac57d2184b3ac384
|
4
|
+
data.tar.gz: 3b3066fb504b910f938cd809eeed480d3a9780b6dac9c6438459aeb8508dc5aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22393427f0a96b8f199ec99781303379897568080c1c41c165518aaa1d06e7aca0943d644be42b7f081b08ce403a306c8f3b66279b49e32210ae970e34cb0f9a
|
7
|
+
data.tar.gz: 114e54e762628f2d79b5f4dad9d148dbd219243c97b819b0445374fb71d69d1b0c5d8b9ea5090c65affeb98bb12bda23f24d755ae4f4444f5d897484c3565c4e
|
data/lib/fasta/cli.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'hanami/router'
|
2
|
+
require_relative 'routes_mapper'
|
3
|
+
|
4
|
+
module Fasta
|
5
|
+
class Router
|
6
|
+
def initialize
|
7
|
+
@router = Hanami::Router.new do
|
8
|
+
action = ->(klass) { ->(env) { klass.call(env) } }
|
9
|
+
root to: ->(_env) { [200, {}, ['Welcome to API']] }
|
10
|
+
|
11
|
+
mapper = Fasta::RoutesMapper.new(action, self)
|
12
|
+
|
13
|
+
yield(mapper)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def runnable
|
18
|
+
router
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_reader :router
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Fasta
|
2
|
+
class RoutesMapper
|
3
|
+
def initialize(action, router)
|
4
|
+
@action = action
|
5
|
+
@router = router
|
6
|
+
end
|
7
|
+
|
8
|
+
def reg(method, route, action_name)
|
9
|
+
router.public_send(method, route, to: action.call(action_name))
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
attr_reader :action, :router
|
15
|
+
end
|
16
|
+
end
|
data/lib/fasta/version.rb
CHANGED
data/templates/boot.ru
CHANGED
data/templates/config/routes.rb
CHANGED
@@ -1,19 +1,16 @@
|
|
1
|
-
require '
|
1
|
+
require 'fasta/services/router'
|
2
2
|
|
3
|
-
$router =
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
$router = Fasta::Router.new do |mapper|
|
4
|
+
mapper.reg(:get, '/users', User::Index)
|
5
|
+
mapper.reg(:post, '/users', User::Create)
|
6
|
+
mapper.reg(:get, '/users/:id', User::Show)
|
7
|
+
mapper.reg(:put, '/users/:id', User::Put)
|
8
|
+
mapper.reg(:patch, '/users/:id', User::Patch)
|
9
|
+
mapper.reg(:delete, '/users/:id', User::Delete)
|
10
|
+
mapper.reg(:get, '/users/:id/boards', User::Boards)
|
11
|
+
end
|
7
12
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
put '/users/:id', to: action.call(User::Put)
|
12
|
-
patch '/users/:id', to: action.call(User::Patch)
|
13
|
-
delete '/users/:id', to: action.call(User::Delete)
|
14
|
-
get '/users/:id/boards', to: action.call(User::Boards)
|
13
|
+
# get '/accounts', to: action.call(Account::Index)
|
14
|
+
# get '/accounts/:id', to: action.call(Account::Show)
|
15
|
+
# get 'team/users', to: action.call(Team::User::Index)
|
15
16
|
|
16
|
-
# get '/accounts', to: action.call(Account::Index)
|
17
|
-
# get '/accounts/:id', to: action.call(Account::Show)
|
18
|
-
# get 'team/users', to: action.call(Team::User::Index)
|
19
|
-
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fasta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yaro
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hanami-router
|
@@ -203,6 +203,8 @@ files:
|
|
203
203
|
- lib/fasta/server/core/read.rb
|
204
204
|
- lib/fasta/server/core/responder.rb
|
205
205
|
- lib/fasta/server/core/write.rb
|
206
|
+
- lib/fasta/services/router.rb
|
207
|
+
- lib/fasta/services/routes_mapper.rb
|
206
208
|
- lib/fasta/version.rb
|
207
209
|
- tasks/console.rake
|
208
210
|
- tasks/database.rake
|