woah 1.0.0 → 1.0.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
  SHA256:
3
- metadata.gz: 1f1640d590890f586e4b4d0f4a05fb83bc47d4e3a444496eaa634def37be851d
4
- data.tar.gz: cf163513135e99c8998c317a70bfb120849d15c835164ebcb5f01787db6a8d6e
3
+ metadata.gz: e89d5accb3e229e345ca7252a4cdc38a4858b242c03d213d50fa586595cfc209
4
+ data.tar.gz: 63eec991362896f918a6b775c16ec7e92d4229333013723996ba21a934399218
5
5
  SHA512:
6
- metadata.gz: e98ff9bee429818defe3dd9582059cb2949b10cfd1b8c85bdd2c84c8aabac4bf354d84f474d5852cee5261d6e083d52d0b53f86f460aba736dc7d4fb3bb2e3fa
7
- data.tar.gz: c956a1ae35bf2a132aab05fbd10a27c72b2da3bd2d73adb5e917e187203dd7e21d191c85506187bd1c40e2f2cda2daf736a76d88a420a45fda0c32fd9dc2f988
6
+ metadata.gz: 9a75175eab7ec60a0b21eabd1b13773e7d59541d6371e32d08873b1f64b8395fb11d87aec770357ab643c68820b35302af7f035a4e15499651ab4b3ba7c76467
7
+ data.tar.gz: 832ac1d476cb10c78bf094a76d0674d14db0fed992e0c2715c460473e3d647c490d91bab97162f851ffe18eea4a3ba777efd0d1260dde4427df8d035df844a82
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Woah!
2
2
  [![Build Status](https://travis-ci.org/knarka/woah.svg?branch=master)](https://travis-ci.org/knarka/woah)
3
+ [![Coverage Status](https://coveralls.io/repos/github/knarka/woah/badge.svg?branch=master)](https://coveralls.io/github/knarka/woah?branch=master)
3
4
  [![Gem Version](https://badge.fury.io/rb/woah.svg)](https://badge.fury.io/rb/woah)
4
5
 
5
6
  Woah! is a minimal web framework built on Rack. It's primary design goal is to be unobtrusive, and to just let you do your thing, dude.
@@ -7,7 +8,7 @@ Woah! is a minimal web framework built on Rack. It's primary design goal is to b
7
8
  ## Installation
8
9
  `gem install woah`
9
10
 
10
- ## What now???
11
+ ## What do I do with it???
11
12
  Simple. You're gonna want to extend Woah::Base, which will be your app's, er, base.
12
13
 
13
14
  ```ruby
@@ -14,7 +14,7 @@ module Woah
14
14
 
15
15
  @@before&.call
16
16
 
17
- response = handle_route env
17
+ response = resolve_route env['REQUEST_METHOD'], env['REQUEST_URI']
18
18
 
19
19
  @@after&.call
20
20
 
@@ -25,10 +25,9 @@ module Woah
25
25
  response.values
26
26
  end
27
27
 
28
- private
29
-
30
- def handle_route(env)
31
- route = @@routes.select { |r| r.matches?(env['REQUEST_METHOD'], env['REQUEST_URI']) }[0]
28
+ # Resolves and executes a round
29
+ def resolve_route(method, path)
30
+ route = @@routes.select { |r| r.matches?(method, path) }[0]
32
31
 
33
32
  if route.nil?
34
33
  return {
@@ -73,11 +72,20 @@ module Woah
73
72
  @@after = action
74
73
  end
75
74
 
75
+ # Redirect to another route.
76
+ def redirect_to(path, method = 'GET')
77
+ result = new.resolve_route method, path
78
+
79
+ %i[status headers].each do |r|
80
+ set r, result[r]
81
+ end
82
+
83
+ result[:body]
84
+ end
85
+
76
86
  # Override an item in the response.
77
87
  def set(item, content)
78
- unless %i[status headers body].include? item
79
- raise 'unknown item ' + item.to_s + ', cannot override'
80
- end
88
+ raise "unknown item #{item}, cannot override" unless %i[status headers body].include? item
81
89
 
82
90
  @@override[item] = content
83
91
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Woah
4
4
  # Woah!'s current version.
5
- VERSION = '1.0.0'
5
+ VERSION = '1.0.1'
6
6
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ class RedirectTest < MiniTest::Test
4
+ def setup
5
+ @env = {}
6
+ end
7
+
8
+ # rubocop:disable Style/GlobalVars
9
+ def test_redirect
10
+ TestApp.on '/goback' do
11
+ $something = 'gone back'
12
+ TestApp.redirect_to '/'
13
+ end
14
+
15
+ @env['REQUEST_URI'] = '/goback'
16
+ @env['REQUEST_METHOD'] = 'GET'
17
+ response = TestApp.call @env
18
+
19
+ assert_equal 200, response[0]
20
+ assert_equal 'hi there!', response[2]
21
+ assert_equal 'gone back', $something
22
+ end
23
+ # rubocop:enable Style/GlobalVars
24
+ end
File without changes
@@ -1,16 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'simplecov'
4
+ require 'coveralls'
5
+
6
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
4
7
  SimpleCov.start do
5
- add_filter 'test/'
8
+ add_filter 'test/'
6
9
  end
7
- SimpleCov.start
8
10
 
9
11
  ENV['RACK_ENV'] = 'test'
10
12
 
11
13
  require 'minitest/autorun'
12
14
 
13
- require_relative 'testapp'
15
+ require_relative 'test_app'
14
16
 
15
17
  Dir.foreach('test/') do |test|
16
18
  next if ['.', '..'].include? test
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: woah
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - knarka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-24 00:00:00.000000000 Z
11
+ date: 2018-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -40,8 +40,9 @@ files:
40
40
  - test/basic_verbs_test.rb
41
41
  - test/before_after_test.rb
42
42
  - test/on_method_test.rb
43
+ - test/redirect_test.rb
44
+ - test/test_app.rb
43
45
  - test/test_helper.rb
44
- - test/testapp.rb
45
46
  homepage: https://github.com/knarka/woah
46
47
  licenses:
47
48
  - GPL-3.0