phearb 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/phearb/agent.rb +7 -2
- data/lib/phearb/configuration.rb +3 -0
- data/lib/phearb/error.rb +3 -0
- data/lib/phearb/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e84cc1692610bdae82f05d919ce92d819fe329c
|
4
|
+
data.tar.gz: 5c2dd78d4b1c9d4f2235e4b4e79337d9583f6bee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1ea2f12f503cf0670754276979c3e2f84fcc0f2784ebf00381ba985ebadac2664d3376616423a5af1a3b1c57067e1004a39a73c4d20d9ff1614a506491e3236
|
7
|
+
data.tar.gz: 4e5df816ff94d67f8251b5b9de2d52df5abf2dbbfaf3c4275348345358fc1a6afea3b789940e3e35df2d7a05636bb80565a06ee43fc9c16b606cb1c4e1a45d00
|
data/README.md
CHANGED
@@ -29,6 +29,7 @@ Put these lines in the configuration section of you app. In rails you should pro
|
|
29
29
|
Phearb.configure do |config|
|
30
30
|
config.host = <host> # Defaults to 'localhost'
|
31
31
|
config.port = <port> # Defaults to 8100
|
32
|
+
config.timeout <timeout_in_seconds> # Defaults to 5
|
32
33
|
end
|
33
34
|
```
|
34
35
|
|
@@ -39,7 +40,7 @@ puts response.content if response.success
|
|
39
40
|
```
|
40
41
|
|
41
42
|
Simply calling `Phearb.fetch(<url>)` will do the job. It returns an `Phearb::Response` object wrapping the phearb server response with one method per key:
|
42
|
-
```
|
43
|
+
```js
|
43
44
|
{
|
44
45
|
"success": true,
|
45
46
|
"input_url": "http://such-website.com",
|
data/lib/phearb/agent.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'rest_client'
|
2
2
|
require 'phearb/response'
|
3
|
+
require 'phearb/error'
|
3
4
|
|
4
5
|
module Phearb
|
5
6
|
class Agent
|
@@ -9,8 +10,12 @@ module Phearb
|
|
9
10
|
end
|
10
11
|
|
11
12
|
def fetch
|
12
|
-
|
13
|
-
|
13
|
+
Timeout::timeout(Phearb.configuration.timeout.to_f) do
|
14
|
+
http_response = RestClient.get(server_url, params: { fetch_url: @url })
|
15
|
+
Response.from_json(http_response)
|
16
|
+
end
|
17
|
+
rescue Timeout::Error => exception
|
18
|
+
raise Error::Timeout
|
14
19
|
end
|
15
20
|
|
16
21
|
private
|
data/lib/phearb/configuration.rb
CHANGED
@@ -2,13 +2,16 @@ module Phearb
|
|
2
2
|
class Configuration
|
3
3
|
attr_accessor :host
|
4
4
|
attr_accessor :port
|
5
|
+
attr_accessor :timeout
|
5
6
|
|
6
7
|
DEFAULT_HOST = 'localhost'
|
7
8
|
DEFAULT_PORT = 8100
|
9
|
+
DEFAULT_TIMEOUT = 5
|
8
10
|
|
9
11
|
def initialize
|
10
12
|
@host = DEFAULT_HOST
|
11
13
|
@port = DEFAULT_PORT
|
14
|
+
@timeout = DEFAULT_TIMEOUT
|
12
15
|
end
|
13
16
|
end
|
14
17
|
end
|
data/lib/phearb/error.rb
ADDED
data/lib/phearb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phearb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joaquín Moreira
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -126,6 +126,7 @@ files:
|
|
126
126
|
- lib/phearb.rb
|
127
127
|
- lib/phearb/agent.rb
|
128
128
|
- lib/phearb/configuration.rb
|
129
|
+
- lib/phearb/error.rb
|
129
130
|
- lib/phearb/response.rb
|
130
131
|
- lib/phearb/version.rb
|
131
132
|
- phearb.gemspec
|