tiny_http_parser 0.0.2 → 0.0.3

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
  SHA1:
3
- metadata.gz: 94ad9fb242a775a1deb3b2c0b0a959a40ab87e56
4
- data.tar.gz: 14aee4f270796bfddfc418a6050f0643e1758922
3
+ metadata.gz: 641084bffe174f3a2c5849ee9cdc916e875d4598
4
+ data.tar.gz: c1ee6d0fea9f1ceb1693b75e1ab701020ba37936
5
5
  SHA512:
6
- metadata.gz: 64d768d5f3bde08ec3d41906266709d07246f10044c49d5b43d4158bf0c8c7dd1ea6d4f5d8303633a4d6db41eca0b41e6848253763ea03e9007f0a23d32b5554
7
- data.tar.gz: ce889124e1005b0fa1aa704ef216ff53e9cc2491a1ba9a9ae6f9bba359d7f1fa8afa38ca76cadb292ca25fa4166bdd80b5c57e6619cadd9f5939d744b3da69fb
6
+ metadata.gz: c62f28dbb03e571a542b73e700ecf2c03499f1c618cf441435f0715b0367a24c4de933b6ad4945c1f7422fedb6fb7040b69fafb686c63e9ef92f4dbc2466a514
7
+ data.tar.gz: feb7bd9028ddbd8caff72b5058009080e9a9e0d07af3368aadd3d7824c535cdc26c34fb11740f7f5d766a3ad5f62c16b2d46d864990fa976bab01e5a15f9497a
data/README.md CHANGED
@@ -18,6 +18,7 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
+ ```ruby
21
22
  require 'tiny_parser'
22
23
 
23
24
  fetcher = FetcherFromEnum.new ['http://ya.ru','http://google.com']
@@ -30,7 +31,7 @@ fetcher.on_exception_raised do |e|
30
31
  end
31
32
 
32
33
  fetcher.perform
33
-
34
+ ```
34
35
  ## Contributing
35
36
 
36
37
  1. Fork it ( https://github.com/[my-github-username]/tiny_http_parser/fork )
@@ -1,4 +1,5 @@
1
- require 'httpclient'
1
+ # require 'httpclient'
2
+ require 'faraday'
2
3
  class FetcherBase
3
4
 
4
5
  def initialize
@@ -21,8 +22,8 @@ class FetcherBase
21
22
  raise 'abstract method called exception'
22
23
  end
23
24
 
24
- def on_content_get &block
25
- @content_block = block if block_given?
25
+ def on_action &block
26
+ @on_action = block if block_given?
26
27
  end
27
28
 
28
29
  def configure &block
@@ -35,21 +36,16 @@ class FetcherBase
35
36
 
36
37
  def perform
37
38
  before_start if defined? before_start
38
- raise 'no on_content_get block given' unless @content_block
39
- http_client = HTTPClient.new
40
- http_client = HTTPClient.new(get_proxy) if proxy_set?
39
+ raise 'no on_action block given' unless @on_action
40
+ http_client = Faraday.new
41
41
  while true do
42
42
  url = parse_url
43
43
  break unless url
44
- content_block.call(http_client) if @configure_block
45
44
  begin
46
- content = http_client.get_content url
45
+ @on_action.call url, http_client
47
46
  rescue Exception => e
48
47
  @exception_raised_block.call(e,url,http_client) if @exception_raised_block
49
- else
50
- @content_block.call url, content, http_client
51
48
  end
52
- http_client = HTTPClient.new(get_proxy) if proxy_set?
53
49
  end
54
50
  end
55
51
  end
@@ -1,3 +1,3 @@
1
1
  module TinyHttpParser
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny_http_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - gingray