blockstack 0.5.9 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/blockstack.rb +1 -0
- data/lib/blockstack/user.rb +124 -0
- data/lib/blockstack/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: 110e13f945818be7f021ec364e7922949c32e043
|
4
|
+
data.tar.gz: 6836fce8e6391e69cb0b76a2b738f72656327af2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd2c6838722c54914fb638ab9cb468b03527ef45f037cd19c3f212494962106b68ed0b967af173c3bf5528e061b8b66d9ed6c0b15b193c003341f83bf1d03ba8
|
7
|
+
data.tar.gz: ba8438c6b75277d522bcc8ead5f845418ccc7aeb1a4d396f0aab9c1e668b1cc40d7f78a7d92e2085117f5bda038e140c59e3ee3b4f2d1c8aded9523133fc7175
|
data/lib/blockstack.rb
CHANGED
@@ -0,0 +1,124 @@
|
|
1
|
+
module Blockstack
|
2
|
+
class User
|
3
|
+
def self.from_json(json, username)
|
4
|
+
User.new(json, username)
|
5
|
+
end
|
6
|
+
|
7
|
+
attr_reader :username
|
8
|
+
attr_reader :name_formatted
|
9
|
+
attr_reader :avatar_url
|
10
|
+
attr_reader :cover_url
|
11
|
+
attr_reader :location_formatted
|
12
|
+
attr_reader :website
|
13
|
+
attr_reader :bio
|
14
|
+
attr_reader :angellist_username
|
15
|
+
attr_reader :github_username
|
16
|
+
attr_reader :facebook_username
|
17
|
+
attr_reader :twitter_username
|
18
|
+
attr_reader :instagram_username
|
19
|
+
attr_reader :linkedin_url
|
20
|
+
attr_reader :bitcoin_address
|
21
|
+
attr_reader :bitmessage_address
|
22
|
+
attr_reader :bitcoinotc_username
|
23
|
+
attr_reader :pgp_fingerprint
|
24
|
+
attr_reader :pgp_url
|
25
|
+
attr_reader :orgs
|
26
|
+
attr_reader :schema_version
|
27
|
+
|
28
|
+
def initialize(json, username)
|
29
|
+
if(json["profile"])
|
30
|
+
json = json["profile"]
|
31
|
+
end
|
32
|
+
if(json['v'] == "0.2")
|
33
|
+
@username = username
|
34
|
+
@name_formatted = json["name"]["formatted"] if json["name"]
|
35
|
+
@avatar_url = json["avatar"]["url"] if json["avatar"]
|
36
|
+
@cover_url = json["cover"]["url"] if json["cover"]
|
37
|
+
@location_formatted = json["location"]["formatted"] if json["location"]
|
38
|
+
@website = json["website"]
|
39
|
+
@bio = json["bio"]
|
40
|
+
@angellist_username = json["angellist"]["username"] if json["angellist"]
|
41
|
+
@github_username = json["github"]["username"] if json["github"]
|
42
|
+
@facebook_username = json["facebook"]["username"] if json["facebook"]
|
43
|
+
@twitter_username = json["twitter"]["username"] if json["twitter"]
|
44
|
+
@instagram_username = json["instagram"]["username"] if json["instagram"]
|
45
|
+
@linkedin_url = json["linkedin"]["url"] if json["linkedin"]
|
46
|
+
@bitcoin_address = json["bitcoin"]["address"] if json["bitcoin"]
|
47
|
+
@bitmessage_address = json["bitmessage"]["address"] if json["bitmessage"]
|
48
|
+
@bitcoinotc_username = json["bitcoinotc"]["username"] if json["bitcoinotc"]
|
49
|
+
@pgp_fingerprint = json["pgp"]["fingerprint"] if json["pgp"]
|
50
|
+
@pgp_url = json["pgp"]["url"] if json["pgp"]
|
51
|
+
@schema_version = json["v"]
|
52
|
+
@orgs = parse_orgs(json["orgs"])
|
53
|
+
else
|
54
|
+
@username = username
|
55
|
+
@name_formatted = json["name"] if json["name"]
|
56
|
+
@avatar_url = find_image_url(json, 'avatar')
|
57
|
+
@cover_url = find_image_url(json, 'cover')
|
58
|
+
@location_formatted = json["address"]["addressLocality"] if json["address"]
|
59
|
+
@website = json["website"][0]["url"] if json["website"] && json["website"][0]
|
60
|
+
@bio = json["description"]
|
61
|
+
@angellist_username = find_account_username(json, "angellist")
|
62
|
+
@github_username = find_account_username(json, "github")
|
63
|
+
@facebook_username = find_account_username(json, "facebook")
|
64
|
+
@twitter_username = find_account_username(json, "twitter")
|
65
|
+
@instagram_username = find_account_username(json, "instagram")
|
66
|
+
@linkedin_url = find_account_username(json, "linkedin")
|
67
|
+
@bitcoin_address = find_account_username(json, "bitcoin")
|
68
|
+
@bitmessage_address = find_account_username(json, "bitmessage")
|
69
|
+
@bitcoinotc_username = find_account_username(json, "bitcoinotc")
|
70
|
+
@pgp_fingerprint = find_account_username(json, "pgp")
|
71
|
+
@pgp_url = find_account(json, "pgp")['contentUrl'] if @pgp_fingerprint
|
72
|
+
@schema_version = "0.3"
|
73
|
+
@orgs = parse_orgs(json["orgs"])
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
def openname
|
79
|
+
warn "[DEPRECATION] `openname` is deprecated. Please use `username` instead."
|
80
|
+
username
|
81
|
+
end
|
82
|
+
|
83
|
+
protected
|
84
|
+
|
85
|
+
def find_image_url(json, type)
|
86
|
+
images = json['image']
|
87
|
+
if(images && images.kind_of?(Array))
|
88
|
+
for image in images
|
89
|
+
return image['contentUrl'] if image['name'] == type
|
90
|
+
end
|
91
|
+
end
|
92
|
+
nil
|
93
|
+
end
|
94
|
+
|
95
|
+
def find_account(json, service)
|
96
|
+
accounts = json['account']
|
97
|
+
if(accounts && accounts.kind_of?(Array))
|
98
|
+
for account in accounts
|
99
|
+
return account if account['service'] == service
|
100
|
+
end
|
101
|
+
end
|
102
|
+
nil
|
103
|
+
end
|
104
|
+
|
105
|
+
def find_account_username(json, service)
|
106
|
+
account = find_account(json, service)
|
107
|
+
if(account)
|
108
|
+
return account['identifier']
|
109
|
+
end
|
110
|
+
nil
|
111
|
+
end
|
112
|
+
|
113
|
+
def parse_orgs(orgs_json)
|
114
|
+
orgs = Array.new
|
115
|
+
if orgs_json
|
116
|
+
for org_json in orgs_json
|
117
|
+
orgs << Org.new(org_json)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
orgs
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
end
|
data/lib/blockstack/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blockstack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Larry Salibra
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- blockstack.gemspec
|
140
140
|
- circle.yml
|
141
141
|
- lib/blockstack.rb
|
142
|
+
- lib/blockstack/user.rb
|
142
143
|
- lib/blockstack/version.rb
|
143
144
|
homepage: https://github.com/larrysalibra/blockstack-ruby
|
144
145
|
licenses:
|