superavatar 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/superavatar/sources/github.rb +25 -0
- data/lib/superavatar/utils/apiclient.rb +25 -0
- data/lib/superavatar.rb +3 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93335ffca2acdaf312d15aec1db6d009d42773a1af730d3332b9583df371f84e
|
4
|
+
data.tar.gz: dfc75804b85bac862aa8b6feaa3c962acb9f12685aef305122e73c90e1b96f97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a4bbb246b120a8b5bc173469b326c3d4bf7bf5dc702dbecd6158c759fa950b3927cdd8bfc23e4475cd554784fe31262dfb8547888fe8af6c1ea59447769ac32
|
7
|
+
data.tar.gz: a99fcb498c2193f994748c31e726b0e47d9b2b917375230428d7204142abe90897be0232aef67ce58b65b9d164e80a284d409fcfe275f536e7acd57e1a2a0167
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Superavatar
|
4
|
+
module Sources
|
5
|
+
class Github
|
6
|
+
def initialize(username)
|
7
|
+
@username = username
|
8
|
+
end
|
9
|
+
|
10
|
+
def avatar_url
|
11
|
+
res = api_profile
|
12
|
+
p res
|
13
|
+
# JSON.parse(res)[:avatar_url]
|
14
|
+
end
|
15
|
+
|
16
|
+
def web_profile
|
17
|
+
"https://github.com/#{@username}/"
|
18
|
+
end
|
19
|
+
|
20
|
+
def api_profile
|
21
|
+
"https://api.github.com/users/#{@username}/"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Superavatar::APIClient
|
4
|
+
#
|
5
|
+
# Fetches external resources
|
6
|
+
#
|
7
|
+
module Superavatar
|
8
|
+
module APIClient
|
9
|
+
class Fetch
|
10
|
+
require 'net/http'
|
11
|
+
require 'json'
|
12
|
+
require 'open-uri'
|
13
|
+
|
14
|
+
def self.fetch_external_api(url, json=true)
|
15
|
+
begin
|
16
|
+
puts 'Fetching...'
|
17
|
+
response = URI.open(url).read
|
18
|
+
response
|
19
|
+
JSON.parse(response) if json==true
|
20
|
+
rescue StandardError => e
|
21
|
+
puts 'Request failed #{e.message}'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/superavatar.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: superavatar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Arce
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A gem to get your users' backup avatar from public resources
|
14
14
|
email: martin.arce.teixeira@gmail.com
|
@@ -17,6 +17,8 @@ extensions: []
|
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
19
|
- lib/superavatar.rb
|
20
|
+
- lib/superavatar/sources/github.rb
|
21
|
+
- lib/superavatar/utils/apiclient.rb
|
20
22
|
homepage: https://github.com/divagueame/superavatar
|
21
23
|
licenses:
|
22
24
|
- MIT
|