spidy 0.2.6 → 0.2.7

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: c6c2e2e85979c5d5492564fec243c23c44ef1d762230cd1a59400fcc46bf42a3
4
- data.tar.gz: d551534240f528923ccb862e17ae521aaccdc5596e45c09e1cee0e90f0c990c5
3
+ metadata.gz: 177e6b5e3b4f864251d7071d23b2b42b219d8193673a5b57ee9b376e393092a9
4
+ data.tar.gz: 92b39a277d752eb5b1944f822702eae803356f7f5e3211b1f91e2d9ad635090e
5
5
  SHA512:
6
- metadata.gz: 3348c6243500f90f7157435bf36f1675744f46c0025dc4bab81fad4ccfb65c4e2ac0d029a837fb589c768b4868fbaf8ab7c258ad67aa4e1a9f33f0949701b2da
7
- data.tar.gz: ef8d804eae97e2300747abb1b9e97f84e100b6b151e01b587fff95c98327ce21e0024456c6d8208ecd81ceaead8a0353d251f15a4ef4deff7e3b077e13c872cb
6
+ metadata.gz: b4078e3d1ad9813b0273f267d99bf7a9bf4473bb86b6cfa4fa283e6c5b060fa248e0b6fb517bede448f94e0dcebbb90ee71ef4eeb4bd5a45b1405c50005985fe
7
+ data.tar.gz: 00aa2cd512cf3a083082227234f59148d86e8ee0e4f602e07d1c67cbf9f3e8160b9144ebd29f3a67efded607c1705c2ce3008df235325afc7f3a715a6dd7527d
@@ -10,6 +10,15 @@ module Spidy::Connector
10
10
  autoload :Json
11
11
  autoload :Xml
12
12
 
13
+ module StaticAccessor
14
+ extend ActiveSupport::Concern
15
+ class_methods do
16
+ def call(url, wait_time: nil, user_agent: Spidy::Connector::USER_AGENT, &block)
17
+ new(wait_time: wait_time, user_agent: user_agent).call(url, &block)
18
+ end
19
+ end
20
+ end
21
+
13
22
  #
14
23
  # retry class
15
24
  #
@@ -4,6 +4,8 @@
4
4
  # Mechanize wrapper
5
5
  #
6
6
  class Spidy::Connector::Html
7
+ include Spidy::Connector::StaticAccessor
8
+
7
9
  def initialize(wait_time:, user_agent:, logger: nil)
8
10
  @wait_time = wait_time
9
11
  @logger = logger || proc { |values| STDERR.puts(values.to_json) }
@@ -4,6 +4,8 @@
4
4
  # OpenURI to JSON.parse
5
5
  #
6
6
  class Spidy::Connector::Json
7
+ include Spidy::Connector::StaticAccessor
8
+
7
9
  def initialize(wait_time: nil, user_agent: nil)
8
10
  @user_agent = user_agent
9
11
  end
@@ -4,6 +4,8 @@
4
4
  # xml
5
5
  #
6
6
  class Spidy::Connector::Xml
7
+ include Spidy::Connector::StaticAccessor
8
+
7
9
  def call(url)
8
10
  fail 'URL is undefined' if url.blank?
9
11
 
@@ -50,7 +50,7 @@ module Spidy::Definition
50
50
 
51
51
  def define(name = :default, connector: nil, binder: nil, as: nil, &define_block)
52
52
  @namespace ||= {}
53
- connector = Spidy::Connector.get(connector || as, wait_time: @wait_time, user_agent: @user_agent)
53
+ connector = Spidy::Connector.get(connector || as, wait_time: @wait_time, user_agent: @user_agent, socks_proxy: @socks_proxy)
54
54
  binder = Spidy::Binder.get(self, binder || as)
55
55
  @namespace[:"#{name}_scraper"] = define_proc(name, connector, binder, define_block)
56
56
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spidy
4
- VERSION = '0.2.6'
4
+ VERSION = '0.2.7'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spidy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - aileron