pupa 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 97c9d9fa0543551ea5408129269350f772f5622b
4
- data.tar.gz: c5784cad0628a12a1b6bd7f1b88e023da0c93b21
3
+ metadata.gz: 07c621bf45737244947d412e6282581a49c63dac
4
+ data.tar.gz: 0844ac4046529df46e52a3d48376fc49c5fa39e4
5
5
  SHA512:
6
- metadata.gz: 9fb0c239b6b7d8f3b3c9e264ca83051a6b7e7156578543f99d29034c8385da32055e0b03ab685d740afc46a6cea1a0c18e2ec92a65605575153c1da30a2bd5c9
7
- data.tar.gz: 49dd4745dcb8ad7db1bd54ca9d5aaf3c2a640d16c62494699fbf3ab601034055ba77d8a800e1b632efe4638d74fb4d92aa99525bc8286e63591bb120a28990a3
6
+ metadata.gz: 4a1e4d54ae62fc327454cc54ce9ce8eb0a2f9cccc716a0001d38e526f7030a900149dbda72ff967bcaa38857ecd2621429fb67f57007f148c9b08c5f3f724ef7
7
+ data.tar.gz: 4059e6c7c8e5f7c6927fc3f7b9ea11b7d6f5a8139e2bb3546a84b06641fad60014d0ca65adc1188a8e748191f67cfc0fdd88020aa2f88cfd7b4984f629abffb5
@@ -6,8 +6,6 @@ require 'pupa/processor/middleware/logger'
6
6
  require 'pupa/processor/middleware/parse_html'
7
7
  require 'pupa/refinements/faraday_middleware'
8
8
 
9
- using Pupa::Refinements::FaradayMiddleware
10
-
11
9
  module Pupa
12
10
  class Processor
13
11
  # An HTTP client factory.
@@ -1,32 +1,27 @@
1
- module Pupa
2
- class Refinements
3
- # A refinement for the Faraday caching middleware to cache all requests, not
4
- # only GET requests.
5
- module FaradayMiddleware
6
- refine ::FaradayMiddleware::Caching do
7
- def call(env)
8
- # Remove if-statement to cache any request, not only GET.
9
- if env[:parallel_manager]
10
- # callback mode
11
- cache_on_complete(env)
12
- else
13
- # synchronous mode
14
- response = cache.fetch(cache_key(env)) { @app.call(env) }
15
- finalize_response(response, env)
16
- end
17
- end
1
+ # A refinement for the Faraday caching middleware to cache all requests, not
2
+ # only GET requests. Using Ruby's refinements doesn't seem to work, possibly
3
+ # because Faraday caches middlewares.
4
+ class FaradayMiddleware::Caching
5
+ def call(env)
6
+ # Remove if-statement to cache any request, not only GET.
7
+ if env[:parallel_manager]
8
+ # callback mode
9
+ cache_on_complete(env)
10
+ else
11
+ # synchronous mode
12
+ response = cache.fetch(cache_key(env)) { @app.call(env) }
13
+ finalize_response(response, env)
14
+ end
15
+ end
18
16
 
19
- def cache_key(env)
20
- url = env[:url].dup
21
- if url.query && params_to_ignore.any?
22
- params = parse_query url.query
23
- params.reject! {|k,| params_to_ignore.include? k }
24
- url.query = build_query params
25
- end
26
- url.normalize!
27
- url.request_uri + env[:body].to_s # Add for POST requests.
28
- end
29
- end
17
+ def cache_key(env)
18
+ url = env[:url].dup
19
+ if url.query && params_to_ignore.any?
20
+ params = parse_query url.query
21
+ params.reject! {|k,| params_to_ignore.include? k }
22
+ url.query = build_query params
30
23
  end
24
+ url.normalize!
25
+ url.request_uri + env[:body].to_s # Add for POST requests.
31
26
  end
32
27
  end
@@ -26,11 +26,11 @@ module Pupa
26
26
  end
27
27
  end
28
28
  end
29
+ end
30
+ end
29
31
 
30
- class ::JSON::Schema::FormatAttribute
31
- class << self
32
- prepend Pupa::Refinements::Format
33
- end
34
- end
32
+ class JSON::Schema::FormatAttribute
33
+ class << self
34
+ prepend Pupa::Refinements::Format
35
35
  end
36
36
  end
data/lib/pupa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pupa
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pupa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Open North