whoisxmlapi2 0.2.0 → 0.2.1

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
  SHA256:
3
- metadata.gz: fe3742849c111594262b4bd25f44f4cc6327bf3475977efe91e30aed3b791548
4
- data.tar.gz: a1e0418fc2d0383d5f7aaba0384ff23c7909cc6abd130c858c244346dcb0a16e
3
+ metadata.gz: 11aacdb5bb689acfaba0658db2a5090c23dbcb49a34c4af768a793d2284c32d2
4
+ data.tar.gz: 11ccbe22adbd9841eba7e84adaa29a487485fbae058995eb91f8c772572ee8fb
5
5
  SHA512:
6
- metadata.gz: 10c8922787de04a51a6fd405ed1875a77757ef9fb741eeb80b5b6ffe080a803d6e940a8d6510e02275add10531514a88c10fee4d3ac45e21b3842fc9a229f13f
7
- data.tar.gz: aefce1771e65c893ec467de6bee69df757e7727af9c0bac856fa4efc80da469227cd5401d9b45b019c90acaa4031278563fa5c77d9232ec91d3859dd5fa8f4a8
6
+ metadata.gz: 5a1fbc6287dfd329450a4c59309eafbf4ee3e9a34d5e204f333da95af3eed54f7e9f0ea17cce63d8ac8fe6f21b783854a0baf0078e16292d6314d14e74f879cd
7
+ data.tar.gz: b05db8de12b6a44b4f87f209edfc0b26bcfe4af4df334af4880e532a690070db9963df38487f7d5c9d0296aef32e6059626514f93baf7c13cd54d17864b1b054
data/README.md CHANGED
@@ -20,12 +20,30 @@ Or install it yourself as:
20
20
 
21
21
  Provide your credentials
22
22
 
23
+ #### With block
24
+
23
25
  ```ruby
24
26
  WhoisXMLAPI2.configure do |config|
25
27
  config.api_key = "your-api-key"
28
+ config.username = "your-api-username"
29
+ config.secret = "your-secret-key"
30
+ config.mock_out_for_testing = false
26
31
  end
27
32
  ```
28
33
 
34
+ #### With params
35
+
36
+ ```ruby
37
+ config_params = {
38
+ api_key: "your-api-key",
39
+ username: "your-api-username",
40
+ secret: "your-secret-key",
41
+ mock_out_for_testing: false
42
+ }
43
+
44
+ WhoisXMLAPI2.configure(config_params)
45
+ ```
46
+
29
47
  Make a request
30
48
 
31
49
  ```ruby
@@ -12,11 +12,20 @@ require "whoisxmlapi2/request"
12
12
  require "whoisxmlapi2/version"
13
13
 
14
14
  module WhoisXMLAPI2
15
- def self.configuration
16
- @configuration ||= Configuration.new
17
- end
15
+ class << self
16
+ def configuration(params = {})
17
+ @configuration ||= Configuration.new(params)
18
+ end
19
+
20
+ def config_instance
21
+ @configuration
22
+ end
23
+
24
+ def configure(params = {})
25
+ configuration(params) unless params.empty?
26
+ raise InvalidArgument, 'Block is required' if params.empty? && !block_given?
18
27
 
19
- def self.configure
20
- yield(configuration)
28
+ yield configuration if block_given?
29
+ end
21
30
  end
22
31
  end
@@ -5,20 +5,35 @@ module WhoisXMLAPI2
5
5
 
6
6
  DEFAULT_SERVICE_ENDPOINT = "https://whoisxmlapi.com/whoisserver/WhoisService?".freeze
7
7
 
8
- def initialize
9
- @url = DEFAULT_SERVICE_ENDPOINT
8
+ def initialize(params = {})
9
+ apply_configuration(params)
10
10
  end
11
11
 
12
- def self.set?
13
- WhoisXMLAPI2.configuration.url && \
14
- WhoisXMLAPI2.configuration.api_key
12
+ class << self
13
+ def set?
14
+ WhoisXMLAPI2.configuration.url && \
15
+ WhoisXMLAPI2.configuration.api_key || \
16
+ WhoisXMLAPI2.configuration.mock_out_for_testing
17
+ end
18
+
19
+ def set_v1?
20
+ WhoisXMLAPI2.configuration.url && \
21
+ WhoisXMLAPI2.configuration.username && \
22
+ WhoisXMLAPI2.configuration.api_key && \
23
+ WhoisXMLAPI2.configuration.secret || \
24
+ WhoisXMLAPI2.configuration.mock_out_for_testing
25
+ end
15
26
  end
16
27
 
17
- def self.set_v1?
18
- WhoisXMLAPI2.configuration.url && \
19
- WhoisXMLAPI2.configuration.username && \
20
- WhoisXMLAPI2.configuration.api_key && \
21
- WhoisXMLAPI2.configuration.secret
28
+ def apply_configuration(params)
29
+ params[:url] ||= DEFAULT_SERVICE_ENDPOINT
30
+
31
+ @username = params[:username]
32
+ @api_key = params[:api_key]
33
+ @secret = params[:secret]
34
+ @url = params[:url]
35
+ @browser_key = params[:browser_key]
36
+ @mock_out_for_testing = params[:mock_out_for_testing]
22
37
  end
23
38
  end
24
39
  end
@@ -1,3 +1,3 @@
1
1
  module WhoisXMLAPI2
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -10,7 +10,6 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["scnissen@gmail.com"]
11
11
 
12
12
  spec.summary = %q{An open source WhoisXMLAPI interface}
13
- # spec.description = %q{TODO: Write a longer description or delete this line.}
14
13
  spec.homepage = "https://github.com"
15
14
  spec.license = "MIT"
16
15
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whoisxmlapi2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Nissen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-23 00:00:00.000000000 Z
11
+ date: 2020-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler