proxycheck 0.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9edc66055b4be58e5ded538284133d4f64a6d6a4
4
+ data.tar.gz: 8af1482bed425ceef1f09adce95faceab3ce85de
5
+ SHA512:
6
+ metadata.gz: cadd4c09a32e65e8c1fc079fa06bed6e9f01ac76c7feaa38a799ac2fcd11c4b557ad4bf93024fa57d2a3214ad4affabac00142892ddd3309b92bbb0eb375706b
7
+ data.tar.gz: 23ea327f27497d6240832b789a961f92a84f0b9151668f3d1e40fe11e04bc642575e3cf1b472c68c2b2efde3cc5bdf659381be756739a77262a7369504a2270b
@@ -0,0 +1,22 @@
1
+ require 'proxycheck/configurable'
2
+ require 'proxycheck/client'
3
+
4
+ module ProxyCheck
5
+
6
+ class << self
7
+ include ProxyCheck::Configurable
8
+ end
9
+
10
+ # def configure
11
+ # yield config
12
+ # end
13
+
14
+ # def config
15
+ # @config ||= Configuration.new
16
+ # end
17
+
18
+
19
+ # def reset_config
20
+ # @config = nil
21
+ # end
22
+ end
@@ -0,0 +1,15 @@
1
+ require 'proxycheck/api/util'
2
+ module ProxyCheck
3
+ module API
4
+ module ProxyLookup
5
+ include ProxyCheck::API::Util
6
+
7
+ API_VERSION = 'v1'
8
+
9
+ def proxy_lookup(ip_address, options = {})
10
+ call(ip_address, API_VERSION, :get, options)
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,41 @@
1
+ require 'net/http'
2
+ require 'json'
3
+
4
+ module ProxyCheck
5
+ module API
6
+ module Util
7
+
8
+ include ProxyCheck::Configurable
9
+
10
+ ROOT_URL = 'https://proxycheck.io'
11
+
12
+ def call(path, api_version = "v1", type = :get, params = {})
13
+
14
+ params.merge!({api_key: api_key}) if !api_key.blank?
15
+
16
+ uri = URI.parse(build_url(path, api_version))
17
+ uri.query = URI.encode_www_form(params)
18
+
19
+ http = Net::HTTP.new(uri.host, uri.port)
20
+
21
+ http.use_ssl = true if uri.scheme.upcase == "HTTPS"
22
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE if uri.scheme.upcase == "HTTPS"
23
+
24
+ case type
25
+ when :get
26
+ request = Net::HTTP::Get.new(uri.request_uri)
27
+ when :post
28
+ request = Net::HTTP::Post.new(uri.request_uri)
29
+ end
30
+
31
+ response = http.request(request)
32
+ JSON.parse(response.body)
33
+ end
34
+
35
+ def build_url(path, api_version)
36
+ "#{ File.join(ROOT_URL, api_version, path) }"
37
+ end
38
+
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,16 @@
1
+ require 'proxycheck/api/util'
2
+ require 'proxycheck/api/proxy_lookup'
3
+
4
+ module ProxyCheck
5
+
6
+ class Client
7
+ include ProxyCheck::Configurable
8
+ include ProxyCheck::API::ProxyLookup
9
+
10
+ def initialize(options={})
11
+ ProxyCheck::Configurable.keys.each do |key|
12
+ instance_variable_set(:"@#{key}", options[key] || ProxyCheck.instance_variable_get(:"@#{key}"))
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,37 @@
1
+
2
+ module ProxyCheck
3
+ module Configurable
4
+
5
+ attr_writer :api_key
6
+
7
+ class << self
8
+ def keys
9
+ @keys ||= [
10
+ :api_key
11
+ ]
12
+ end
13
+ end
14
+
15
+ def configure
16
+ yield self
17
+ self
18
+ end
19
+
20
+ def api_key
21
+ @api_key
22
+ end
23
+
24
+ # def api_keys
25
+ #
26
+ # {
27
+ # identity_check_api_key: @identity_check_api_key,
28
+ # lead_verify_api_key: @lead_verify_api_key,
29
+ # reverse_phone_api_key: @reverse_phone_api_key,
30
+ # phone_intelligence_api_key: @phone_intelligence_api_key,
31
+ # phone_reputation_api_key: @phone_reputation_api_key,
32
+ # find_person_api_key: @find_person_api_key,
33
+ # reverse_address_api_key: @reverse_address_api_key
34
+ # }
35
+ # end
36
+ end
37
+ end
@@ -0,0 +1,6 @@
1
+
2
+ require 'spec_helper'
3
+
4
+ describe ProxyCheck::API::ProxyLookup do
5
+
6
+ end
@@ -0,0 +1,6 @@
1
+
2
+ require 'spec_helper'
3
+
4
+ describe ProxyCheck::API::Util do
5
+
6
+ end
@@ -0,0 +1,20 @@
1
+
2
+ require 'simplecov'
3
+
4
+ SimpleCov.start do
5
+ add_filter {|sf| sf.filename !~ /\/lib\//}
6
+ end
7
+
8
+ require 'proxycheck'
9
+
10
+ # Require the debugger, if present.
11
+ begin
12
+ require 'debugger'
13
+ rescue LoadError
14
+ module Kernel
15
+ def debugger(*args, &block)
16
+ STDERR.puts "*** Debugger not available."
17
+ end
18
+ end
19
+ end
20
+
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: proxycheck
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jonathan De Jong
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-11-09 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: This gem is for interacting the proxycheck.io API
14
+ email: ''
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/proxycheck.rb
20
+ - lib/proxycheck/api/proxy_lookup.rb
21
+ - lib/proxycheck/api/util.rb
22
+ - lib/proxycheck/client.rb
23
+ - lib/proxycheck/configurable.rb
24
+ - spec/api/proxy_lookup_spec.rb
25
+ - spec/api/util_spec.rb
26
+ - spec/spec_helper.rb
27
+ homepage: http://rubygems.org/gems/proxycheck
28
+ licenses:
29
+ - MIT
30
+ metadata: {}
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ requirements: []
46
+ rubyforge_project:
47
+ rubygems_version: 2.6.8
48
+ signing_key:
49
+ specification_version: 4
50
+ summary: proxycheck
51
+ test_files: []