web_router 0.1.0 → 0.1.1

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: e8ff3199296ad3b1c34874458bbc49b3cec58cb4
4
- data.tar.gz: 041cf5709028df30ac61a26fc36140df35c75cff
3
+ metadata.gz: faf2d63560060a2e0fea9c1528cc4510d51ba4b8
4
+ data.tar.gz: a720b2011e9abe331e9e0c95aaec7e5c46b61b45
5
5
  SHA512:
6
- metadata.gz: 7a6a26708dd53c48f5951fbdaba03b98924f5da9ccf13c2b60061979d8ffaff3cd03c0900365b970195c8745f5666e2c2e799311f5aea9d1f4db95b4bbdc4947
7
- data.tar.gz: 29b42abba8f4450afe56266dce2fac9faa1e71015424a0c2e16e527c339eeda4465c1cf7af65ee1ef81b1e5416be93dc6e012ee35fd72d7d9989177be6a7e3c1
6
+ metadata.gz: b2e18908986771377366b58799852c9a49b7dc9fe4c1cf2ece0b7254533125a2efed29dcd271c5ae463652b131da20941b6b0545405b5428c0114f7a5bc34d52
7
+ data.tar.gz: 0077269c48ddd3758f5c0fed3ba254fd5b2b2c907f8f501e1c1d056d1c6f3ed9f1112f3277cb15542d20bd96ac7aac2bf591d661df15b5bb6bd10300206f8ab7
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  /.bundle/
2
+ /.idea/
2
3
  /.yardoc
3
4
  /Gemfile.lock
4
5
  /_yardoc/
data/README.md CHANGED
@@ -25,8 +25,33 @@ Or install it yourself as:
25
25
 
26
26
  ## Usage
27
27
 
28
- TODO: Write usage instructions here
28
+ 1. Write controllers with methods. WebRouter controllers responds to json, text
29
29
 
30
+ ```ruby
31
+ class TestsController < WebRouter::Controller
32
+ def show
33
+ response(:json, params)
34
+ end
35
+
36
+ def test
37
+ response(:text, "Required method #{request.request_method}")
38
+ end
39
+ end
40
+ ```
41
+
42
+ 2. Create new application and configure it with block of routes
43
+ Available HTTP methods: get, post, put, delete
44
+ You can configure routs using controller`s methods or Rack Applications
45
+
46
+ ```ruby
47
+ WebRouter::Router.new.configure do
48
+ get '/test', ->(env) { [200, {}, ['get test']] }
49
+ post '/test', ->(env) { [200, {}, ['post test']] }
50
+ get '/comments/:name/:other_one', 'tests#show'
51
+ get '/testing', 'tests#test'
52
+ end
53
+
54
+ ```
30
55
  ## Development
31
56
 
32
57
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -15,13 +15,10 @@ private
15
15
  @routes = []
16
16
  end
17
17
 
18
- def get(path, rack_app)
19
- match('GET', path, rack_app)
20
- end
21
-
22
- def post(path, rack_app)
23
- match('POST', path, rack_app)
24
- end
18
+ def get(path, rack_app) match('GET', path, rack_app) end
19
+ def post(path, rack_app) match('POST', path, rack_app) end
20
+ def put(path, rack_app) match('PUT', path, rack_app) end
21
+ def delete(path, rack_app) match('DELETE', path, rack_app) end
25
22
 
26
23
  def match(http_method, path, rack_app)
27
24
  rack_app = get_controller_action(rack_app) if rack_app.is_a? String
@@ -1,3 +1,3 @@
1
1
  module WebRouter
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web_router
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - superedriver