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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 97a79db2d44895104a87860165f149d3b08ebe7b
4
- data.tar.gz: 28bd5801d93445f394629766cf18d6bc2547ece3
3
+ metadata.gz: 9fe993b148492a811c70a78c299c483b2d23ef5e
4
+ data.tar.gz: '0180f279e8372d85c5e908060cb3c43e50467d62'
5
5
  SHA512:
6
- metadata.gz: 7c04fbf4d9943121888bb8d211a4a31d8098e891150154f7c6853e4309d55fb87f46b2c86046fca8589d981d2d7eb5827fee54487d6f8ce12109abcad6bb2690
7
- data.tar.gz: 05d6a9d9f3f4064d7e461eb57a4702eed647e9fca734e722e21db50ab973a901335fcb0f0e4a9ef339ffe2ecbaa01c5c00a6307d25a74ce50e748a165869177c
6
+ metadata.gz: '09ca432db72f3bb2f2c6456672f95a075c58ce32530fe0fc4fdd52849918d013f361157d2626e2899bc9b8f8912979cfbce46bbdf32cc5750a900d6b6cdb6d4a'
7
+ data.tar.gz: 6c1384ff84dcb8ce3afbafed63e61562b58743194a1ccf6c50f24be0624d95cd70165a543235b6f2e016fbaf5f3879b94be577da560883504b5cf5f5276302e1
data/.gitignore CHANGED
@@ -9,4 +9,5 @@
9
9
  /tmp/
10
10
 
11
11
  *.swp
12
+ *.gem
12
13
  .rspec
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
 
@@ -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
- # downloader = Ferto::Client.new
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://example.com/downloads/myfile',
58
- # extra: { groupno: 'foobar' }
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 the client failed to connect to the
62
- # downloader API
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, mime_type, extra)
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
@@ -1,3 +1,3 @@
1
1
  module Ferto
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
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.3
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-08 00:00:00.000000000 Z
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
Binary file