ferto 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +1 -0
- data/lib/ferto/client.rb +37 -11
- data/lib/ferto/version.rb +1 -1
- metadata +2 -3
- data/ferto-0.1.0.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fe993b148492a811c70a78c299c483b2d23ef5e
|
4
|
+
data.tar.gz: '0180f279e8372d85c5e908060cb3c43e50467d62'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09ca432db72f3bb2f2c6456672f95a075c58ce32530fe0fc4fdd52849918d013f361157d2626e2899bc9b8f8912979cfbce46bbdf32cc5750a900d6b6cdb6d4a'
|
7
|
+
data.tar.gz: 6c1384ff84dcb8ce3afbafed63e61562b58743194a1ccf6c50f24be0624d95cd70165a543235b6f2e016fbaf5f3879b94be577da560883504b5cf5f5276302e1
|
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/skroutz/ferto.svg?branch=master)](https://travis-ci.org/skroutz/ferto)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/ferto.svg)](https://badge.fury.io/rb/ferto)
|
5
|
+
[![Documentation](http://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/github/skroutz/ferto)
|
5
6
|
|
6
7
|
A Ruby client for [skroutz/downloader](https://github.com/skroutz/downloader).
|
7
8
|
|
data/lib/ferto/client.rb
CHANGED
@@ -26,7 +26,7 @@ module Ferto
|
|
26
26
|
# the service to make.
|
27
27
|
attr_reader :aggr_limit
|
28
28
|
|
29
|
-
# @param [Hash{Symbol => String, Fixnum}]
|
29
|
+
# @param opts [Hash{Symbol => String, Fixnum}]
|
30
30
|
# @option opts [String] :scheme
|
31
31
|
# @option opts [String] :host
|
32
32
|
# @option opts [String] :path
|
@@ -47,22 +47,43 @@ module Ferto
|
|
47
47
|
|
48
48
|
# Sends a request to Downloader and returns its reply.
|
49
49
|
#
|
50
|
+
# @param url [String] the resource to be downloaded
|
51
|
+
# @param callback_type [String]
|
52
|
+
# @param callback_dst [String] the callback destination
|
53
|
+
# @param mime_type [String] (default: "") accepted MIME types for the
|
54
|
+
# resource
|
55
|
+
# @param aggr_id [String] aggregation identifier
|
56
|
+
# @param aggr_limit [Integer] aggregation concurrency limit
|
57
|
+
# @param aggr_proxy [String] the HTTP proxy to use for downloading the
|
58
|
+
# resource, by default no proxy is used. The proxy is set up on
|
59
|
+
# aggregation level and it cannot be updated for an existing aggregation.
|
60
|
+
# @param download_timeout [Integer] the maximum time to wait for the
|
61
|
+
# resource to be downloaded in seconds, by default there is no timeout
|
62
|
+
# @param user_agent [String] the User-Agent string to use for
|
63
|
+
# downloading the resource, by default it uses the User-Agent string
|
64
|
+
# set in the downloader's configuration
|
65
|
+
#
|
50
66
|
# @example
|
51
|
-
#
|
52
|
-
# dl_resp = downloader.download(
|
53
|
-
# aggr_id: 'msystems',
|
54
|
-
# aggr_limit: 3,
|
67
|
+
# client.download(
|
55
68
|
# url: 'http://foo.bar/a.jpg',
|
56
69
|
# callback_type: 'http',
|
57
|
-
# callback_dst: 'http://
|
58
|
-
#
|
70
|
+
# callback_dst: 'http://myapp.com/handle-download',
|
71
|
+
# aggr_id: 'foo', aggr_limit: 3,
|
72
|
+
# download_timeout: 120,
|
73
|
+
# aggr_proxy: 'http://myproxy.com/',
|
74
|
+
# user_agent: 'my-useragent',
|
75
|
+
# mime_type: "image/jpeg",
|
76
|
+
# extra: { something: 'someone' }
|
59
77
|
# )
|
60
78
|
#
|
61
|
-
# @raise [Ferto::ConnectionError] if
|
62
|
-
# downloader
|
79
|
+
# @raise [Ferto::ConnectionError] if there was an error scheduling the
|
80
|
+
# job to downloader
|
63
81
|
#
|
64
82
|
# @return [Ferto::Response]
|
83
|
+
#
|
84
|
+
# @see https://github.com/skroutz/downloader/#post-download
|
65
85
|
def download(aggr_id:, aggr_limit: @aggr_limit, url:,
|
86
|
+
aggr_proxy: nil, download_timeout: nil, user_agent: nil,
|
66
87
|
callback_url: "", callback_dst: "",
|
67
88
|
callback_type: "", mime_type: "", extra: {})
|
68
89
|
uri = URI::HTTP.build(
|
@@ -70,7 +91,7 @@ module Ferto
|
|
70
91
|
)
|
71
92
|
body = build_body(
|
72
93
|
aggr_id, aggr_limit, url, callback_url, callback_type, callback_dst,
|
73
|
-
mime_type, extra
|
94
|
+
aggr_proxy, download_timeout, user_agent, mime_type, extra
|
74
95
|
)
|
75
96
|
# Curl.post reuses the same handler
|
76
97
|
begin
|
@@ -96,7 +117,8 @@ module Ferto
|
|
96
117
|
end
|
97
118
|
|
98
119
|
def build_body(aggr_id, aggr_limit, url, callback_url, callback_type,
|
99
|
-
callback_dst,
|
120
|
+
callback_dst, aggr_proxy, download_timeout, user_agent,
|
121
|
+
mime_type, extra)
|
100
122
|
body = {
|
101
123
|
aggr_id: aggr_id,
|
102
124
|
aggr_limit: aggr_limit,
|
@@ -114,6 +136,10 @@ module Ferto
|
|
114
136
|
body[:mime_type] = mime_type
|
115
137
|
end
|
116
138
|
|
139
|
+
body[:aggr_proxy] = aggr_proxy if aggr_proxy
|
140
|
+
body[:download_timeout] = download_timeout if download_timeout
|
141
|
+
body[:user_agent] = user_agent if user_agent
|
142
|
+
|
117
143
|
if !extra.nil?
|
118
144
|
body[:extra] = extra.is_a?(Hash) ? extra.to_json : extra.to_s
|
119
145
|
end
|
data/lib/ferto/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ferto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aggelos Avgerinos
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: curb
|
@@ -123,7 +123,6 @@ files:
|
|
123
123
|
- Rakefile
|
124
124
|
- bin/console
|
125
125
|
- bin/setup
|
126
|
-
- ferto-0.1.0.gem
|
127
126
|
- ferto.gemspec
|
128
127
|
- lib/ferto.rb
|
129
128
|
- lib/ferto/callback.rb
|
data/ferto-0.1.0.gem
DELETED
Binary file
|