fuprint 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/fuprint.gemspec +2 -2
- data/lib/fuprint/helpers.rb +36 -0
- data/lib/fuprint/request.rb +8 -28
- data/lib/fuprint.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7051e0881790746191bfc00fc388210c0a3744e5
|
4
|
+
data.tar.gz: 9af912982dfef3a4b29a71355f3c6236d051ecdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d4dd48477a746b76ddb309192d7ad5cfe66f5cadc1e12fbc05291e28708630b0b6ec3598eb3112019f7199bc1a2ce479eb054594e323e120712c605935c5a37
|
7
|
+
data.tar.gz: 0066dbf465f5f0bb0799f6b4fd2475132e059b5fd0409c6524b39cde40c8b2172ba586b3e2a4daf1bc354068f987c4b3c7e66053fcfdbf88e0ce53180bc0e12d
|
data/CHANGELOG.md
CHANGED
data/fuprint.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'fuprint'
|
3
|
-
s.version = '0.1.
|
4
|
-
s.date = '2017-
|
3
|
+
s.version = '0.1.4'
|
4
|
+
s.date = '2017-07-12'
|
5
5
|
s.summary = "Fuprint Rack request printer middleware"
|
6
6
|
s.description = "Rack middleware that prints information about your request to console in development."
|
7
7
|
s.authors = ["Fugroup Limited"]
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Fuprint
|
2
|
+
module Helpers
|
3
|
+
|
4
|
+
# Print info
|
5
|
+
def print_info(env, req = nil)
|
6
|
+
|
7
|
+
# Only active in development or test modes
|
8
|
+
return unless %w[development test].include?(Fuprint.mode)
|
9
|
+
|
10
|
+
# Create request unless it exists
|
11
|
+
req = ::Rack::Request.new(env) unless req
|
12
|
+
|
13
|
+
# Print debug
|
14
|
+
puts env.inspect if Fuprint.debug
|
15
|
+
|
16
|
+
# Delete the splat and captures if Fuprint.splat = false (default)
|
17
|
+
req.params.delete_if{|k, v| %w[splat captures].include?(k)} unless Fuprint.splat
|
18
|
+
|
19
|
+
# Strip all params if Fuprint.strip = true (default)
|
20
|
+
req.params.each{|k, v| req.params[k] = (v.is_a?(String) ? v.strip : v)} if Fuprint.strip
|
21
|
+
|
22
|
+
begin
|
23
|
+
puts "\n@ #{colorize(req.request_method.upcase)} #{colorize(req.fullpath)}"
|
24
|
+
puts "$ #{colorize(req.params)}"
|
25
|
+
rescue => e
|
26
|
+
puts "! #{e}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Colorize output, 33 is :green (default), 31 is :red
|
31
|
+
def colorize(s, c = :green)
|
32
|
+
%{\e[#{c == :green ? 33 : 31}m#{s}\e[0m}
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
data/lib/fuprint/request.rb
CHANGED
@@ -1,41 +1,21 @@
|
|
1
1
|
module Fuprint
|
2
2
|
class Request
|
3
3
|
|
4
|
+
include ::Fuprint::Helpers
|
5
|
+
|
4
6
|
def initialize(app)
|
5
7
|
@app = app
|
6
8
|
end
|
7
9
|
|
8
|
-
#
|
10
|
+
# Thread safe call
|
9
11
|
def call(env)
|
10
|
-
|
11
|
-
# Only active in development or test modes
|
12
|
-
if %w[development test].include?(Fuprint.mode)
|
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| r.params[k] = (v.is_a?(String) ? v.strip : v)} 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)
|
12
|
+
dup.call!(env)
|
32
13
|
end
|
33
14
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
%{\e[#{c == :green ? 33 : 31}m#{s}\e[0m}
|
15
|
+
# Receive the request and print info
|
16
|
+
def call!(env)
|
17
|
+
print_info(env)
|
18
|
+
@app.call(env)
|
39
19
|
end
|
40
20
|
|
41
21
|
end
|
data/lib/fuprint.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fuprint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
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-
|
11
|
+
date: 2017-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- config/boot.rb
|
54
54
|
- fuprint.gemspec
|
55
55
|
- lib/fuprint.rb
|
56
|
+
- lib/fuprint/helpers.rb
|
56
57
|
- lib/fuprint/request.rb
|
57
58
|
homepage: https://github.com/fugroup/fuprint
|
58
59
|
licenses:
|
@@ -74,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
75
|
version: '0'
|
75
76
|
requirements: []
|
76
77
|
rubyforge_project:
|
77
|
-
rubygems_version: 2.6.
|
78
|
+
rubygems_version: 2.6.10
|
78
79
|
signing_key:
|
79
80
|
specification_version: 4
|
80
81
|
summary: Fuprint Rack request printer middleware
|