hexillion 1.0.0 → 1.1.0

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: fff80e1d33f1c3a6dde7de87c510f410a3fe35a9
4
- data.tar.gz: bc47a9cd6622cf159552b51f4428c0085cdb24fd
3
+ metadata.gz: f3dcf43553d22627e94b670b299d7f1eb99ade4c
4
+ data.tar.gz: b7cdec679ecc58adb27a57de46db5d654f1eb4ee
5
5
  SHA512:
6
- metadata.gz: 0877b52aa4d14153534202cafb0781e249cf503b58ba07b527535a145568fef0d20921993ec14f5c67dc8b101fcf1247db32a9bce3c7de65752bdab03cdaf2c5
7
- data.tar.gz: a30d75982c1822d1570d7eb946c0df70d206a00d253979918681881702ab8fff13d8406ca975effd172c703870d73bb9da82a8f25ced7089ad6992b846e657b2
6
+ metadata.gz: 1d7fc534f28132d2c1dca6b6ccf7e86289f10233a8122d2088bc766351b294297aad54042456a5a73593925a2269aa8d748e19e03e3a220e7aa4ba052b34138e
7
+ data.tar.gz: 087bca15bda8a7591920bb543d31cbba52ab9c57cb0a10a7a911ff6bdcfa148c5919784f490383052236e2370d220b08c3030f9a5332cdeb5ff457ee199e2a86
@@ -13,25 +13,28 @@ module Hexillion
13
13
  raise "Authentication failed"
14
14
  end
15
15
  end
16
-
16
+
17
17
  # Query the API for a given domain
18
- #
19
- # @example
20
- # client.whois('flippa.com') # => { ... }
21
- #
22
- #
23
-
24
- def whois(domain)
25
- response = RestClient.get "http://hexillion.com/rf/xml/1.0/whois/", :params => {:sessionkey => @session_key, :query => domain}
18
+ #
19
+ # @example
20
+ # client.whois('flippa.com', {optional_param: value, ...}) # => { ... }
21
+ #
22
+ #
23
+
24
+ def whois(domain, extra_params = {})
25
+ base_params = {:sessionkey => @session_key, :query => domain}
26
+ params = base_params.merge(extra_params)
27
+
28
+ response = RestClient.get "http://hexillion.com/rf/xml/1.0/whois/", :params => params
26
29
  parse_xml(response.body)
27
30
  end
28
-
31
+
29
32
  private
30
-
33
+
31
34
  def parse_xml(xml)
32
35
  doc = Nokogiri::XML(xml)
33
36
  records = doc.xpath(".//QueryResult[ErrorCode='Success' and FoundMatch='Yes']/WhoisRecord")
34
-
37
+
35
38
  strings = {
36
39
  :registrant_name => "Registrant Name",
37
40
  :registrant_person => "Registrant Person",
@@ -83,18 +86,18 @@ module Hexillion
83
86
  :stripped_text => "StrippedText",
84
87
  :raw_text => "RawText"
85
88
  }
86
-
89
+
87
90
  dates = {
88
91
  :created_date => './CreatedDate',
89
92
  :expires_date => './ExpiresDate',
90
93
  :updated_date => './UpdatedDate'
91
94
  }
92
-
95
+
93
96
  result = { :xml_response => xml }
94
-
97
+
95
98
  records.each do |record|
96
99
  result[:nameservers] = record.css('Domain NameServer').map { |x| x.content unless x.content == '' }
97
-
100
+
98
101
  strings.each do | attr, selector |
99
102
  nodes = record.css(selector)
100
103
  next if nodes.empty?
@@ -104,13 +107,13 @@ module Hexillion
104
107
  result[attr] = nodes.to_a.reject { |s| s.blank? }.join("\n")
105
108
  end
106
109
  end
107
-
110
+
108
111
  dates.each do | attr, selector |
109
112
  next unless node = record.at_xpath(selector)
110
113
  result[attr] = DateTime.parse(node.content) unless node.content == ''
111
114
  end
112
115
  end
113
-
116
+
114
117
  result
115
118
  end
116
119
  end
@@ -1,3 +1,3 @@
1
1
  module Hexillion
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -18,7 +18,7 @@ describe Hexillion::Client do
18
18
  hex.instance_variable_get('@session_key').should == 'nOIANdfjL4524ynjlssasjfDFaqe4'
19
19
  end
20
20
  end
21
-
21
+
22
22
  describe "#whois" do
23
23
  before(:each) do
24
24
  @response = double()
@@ -27,12 +27,25 @@ describe Hexillion::Client do
27
27
  @response.stub(:body) { "" }
28
28
  @hex = Hexillion::Client.new(:username => "username", :password => "password")
29
29
  end
30
-
31
- it "queries the API for the provided domain" do
32
- RestClient.should_receive(:get)
33
- @hex.whois("example.com")
30
+
31
+ it "queries the API and passes all the params to the endpoint" do
32
+ domain_name = "example.com"
33
+ extra_params = {:data => "awesome", :more_data => "awesomer"}
34
+ endpoint_url = kind_of(String)
35
+ sessionkey = kind_of(String)
36
+
37
+ payload = [
38
+ endpoint_url,
39
+ :params => {
40
+ :sessionkey => sessionkey,
41
+ :query => domain_name
42
+ }.merge(extra_params)
43
+ ]
44
+
45
+ expect(RestClient).to receive(:get).with(*payload)
46
+ @hex.whois(domain_name, extra_params)
34
47
  end
35
-
48
+
36
49
  it "concats multiline address fields" do
37
50
  @response.stub(:body) do
38
51
  <<-XML
@@ -44,7 +57,7 @@ describe Hexillion::Client do
44
57
  </WhoisRecord></QueryResult>
45
58
  XML
46
59
  end
47
-
60
+
48
61
  @hex.whois("example.com")[:registrant_address].should == "48 Cambridge Street\nLevel 3"
49
62
  end
50
63
 
@@ -60,7 +73,7 @@ describe Hexillion::Client do
60
73
  </WhoisRecord></QueryResult>
61
74
  XML
62
75
  end
63
-
76
+
64
77
  @hex.whois("example.com")[:registrant_email].should == "me@example.com"
65
78
  end
66
79
 
@@ -75,13 +88,13 @@ describe Hexillion::Client do
75
88
  </WhoisRecord></QueryResult>
76
89
  XML
77
90
  end
78
-
91
+
79
92
  @hex.whois("example.com")[:admin_contact_email].should == "john@example.com"
80
93
  end
81
-
94
+
82
95
  it "makes an array of nameservers" do
83
96
  @response.stub(:body) do
84
- <<-XML
97
+ <<-XML
85
98
  <QueryResult><ErrorCode>Success</ErrorCode><FoundMatch>Yes</FoundMatch><WhoisRecord>
86
99
  <Domain>
87
100
  <NameServer>ns1.registrar.com</NameServer>
@@ -91,36 +104,36 @@ describe Hexillion::Client do
91
104
  </WhoisRecord></QueryResult>
92
105
  XML
93
106
  end
94
-
107
+
95
108
  @hex.whois("example.com")[:nameservers].should == ['ns1.registrar.com', 'ns2.registrar.com', 'ns3.registrar.com']
96
109
  end
97
110
 
98
111
  it "parses date fields" do
99
112
  @response.stub(:body) do
100
- <<-XML
113
+ <<-XML
101
114
  <QueryResult><ErrorCode>Success</ErrorCode><FoundMatch>Yes</FoundMatch><WhoisRecord>
102
115
  <CreatedDate>1999-10-04T00:00:00Z</CreatedDate>
103
116
  <UpdatedDate>2010-11-25T00:00:00Z</UpdatedDate>
104
117
  <ExpiresDate>2019-10-04T00:00:00Z</ExpiresDate>
105
118
  </WhoisRecord></QueryResult>
106
119
  XML
107
- end
108
-
120
+ end
121
+
109
122
  @hex.whois("example.com")[:created_date].should == DateTime::civil(1999,10,4)
110
123
  end
111
-
124
+
112
125
  it "returns the entire xml response as :xml_response" do
113
- xml = <<-XML
126
+ xml = <<-XML
114
127
  <QueryResult><ErrorCode>Success</ErrorCode><FoundMatch>Yes</FoundMatch><WhoisRecord>
115
128
  <CreatedDate>1999-10-04T00:00:00Z</CreatedDate>
116
129
  <UpdatedDate>2010-11-25T00:00:00Z</UpdatedDate>
117
130
  <ExpiresDate>2019-10-04T00:00:00Z</ExpiresDate>
118
131
  </WhoisRecord></QueryResult>
119
132
  XML
120
-
133
+
121
134
  @response.stub(:body) { xml }
122
-
135
+
123
136
  @hex.whois("example.com")[:xml_response].should == xml
124
137
  end
125
138
  end
126
- end
139
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hexillion
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louis Simoneau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-15 00:00:00.000000000 Z
11
+ date: 2014-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  version: '0'
89
89
  requirements: []
90
90
  rubyforge_project:
91
- rubygems_version: 2.2.2
91
+ rubygems_version: 2.4.1
92
92
  signing_key:
93
93
  specification_version: 4
94
94
  summary: Provides a simple client for the Hexillion API