reck 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +50 -74
- data/lib/reck.rb +16 -1
- data/lib/reck/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9e41fabc8f64172e6a876965805f8809f023d6a69a4c72658fab8e5ad5e7a7f
|
4
|
+
data.tar.gz: a7728943273b489293f1427c7a13d39527ebd7e401dccc91b4c52131583f0434
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b223feb28dc8c6e0f4a0dcbeacb529bab88cfc115a8ec9152e6df508835221e4145455c4146c45a1d2609e1e3f7cd948024be02554b137049a0a35af6ba7101d
|
7
|
+
data.tar.gz: d471b6fb88845324c7ae227e4e94ff1a00c2727fa1684e5d57d8728533444e02c1e4d919d66691256efa120173b2704545f8ec2726264cd505d448d7724f3295
|
data/README.md
CHANGED
@@ -2,20 +2,22 @@
|
|
2
2
|
|
3
3
|
An exception-based web framework for Ruby.
|
4
4
|
|
5
|
-
|
5
|
+
[](https://travis-ci.org/honeybadger-io/reck)
|
6
|
+
[](https://badge.fury.io/rb/reck)
|
7
|
+
|
8
|
+
---
|
9
|
+
:zap: Brought to you by **Honeybadger.io**: Zero-instrumentation, 360 degree
|
10
|
+
coverage of errors, outages and service degradation. [Deploy with confidence and
|
11
|
+
be your team's devops
|
12
|
+
hero!](https://www.honeybadger.io/?utm_source=github&utm_medium=readme&utm_campaign=reck)
|
13
|
+
:zap:
|
6
14
|
|
7
|
-
|
8
|
-
over configuration. We believe this approach works well as a design paradigm but
|
9
|
-
falls down over time (just ask anyone who has maintained a Rails application
|
10
|
-
since version 1). In order to remain competitive with newer high-level (and
|
11
|
-
often concurrent) programming languages like Node and Elixir, Ruby needs a
|
12
|
-
strong component-based framework which let's you use the *right* tool for the
|
13
|
-
job.
|
15
|
+
# Why another framework?
|
14
16
|
|
15
17
|
Reck is very light-weight compared to other web frameworks such as Rails
|
16
|
-
|
17
|
-
exception-based DSL and then get out of the way so that
|
18
|
-
view
|
18
|
+
and Sinatra. We handle the routing layer using a very simple
|
19
|
+
exception-based DSL and then get out of the way so that you can use your
|
20
|
+
preferred model, view, and controller components.
|
19
21
|
|
20
22
|
## Installation
|
21
23
|
|
@@ -26,12 +28,12 @@ $ gem install reck
|
|
26
28
|
## Usage
|
27
29
|
|
28
30
|
To respond to the defined route with rendered content, simply raise an
|
29
|
-
exception. The message of the exception will be evaluated as ERB before
|
30
|
-
added to the response. If the exception is raised without a message,
|
31
|
-
no-content response will be sent. This exception-based DSL is
|
32
|
-
|
31
|
+
exception. The message of the exception will be evaluated as ERB before
|
32
|
+
being added to the response. If the exception is raised without a message,
|
33
|
+
a no-content response will be sent. This exception-based DSL is great for
|
34
|
+
controlling the flow of your application.
|
33
35
|
|
34
|
-
Routing
|
36
|
+
Routing is as simple as:
|
35
37
|
|
36
38
|
```ruby
|
37
39
|
Reck.route '/' do |request|
|
@@ -39,7 +41,7 @@ Reck.route '/' do |request|
|
|
39
41
|
end
|
40
42
|
```
|
41
43
|
|
42
|
-
Want to add authentication? No problem.
|
44
|
+
Want to add authentication? No problem.
|
43
45
|
|
44
46
|
```ruby
|
45
47
|
Reck.route '/admin' do |request|
|
@@ -49,7 +51,7 @@ Reck.route '/admin' do |request|
|
|
49
51
|
end
|
50
52
|
```
|
51
53
|
|
52
|
-
|
54
|
+
The message of each exception is actually a template. Use ERB tags to
|
53
55
|
interpolate Ruby values in your views:
|
54
56
|
|
55
57
|
```ruby
|
@@ -58,7 +60,7 @@ Reck.route '/version' do |request|
|
|
58
60
|
end
|
59
61
|
```
|
60
62
|
|
61
|
-
|
63
|
+
Reck depends on Rack. You also have access to helper methods
|
62
64
|
derived from the keys in Rack's env hash:
|
63
65
|
|
64
66
|
```ruby
|
@@ -87,65 +89,42 @@ Each response inherits from the exception `Reck::Response`.
|
|
87
89
|
## Handling exceptions
|
88
90
|
|
89
91
|
While responses should always be raised, you may wish to handle other types of
|
90
|
-
unexpected exceptions, or "exceptional exceptions"
|
91
|
-
|
92
|
-
|
93
|
-
using Reck, Rails, Sinatra, Rack, or rolling
|
94
|
-
|
95
|
-
There are two ways you can get Honeybadger to monitor Reck:
|
96
|
-
|
97
|
-
1. Reporting errors inside a controller
|
98
|
-
|
99
|
-
```ruby
|
100
|
-
require 'reck'
|
101
|
-
require 'honeybadger'
|
102
|
-
|
103
|
-
Honeybadger.configure do |config|
|
104
|
-
config.api_key = 'your_api_key'
|
105
|
-
end
|
106
|
-
|
107
|
-
Reck.route '/oops' do |request|
|
108
|
-
begin
|
109
|
-
fail 'oops!'
|
110
|
-
rescue Reck::Response
|
111
|
-
raise # Raise the response to the router
|
112
|
-
rescue => e
|
113
|
-
# Exceptional Reck exception: report it with Honeybadger!
|
114
|
-
Honeybadger.notify(e)
|
115
|
-
end
|
116
|
-
end
|
117
|
-
```
|
118
|
-
|
119
|
-
```sh
|
120
|
-
ruby application.rb
|
121
|
-
```
|
92
|
+
unexpected exceptions, or "exceptional exceptions". In these cases, use
|
93
|
+
[Honeybadger](https://www.honeybadger.io/?utm_source=github&utm_medium=readme&utm_campaign=reck).
|
94
|
+
Honeybadger provides middleware (and a bunch of other cool features) to monitor
|
95
|
+
Ruby applications -- whether you're using Reck, Rails, Sinatra, Rack, or rolling
|
96
|
+
your own Ruby web-framework.
|
122
97
|
|
123
|
-
|
98
|
+
To monitor Reck for exceptions:
|
124
99
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
100
|
+
```ruby
|
101
|
+
# application.rb
|
102
|
+
require 'honeybadger'
|
103
|
+
require 'reck'
|
104
|
+
|
105
|
+
Honeybadger.configure do |config|
|
106
|
+
config.api_key = 'your_api_key'
|
107
|
+
config.report_data = true
|
108
|
+
config.exceptions.ignore = [Reck::Response]
|
109
|
+
end
|
133
110
|
|
134
|
-
|
135
|
-
fail 'oops!'
|
136
|
-
end
|
111
|
+
use Honeybadger::Rack::ErrorNotifier
|
137
112
|
|
138
|
-
|
113
|
+
Reck.route '/oops' do |request|
|
114
|
+
fail 'oops!'
|
115
|
+
end
|
116
|
+
```
|
139
117
|
|
140
|
-
|
141
|
-
```
|
118
|
+
Run the server:
|
142
119
|
|
143
|
-
|
144
|
-
|
145
|
-
|
120
|
+
```sh
|
121
|
+
$ ruby application.rb
|
122
|
+
```
|
146
123
|
|
147
124
|
Don't forget to replace `'your_api_key'` with the API key from your [project
|
148
|
-
settings
|
125
|
+
settings
|
126
|
+
page](https://www.honeybadger.io/?utm_source=github&utm_medium=readme&utm_campaign=reck)
|
127
|
+
in Honeybadger.
|
149
128
|
|
150
129
|
## TODO
|
151
130
|
|
@@ -163,8 +142,5 @@ settings page](https://www.honeybadger.io/) on Honeybadger.
|
|
163
142
|
|
164
143
|
## License
|
165
144
|
|
166
|
-
Reck is Copyright
|
145
|
+
Reck is Copyright 2018 © Honeybadger Industries LLC. It is free software, and
|
167
146
|
may be redistributed under the terms specified in the LICENSE file.
|
168
|
-
|
169
|
-
Brought to you by :zap: **Honeybadger.io**: our kick-ass exception tracking is no joke. :trollface:
|
170
|
-
[Start exterminating errors in your Ruby apps today](https://www.honeybadger.io/)!
|
data/lib/reck.rb
CHANGED
@@ -1,7 +1,22 @@
|
|
1
1
|
require 'reck/application'
|
2
2
|
|
3
|
+
$middleware = []
|
4
|
+
|
5
|
+
def use(middleware, *args, &block)
|
6
|
+
$middleware << [middleware, args, block]
|
7
|
+
end
|
8
|
+
|
3
9
|
module Reck
|
4
10
|
at_exit do
|
5
|
-
Rack::
|
11
|
+
app = Rack::Builder.new
|
12
|
+
|
13
|
+
$middleware.each { |c,a,b| app.use(c, *a, &b) }
|
14
|
+
app.run(Reck::Application)
|
15
|
+
|
16
|
+
begin
|
17
|
+
Rack::Handler::WEBrick.run(app)
|
18
|
+
rescue Interrupt
|
19
|
+
# Clean exit
|
20
|
+
end
|
6
21
|
end
|
7
22
|
end
|
data/lib/reck/version.rb
CHANGED