fuprint 0.0.2 → 0.1.0
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/.gitignore +2 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +9 -0
- data/LICENSE +21 -0
- data/README.md +34 -0
- data/config/boot.rb +6 -0
- data/fuprint.gemspec +20 -0
- data/lib/fuprint/request.rb +42 -0
- data/lib/fuprint.rb +12 -1
- metadata +40 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf89346bb5f34af344735449f8b0d8bd488688f1
|
4
|
+
data.tar.gz: 43041a498e150fdefe5a740afc6adea474c96ec7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11e828aa8f0bfb1ae4001607e844cff270c86cdbdeccbddbf9f885384d98032e3ad57f79db1ae0d67390fdcd80c265dbfb51f9047ea9aff48d626bd813adbe4b
|
7
|
+
data.tar.gz: d7b3f646c52f570f4feb5af9cc5937c2b1057f4e26c30109ae468370e5f9b26af9c95302328241773e46efb26fd32d06dc6a14f1214180909e6b2b224e7f9f12
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2016 Fugroup
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Fuprint request printer middleware
|
2
|
+
Rack middleware that prints information about your request to console in development. Perfect for Sinatra or Rack apps that don't come with request ouput built in.
|
3
|
+
|
4
|
+
### Installation
|
5
|
+
```ruby
|
6
|
+
gem install fuprint
|
7
|
+
```
|
8
|
+
or add to Gemfile.
|
9
|
+
|
10
|
+
### Settings
|
11
|
+
```ruby
|
12
|
+
# Print the whole env hash for each request if true
|
13
|
+
Fuprint.debug = false
|
14
|
+
|
15
|
+
# Fuprint only prints in development mode
|
16
|
+
@mode = ENV['RACK_ENV'] || 'development'
|
17
|
+
```
|
18
|
+
|
19
|
+
### Usage
|
20
|
+
```ruby
|
21
|
+
# Require fuprint if you're not using Bundler
|
22
|
+
require 'fuprint'
|
23
|
+
|
24
|
+
# Include as middleware
|
25
|
+
use Fuprint::Request
|
26
|
+
```
|
27
|
+
|
28
|
+
That's it!
|
29
|
+
|
30
|
+
This library is actively maintained by [Fugroup Ltd.](http://www.fugroup.net) We are the creators of [CrowdfundHQ.](https://crowdfundhq.com)
|
31
|
+
|
32
|
+
Thanks!
|
33
|
+
|
34
|
+
`@authors: Vidar`
|
data/config/boot.rb
ADDED
data/fuprint.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'fuprint'
|
3
|
+
s.version = '0.1.0'
|
4
|
+
s.date = '2017-01-05'
|
5
|
+
s.summary = "Fuprint Rack request printer middleware"
|
6
|
+
s.description = "Rack middleware that prints information about your request to console in development."
|
7
|
+
s.authors = ["Fugroup Limited"]
|
8
|
+
s.email = 'mail@fugroup.net'
|
9
|
+
|
10
|
+
s.homepage = 'https://github.com/fugroup/fuprint'
|
11
|
+
s.license = 'MIT'
|
12
|
+
|
13
|
+
s.add_runtime_dependency 'rack', '>= 0'
|
14
|
+
s.add_development_dependency 'futest', '>= 0'
|
15
|
+
|
16
|
+
s.require_paths = ['lib']
|
17
|
+
s.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Fuprint
|
2
|
+
class Request
|
3
|
+
|
4
|
+
def initialize(app)
|
5
|
+
@app = app
|
6
|
+
end
|
7
|
+
|
8
|
+
# Receive the request and print info
|
9
|
+
def call(env)
|
10
|
+
|
11
|
+
# Only active in development mode
|
12
|
+
if Fuprint.mode == 'development'
|
13
|
+
r = ::Rack::Request.new(env)
|
14
|
+
|
15
|
+
puts env.inspect if Fuprint.debug
|
16
|
+
|
17
|
+
# Delete the splat and captures if Fuprint.splat = false (default)
|
18
|
+
r.params.delete_if{|k, v| %w[splat captures].include?(k)} unless Fuprint.splat
|
19
|
+
|
20
|
+
# Strip all params if Fuprint.strip = true (default)
|
21
|
+
r.params.each{|k, v| request.params[k] = v.strip} if Fuprint.strip
|
22
|
+
|
23
|
+
begin
|
24
|
+
puts "\n@ #{o(r.request_method.upcase)} #{o(r.fullpath)}"
|
25
|
+
puts "$ #{o(r.params)}"
|
26
|
+
rescue => e
|
27
|
+
puts "! #{e}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
@app.call(env)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
# Colorize output, 33 is :green (default), 31 is :red
|
37
|
+
def o(s, c = :green)
|
38
|
+
%{\e[#{c == :green ? 33 : 31}m#{s}\e[0m}
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
data/lib/fuprint.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rack'
|
2
|
+
|
1
3
|
module Fuprint
|
2
4
|
|
3
5
|
# # # # # #
|
@@ -7,8 +9,17 @@ module Fuprint
|
|
7
9
|
# @license: MIT, contributions are welcome.
|
8
10
|
# # # # # #
|
9
11
|
|
10
|
-
class << self; attr_accessor :mode, :debug; end
|
12
|
+
class << self; attr_accessor :splat, :strip, :mode, :debug; end
|
13
|
+
# Include splat and captures from Sinatra params
|
14
|
+
@splat = false
|
15
|
+
|
16
|
+
# Strip all params
|
17
|
+
@strip = true
|
18
|
+
|
19
|
+
# Mode
|
11
20
|
@mode = ENV['RACK_ENV'] || 'development'
|
21
|
+
|
22
|
+
# Debug
|
12
23
|
@debug = false
|
13
24
|
end
|
14
25
|
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fuprint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fugroup Limited
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
12
|
-
dependencies:
|
11
|
+
date: 2017-01-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rack
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: futest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
description: Rack middleware that prints information about your request to console
|
14
42
|
in development.
|
15
43
|
email: mail@fugroup.net
|
@@ -17,7 +45,15 @@ executables: []
|
|
17
45
|
extensions: []
|
18
46
|
extra_rdoc_files: []
|
19
47
|
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- CHANGELOG.md
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE
|
52
|
+
- README.md
|
53
|
+
- config/boot.rb
|
54
|
+
- fuprint.gemspec
|
20
55
|
- lib/fuprint.rb
|
56
|
+
- lib/fuprint/request.rb
|
21
57
|
homepage: https://github.com/fugroup/fuprint
|
22
58
|
licenses:
|
23
59
|
- MIT
|
@@ -38,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
38
74
|
version: '0'
|
39
75
|
requirements: []
|
40
76
|
rubyforge_project:
|
41
|
-
rubygems_version: 2.
|
77
|
+
rubygems_version: 2.6.8
|
42
78
|
signing_key:
|
43
79
|
specification_version: 4
|
44
80
|
summary: Fuprint Rack request printer middleware
|