openname 0.4.1 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cd17a3d6eb5dd6fd7cabc78a9b2ef8653d59526d
4
- data.tar.gz: cec3ac486e87161e411803bdae34e0a5794236db
3
+ metadata.gz: a0c755600d887384bfcf4e2efc15cbfd2e00adac
4
+ data.tar.gz: 1c565e3bca7e98e0e731a6ff7ed45e712261fc62
5
5
  SHA512:
6
- metadata.gz: ba21031a56cc038f14f8b3af0b2af11ae38f1085e42d0671bb4bd7f791f6e4164aa722a388afe76f640b087be696d9bc6e48905b03b6b9bf29f680e0b6c2291f
7
- data.tar.gz: fee9ad61ccf8093f7e1cc5918064fc4d110b34d33b82a4846cf10ad13713fc8d98420bd0ba93caa8da230a393fb9c342982c94700ee6162fbd17a2530df9bfde
6
+ metadata.gz: f411e3f0cca09ee79e80e83cf371ed1711be5dce464422d750d5c34e083c855829bc70d11779cf668ba9d00a33e7c7a0efce167f0817b61d02cf507f18d8da71
7
+ data.tar.gz: 29b52f8b05fb2223a5522bf4b3a4e9212d1b8ae36e5aa9589d47cadf684d6fc9ab660ca17dcd312c674b327b6429028de6bed4d501b32dcd00e08681d6949c9a
data/lib/openname.rb CHANGED
@@ -5,15 +5,15 @@ require 'bitcoin'
5
5
 
6
6
 
7
7
  ##
8
- # A toolkit for the Openname distributed identity & naming system
8
+ # A toolkit for the Openname distributed identity & naming system
9
9
  module Openname
10
- DEFAULT_ENDPOINT = "https://www.onename.io"
10
+ DEFAULT_ENDPOINT = "https://openname.nametiles.co/v2/"
11
11
  SCHEMA_VERSION = "0.2"
12
12
  USERAGENT = "openname-ruby #{VERSION}"
13
-
13
+
14
14
  # https://github.com/openname/openname-specifications#usernames
15
15
  OPENNAME_REGEX = /^[a-z0-9_]{1,60}$/
16
-
16
+
17
17
  @@endpoint = nil
18
18
 
19
19
  ##
@@ -25,7 +25,7 @@ module Openname
25
25
  return @@endpoint
26
26
  end
27
27
  end
28
-
28
+
29
29
  ##
30
30
  # Set endpoint to +url+
31
31
  # if +url+ is +nil+, +DEFAULT_ENDPOINT+ is used as the endpoint
@@ -42,7 +42,7 @@ module Openname
42
42
 
43
43
  ##
44
44
  # Retrieve JSON data stored in Openname record
45
- def self.get_json(openname)
45
+ def self.get_json(openname)
46
46
  raise ArgumentError.new("#{openname} is not a valid Openname") if !self.valid?(openname)
47
47
  uri = URI(self.endpoint + "/#{openname.downcase}.json")
48
48
  http = Net::HTTP.new(uri.host,uri.port)
@@ -50,21 +50,27 @@ module Openname
50
50
  req = Net::HTTP::Get.new(uri.path, {'User-Agent' => USERAGENT})
51
51
  res = http.request(req)
52
52
  case res.code.to_s
53
- when "404" then raise NameError.new("User with Openname \"#{openname}\" does not exist")
54
- when "200" then return JSON.parse(res.body)
53
+ when "404" then raise NameError.new("Openname \"#{openname}\" does not exist")
54
+ when "200" then
55
+ json_body = JSON.parse(res.body)
56
+ if(json_body["status"] && json_body["status"] == "reserved")
57
+ NameError.new("Openname \"#{openname}\" does not exist. It is reserved.")
58
+ else
59
+ json_body
60
+ end
55
61
  else
56
62
  error = JSON.parse(res.body)
57
63
  raise RuntimeError.new("Openname endpoint returned error: #{error["error"]}")
58
- end
59
-
64
+ end
65
+
60
66
  end
61
-
67
+
62
68
  ##
63
69
  # Return a +User+ representing the given openname
64
70
  def self.get(openname)
65
71
  User.from_json(self.get_json(openname),openname)
66
72
  end
67
-
73
+
68
74
  ##
69
75
  # Takes either a bitcoin address or a openname
70
76
  # Returns the bitcoin address associated with the openname or passes through address provided
@@ -73,14 +79,14 @@ module Openname
73
79
  raise ArgumentError.new("#{openname_or_address} is not a valid Openname or Bitcoin address") if !self.valid?(openname_or_address)
74
80
  user = get(openname_or_address)
75
81
  raise NameError.new("Openname user #{openname_or_address} does not have a Bitcoin address") if !Bitcoin.valid_address?(user.bitcoin_address)
76
- return user.bitcoin_address
82
+ return user.bitcoin_address
77
83
  end
78
-
84
+
79
85
  class User
80
86
  def self.from_json(json,openname)
81
87
  User.new(json,openname)
82
88
  end
83
-
89
+
84
90
  attr_reader :openname
85
91
  attr_reader :name_formatted
86
92
  attr_reader :avatar_url
@@ -88,10 +94,11 @@ module Openname
88
94
  attr_reader :location_formatted
89
95
  attr_reader :website
90
96
  attr_reader :bio
97
+ attr_reader :angellist_username
91
98
  attr_reader :github_username
92
99
  attr_reader :facebook_username
93
100
  attr_reader :twitter_username
94
- attr_reader :linkedin_username
101
+ attr_reader :linkedin_url
95
102
  attr_reader :bitcoin_address
96
103
  attr_reader :bitmessage_address
97
104
  attr_reader :bitcoinotc_username
@@ -99,8 +106,8 @@ module Openname
99
106
  attr_reader :pgp_url
100
107
  attr_reader :orgs
101
108
  attr_reader :schema_version
102
-
103
-
109
+
110
+
104
111
  def initialize(json,openname)
105
112
  @openname = openname
106
113
  @name_formatted = json["name"]["formatted"] if json["name"]
@@ -109,58 +116,59 @@ module Openname
109
116
  @location_formatted = json["location"]["formatted"] if json["location"]
110
117
  @website = json["website"]
111
118
  @bio = json["bio"]
119
+ @angellist_username = json["angellist"]["username"] if json["angellist"]
112
120
  @github_username = json["github"]["username"] if json["github"]
113
121
  @facebook_username = json["facebook"]["username"] if json["facebook"]
114
122
  @twitter_username = json["twitter"]["username"] if json["twitter"]
115
- @linkedin_username = json["linkedin"]["username"] if json["linkedin"]
123
+ @linkedin_url = json["linkedin"]["url"] if json["linkedin"]
116
124
  @bitcoin_address = json["bitcoin"]["address"] if json["bitcoin"]
117
125
  @bitmessage_address = json["bitmessage"]["username"] if json["bitmessage"]
118
126
  @bitcoinotc_username = json["bitcoinotc"]["username"] if json["bitcoinotc"]
119
127
  @pgp_fingerprint = json["pgp"]["fingerprint"] if json["pgp"]
120
- @pgp_url = json["pgp"]["url"] if json["url"]
128
+ @pgp_url = json["pgp"]["url"] if json["pgp"]["url"]
121
129
  @schema_version = json["v"]
122
130
  @orgs = parse_orgs(json["orgs"])
123
131
  end
124
-
125
- protected
126
-
127
- def parse_orgs(orgs_json)
132
+
133
+ protected
134
+
135
+ def parse_orgs(orgs_json)
128
136
  orgs = Array.new
129
137
  if orgs_json
130
138
  for org_json in orgs_json
131
- orgs << Org.new(org_json)
139
+ orgs << Org.new(org_json)
132
140
  end
133
141
  end
134
142
  orgs
135
143
  end
136
-
144
+
137
145
  end
138
-
146
+
139
147
  class Org
140
148
  def self.from_json(json)
141
149
  Org.new(json)
142
150
  end
143
-
151
+
144
152
  attr_reader :url
145
153
  attr_reader :relationship
146
154
  attr_reader :name
147
-
148
-
155
+
156
+
149
157
  def initialize(json)
150
158
  @url = json["url"] if json["url"]
151
159
  @relationship = json["relationship"] if json["relationship"]
152
160
  @name = json["name"] if json["name"]
153
161
  end
154
-
155
-
162
+
163
+
156
164
  end
157
-
165
+
158
166
  protected
159
-
167
+
160
168
  def self.check_schema_version(json_result)
161
169
  if json_result["v"] != SCHEMA_VERSION
162
170
  warn "Openname gem only supports Openname schema version #{SCHEMA_VERSION}"
163
171
  end
164
172
  end
165
173
 
166
- end
174
+ end
@@ -1,3 +1,3 @@
1
1
  module Openname
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://www.onename.io/larry.json
5
+ uri: https://onename.io/larry.json
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -12,7 +12,7 @@ http_interactions:
12
12
  Accept-Encoding:
13
13
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
14
  Accept:
15
- - '*/*'
15
+ - "*/*"
16
16
  response:
17
17
  status:
18
18
  code: 200
@@ -59,7 +59,7 @@ http_interactions:
59
59
  Accept-Encoding:
60
60
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
61
61
  Accept:
62
- - '*/*'
62
+ - "*/*"
63
63
  response:
64
64
  status:
65
65
  code: 200
@@ -80,8 +80,7 @@ http_interactions:
80
80
  body:
81
81
  encoding: UTF-8
82
82
  string: "{\n \n \"avatar\": {\n \"url\": \"http://www.example.com/pic.png\"\n
83
- \ }, \n
84
- \ \"name\": {\n \"formatted\": \"Bitcoin Hater\"\n }\n}"
83
+ \ }, \n \"name\": {\n \"formatted\": \"Bitcoin Hater\"\n }\n}"
85
84
  http_version:
86
85
  recorded_at: Sun, 06 Apr 2014 14:00:02 GMT
87
86
  - request:
@@ -96,7 +95,7 @@ http_interactions:
96
95
  Accept-Encoding:
97
96
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
98
97
  Accept:
99
- - '*/*'
98
+ - "*/*"
100
99
  response:
101
100
  status:
102
101
  code: 404
@@ -116,7 +115,369 @@ http_interactions:
116
115
  - keep-alive
117
116
  body:
118
117
  encoding: UTF-8
119
- string: ""
118
+ string: ''
120
119
  http_version:
121
120
  recorded_at: Sun, 06 Apr 2014 14:00:02 GMT
121
+ - request:
122
+ method: get
123
+ uri: https://onename.com/larry.json
124
+ body:
125
+ encoding: US-ASCII
126
+ string: ''
127
+ headers:
128
+ User-Agent:
129
+ - openname-ruby 0.4.1
130
+ Accept-Encoding:
131
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
132
+ Accept:
133
+ - "*/*"
134
+ response:
135
+ status:
136
+ code: 200
137
+ message: OK
138
+ headers:
139
+ Connection:
140
+ - keep-alive
141
+ Server:
142
+ - gunicorn/18.0
143
+ Date:
144
+ - Sun, 22 Feb 2015 11:58:29 GMT
145
+ Content-Type:
146
+ - application/json
147
+ Content-Length:
148
+ - '1231'
149
+ Access-Control-Allow-Origin:
150
+ - "*"
151
+ Access-Control-Allow-Methods:
152
+ - HEAD, GET
153
+ Access-Control-Max-Age:
154
+ - '21600'
155
+ Access-Control-Allow-Headers:
156
+ - X-REQUESTED-WITH, ACCEPT, CONTENT-TYPE, X-HTTP-METHOD-OVERRIDE, ORIGIN, PRAGMA,
157
+ REFERER, USER-AGENT, IF-MATCH, IF-NONE-MATCH
158
+ X-Frame-Options:
159
+ - DENY
160
+ Strict-Transport-Security:
161
+ - max-age=31536000
162
+ Set-Cookie:
163
+ - session=eyJfaWQiOnsiIGIiOiJOV1JtTVRRd1kyUTJaRGRoWmpJMllXWmxZVEV5TmpnMU1UQXhaRGt4WWpjPSJ9fQ.B8tV5Q.WycKK9I2qwgsYDiv3Z-A4F2YOhI;
164
+ HttpOnly; Path=/
165
+ Via:
166
+ - 1.1 vegur
167
+ body:
168
+ encoding: UTF-8
169
+ string: "{\n \"name\": {\n \"formatted\": \"Larry Salibra\"\n }, \n \"location\":
170
+ {\n \"formatted\": \"Hong Kong\"\n }, \n \"avatar\": {\n \"url\":
171
+ \"https://s3.amazonaws.com/kd4/larry\"\n }, \n \"graph\": {\n \"url\":
172
+ \"https://s3.amazonaws.com/grph/larry\"\n }, \n \"pgp\": {\n \"fingerprint\":
173
+ \"B516CB7A08819697B25E4694DE3B5425164C4849\", \n \"url\": \"https://s3.amazonaws.com/pk9/larry\"\n
174
+ \ }, \n \"facebook\": {\n \"username\": \"larry.salibra\", \n \"proof\":
175
+ {\n \"url\": \"https://facebook.com/larry.salibra/posts/947870672453\"\n
176
+ \ }\n }, \n \"v\": \"0.2\", \n \"linkedin\": {\n \"url\": \"http://www.linkedin.com/in/larrysalibra\"\n
177
+ \ }, \n \"cover\": {\n \"url\": \"https://s3.amazonaws.com/dx3/larry\"\n
178
+ \ }, \n \"bio\": \"Founder & CEO Pay4Bugs\", \n \"github\": {\n \"username\":
179
+ \"larrysalibra\", \n \"proof\": {\n \"url\": \"https://gist.github.com/larrysalibra/510cc3fe4386f811b5bf\"\n
180
+ \ }\n }, \n \"twitter\": {\n \"username\": \"larrysalibra\", \n \"proof\":
181
+ {\n \"url\": \"https://twitter.com/larrysalibra/status/492049735935459328\"\n
182
+ \ }\n }, \n \"instagram\": {\n \"username\": \"larrysalibra\"\n },
183
+ \n \"angellist\": {\n \"username\": \"larry-salibra\"\n }, \n \"website\":
184
+ \"https://www.larrysalibra.com\", \n \"bitcoin\": {\n \"address\": \"1Q7zdhtkSMQp6Mp5ooyWyJgoXSLiApnmVT\"\n
185
+ \ }\n}"
186
+ http_version:
187
+ recorded_at: Sun, 22 Feb 2015 11:58:29 GMT
188
+ - request:
189
+ method: get
190
+ uri: https://onename.com/nothere.json
191
+ body:
192
+ encoding: US-ASCII
193
+ string: ''
194
+ headers:
195
+ User-Agent:
196
+ - openname-ruby 0.4.1
197
+ Accept-Encoding:
198
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
199
+ Accept:
200
+ - "*/*"
201
+ response:
202
+ status:
203
+ code: 500
204
+ message: Internal Server Error
205
+ headers:
206
+ Server:
207
+ - Cowboy
208
+ Date:
209
+ - Sun, 22 Feb 2015 11:58:30 GMT
210
+ Connection:
211
+ - keep-alive
212
+ Content-Type:
213
+ - text/html
214
+ Content-Length:
215
+ - '134'
216
+ Via:
217
+ - 1.1 vegur
218
+ body:
219
+ encoding: UTF-8
220
+ string: "<html>\n <head>\n <title>Internal Server Error</title>\n </head>\n
221
+ \ <body>\n <h1>Internal Server Error</h1>\n \n </body>\n</html>\n"
222
+ http_version:
223
+ recorded_at: Sun, 22 Feb 2015 11:58:31 GMT
224
+ - request:
225
+ method: get
226
+ uri: https://onename.com/bitcoinhater.json
227
+ body:
228
+ encoding: US-ASCII
229
+ string: ''
230
+ headers:
231
+ User-Agent:
232
+ - openname-ruby 0.4.1
233
+ Accept-Encoding:
234
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
235
+ Accept:
236
+ - "*/*"
237
+ response:
238
+ status:
239
+ code: 500
240
+ message: Internal Server Error
241
+ headers:
242
+ Server:
243
+ - Cowboy
244
+ Date:
245
+ - Sun, 22 Feb 2015 11:58:32 GMT
246
+ Connection:
247
+ - keep-alive
248
+ Content-Type:
249
+ - text/html
250
+ Content-Length:
251
+ - '134'
252
+ Via:
253
+ - 1.1 vegur
254
+ body:
255
+ encoding: UTF-8
256
+ string: "<html>\n <head>\n <title>Internal Server Error</title>\n </head>\n
257
+ \ <body>\n <h1>Internal Server Error</h1>\n \n </body>\n</html>\n"
258
+ http_version:
259
+ recorded_at: Sun, 22 Feb 2015 11:58:32 GMT
260
+ - request:
261
+ method: get
262
+ uri: https://onename.com/pmarca.json
263
+ body:
264
+ encoding: US-ASCII
265
+ string: ''
266
+ headers:
267
+ User-Agent:
268
+ - openname-ruby 0.4.1
269
+ Accept-Encoding:
270
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
271
+ Accept:
272
+ - "*/*"
273
+ response:
274
+ status:
275
+ code: 500
276
+ message: Internal Server Error
277
+ headers:
278
+ Server:
279
+ - Cowboy
280
+ Date:
281
+ - Sun, 22 Feb 2015 11:58:33 GMT
282
+ Connection:
283
+ - keep-alive
284
+ Content-Type:
285
+ - text/html
286
+ Content-Length:
287
+ - '134'
288
+ Via:
289
+ - 1.1 vegur
290
+ body:
291
+ encoding: UTF-8
292
+ string: "<html>\n <head>\n <title>Internal Server Error</title>\n </head>\n
293
+ \ <body>\n <h1>Internal Server Error</h1>\n \n </body>\n</html>\n"
294
+ http_version:
295
+ recorded_at: Sun, 22 Feb 2015 11:58:33 GMT
296
+ - request:
297
+ method: get
298
+ uri: http://openname.nametiles.dev/v2//larry.json
299
+ body:
300
+ encoding: US-ASCII
301
+ string: ''
302
+ headers:
303
+ User-Agent:
304
+ - openname-ruby 0.4.1
305
+ Accept-Encoding:
306
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
307
+ Accept:
308
+ - "*/*"
309
+ response:
310
+ status:
311
+ code: 200
312
+ message: OK
313
+ headers:
314
+ Content-Type:
315
+ - application/json
316
+ Content-Length:
317
+ - '972'
318
+ Access-Control-Allow-Origin:
319
+ - "*"
320
+ Access-Control-Allow-Credentials:
321
+ - 'true'
322
+ Access-Control-Max-Age:
323
+ - '180'
324
+ Access-Control-Allow-Methods:
325
+ - GET, POST, PUT, DELETE, OPTIONS
326
+ Cache-Control:
327
+ - public,max-age=300
328
+ Etag:
329
+ - W/"2bb9b1b06d25c6bd7f77588c62af6882"
330
+ X-Request-Id:
331
+ - cdf2578f-89b5-4fa4-a0a5-15b8c37b81e1
332
+ X-Runtime:
333
+ - '0.603472'
334
+ Date:
335
+ - Mon, 23 Feb 2015 06:32:35 GMT
336
+ Connection:
337
+ - keep-alive
338
+ body:
339
+ encoding: UTF-8
340
+ string: '{"angellist":{"username":"larry-salibra"},"avatar":{"url":"https://s3.amazonaws.com/kd4/larry"},"bio":"Founder
341
+ \u0026 CEO Pay4Bugs","bitcoin":{"address":"1Q7zdhtkSMQp6Mp5ooyWyJgoXSLiApnmVT"},"cover":{"url":"https://s3.amazonaws.com/dx3/larry"},"facebook":{"proof":{"url":"https://facebook.com/larry.salibra/posts/947870672453"},"username":"larry.salibra"},"github":{"proof":{"url":"https://gist.github.com/larrysalibra/510cc3fe4386f811b5bf"},"username":"larrysalibra"},"graph":{"url":"https://s3.amazonaws.com/grph/larry"},"instagram":{"username":"larrysalibra"},"linkedin":{"url":"http://www.linkedin.com/in/larrysalibra"},"location":{"formatted":"Hong
342
+ Kong"},"name":{"formatted":"Larry Salibra"},"pgp":{"fingerprint":"B516CB7A08819697B25E4694DE3B5425164C4849","url":"https://s3.amazonaws.com/pk9/larry"},"twitter":{"proof":{"url":"https://twitter.com/larrysalibra/status/492049735935459328"},"username":"larrysalibra"},"v":"0.2","website":"https://www.larrysalibra.com"}'
343
+ http_version:
344
+ recorded_at: Mon, 23 Feb 2015 06:32:35 GMT
345
+ - request:
346
+ method: get
347
+ uri: http://openname.nametiles.dev/v2//nothere.json
348
+ body:
349
+ encoding: US-ASCII
350
+ string: ''
351
+ headers:
352
+ User-Agent:
353
+ - openname-ruby 0.4.1
354
+ Accept-Encoding:
355
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
356
+ Accept:
357
+ - "*/*"
358
+ response:
359
+ status:
360
+ code: 404
361
+ message: Not Found
362
+ headers:
363
+ Content-Type:
364
+ - application/json
365
+ Access-Control-Allow-Origin:
366
+ - "*"
367
+ Access-Control-Allow-Credentials:
368
+ - 'true'
369
+ Access-Control-Max-Age:
370
+ - '180'
371
+ Access-Control-Allow-Methods:
372
+ - GET, POST, PUT, DELETE, OPTIONS
373
+ Cache-Control:
374
+ - public,max-age=300
375
+ Content-Length:
376
+ - '42'
377
+ X-Request-Id:
378
+ - 6c34dd23-1679-4053-ad1f-a2c714c0a7c5
379
+ X-Runtime:
380
+ - '0.557525'
381
+ Date:
382
+ - Mon, 23 Feb 2015 06:32:35 GMT
383
+ Connection:
384
+ - keep-alive
385
+ body:
386
+ encoding: UTF-8
387
+ string: '{"error":"Openname nothere doesn''t exist"}'
388
+ http_version:
389
+ recorded_at: Mon, 23 Feb 2015 06:32:35 GMT
390
+ - request:
391
+ method: get
392
+ uri: http://openname.nametiles.dev/v2//bitcoinhater.json
393
+ body:
394
+ encoding: US-ASCII
395
+ string: ''
396
+ headers:
397
+ User-Agent:
398
+ - openname-ruby 0.4.1
399
+ Accept-Encoding:
400
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
401
+ Accept:
402
+ - "*/*"
403
+ response:
404
+ status:
405
+ code: 404
406
+ message: Not Found
407
+ headers:
408
+ Content-Type:
409
+ - application/json
410
+ Access-Control-Allow-Origin:
411
+ - "*"
412
+ Access-Control-Allow-Credentials:
413
+ - 'true'
414
+ Access-Control-Max-Age:
415
+ - '180'
416
+ Access-Control-Allow-Methods:
417
+ - GET, POST, PUT, DELETE, OPTIONS
418
+ Cache-Control:
419
+ - public,max-age=300
420
+ Content-Length:
421
+ - '47'
422
+ X-Request-Id:
423
+ - 17a8bddc-c806-4bab-a501-d2eaa853da79
424
+ X-Runtime:
425
+ - '0.488571'
426
+ Date:
427
+ - Mon, 23 Feb 2015 06:32:36 GMT
428
+ Connection:
429
+ - keep-alive
430
+ body:
431
+ encoding: UTF-8
432
+ string: '{"error":"Openname bitcoinhater doesn''t exist"}'
433
+ http_version:
434
+ recorded_at: Mon, 23 Feb 2015 06:32:36 GMT
435
+ - request:
436
+ method: get
437
+ uri: http://openname.nametiles.dev/v2//pmarca.json
438
+ body:
439
+ encoding: US-ASCII
440
+ string: ''
441
+ headers:
442
+ User-Agent:
443
+ - openname-ruby 0.4.1
444
+ Accept-Encoding:
445
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
446
+ Accept:
447
+ - "*/*"
448
+ response:
449
+ status:
450
+ code: 200
451
+ message: OK
452
+ headers:
453
+ Content-Type:
454
+ - application/json
455
+ Content-Length:
456
+ - '155'
457
+ Access-Control-Allow-Origin:
458
+ - "*"
459
+ Access-Control-Allow-Credentials:
460
+ - 'true'
461
+ Access-Control-Max-Age:
462
+ - '180'
463
+ Access-Control-Allow-Methods:
464
+ - GET, POST, PUT, DELETE, OPTIONS
465
+ Cache-Control:
466
+ - public,max-age=300
467
+ Etag:
468
+ - W/"347382fb1b572025a03e43d948c1155b"
469
+ X-Request-Id:
470
+ - 944b94fb-7edf-4822-9851-538abb5f74b4
471
+ X-Runtime:
472
+ - '0.547531'
473
+ Date:
474
+ - Mon, 23 Feb 2015 06:32:37 GMT
475
+ Connection:
476
+ - keep-alive
477
+ body:
478
+ encoding: UTF-8
479
+ string: '{"message":"This username is reserved for Marc Andreessen. If this
480
+ is you, please email reservations@onename.io to claim it for free.","status":"reserved"}'
481
+ http_version:
482
+ recorded_at: Mon, 23 Feb 2015 06:32:37 GMT
122
483
  recorded_with: VCR 2.9.0
@@ -1,68 +1,75 @@
1
1
  require 'spec_helper'
2
2
  require 'bitcoin'
3
3
 
4
- describe Openname, :vcr => { :cassette_name => "openname" } do
5
-
6
-
4
+ describe Openname, :vcr => { :cassette_name => "openname", :record => :new_episodes } do
5
+
6
+
7
7
  it "should have a default endpoint" do
8
- Openname.endpoint.should == "https://www.onename.io"
8
+ Openname.endpoint.should == "https://openname.nametiles.co/v2/"
9
9
  end
10
-
10
+
11
11
  it "should allow setting a different endpoint and returning to default" do
12
12
  Openname.endpoint = "https://www.example.com"
13
13
  Openname.endpoint.should == "https://www.example.com"
14
14
  Openname.endpoint = nil
15
- Openname.endpoint.should == "https://www.onename.io"
15
+ Openname.endpoint.should == "https://openname.nametiles.co/v2/"
16
16
  end
17
-
18
- it "should retrieve openname user" do
17
+
18
+ it "should retrieve openname user" do
19
19
  user = Openname.get("larry")
20
20
  user.is_a?(Openname::User).should == true
21
21
  end
22
-
23
- it "should give error if openname user does not exist" do
22
+
23
+ it "should give error if openname user does not exist" do
24
24
  expect {
25
25
  user = Openname.get("nothere")
26
26
  }.to raise_error(NameError)
27
27
  end
28
-
29
- context "we've retrieved an openname user" do
30
- before :each do
28
+
29
+ context "we've retrieved an openname user" do
30
+ before :each do
31
31
  @user = Openname.get("larry")
32
32
  end
33
-
34
- it "should have a openname" do
33
+
34
+ it "should have a openname" do
35
35
  @user.openname.should == "larry"
36
36
  end
37
-
37
+
38
38
  it "should have a bitcoin address" do
39
39
  address = @user.bitcoin_address
40
40
  Bitcoin.valid_address?(address).should == true
41
41
  end
42
-
42
+
43
43
  end
44
-
45
- context "retrieving Bitcoin addreses" do
46
- it "should retrieve a Bitcoin address" do
44
+
45
+ context "retrieving Bitcoin addreses" do
46
+ it "should retrieve a Bitcoin address" do
47
47
  address = Openname.get_bitcoin_address("larry")
48
48
  Bitcoin.valid_address?(address).should == true
49
-
49
+
50
50
  address = Openname.get_bitcoin_address("143xFrxppUD9oQE7mGvQFe23h814YorMBs")
51
51
  Bitcoin.valid_address?(address).should == true
52
52
  end
53
-
53
+
54
54
  it "should raise an error when retrieving poorly formed Bitcoin address" do
55
55
  expect {
56
56
  address = Openname.get_bitcoin_address("143xFrxpp")
57
57
  }.to raise_error(ArgumentError)
58
58
 
59
59
  end
60
-
60
+
61
61
  it "should raise an error when user has no Bitcoin address" do
62
62
  expect {
63
63
  address = Openname.get_bitcoin_address("bitcoinhater")
64
64
  }.to raise_error(NameError)
65
65
 
66
66
  end
67
+
68
+ it "should raise an error when name is reserved" do
69
+ expect {
70
+ Openname.get("pmarca")
71
+ }.to raise_error(NameError)
72
+
73
+ end
67
74
  end
68
75
  end
data/spec/spec_helper.rb CHANGED
@@ -8,5 +8,5 @@ VCR.configure do |c|
8
8
  end
9
9
 
10
10
  RSpec.configure do |config|
11
-
11
+
12
12
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openname
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Larry Salibra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-21 00:00:00.000000000 Z
11
+ date: 2015-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler