mirror of https://github.com/mastodon/goldfinger
Compare commits
10 Commits
Author | SHA1 | Date |
---|---|---|
dependabot[bot] | d013213138 | |
Eugen Rochko | 4f585464ba | |
Eugen Rochko | 62d296bb98 | |
Eugen Rochko | 4c57f5978d | |
dependabot[bot] | d0f59cb65d | |
Tom Scott | 2deb9da0ab | |
Eugen Rochko | 1fca7e670e | |
MIYAGI Hikaru | d5f16ebeca | |
Eugen Rochko | 114c45f62d | |
Yamagishi Kazutoshi | 29dce59043 |
|
@ -0,0 +1,41 @@
|
|||
name: Ruby Gem
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- v*
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build + Publish
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Set up Ruby 2.6
|
||||
uses: actions/setup-ruby@v1
|
||||
with:
|
||||
version: 2.6.x
|
||||
|
||||
- name: Publish to GPR
|
||||
run: |
|
||||
mkdir -p $HOME/.gem
|
||||
touch $HOME/.gem/credentials
|
||||
chmod 0600 $HOME/.gem/credentials
|
||||
printf -- "---\n:github: Bearer ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
||||
gem build *.gemspec
|
||||
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
|
||||
env:
|
||||
GEM_HOST_API_KEY: ${{secrets.GPR_AUTH_TOKEN}}
|
||||
OWNER: tootsuite
|
||||
|
||||
- name: Publish to RubyGems
|
||||
run: |
|
||||
mkdir -p $HOME/.gem
|
||||
touch $HOME/.gem/credentials
|
||||
chmod 0600 $HOME/.gem/credentials
|
||||
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
||||
gem build *.gemspec
|
||||
gem push *.gem
|
||||
env:
|
||||
GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
|
|
@ -1 +1 @@
|
|||
2.4.1
|
||||
2.5.0
|
||||
|
|
41
Gemfile.lock
41
Gemfile.lock
|
@ -1,47 +1,52 @@
|
|||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
goldfinger (2.0.0)
|
||||
goldfinger (2.1.1)
|
||||
addressable (~> 2.5)
|
||||
http (~> 2.2)
|
||||
http (~> 4.0)
|
||||
nokogiri (~> 1.8)
|
||||
oj (~> 3.0)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
addressable (2.5.1)
|
||||
public_suffix (~> 2.0, >= 2.0.2)
|
||||
addressable (2.5.2)
|
||||
public_suffix (>= 2.0.2, < 4.0)
|
||||
coderay (1.1.1)
|
||||
crack (0.4.3)
|
||||
safe_yaml (~> 1.0.0)
|
||||
diff-lcs (1.3)
|
||||
domain_name (0.5.20170404)
|
||||
domain_name (0.5.20190701)
|
||||
unf (>= 0.0.5, < 1.0.0)
|
||||
ffi (1.12.2)
|
||||
ffi-compiler (1.0.1)
|
||||
ffi (>= 1.0.0)
|
||||
rake
|
||||
fuubar (2.2.0)
|
||||
rspec-core (~> 3.0)
|
||||
ruby-progressbar (~> 1.4)
|
||||
hashdiff (0.3.4)
|
||||
http (2.2.2)
|
||||
http (4.3.0)
|
||||
addressable (~> 2.3)
|
||||
http-cookie (~> 1.0)
|
||||
http-form_data (~> 1.0.1)
|
||||
http_parser.rb (~> 0.6.0)
|
||||
http-form_data (~> 2.2)
|
||||
http-parser (~> 1.2.0)
|
||||
http-cookie (1.0.3)
|
||||
domain_name (~> 0.5)
|
||||
http-form_data (1.0.3)
|
||||
http_parser.rb (0.6.0)
|
||||
http-form_data (2.2.0)
|
||||
http-parser (1.2.1)
|
||||
ffi-compiler (>= 1.0, < 2.0)
|
||||
method_source (0.8.2)
|
||||
mini_portile2 (2.2.0)
|
||||
nokogiri (1.8.0)
|
||||
mini_portile2 (~> 2.2.0)
|
||||
oj (3.3.2)
|
||||
mini_portile2 (2.4.0)
|
||||
nokogiri (1.10.8)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
oj (3.10.2)
|
||||
pry (0.10.4)
|
||||
coderay (~> 1.1.0)
|
||||
method_source (~> 0.8.1)
|
||||
slop (~> 3.4)
|
||||
public_suffix (2.0.5)
|
||||
rake (12.0.0)
|
||||
public_suffix (3.0.3)
|
||||
rake (12.3.3)
|
||||
rspec (3.6.0)
|
||||
rspec-core (~> 3.6.0)
|
||||
rspec-expectations (~> 3.6.0)
|
||||
|
@ -60,7 +65,7 @@ GEM
|
|||
slop (3.6.0)
|
||||
unf (0.1.4)
|
||||
unf_ext
|
||||
unf_ext (0.0.7.4)
|
||||
unf_ext (0.0.7.6)
|
||||
webmock (3.0.1)
|
||||
addressable (>= 2.3.6)
|
||||
crack (>= 0.3.2)
|
||||
|
@ -79,4 +84,4 @@ DEPENDENCIES
|
|||
webmock
|
||||
|
||||
BUNDLED WITH
|
||||
1.15.2
|
||||
1.16.1
|
||||
|
|
|
@ -3,11 +3,9 @@ Goldfinger, a WebFinger client for Ruby
|
|||
|
||||
[![Gem Version](http://img.shields.io/gem/v/goldfinger.svg)][gem]
|
||||
[![Build Status](http://img.shields.io/travis/tootsuite/goldfinger.svg)][travis]
|
||||
[![Dependency Status](http://img.shields.io/gemnasium/tootsuite/goldfinger.svg)][gemnasium]
|
||||
|
||||
[gem]: https://rubygems.org/gems/goldfinger
|
||||
[travis]: https://travis-ci.org/tootsuite/goldfinger
|
||||
[gemnasium]: https://gemnasium.com/tootsuite/goldfinger
|
||||
|
||||
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, can also raise `HTTP:Error` or `OpenSSL::SSL::SSLError` if something is wrong with the HTTPS connection it uses.
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
Gem::Specification.new do |s|
|
||||
s.name = 'goldfinger'
|
||||
s.version = '2.0.0'
|
||||
s.version = '2.1.1'
|
||||
s.platform = Gem::Platform::RUBY
|
||||
s.required_ruby_version = '>= 2.3.0'
|
||||
s.date = '2016-02-17'
|
||||
|
@ -11,10 +11,10 @@ Gem::Specification.new do |s|
|
|||
s.authors = ['Eugen Rochko']
|
||||
s.email = 'eugen@zeonfederated.com'
|
||||
s.files = `git ls-files lib LICENSE README.md`.split($RS)
|
||||
s.homepage = 'https://github.com/Gargron/goldfinger'
|
||||
s.homepage = 'https://github.com/tootsuite/goldfinger'
|
||||
s.licenses = ['MIT']
|
||||
|
||||
s.add_dependency('http', '~> 2.2')
|
||||
s.add_dependency('http', '~> 4.0')
|
||||
s.add_dependency('addressable', '~> 2.5')
|
||||
s.add_dependency('nokogiri', '~> 1.8')
|
||||
s.add_dependency('oj', '~> 3.0')
|
||||
|
|
|
@ -18,8 +18,9 @@ module Goldfinger
|
|||
# @raise [Goldfinger::NotFoundError] Error raised when the Webfinger resource could not be retrieved
|
||||
# @raise [Goldfinger::SSLError] Error raised when there was a SSL error when fetching the resource
|
||||
# @param uri [String] A full resource identifier in the format acct:user@example.com
|
||||
# @param opts [Hash] Options passed to HTTP.rb client
|
||||
# @return [Goldfinger::Result]
|
||||
def self.finger(uri)
|
||||
Goldfinger::Client.new(uri).finger
|
||||
def self.finger(uri, opts = {})
|
||||
Goldfinger::Client.new(uri, opts).finger
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,12 +7,15 @@ module Goldfinger
|
|||
class Client
|
||||
include Goldfinger::Utils
|
||||
|
||||
def initialize(uri)
|
||||
def initialize(uri, opts = {})
|
||||
@uri = uri
|
||||
@ssl = opts.delete(:ssl) { true }
|
||||
@scheme = @ssl ? 'https' : 'http'
|
||||
@opts = opts
|
||||
end
|
||||
|
||||
def finger
|
||||
response = perform_get(standard_url)
|
||||
response = perform_get(standard_url, @opts)
|
||||
|
||||
return finger_from_template if response.code != 200
|
||||
|
||||
|
@ -24,11 +27,11 @@ module Goldfinger
|
|||
private
|
||||
|
||||
def finger_from_template
|
||||
template = perform_get(url)
|
||||
template = perform_get(url, @opts)
|
||||
|
||||
raise Goldfinger::NotFoundError, 'No host-meta on the server' if template.code != 200
|
||||
|
||||
response = perform_get(url_from_template(template.body))
|
||||
response = perform_get(url_from_template(template.body), @opts)
|
||||
|
||||
raise Goldfinger::NotFoundError, 'No such user on the server' if response.code != 200
|
||||
|
||||
|
@ -36,11 +39,11 @@ module Goldfinger
|
|||
end
|
||||
|
||||
def url
|
||||
"https://#{domain}/.well-known/host-meta"
|
||||
"#{@scheme}://#{domain}/.well-known/host-meta"
|
||||
end
|
||||
|
||||
def standard_url
|
||||
"https://#{domain}/.well-known/webfinger?resource=#{@uri}"
|
||||
"#{@scheme}://#{domain}/.well-known/webfinger?resource=#{@uri}"
|
||||
end
|
||||
|
||||
def url_from_template(template)
|
||||
|
|
|
@ -18,7 +18,7 @@ module Goldfinger
|
|||
private
|
||||
|
||||
def http_client
|
||||
HTTP.timeout(:per_operation, write: 60, connect: 20, read: 60).follow
|
||||
HTTP.timeout(write: 60, connect: 20, read: 60).follow
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -74,7 +74,7 @@ module Goldfinger
|
|||
end
|
||||
|
||||
def parse_json
|
||||
json = Oj.load(@body, mode: :null)
|
||||
json = Oj.load(@body.to_s, mode: :null)
|
||||
|
||||
@subject = json['subject']
|
||||
@aliases = json['aliases'] || []
|
||||
|
|
Loading…
Reference in New Issue