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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b30f33c3c718f175f730590bdd9574aace6896affa9ca21ba3ee9e6935966e98
4
- data.tar.gz: 483840788ea929c19331a3deb5e29345d4b1a6fe14221c0f5d8e31c9633ed7e0
3
+ metadata.gz: ccc6ea929c578f89d0a6ed2b86698e9ec3b9c49059f85a56ac57d2184b3ac384
4
+ data.tar.gz: 3b3066fb504b910f938cd809eeed480d3a9780b6dac9c6438459aeb8508dc5aa
5
5
  SHA512:
6
- metadata.gz: 2d7330d18a22fb0ba5284b2aba7fbacbe4cd9b0c22eeb3ba8c647e20d7fcd000afa5109f2e840912fea94d6979a39ea90d57071bdf7a7c1d75d0943abb29b73e
7
- data.tar.gz: 618b42a35389df7ab4fc88c7f9e37d689183a640ca9ced74c482a85a3b204532ec6d382ec816f8d0997df957f808f53675b0ea1b1360187ae2b90784db95f00a
6
+ metadata.gz: 22393427f0a96b8f199ec99781303379897568080c1c41c165518aaa1d06e7aca0943d644be42b7f081b08ce403a306c8f3b66279b49e32210ae970e34cb0f9a
7
+ data.tar.gz: 114e54e762628f2d79b5f4dad9d148dbd219243c97b819b0445374fb71d69d1b0c5d8b9ea5090c65affeb98bb12bda23f24d755ae4f4444f5d897484c3565c4e
data/lib/fasta/cli.rb CHANGED
@@ -19,5 +19,10 @@ module Fasta
19
19
  copy_file 'Procfile', "#{name}/Procfile"
20
20
  copy_file 'Rakefile', "#{name}/Rakefile"
21
21
  end
22
+
23
+ desc 'go', 'Start your application very fast!'
24
+ def go
25
+ exec("puma boot.ru -e production -p 3210")
26
+ end
22
27
  end
23
28
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Fasta
2
- VERSION = '0.2.4'.freeze
2
+ VERSION = '0.2.6'.freeze
3
3
  end
data/templates/boot.ru CHANGED
@@ -1,3 +1,3 @@
1
1
  require './application.rb'
2
2
 
3
- run $router
3
+ run $router.runnable
@@ -1,19 +1,16 @@
1
- require 'hanami/router'
1
+ require 'fasta/services/router'
2
2
 
3
- $router = Hanami::Router.new do
4
- action = ->(klass) { ->(env) { klass.call(env) } }
5
-
6
- root to: ->(_env) { [200, {}, ['Welcome to API']] }
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
- get '/users', to: action.call(User::Index)
9
- post '/users', to: action.call(User::Create)
10
- get '/users/:id', to: action.call(User::Show)
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
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-05 00:00:00.000000000 Z
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