peek-faraday 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
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=
2
+ SHA1:
3
+ metadata.gz: 2d42f1e796e6b1d44b642e605d64ceeb021bf111
4
+ data.tar.gz: 5d2d38f84f52482894ba27975d32150a71de4eb0
5
+ SHA512:
6
+ metadata.gz: 0ac19e4bc5d517635043a8803baf6df110d6b02a440349669ea4ebc914a29fb4fcadde034367d9a4d37f79b27089c1cc0ed9623ba2b6ff5f651514d00c5179f1
7
+ data.tar.gz: af4bf09a6884efa6c50cd65307018e3ecb08a1abe4e50d8c84f7562537b7c064f3a39051136757f3cc79043d5a37ae2caf2dded097c764842f550e3128a5c59a
@@ -1,3 +1,8 @@
1
+ # 2.0.0
2
+
3
+ - [API breaking] Need to add `require peek/views/faraday` to your css and js.
4
+ - Adds a drop-down with a list of faraday requests, their execution time and callstack.
5
+
1
6
  # 1.0.0
2
7
 
3
8
  - Initial release.
data/README.md CHANGED
@@ -29,6 +29,20 @@ Add the following to your `config/initializers/peek.rb`:
29
29
  Peek.into Peek::Views::Faraday
30
30
  ```
31
31
 
32
+ Add the following to your `app/assets/javascripts/application.js`:
33
+
34
+ ```javascript
35
+ //= require peek/views/faraday
36
+ ```
37
+
38
+ Add the following to your `app/assets/javascripts/application.css`:
39
+
40
+ ```css
41
+ /*
42
+ *= require peek/views/faraday
43
+ */
44
+ ```
45
+
32
46
  Configure your Faraday connection to use instrumentation
33
47
 
34
48
  ```ruby
@@ -0,0 +1,15 @@
1
+ $(document).on 'peek:render', (e, requestId, results) ->
2
+ requestList = $('#peek-faraday-details > ul')
3
+ requestList.empty()
4
+ for request in results.data['faraday'].requests
5
+ li = $('<li class="peek-faraday-request"></li>').appendTo(requestList).attr('title', 'Click to toggle stacktrace').tipsy()
6
+ $('<span class="peek-faraday-request-duration"></span>').appendTo(li).text(request.duration)
7
+ $('<span class="peek-faraday-request-method"></span>').appendTo(li).text(request.method)
8
+ $('<span class="peek-faraday-request-path"></span>').appendTo(li).text(request.path)
9
+ $('<span class="peek-faraday-request-callstack" style="display:none"></span>').appendTo(li).text(request.callstack)
10
+
11
+ $(document).on 'click', '#peek-faraday-details-toggle', ->
12
+ $('#peek-faraday-details').toggle()
13
+
14
+ $(document).on 'click', '.peek-faraday-request', ->
15
+ $(this).find(".peek-faraday-request-callstack").slideToggle()
@@ -0,0 +1,52 @@
1
+ #peek-faraday-details-toggle {
2
+ cursor: pointer;
3
+ }
4
+ $width: 800px;
5
+ $time_width: 70px;
6
+ $request_method_width: 40px;
7
+ $request_path_width: $width - $time_width - $request_method_width;
8
+ #peek-faraday-details {
9
+ > ul {
10
+ position: absolute;
11
+ z-index: 1000;
12
+ right: 20px;
13
+ width: $width;
14
+ border: solid 1px black;
15
+ background: white;
16
+ border-radius: 3px;
17
+ padding: 3px;
18
+ line-height: 15px;
19
+ font-size: 13px;
20
+ text-shadow: none;
21
+ list-style-type: none;
22
+ > li {
23
+ border-top: solid 1px rgb(153,153,153);
24
+ &:first-child { border-top: none; }
25
+ padding: 2px 0;
26
+ > span {
27
+ display: inline-block;
28
+ vertical-align: top;
29
+ }
30
+ > .peek-faraday-request-duration {
31
+ width: $time_width - 5px;
32
+ padding-right: 5px;
33
+ text-align: right;
34
+ }
35
+ > .peek-faraday-request-method, > .peek-faraday-request-path {
36
+ color: black;
37
+ font-family: monospace;
38
+ }
39
+ > .peek-faraday-request-method {
40
+ width: $request_method_width;
41
+ }
42
+ > .peek-faraday-request-path {
43
+ width: $request_path_width;
44
+ }
45
+ > .peek-faraday-request-callstack {
46
+ font-family: monospace;
47
+ white-space: pre;
48
+ margin-left: 2em;
49
+ }
50
+ }
51
+ }
52
+ }
@@ -1 +1,9 @@
1
- <strong><span data-defer-to="<%= view.defer_key %>-duration">...</span> / <span data-defer-to="<%= view.defer_key %>-calls">...</span></strong> faraday
1
+ <strong>
2
+ <span data-defer-to="<%= view.defer_key %>-duration">...</span>
3
+ /
4
+ <span data-defer-to="<%= view.defer_key %>-calls">...</span>
5
+ </strong>
6
+ <span id="peek-faraday-details-toggle">faraday</span>
7
+ <div id="peek-faraday-details" style="display: none">
8
+ <ul></ul>
9
+ </div>
@@ -1,5 +1,5 @@
1
1
  module Peek
2
2
  module Faraday
3
- VERSION = '1.0.0'
3
+ VERSION = '2.0.0'
4
4
  end
5
5
  end
@@ -6,12 +6,13 @@ module Peek
6
6
  def initialize(options = {})
7
7
  @duration = Atomic.new(0)
8
8
  @calls = Atomic.new(0)
9
+ @requests = Atomic.new([].freeze)
9
10
 
10
11
  setup_subscribers
11
12
  end
12
13
 
13
14
  def formatted_duration
14
- ms = @duration.value * 1000
15
+ ms = @duration.value
15
16
  if ms >= 1000
16
17
  "%.2fms" % ms
17
18
  else
@@ -20,7 +21,7 @@ module Peek
20
21
  end
21
22
 
22
23
  def results
23
- { :duration => formatted_duration, :calls => @calls.value }
24
+ { :duration => formatted_duration, :calls => @calls.value, :requests => @requests.value }
24
25
  end
25
26
 
26
27
  private
@@ -30,14 +31,20 @@ module Peek
30
31
  before_request do
31
32
  @duration.value = 0
32
33
  @calls.value = 0
34
+ @requests.value = [].freeze
33
35
  end
34
36
 
35
37
  subscribe(/request.faraday/) do |name, start, finish, id, payload|
36
- duration = (finish - start)
38
+ duration = (finish - start) * 1000
37
39
  @duration.update { |value| value + duration }
38
40
  @calls.update { |value| value + 1 }
41
+ @requests.update { |value| (value + [{:method => payload[:method].to_s.upcase, :path => payload[:url].to_s, :duration => '%.2fms' % duration, :callstack => clean_backtrace}]).freeze }
39
42
  end
40
43
  end
44
+
45
+ def clean_backtrace
46
+ Rails.backtrace_cleaner.clean(caller).join("\n")
47
+ end
41
48
  end
42
49
  end
43
50
  end
metadata CHANGED
@@ -1,71 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peek-faraday
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grzesiek Kołodziejczyk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-07 00:00:00.000000000 Z
11
+ date: 2015-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
+ name: peek
14
15
  requirement: !ruby/object:Gem::Requirement
15
16
  requirements:
16
- - - ! '>='
17
+ - - ">="
17
18
  - !ruby/object:Gem::Version
18
19
  version: '0'
20
+ type: :runtime
21
+ prerelease: false
19
22
  version_requirements: !ruby/object:Gem::Requirement
20
23
  requirements:
21
- - - ! '>='
24
+ - - ">="
22
25
  - !ruby/object:Gem::Version
23
26
  version: '0'
24
- type: :runtime
25
- prerelease: false
26
- name: peek
27
27
  - !ruby/object:Gem::Dependency
28
+ name: faraday
28
29
  requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ! '>='
31
+ - - ">="
31
32
  - !ruby/object:Gem::Version
32
33
  version: '0'
34
+ type: :runtime
35
+ prerelease: false
33
36
  version_requirements: !ruby/object:Gem::Requirement
34
37
  requirements:
35
- - - ! '>='
38
+ - - ">="
36
39
  - !ruby/object:Gem::Version
37
40
  version: '0'
38
- type: :runtime
39
- prerelease: false
40
- name: faraday
41
41
  - !ruby/object:Gem::Dependency
42
+ name: faraday_middleware
42
43
  requirement: !ruby/object:Gem::Requirement
43
44
  requirements:
44
- - - ! '>='
45
+ - - ">="
45
46
  - !ruby/object:Gem::Version
46
47
  version: '0'
48
+ type: :runtime
49
+ prerelease: false
47
50
  version_requirements: !ruby/object:Gem::Requirement
48
51
  requirements:
49
- - - ! '>='
52
+ - - ">="
50
53
  - !ruby/object:Gem::Version
51
54
  version: '0'
52
- type: :runtime
53
- prerelease: false
54
- name: faraday_middleware
55
55
  - !ruby/object:Gem::Dependency
56
+ name: atomic
56
57
  requirement: !ruby/object:Gem::Requirement
57
58
  requirements:
58
- - - ! '>='
59
+ - - ">="
59
60
  - !ruby/object:Gem::Version
60
61
  version: 1.0.0
62
+ type: :runtime
63
+ prerelease: false
61
64
  version_requirements: !ruby/object:Gem::Requirement
62
65
  requirements:
63
- - - ! '>='
66
+ - - ">="
64
67
  - !ruby/object:Gem::Version
65
68
  version: 1.0.0
66
- type: :runtime
67
- prerelease: false
68
- name: atomic
69
69
  description: Take a peek into the Faraday requests made during your application's
70
70
  requests.
71
71
  email:
@@ -74,12 +74,14 @@ executables: []
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
- - .gitignore
77
+ - ".gitignore"
78
78
  - CHANGELOG.md
79
79
  - Gemfile
80
80
  - LICENSE.txt
81
81
  - README.md
82
82
  - Rakefile
83
+ - app/assets/javascripts/peek/views/faraday.js.coffee
84
+ - app/assets/stylesheets/peek/views/faraday.css.scss
83
85
  - app/views/peek/views/_faraday.html.erb
84
86
  - lib/peek-faraday.rb
85
87
  - lib/peek-faraday/railtie.rb
@@ -95,17 +97,17 @@ require_paths:
95
97
  - lib
96
98
  required_ruby_version: !ruby/object:Gem::Requirement
97
99
  requirements:
98
- - - ! '>='
100
+ - - ">="
99
101
  - !ruby/object:Gem::Version
100
102
  version: '0'
101
103
  required_rubygems_version: !ruby/object:Gem::Requirement
102
104
  requirements:
103
- - - ! '>='
105
+ - - ">="
104
106
  - !ruby/object:Gem::Version
105
107
  version: '0'
106
108
  requirements: []
107
109
  rubyforge_project:
108
- rubygems_version: 2.0.3
110
+ rubygems_version: 2.4.5
109
111
  signing_key:
110
112
  specification_version: 4
111
113
  summary: Take a peek into the Faraday requests made during your application's requests.