rest-tor 0.1.2 → 0.1.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: 7633b710960f440ecc94cf9d03ca0373d39daa10
4
- data.tar.gz: ee7c1d41043e5a7f53c00b9fc2cc51586f6b1537
3
+ metadata.gz: f201b4acba40f747a5e9563f43db9b8e69560d45
4
+ data.tar.gz: cb18946fdf67e37d96b417bc64f1ed824af89658
5
5
  SHA512:
6
- metadata.gz: 59bc545c50834cf402202aea5c91a93fdc72265ea19de9a380174b9df3453ac83cfdafc628931793b623e4b4d8685a4cdaeac2ec3f1d68a493d2cedf284192c4
7
- data.tar.gz: cac174ee711d9c92b0ec296734465ee2a1eac8f41048c20496aa9a420ba00044205e6b215a44d3d057c461231df4a72bfb1e9b0a9852aab0387f77ecf89588d8
6
+ metadata.gz: 7074b36afe2ec36598e2288e349c458dcb3d3c5afebaf0b06d443d8b04f48ae83808f9ea8077a81d48aa0990f48d9f88cabab041d93e888405c0ede3bab45ae4
7
+ data.tar.gz: 23fe7019b7492c38c983e3eca78d4a5e3b756bc56606e29526855b29249948bb65a2b4b14364bbd1fb8ad8d355282a9cb00c5e06c7b4734634fafb11dfd8f719
data/README.md CHANGED
@@ -26,6 +26,7 @@ Or install it yourself as:
26
26
 
27
27
  ## Usage
28
28
 
29
+ ```ruby
29
30
  Tor.request(url: 'http://ip.plusor.cn/')
30
31
  => #<Nokogiri::HTML::Document:0x3fcd64ec6eb0 name="document" children=[#<Nokogiri::XML::DTD:0x3fcd64ec6af0 name="html">, #<Nokogiri::XML::Element:0x3fcd64ec67f8 name="html" children=[#<Nokogiri::XML::Element:0x3fcd64ec6618 name="body" children=[#<Nokogiri::XML::Element:0x3fcd64ec6438 name="p" children=[#<Nokogiri::XML::Text:0x3fcd64ec6258 "185.100.85.101\n">]>]>]>]>
31
32
 
@@ -33,7 +34,7 @@ Or install it yourself as:
33
34
  "64.113.32.29\n"
34
35
 
35
36
  Tor.request(url: 'http://ip.plusor.cn/', mobile: true) # RestClient.get "http://ip.plusor.cn/", "", "Accept"=>"*/*", "Accept-Encoding"=>"gzip, deflate", "Content-Length"=>"0", "Content-Type"=>"application/x-www-form-urlencoded", "User-Agent"=>"ANDROID_KFZ_COM_2.0.9_M6 Note_7.1.2"
36
- Tor.request(url: 'http://ip.plusor.cn/') # RestClient.get "http://ip.plusor.cn/", "", "Accept"=>"*/*", "Accept-Encoding"=>"gzip, deflate", "Content-Length"=>"0", "Content-Type"=>"application/x-www-form-urlencoded", "User-Agent"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36"
37
+ Tor.request(url: 'http://ip.plusor.cn/') # RestClient.get "http://ip.plusor.cn/", "", "Accept"=>"*/*", "Accept-Encoding"=>"gzip, deflate", "Content-Length"=>"0", "Content-Type"=>"application/x-www-form-urlencoded", "User-Agent"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36"
37
38
 
38
39
  Tor.request(method: :post, url: '...', format: :json, mobile: true)
39
40
  => {'hello' => 'world'}
@@ -88,6 +89,7 @@ Or install it yourself as:
88
89
  I, [2017-12-15T20:46:42.588824 #60422] INFO -- : Testing tor 9010
89
90
  I, [2017-12-15T20:47:02.179464 #60422] INFO -- : IP: 173.254.216.66
90
91
 
92
+ ```
91
93
 
92
94
  ## TODO
93
95
 
@@ -3,14 +3,14 @@ module Tor
3
3
  def to_json(body)
4
4
  JSON.parse(body)
5
5
  rescue Exception => e
6
- $Logger.tag("ERROR") { "#{e.class}:#{e.message}" }
6
+ logger.info "#{e.class}:#{e.message}"
7
7
  {}
8
8
  end
9
9
 
10
10
  def number_to_human_size(num, options={})
11
11
  ActiveSupport::NumberHelper::NumberToHumanSizeConverter.convert num, options
12
12
  end
13
-
13
+
14
14
  def encode_html(body)
15
15
  if /<meta .*?content=".*?charset=(\w+)"/ =~ body.encode("UTF-16be", :invalid=>:replace, :replace=>"?").encode('UTF-8')
16
16
  encode = $1
@@ -18,7 +18,7 @@ module Tor
18
18
  begin
19
19
  body = body.dup.force_encoding(encode).encode("utf-8", invalid: :replace, under: :replace)
20
20
  rescue Exception => e
21
- $Logger.tag("ERROR") { "#{e.class}:#{e.message}(Tor.request)" }
21
+ logger.info "#{e.class}:#{e.message}(Tor.request)"
22
22
  end
23
23
  end
24
24
  end
@@ -1,3 +1,3 @@
1
1
  module Tor
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest-tor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - plusor