peek-faraday 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +17 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +47 -0
- data/Rakefile +1 -0
- data/app/views/peek/views/_faraday.html.erb +1 -0
- data/lib/peek/views/faraday.rb +43 -0
- data/lib/peek-faraday/railtie.rb +6 -0
- data/lib/peek-faraday/version.rb +5 -0
- data/lib/peek-faraday.rb +3 -0
- data/peek-faraday.gemspec +24 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YmQ2YTA2OTRhZDQzZTkyZDNiMzVlMGNiMmM3ZmQ1ODUwMTNmZGE5MA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NGJhOTk4ZWMyZDdkNmM0ZWMyNjgyODdkOGQ4M2JmMjg3MGUzNDk5MA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NjkzYjAzNjMyMTNhOTYxZmM3YTk1NDVlYTVmYjg4YTZlYTJiNDJmYjk4NzVm
|
10
|
+
OTc4YTQ4ZDgyOTM0YzgwNjBjN2VlOTJkM2UzZTQzNDcwZmNmZjYxOTgxNWFh
|
11
|
+
MzY3MDM4MmE5NDFlNmZiMjg4NDUxY2RlMzhlMGNlY2Q0ZGZjMDg=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
M2Q1MmQ4ODZkYjI3OGVjMzYxZDkxNWY5ZTcxYTUxYzM2OTZiZTY2NTM4MWZk
|
14
|
+
YmViYzQ3OTJhZmJkYzFhZTU2NmFjNTE0OWMwYmIzNTQ3OTcyNjZkZGI0Mjlh
|
15
|
+
MWNjYmY5YmVlNjBkNjM4YjE3NmRlNmIzY2E1YzZiZjczNmJhNGI=
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Grzegorz Kołodziejczyk
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# Peek::Faraday
|
2
|
+
|
3
|
+
Take a peek into the Faraday requests made during your application's requests.
|
4
|
+
|
5
|
+
Things this peek view provides:
|
6
|
+
|
7
|
+
- Total number of Faraday requests called during the request
|
8
|
+
- The duration of the Faraday requests made during the request
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
gem 'peek-faraday'
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install peek-faraday
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
Add the following to your `config/initializers/peek.rb`:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
Peek.into Peek::Views::Faraday
|
30
|
+
```
|
31
|
+
|
32
|
+
Configure your Faraday connection to use instrumentation
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
conn = Faraday.new(url) do |conn|
|
36
|
+
conn.use :instrumentation
|
37
|
+
conn.adapter Faraday.default_adapter
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
1. Fork it
|
44
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
45
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
46
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
47
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1 @@
|
|
1
|
+
<strong><span data-defer-to="<%= view.defer_key %>-duration">...</span> / <span data-defer-to="<%= view.defer_key %>-calls">...</span></strong> faraday
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'atomic'
|
2
|
+
|
3
|
+
module Peek
|
4
|
+
module Views
|
5
|
+
class Faraday < View
|
6
|
+
def initialize(options = {})
|
7
|
+
@duration = Atomic.new(0)
|
8
|
+
@calls = Atomic.new(0)
|
9
|
+
|
10
|
+
setup_subscribers
|
11
|
+
end
|
12
|
+
|
13
|
+
def formatted_duration
|
14
|
+
ms = @duration.value * 1000
|
15
|
+
if ms >= 1000
|
16
|
+
"%.2fms" % ms
|
17
|
+
else
|
18
|
+
"%.0fms" % ms
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def results
|
23
|
+
{ :duration => formatted_duration, :calls => @calls.value }
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def setup_subscribers
|
29
|
+
# Reset each counter when a new request starts
|
30
|
+
before_request do
|
31
|
+
@duration.value = 0
|
32
|
+
@calls.value = 0
|
33
|
+
end
|
34
|
+
|
35
|
+
subscribe(/request.faraday/) do |name, start, finish, id, payload|
|
36
|
+
duration = (finish - start)
|
37
|
+
@duration.update { |value| value + duration }
|
38
|
+
@calls.update { |value| value + 1 }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/peek-faraday.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'peek-faraday/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = 'peek-faraday'
|
8
|
+
gem.version = Peek::Faraday::VERSION
|
9
|
+
gem.authors = ['Grzesiek Kołodziejczyk']
|
10
|
+
gem.email = ['gk@code-fu.pl']
|
11
|
+
gem.description = %q{Take a peek into the Faraday requests made during your application's requests.}
|
12
|
+
gem.summary = %q{Take a peek into the Faraday requests made during your application's requests.}
|
13
|
+
gem.homepage = 'https://github.com/grk/peek-faraday'
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ['lib']
|
19
|
+
|
20
|
+
gem.add_dependency 'peek'
|
21
|
+
gem.add_dependency 'faraday'
|
22
|
+
gem.add_dependency 'faraday_middleware'
|
23
|
+
gem.add_dependency 'atomic', '>= 1.0.0'
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: peek-faraday
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Grzesiek Kołodziejczyk
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-04-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ! '>='
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0'
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ! '>='
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '0'
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
name: peek
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
version_requirements: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
name: faraday
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
version_requirements: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
type: :runtime
|
53
|
+
prerelease: false
|
54
|
+
name: faraday_middleware
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 1.0.0
|
61
|
+
version_requirements: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 1.0.0
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
name: atomic
|
69
|
+
description: Take a peek into the Faraday requests made during your application's
|
70
|
+
requests.
|
71
|
+
email:
|
72
|
+
- gk@code-fu.pl
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- CHANGELOG.md
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- app/views/peek/views/_faraday.html.erb
|
84
|
+
- lib/peek-faraday.rb
|
85
|
+
- lib/peek-faraday/railtie.rb
|
86
|
+
- lib/peek-faraday/version.rb
|
87
|
+
- lib/peek/views/faraday.rb
|
88
|
+
- peek-faraday.gemspec
|
89
|
+
homepage: https://github.com/grk/peek-faraday
|
90
|
+
licenses: []
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ! '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.0.3
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: Take a peek into the Faraday requests made during your application's requests.
|
112
|
+
test_files: []
|