goldfinger 0.1.0 → 0.1.1

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: 41d3880f49cb4f5e7847384420cca6cca7155daf
4
- data.tar.gz: 7d2c2223eae18798ff18d1575128a934f47470d8
3
+ metadata.gz: ee7cd56211208bae7616ba9a6b6535bcd358f676
4
+ data.tar.gz: d4bcfc1bd907072f3ef3062efd9e7644128a8779
5
5
  SHA512:
6
- metadata.gz: d08628684d7ca1c7b90b71a1fce7ada6b2ec1877a066b187c1c73eea10f63226361b3dd339d78008c39a8e98ad97b798edb0bf40021fbdf77fad5beb1efd5174
7
- data.tar.gz: 844fd60a49aa651cad0995eaec7a844dc11ce31b754e44dc7525e6adbb97813c928f711fffc789ff5e4ef3fa7971583c14f48de7f540c7c1a37a27bc305390f1
6
+ metadata.gz: 6787387b7f7130e0862a7205f8b277b9b017d8687cf6f2cb861c21fe0045c9db775107d7ce9f3dd5ade94d1b74955de0ec9911ddbae1cff23517a62175b58600
7
+ data.tar.gz: 2c7f7975273404131e0b4d2055ff2efd2f87a04f906a6cd065ef2b8af4b818d6413bbeeb7c0e4077b690fc61dd8312ce2c2eb554e3fabc1d3af8d48cf7eeb27c
data/README.md CHANGED
@@ -1,7 +1,11 @@
1
1
  Goldfinger, a Webfinger client for Ruby
2
2
  =======================================
3
3
 
4
- A Webfinger client for Ruby. Supports `application/xrd+xml` and `application/jrd+json` responses. Raises `Goldfinger::Error::NotFound` on failure to fetch the Webfinger or XRD data.
4
+ [![Gem Version](http://img.shields.io/gem/v/goldfinger.svg)][gem]
5
+
6
+ [gem]: https://rubygems.org/gems/goldfinger
7
+
8
+ A Webfinger client for Ruby. Supports `application/xrd+xml` and `application/jrd+json` responses. Raises `Goldfinger::NotFoundError` on failure to fetch the Webfinger or XRD data, or `Goldfinger::SSLError` if something is wrong with the HTTPS connection it uses.
5
9
 
6
10
  ## Installation
7
11
 
data/lib/goldfinger.rb CHANGED
@@ -4,9 +4,13 @@ require 'goldfinger/utils'
4
4
  require 'goldfinger/client'
5
5
 
6
6
  module Goldfinger
7
- module Error
8
- class NotFound < StandardError
9
- end
7
+ class Error < StandardError
8
+ end
9
+
10
+ class NotFoundError < Error
11
+ end
12
+
13
+ class SSLError < Error
10
14
  end
11
15
 
12
16
  def self.finger(uri)
@@ -19,14 +19,16 @@ module Goldfinger
19
19
  ssl = false
20
20
  retry
21
21
  else
22
- raise Goldfinger::Error::NotFound
22
+ raise Goldfinger::NotFoundError
23
23
  end
24
24
  end
25
25
 
26
26
  headers, body = perform_get(url_from_template(template))
27
27
  Goldfinger::Result.new(headers, body)
28
28
  rescue HTTP::Error
29
- raise Goldfinger::Error::NotFound
29
+ raise Goldfinger::NotFoundError
30
+ rescue OpenSSL::SSL::SSLError
31
+ raise Goldfinger::SSLError
30
32
  end
31
33
 
32
34
  private
@@ -39,7 +41,7 @@ module Goldfinger
39
41
  xml = Nokogiri::XML(template)
40
42
  links = xml.xpath('//xmlns:Link[@rel="lrdd"]', xmlns: 'http://docs.oasis-open.org/ns/xri/xrd-1.0')
41
43
 
42
- raise Goldfinger::Error::NotFound if links.empty?
44
+ raise Goldfinger::NotFoundError if links.empty?
43
45
 
44
46
  url = Addressable::Template.new(links.first.attribute('template').value)
45
47
  url.expand({ uri: @uri }).to_s
@@ -20,8 +20,7 @@ module Goldfinger
20
20
 
21
21
  def parse
22
22
  case @mime_type
23
- when 'application/jrd+json'
24
- when 'application/json'
23
+ when 'application/jrd+json', 'application/json'
25
24
  parse_json
26
25
  when 'application/xrd+xml'
27
26
  parse_xml
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goldfinger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugen Rochko