proxy_seeker 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 32f0b5e771e981a545f99359a43e4b25dbf7f6c0
4
+ data.tar.gz: 6246b7ebd55b123db67b1894c6464f92449e5f3b
5
+ SHA512:
6
+ metadata.gz: 362cef25b29f72fe214a92ae9dd6fc22045c30e0db19a4edb2b5d0bcb45f576476ef87c956a678feeba9c366a0ce17ab30d6451734652ac16530a03f495ff725
7
+ data.tar.gz: 9ead2c81a5adcc4e21ad7fefa3f9335f649ca0107f58f4538ab0f325b0f6bf65690cce8edf120419be5d81f700f03b923dc5b49cd4a252a46fb9cd2cd87c5199
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'httparty'
4
+
5
+ group :development do
6
+ gem "rdoc", "~> 3.12"
7
+ gem "bundler", "~> 1.0"
8
+ gem "jeweler", "~> 2.0.1"
9
+ gem "simplecov", ">= 0"
10
+ end
11
+
12
+ group :test do
13
+ gem "rspec", "~> 2.14.0"
14
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,77 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.3.6)
5
+ builder (3.2.2)
6
+ descendants_tracker (0.0.4)
7
+ thread_safe (~> 0.3, >= 0.3.1)
8
+ diff-lcs (1.2.5)
9
+ docile (1.1.5)
10
+ faraday (0.9.0)
11
+ multipart-post (>= 1.2, < 3)
12
+ git (1.2.8)
13
+ github_api (0.12.2)
14
+ addressable (~> 2.3)
15
+ descendants_tracker (~> 0.0.4)
16
+ faraday (~> 0.8, < 0.10)
17
+ hashie (>= 3.3)
18
+ multi_json (>= 1.7.5, < 2.0)
19
+ nokogiri (~> 1.6.3)
20
+ oauth2
21
+ hashie (3.3.2)
22
+ highline (1.6.21)
23
+ httparty (0.13.3)
24
+ json (~> 1.8)
25
+ multi_xml (>= 0.5.2)
26
+ jeweler (2.0.1)
27
+ builder
28
+ bundler (>= 1.0)
29
+ git (>= 1.2.5)
30
+ github_api
31
+ highline (>= 1.6.15)
32
+ nokogiri (>= 1.5.10)
33
+ rake
34
+ rdoc
35
+ json (1.8.1)
36
+ jwt (1.2.0)
37
+ mini_portile (0.6.1)
38
+ multi_json (1.10.1)
39
+ multi_xml (0.5.5)
40
+ multipart-post (2.0.0)
41
+ nokogiri (1.6.5)
42
+ mini_portile (~> 0.6.0)
43
+ oauth2 (1.0.0)
44
+ faraday (>= 0.8, < 0.10)
45
+ jwt (~> 1.0)
46
+ multi_json (~> 1.3)
47
+ multi_xml (~> 0.5)
48
+ rack (~> 1.2)
49
+ rack (1.5.2)
50
+ rake (10.4.2)
51
+ rdoc (3.12.2)
52
+ json (~> 1.4)
53
+ rspec (2.14.1)
54
+ rspec-core (~> 2.14.0)
55
+ rspec-expectations (~> 2.14.0)
56
+ rspec-mocks (~> 2.14.0)
57
+ rspec-core (2.14.8)
58
+ rspec-expectations (2.14.5)
59
+ diff-lcs (>= 1.1.3, < 2.0)
60
+ rspec-mocks (2.14.6)
61
+ simplecov (0.9.1)
62
+ docile (~> 1.1.0)
63
+ multi_json (~> 1.0)
64
+ simplecov-html (~> 0.8.0)
65
+ simplecov-html (0.8.0)
66
+ thread_safe (0.3.4)
67
+
68
+ PLATFORMS
69
+ ruby
70
+
71
+ DEPENDENCIES
72
+ bundler (~> 1.0)
73
+ httparty
74
+ jeweler (~> 2.0.1)
75
+ rdoc (~> 3.12)
76
+ rspec (~> 2.14.0)
77
+ simplecov
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2014 Marcin Kot
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = proxy_seeker
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to proxy_seeker
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2014 Marcin Kot. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,50 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
+ gem.name = "proxy_seeker"
18
+ gem.homepage = "http://github.com/visualitypl/proxy_seeker"
19
+ gem.license = "MIT"
20
+ gem.summary = "Gem for finding and testing http proxy servers"
21
+ gem.description = "Gem for finding and testing http proxy servers"
22
+ gem.email = "m.kot@visuality.pl"
23
+ gem.authors = ["Marcin Kot"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ desc "Code coverage detail"
35
+ task :simplecov do
36
+ ENV['COVERAGE'] = "true"
37
+ Rake::Task['spec'].execute
38
+ end
39
+
40
+ task :default => :spec
41
+
42
+ require 'rdoc/task'
43
+ Rake::RDocTask.new do |rdoc|
44
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
+
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = "proxy_seeker #{version}"
48
+ rdoc.rdoc_files.include('README*')
49
+ rdoc.rdoc_files.include('lib/**/*.rb')
50
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,36 @@
1
+ module ProxySeeker
2
+ class Fetcher
3
+ attr_reader :scrapers, :proxies
4
+
5
+ def initialize(opts = {})
6
+ @scrapers, @proxies = [], []
7
+ @opts = opts
8
+
9
+ Dir["#{File.dirname(__FILE__)}/scrapers/*.rb"].each do |file|
10
+ class_name = file.split('/').last.split('.rb').first.split('_').map(&:capitalize).join
11
+ class_const = Object.const_get("ProxySeeker::Scrapers::#{class_name}") rescue nil
12
+ @scrapers << class_const if !class_const.nil? && class_const.new.respond_to?(:fetch)
13
+ end
14
+ end
15
+
16
+ def execute
17
+ fetch_all
18
+ filer_out
19
+ proxies
20
+ end
21
+
22
+ private
23
+
24
+ def fetch_all
25
+ scrapers.each do |fetcher|
26
+ @proxies << fetcher.new.fetch
27
+ end
28
+
29
+ @proxies = @proxies.flatten.compact
30
+ end
31
+
32
+ def filer_out
33
+ @proxies = @proxies.uniq.select{ |proxy| proxy.valid? }
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,31 @@
1
+ require 'resolv'
2
+
3
+ module ProxySeeker
4
+ class Proxy
5
+ attr_reader :ip, :port, :latency, :opts
6
+
7
+ include Comparable
8
+
9
+ def initialize(ip, port, opts = {})
10
+ @ip = ip
11
+ @port = port.to_i
12
+ @latency = opts[:latency]
13
+ end
14
+
15
+ def to_s
16
+ "#{ip}:#{port}"
17
+ end
18
+
19
+ def valid?
20
+ ip =~ Resolv::IPv4::Regex && port.to_i > 0 ? true : false
21
+ end
22
+
23
+ def <=>(other)
24
+ return 0 if latency.nil? && other.latency.nil?
25
+ return 1 if latency.nil? && !other.latency.nil?
26
+ return -1 if !latency.nil? && other.latency.nil?
27
+
28
+ latency <=> other.latency
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,87 @@
1
+ module ProxySeeker
2
+ module Scrapers
3
+ class FakeScraper
4
+ def initialize(opts = {})
5
+ end
6
+
7
+ def fetch
8
+ [
9
+ ::ProxySeeker::Proxy.new('54.188.223.55','60884'),
10
+ ::ProxySeeker::Proxy.new('112.22.252.76','8123'),
11
+ ::ProxySeeker::Proxy.new('112.142.128.147','80'),
12
+ ::ProxySeeker::Proxy.new('201.234.29.11','80'),
13
+ ::ProxySeeker::Proxy.new('202.158.104.195','80'),
14
+ ::ProxySeeker::Proxy.new('218.92.227.165','23293'),
15
+ ::ProxySeeker::Proxy.new('186.233.55.156','8080'),
16
+ ::ProxySeeker::Proxy.new('113.253.151.1','8088'),
17
+ ::ProxySeeker::Proxy.new('5.53.16.183','8080'),
18
+ ::ProxySeeker::Proxy.new('60.206.153.177','8118'),
19
+ ::ProxySeeker::Proxy.new('176.106.240.1','3128'),
20
+ # ::ProxySeeker::Proxy.new('182.93.229.66','8080'),
21
+ # ::ProxySeeker::Proxy.new('92.222.14.156','8080'),
22
+ # ::ProxySeeker::Proxy.new('115.95.249.116','8081'),
23
+ # ::ProxySeeker::Proxy.new('117.162.61.237','8123'),
24
+ # ::ProxySeeker::Proxy.new('118.70.129.101','8080'),
25
+ # ::ProxySeeker::Proxy.new('115.28.57.12','8080'),
26
+ # ::ProxySeeker::Proxy.new('86.122.124.11','80'),
27
+ # ::ProxySeeker::Proxy.new('119.147.91.21','80'),
28
+ # ::ProxySeeker::Proxy.new('42.117.3.73','3128'),
29
+ # ::ProxySeeker::Proxy.new('37.187.101.22','9912'),
30
+ # ::ProxySeeker::Proxy.new('223.4.21.184','80'),
31
+ # ::ProxySeeker::Proxy.new('161.53.25.200','21320'),
32
+ # ::ProxySeeker::Proxy.new('79.142.55.19','80'),
33
+ # ::ProxySeeker::Proxy.new('85.236.6.54','8081'),
34
+ # ::ProxySeeker::Proxy.new('189.112.88.65','3128'),
35
+ # ::ProxySeeker::Proxy.new('84.22.32.222','3128'),
36
+ # ::ProxySeeker::Proxy.new('85.185.149.31','80'),
37
+ # ::ProxySeeker::Proxy.new('195.74.70.249','80'),
38
+ # ::ProxySeeker::Proxy.new('189.59.9.218','8080'),
39
+ # ::ProxySeeker::Proxy.new('190.40.123.35','8080'),
40
+ # ::ProxySeeker::Proxy.new('192.99.3.129','3128'),
41
+ # ::ProxySeeker::Proxy.new('182.254.228.121','80'),
42
+ # ::ProxySeeker::Proxy.new('195.154.77.104','3128'),
43
+ # ::ProxySeeker::Proxy.new('122.227.42.80','3128'),
44
+ # ::ProxySeeker::Proxy.new('123.30.75.115','80'),
45
+ # ::ProxySeeker::Proxy.new('88.159.140.239','80'),
46
+ # ::ProxySeeker::Proxy.new('93.189.221.26','8080'),
47
+ # ::ProxySeeker::Proxy.new('182.93.226.14','8080'),
48
+ # ::ProxySeeker::Proxy.new('165.139.149.169','3128'),
49
+ # ::ProxySeeker::Proxy.new('122.180.61.107','3128'),
50
+ # ::ProxySeeker::Proxy.new('113.255.114.150','8088'),
51
+ # ::ProxySeeker::Proxy.new('177.128.24.75','8080'),
52
+ # ::ProxySeeker::Proxy.new('85.111.25.189','8080'),
53
+ # ::ProxySeeker::Proxy.new('145.118.111.106','80'),
54
+ # ::ProxySeeker::Proxy.new('190.12.86.211','3128'),
55
+ # ::ProxySeeker::Proxy.new('188.165.158.83','3128'),
56
+ # ::ProxySeeker::Proxy.new('121.200.63.2','8080'),
57
+ # ::ProxySeeker::Proxy.new('189.113.64.126','8080'),
58
+ # ::ProxySeeker::Proxy.new('121.199.30.110','82'),
59
+ # ::ProxySeeker::Proxy.new('116.228.55.217','8003'),
60
+ # ::ProxySeeker::Proxy.new('118.97.170.74','8080'),
61
+ # ::ProxySeeker::Proxy.new('120.199.252.255','8123'),
62
+ # ::ProxySeeker::Proxy.new('119.6.144.70','81'),
63
+ # ::ProxySeeker::Proxy.new('196.201.216.170','50'),
64
+ # ::ProxySeeker::Proxy.new('211.22.11.46','444'),
65
+ # ::ProxySeeker::Proxy.new('188.165.223.173','8123'),
66
+ # ::ProxySeeker::Proxy.new('190.201.157.241','8080'),
67
+ # ::ProxySeeker::Proxy.new('200.93.60.203','8080'),
68
+ # ::ProxySeeker::Proxy.new('210.101.131.231','8080'),
69
+ # ::ProxySeeker::Proxy.new('202.120.188.104','80'),
70
+ # ::ProxySeeker::Proxy.new('91.121.192.178','3128'),
71
+ # ::ProxySeeker::Proxy.new('180.213.2.154','1337'),
72
+ # ::ProxySeeker::Proxy.new('202.96.155.251','8888'),
73
+ # ::ProxySeeker::Proxy.new('196.201.216.171','16'),
74
+ # ::ProxySeeker::Proxy.new('118.26.142.5','80'),
75
+ # ::ProxySeeker::Proxy.new('177.207.211.250','3128'),
76
+ # ::ProxySeeker::Proxy.new('115.28.85.240','8088'),
77
+ # ::ProxySeeker::Proxy.new('218.90.134.138','63000'),
78
+ # ::ProxySeeker::Proxy.new('41.223.119.156','3128'),
79
+ # ::ProxySeeker::Proxy.new('218.71.140.134','8585'),
80
+ # ::ProxySeeker::Proxy.new('203.176.182.98','8080'),
81
+ # ::ProxySeeker::Proxy.new('183.62.172.50','9999'),
82
+ # ::ProxySeeker::Proxy.new('62.163.131.145','80'),
83
+ ]
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,17 @@
1
+ module ProxySeeker
2
+ module Scrapers
3
+ class ProxyListenScraper
4
+ # TODO: real fetching :)
5
+
6
+ URL = 'http://www.proxy-listen.de/Proxy/Proxyliste.html'
7
+
8
+ def initialize(opts = {})
9
+
10
+ end
11
+
12
+ def fetch
13
+ [::ProxySeeker::Proxy.new('190.235.199.189', '3128'), ::ProxySeeker::Proxy.new('14.18.16.67','80')]
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,53 @@
1
+ module ProxySeeker
2
+ class Tester
3
+ attr_reader :proxies, :timeout
4
+
5
+ TEST_URL = "http://www.wikipedia.org"
6
+
7
+ def initialize(proxies, opts = {})
8
+ @timeout = opts[:timeout] || 3
9
+ @proxies = proxies
10
+ end
11
+
12
+ def execute
13
+ filter_out
14
+ proxies
15
+ end
16
+
17
+ private
18
+
19
+ def filter_out
20
+ latency_filter
21
+ end
22
+
23
+ def latency_filter
24
+ threads = []
25
+ proxies_count = proxies.size
26
+ processed_count = 0
27
+
28
+ @proxies.each_with_index do |proxy, i|
29
+ threads << Thread.new {
30
+ test_result = ping_test(proxy, timeout)
31
+ if test_result
32
+ puts "OK: Proxy #{proxy} has passed #{timeout}s health check"
33
+ else
34
+ puts "FAIL: Proxy #{proxy} has failed #{timeout}s check"
35
+ @proxies -= [proxy]
36
+ end
37
+ processed_count += 1
38
+ puts "--> #{((processed_count/proxies_count.to_f) * 100).round}% done"
39
+ }
40
+ end
41
+ threads.each { |t| t.join }
42
+ end
43
+
44
+ def ping_test(proxy, timeout)
45
+ response = HTTParty.get(TEST_URL, http_proxyaddr: proxy.ip, http_proxyport: proxy.port, timeout: timeout)
46
+ response.code == 200 ? true : false
47
+ rescue
48
+ false
49
+ else
50
+ true
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,29 @@
1
+ require 'httparty'
2
+ require 'thread'
3
+ require 'proxy_seeker/proxy'
4
+ require 'proxy_seeker/fetcher'
5
+ require 'proxy_seeker/tester'
6
+ Dir["#{File.dirname(__FILE__)}/proxy_seeker/scrapers/*.rb"].each { |f| require f }
7
+
8
+ module ProxySeeker
9
+ module_function
10
+
11
+ DEFAULTS = { timeout: 3 }
12
+
13
+ def find(opts = {})
14
+ opts = DEFAULTS.merge(opts)
15
+ proxies = fetch_proxies(opts)
16
+ proxies = test_proxies(proxies, opts)
17
+ proxies
18
+ end
19
+
20
+ def fetch_proxies(opts = {})
21
+ fetcher = ProxySeeker::Fetcher.new(opts)
22
+ fetcher.execute
23
+ end
24
+
25
+ def test_proxies(proxies, opts = {})
26
+ tester = ProxySeeker::Tester::new(proxies, opts)
27
+ tester.execute
28
+ end
29
+ end
@@ -0,0 +1,71 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: proxy_seeker 1.0.0 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "proxy_seeker"
9
+ s.version = "1.0.0"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Marcin Kot"]
14
+ s.date = "2014-12-05"
15
+ s.description = "Gem for finding and testing http proxy servers"
16
+ s.email = "m.kot@visuality.pl"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".rspec",
24
+ "Gemfile",
25
+ "Gemfile.lock",
26
+ "LICENSE.txt",
27
+ "README.rdoc",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "lib/proxy_seeker.rb",
31
+ "lib/proxy_seeker/fetcher.rb",
32
+ "lib/proxy_seeker/proxy.rb",
33
+ "lib/proxy_seeker/scrapers/fake_scraper.rb",
34
+ "lib/proxy_seeker/scrapers/proxy_listen_scraper.rb",
35
+ "lib/proxy_seeker/tester.rb",
36
+ "proxy_seeker.gemspec",
37
+ "spec/proxy_seeker/fetcher_spec.rb",
38
+ "spec/proxy_seeker/tester_spec.rb",
39
+ "spec/proxy_seeker_spec.rb",
40
+ "spec/spec_helper.rb"
41
+ ]
42
+ s.homepage = "http://github.com/visualitypl/proxy_seeker"
43
+ s.licenses = ["MIT"]
44
+ s.rubygems_version = "2.2.2"
45
+ s.summary = "Gem for finding and testing http proxy servers"
46
+
47
+ if s.respond_to? :specification_version then
48
+ s.specification_version = 4
49
+
50
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
51
+ s.add_runtime_dependency(%q<httparty>, [">= 0"])
52
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
53
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
54
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
55
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
56
+ else
57
+ s.add_dependency(%q<httparty>, [">= 0"])
58
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
59
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
60
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
61
+ s.add_dependency(%q<simplecov>, [">= 0"])
62
+ end
63
+ else
64
+ s.add_dependency(%q<httparty>, [">= 0"])
65
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
66
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
67
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
68
+ s.add_dependency(%q<simplecov>, [">= 0"])
69
+ end
70
+ end
71
+
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe ProxySeeker::Fetcher do
4
+ let(:fetcher) { ProxySeeker::Fetcher.new }
5
+ let(:valid_proxy) { ::ProxySeeker::Proxy.new('190.235.199.189', '3128')}
6
+ let(:invalid_proxy1) { ::ProxySeeker::Proxy.new('AAAA', '3128') }
7
+ let(:invalid_proxy2) { ::ProxySeeker::Proxy.new('190.235.199.189', 'BBB') }
8
+
9
+ context "returned results" do
10
+ before do
11
+ allow_any_instance_of(::ProxySeeker::Fetcher).to receive(:scrapers).and_return([::ProxySeeker::Scrapers::ProxyListenScraper])
12
+ allow_any_instance_of(::ProxySeeker::Scrapers::ProxyListenScraper).to receive(:fetch).and_return([valid_proxy, invalid_proxy1, invalid_proxy2])
13
+ end
14
+
15
+ it "return return results as enumerable proxy classes collection" do
16
+ results = fetcher.execute
17
+
18
+ expect(results).not_to be_empty
19
+ expect(results.last).to be_a ::ProxySeeker::Proxy
20
+ end
21
+
22
+ it "clear not valid proxy instances" do
23
+ results = fetcher.execute
24
+
25
+ expect(results.size).to eq 1
26
+ expect(results).not_to eq include(invalid_proxy1, invalid_proxy2)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe ProxySeeker::Tester do
4
+ end
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "ProxySeeker" do
4
+ it "general tests"
5
+ end
@@ -0,0 +1,35 @@
1
+ require 'simplecov'
2
+
3
+ module SimpleCov::Configuration
4
+ def clean_filters
5
+ @filters = []
6
+ end
7
+ end
8
+
9
+ SimpleCov.configure do
10
+ clean_filters
11
+ load_adapter 'test_frameworks'
12
+ end
13
+
14
+ ENV["COVERAGE"] && SimpleCov.start do
15
+ add_filter "/.rvm/"
16
+ end
17
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
18
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
19
+
20
+ require 'rspec'
21
+ require 'proxy_seeker'
22
+
23
+ # Requires supporting files with custom matchers and macros, etc,
24
+ # in ./support/ and its subdirectories.
25
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
26
+
27
+ RSpec.configure do |c|
28
+ c.expect_with :rspec do |expectations|
29
+ expectations.syntax = :expect
30
+ end
31
+ c.mock_with :rspec do |mocks|
32
+ mocks.syntax = :expect
33
+ end
34
+ c.color = true
35
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: proxy_seeker
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Marcin Kot
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rdoc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: jeweler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.0.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.0.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Gem for finding and testing http proxy servers
84
+ email: m.kot@visuality.pl
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files:
88
+ - LICENSE.txt
89
+ - README.rdoc
90
+ files:
91
+ - ".document"
92
+ - ".rspec"
93
+ - Gemfile
94
+ - Gemfile.lock
95
+ - LICENSE.txt
96
+ - README.rdoc
97
+ - Rakefile
98
+ - VERSION
99
+ - lib/proxy_seeker.rb
100
+ - lib/proxy_seeker/fetcher.rb
101
+ - lib/proxy_seeker/proxy.rb
102
+ - lib/proxy_seeker/scrapers/fake_scraper.rb
103
+ - lib/proxy_seeker/scrapers/proxy_listen_scraper.rb
104
+ - lib/proxy_seeker/tester.rb
105
+ - proxy_seeker.gemspec
106
+ - spec/proxy_seeker/fetcher_spec.rb
107
+ - spec/proxy_seeker/tester_spec.rb
108
+ - spec/proxy_seeker_spec.rb
109
+ - spec/spec_helper.rb
110
+ homepage: http://github.com/visualitypl/proxy_seeker
111
+ licenses:
112
+ - MIT
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 2.2.2
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: Gem for finding and testing http proxy servers
134
+ test_files: []