Skip to content

Commit

Permalink
Release 0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
nbulaj committed Jan 28, 2020
1 parent 061744b commit d55d636
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 16 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ Reverse Chronological Order:

* Add your description here

## `0.12.0` (2020-01-28)

* Fix XRoxy provider
* Fix multi-threading issues with config and adapter

## `0.11.0` (2019-10-24)

* Big gem refactoring

## `0.10.2` (2019-03-15)

* Remove ProxyDocker provider (no longer workable)
Expand Down
10 changes: 8 additions & 2 deletions lib/proxy_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ module Providers
require File.dirname(__FILE__) + "/proxy_fetcher/providers/xroxy"
end

@__config_access_lock__ = Mutex.new
@__config_definition_lock__ = Mutex.new

# Main ProxyFetcher module.
class << self

##
# Returns ProxyFetcher configuration.
#
Expand All @@ -58,7 +62,9 @@ class << self
# @providers=[:free_proxy_list, ...], @adapter=ProxyFetcher::Document::NokogiriAdapter>
#
def config
@config ||= ProxyFetcher::Configuration.new
@__config_definition_lock__.synchronize do
@config ||= ProxyFetcher::Configuration.new
end
end

##
Expand All @@ -70,7 +76,7 @@ def config
# Configuration object.
#
def configure
yield config
@__config_access_lock__.synchronize { yield config }
end

# Returns ProxyFetcher logger instance.
Expand Down
14 changes: 9 additions & 5 deletions lib/proxy_fetcher/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Configuration
attr_accessor :logger

# @!attribute [r] adapter
# @return [Object] HTML parser adapter
# @return [#to_s] HTML parser adapter
attr_reader :adapter

# @!attribute [r] http_client
Expand Down Expand Up @@ -68,6 +68,8 @@ class Configuration
#
DEFAULT_ADAPTER = :nokogiri

@__adapter_lock__ = Mutex.new

class << self
# Registry for handling proxy providers.
#
Expand Down Expand Up @@ -131,11 +133,13 @@ def adapter=(value)
end

def adapter_class
return @adapter_class if defined?(@adapter_class)
self.class.instance_variable_get(:@__adapter_lock__).synchronize do
return @adapter_class if defined?(@adapter_class)

@adapter_class = ProxyFetcher::Document::Adapters.lookup(adapter)
@adapter_class.setup!
@adapter_class
@adapter_class = ProxyFetcher::Document::Adapters.lookup(adapter)
@adapter_class.setup!
@adapter_class
end
end

# Setups collection of providers that will be used to fetch proxies.
Expand Down
16 changes: 8 additions & 8 deletions lib/proxy_fetcher/providers/xroxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ module Providers
class XRoxy < Base
# Provider URL to fetch proxy list
def provider_url
"https://www.xroxy.com/free-proxy-lists/"
"https://madison.xroxy.com/proxylist.html"
end

def xpath
"//div/table/tbody/tr"
"//tr[@class='row1' or @class='row0']"
end

# Converts HTML node (entry of N tags) to <code>ProxyFetcher::Proxy</code>
Expand All @@ -24,12 +24,12 @@ def xpath
#
def to_proxy(html_node)
ProxyFetcher::Proxy.new.tap do |proxy|
proxy.addr = html_node.content_at("td[1]")
proxy.port = Integer(html_node.content_at("td[2]").gsub(/^0+/, ""))
proxy.anonymity = html_node.content_at("td[3]")
proxy.country = html_node.content_at("td[5]")
proxy.response_time = Integer(html_node.content_at("td[6]"))
proxy.type = html_node.content_at("td[3]")
proxy.addr = html_node.content_at("td[2]")
proxy.port = Integer(html_node.content_at("td[3]").gsub(/^0+/, ""))
proxy.anonymity = html_node.content_at("td[4]")
proxy.country = html_node.content_at("td[6]")
proxy.response_time = Integer(html_node.content_at("td[7]"))
proxy.type = html_node.content_at("td[4]")
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/proxy_fetcher/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module VERSION
# Major version number
MAJOR = 0
# Minor version number
MINOR = 11
MINOR = 12
# Smallest version number
TINY = 0

Expand Down

0 comments on commit d55d636

Please sign in to comment.