faraday-log-subscriber 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d7e5460b895f155fd53e7470064ec0d1d45a27c
4
- data.tar.gz: c2bceb0c8a152add6ddb34c8a96ef7739d3c4037
3
+ metadata.gz: 8b2fbdc08f802375c00f7e51d146438c5eaba500
4
+ data.tar.gz: c1941d984cbecbcb6c25d74de7f768b90b311d4d
5
5
  SHA512:
6
- metadata.gz: 48875b2b7792c1234662c9e82414421e12ce2f97dc3d55c37a099e408448567acb59d1dac573d7cc6497ff3ba0bdc3d3076f360f98c60586a2c378389ae4eb11
7
- data.tar.gz: 39e36421da6a5f6b514b070677cdb81fca8470404d657350d3b570ee8455d19de99910137996a4326c07ae8da93d0d96b008b747d88b0710897fe1efa9b17fe6
6
+ metadata.gz: 2f064e0c4fffb36073c59ee0a4ad51da1305c9d7e58fde394f7f9af0be2e0f5b531307aa5b93317a1f01c7aceac6d016fffcc00d50243f8c2385e400f7d9db6a
7
+ data.tar.gz: 7e40b22ac4c5999d233ffca8528d9c6e9e202163fb2605c3a16d9a2961876cce9b8e8eaac9abb5f621f6468716dd0dc597ba0f068c9f97cf635afd9739ca711f
data/README.md CHANGED
@@ -1,36 +1,49 @@
1
- # Faraday::Log::Subscriber
1
+ # Faraday Log Subscriber
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/faraday/log/subscriber`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ A `ActiveSupport::LogSubscriber` to log HTTP requests made by a [Faraday](https://github.com/lostisland/faraday) client instance.
6
4
 
7
5
  ## Installation
8
6
 
9
- Add this line to your application's Gemfile:
7
+ Add it to your Gemfile:
10
8
 
11
9
  ```ruby
12
10
  gem 'faraday-log-subscriber'
13
11
  ```
14
12
 
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
13
+ ## Usage
20
14
 
21
- $ gem install faraday-log-subscriber
15
+ You have to use the `:instrumentation` middleware from [`faraday_middleware`](https://github.com/lostisland/faraday_middleware) to
16
+ instrument your requests.
22
17
 
23
- ## Usage
18
+ ```ruby
19
+ client = Faraday.new('https://api.github.com') do |builder|
20
+ builder.use :instrumentation
21
+ builder.adapter :net_http
22
+ end
24
23
 
25
- TODO: Write usage instructions here
24
+ client.get('repos/rails/rails')
25
+ # 'Faraday GET [200] (1026.9ms) https://api.github.com/repos/rails/rails'
26
+ ```
26
27
 
27
- ## Development
28
+ ### `faraday-http-cache` integration
28
29
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+ If you use the [`faraday-http-cache`](https://github.com/plataformatec/faraday-http-cache) gem, an extra line will be logged regarding
31
+ the cache status of the requested URL:
30
32
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
33
 
33
- ## Contributing
34
+ ```ruby
35
+ client = Faraday.new('https://api.github.com') do |builder|
36
+ builder.use :instrumentation
37
+ builder.use :http_cache, instrumenter: ActiveSupport::Notifications
38
+ builder.adapter :net_http
39
+ end
40
+
41
+ client.get('repos/rails/rails')
42
+ client.get('repos/rails/rails')
43
+ # Faraday HTTP Cache [fresh] https://api.github.com/repos/rails/rails
44
+ # Faraday GET [200] (1.7ms) https://api.github.com/repos/rails/rails
45
+ ```
34
46
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/faraday-log-subscriber.
47
+ ## License
36
48
 
49
+ Copyright (c) 2015 Plataformatec. See LICENSE file.
@@ -4,6 +4,11 @@ module Faraday
4
4
 
5
5
  protected
6
6
 
7
+ def process_action(action, *args)
8
+ Faraday::LogSubscriber.reset_runtime
9
+ super
10
+ end
11
+
7
12
  def append_info_to_payload(payload)
8
13
  super
9
14
  payload[:faraday_runtime] = Faraday::LogSubscriber.runtime
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faraday-log-subscriber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Mazza
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-14 00:00:00.000000000 Z
11
+ date: 2016-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.9'
41
41
  - !ruby/object:Gem::Dependency
42
- name: activesupport
42
+ name: actionpack
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  version: '0'
140
140
  requirements: []
141
141
  rubyforge_project:
142
- rubygems_version: 2.4.5
142
+ rubygems_version: 2.5.1
143
143
  signing_key:
144
144
  specification_version: 4
145
145
  summary: A Log Subscriber for Faraday clients