openname 0.4.8 → 0.4.9

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: 9f37acaebb9cabcb29fc2f7e86be6e170a147bc2
4
- data.tar.gz: d6ce2d8f644845e332a4b1f2d5547c5ee5b8cc98
3
+ metadata.gz: 230cf6eb56f09632379dd5c096ca5c84b9d651d0
4
+ data.tar.gz: c7a8d3bd21dbcf425d9d484f2b1ee35f51ef3835
5
5
  SHA512:
6
- metadata.gz: 857bba05fe8b8cdb20bd080bbfd806637421becae9f8e15baf118bba9d035b498c9e729f1c566fa0560914545d75b52d8b18d93be17798e30a670c50a071fd66
7
- data.tar.gz: 03628b4315805687e352ad81e6f95ebec144f203b15ea696b4cab2be643807b73398fbe0f3dcbd3da1f6a9de50e2c5e876606344a7e64dc474ddb488651f7412
6
+ metadata.gz: 6a56ecf26935db8e94ed934cf6ba97e4a28f83cf67f5137110420b09eb7697375e8c8e761d4af137efc6948901bdda4e91f00fd7fcf3a4d289630e44bf7efd61
7
+ data.tar.gz: afc53c53d14cb218c712bbf37ecada2ed94cadb7684db085506f2d1ebeaef92457175413e136762526667c8a47f4af9d45a8bbbe3f2e87dd9101b313c12b9818
data/lib/openname.rb CHANGED
@@ -18,6 +18,9 @@ module Openname
18
18
 
19
19
  @@suffix = ".json"
20
20
 
21
+ @@username = nil
22
+ @@password = nil
23
+
21
24
  ##
22
25
  # Current endpoint used by the library
23
26
  def self.endpoint
@@ -28,6 +31,14 @@ module Openname
28
31
  end
29
32
  end
30
33
 
34
+ ##
35
+ # Send basic authentication
36
+ #
37
+ def self.auth(username, password)
38
+ @@username = username
39
+ @@password = password
40
+ end
41
+
31
42
  ##
32
43
  # Set suffix appended to openname to +suffix+
33
44
  # if +suffix+ is +nil+, no suffix will be appended
@@ -69,6 +80,7 @@ module Openname
69
80
  http = Net::HTTP.new(uri.host,uri.port)
70
81
  http.use_ssl = uri.scheme == "https" ? true : false
71
82
  req = Net::HTTP::Get.new(uri.path, {'User-Agent' => USERAGENT})
83
+ req.basic_auth(@@username, @@password) if @@username && @@password
72
84
  res = http.request(req)
73
85
  case res.code.to_s
74
86
  when "404" then raise NameError.new("Openname \"#{openname}\" does not exist")
@@ -1,3 +1,3 @@
1
1
  module Openname
2
- VERSION = "0.4.8"
2
+ VERSION = "0.4.9"
3
3
  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.8
4
+ version: 0.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Larry Salibra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-23 00:00:00.000000000 Z
11
+ date: 2015-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler