webget 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +0 -1
- data/README.md +4 -3
- data/Rakefile +5 -3
- data/lib/webget.rb +1 -15
- data/lib/webget/version.rb +2 -2
- metadata +19 -6
- data/lib/webget/webclient.rb +0 -85
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbf6e29e3e80b0a0fe7b80ad8a4870c00601006c
|
4
|
+
data.tar.gz: c03efecb7b2362efef7392f26293c921f8422eca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3d026c4b3b6932eca4b22377ce1da9b08bd7836713c4e69c6a5fd28ba8de52449b28bca2be877e759eb73a30fb17b62966b779bed25a26fd072913abd284120
|
7
|
+
data.tar.gz: 5f7822300304672b181a3001fb5d5e4cb3ad2adc55853179895ba100e03b21a8ede90a800ad2cced34e3b13603162d22876acaf34abfabe61c665f1d821f0455
|
data/Manifest.txt
CHANGED
data/README.md
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# webget
|
2
2
|
|
3
|
-
webget gem -
|
3
|
+
webget gem - a web (go get) crawler incl. web cache
|
4
4
|
|
5
|
-
* home :: [github.com/rubycoco/
|
6
|
-
* bugs :: [github.com/rubycoco/
|
5
|
+
* home :: [github.com/rubycoco/webclient](https://github.com/rubycoco/webclient)
|
6
|
+
* bugs :: [github.com/rubycoco/webclient/issues](https://github.com/rubycoco/webclient/issues)
|
7
7
|
* gem :: [rubygems.org/gems/webget](https://rubygems.org/gems/webget)
|
8
8
|
* rdoc :: [rubydoc.info/gems/webget](http://rubydoc.info/gems/webget)
|
9
|
+
* forum :: [groups.google.com/group/wwwmake](https://groups.google.com/group/wwwmake)
|
9
10
|
|
10
11
|
|
11
12
|
## Usage
|
data/Rakefile
CHANGED
@@ -5,10 +5,10 @@ Hoe.spec 'webget' do
|
|
5
5
|
|
6
6
|
self.version = Webget::VERSION
|
7
7
|
|
8
|
-
self.summary = 'webget gem -
|
8
|
+
self.summary = 'webget gem - a web (go get) crawler incl. web cache'
|
9
9
|
self.description = summary
|
10
10
|
|
11
|
-
self.urls = { home: 'https://github.com/rubycoco/
|
11
|
+
self.urls = { home: 'https://github.com/rubycoco/webclient' }
|
12
12
|
|
13
13
|
self.author = 'Gerald Bauer'
|
14
14
|
self.email = 'ruby-talk@ruby-lang.org'
|
@@ -17,7 +17,9 @@ Hoe.spec 'webget' do
|
|
17
17
|
self.readme_file = 'README.md'
|
18
18
|
self.history_file = 'CHANGELOG.md'
|
19
19
|
|
20
|
-
self.extra_deps = [
|
20
|
+
self.extra_deps = [
|
21
|
+
['webclient', '>= 0.1.0']
|
22
|
+
]
|
21
23
|
|
22
24
|
self.licenses = ['Public Domain']
|
23
25
|
|
data/lib/webget.rb
CHANGED
@@ -1,20 +1,7 @@
|
|
1
|
-
require '
|
2
|
-
require 'time'
|
3
|
-
require 'date'
|
4
|
-
require 'fileutils'
|
5
|
-
|
6
|
-
require 'uri'
|
7
|
-
require 'net/http'
|
8
|
-
require 'net/https'
|
9
|
-
|
10
|
-
require 'json'
|
11
|
-
require 'yaml'
|
12
|
-
|
13
|
-
|
1
|
+
require 'webclient'
|
14
2
|
|
15
3
|
## our own code
|
16
4
|
require 'webget/version' # let version go first
|
17
|
-
require 'webget/webclient'
|
18
5
|
require 'webget/webcache'
|
19
6
|
require 'webget/webget'
|
20
7
|
|
@@ -24,7 +11,6 @@ require 'webget/webget'
|
|
24
11
|
############
|
25
12
|
## add convenience alias for camel case / alternate different spelling
|
26
13
|
WebCache = Webcache
|
27
|
-
WebClient = Webclient
|
28
14
|
WebGet = Webget
|
29
15
|
|
30
16
|
## use Webgo as (alias) name (keep reserver for now) - why? why not?
|
data/lib/webget/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webget
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: webclient
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.1.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.1.0
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rdoc
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,7 +58,7 @@ dependencies:
|
|
44
58
|
- - "~>"
|
45
59
|
- !ruby/object:Gem::Version
|
46
60
|
version: '3.22'
|
47
|
-
description: webget gem -
|
61
|
+
description: webget gem - a web (go get) crawler incl. web cache
|
48
62
|
email: ruby-talk@ruby-lang.org
|
49
63
|
executables: []
|
50
64
|
extensions: []
|
@@ -60,9 +74,8 @@ files:
|
|
60
74
|
- lib/webget.rb
|
61
75
|
- lib/webget/version.rb
|
62
76
|
- lib/webget/webcache.rb
|
63
|
-
- lib/webget/webclient.rb
|
64
77
|
- lib/webget/webget.rb
|
65
|
-
homepage: https://github.com/rubycoco/
|
78
|
+
homepage: https://github.com/rubycoco/webclient
|
66
79
|
licenses:
|
67
80
|
- Public Domain
|
68
81
|
metadata: {}
|
@@ -87,5 +100,5 @@ rubyforge_project:
|
|
87
100
|
rubygems_version: 2.5.2
|
88
101
|
signing_key:
|
89
102
|
specification_version: 4
|
90
|
-
summary: webget gem -
|
103
|
+
summary: webget gem - a web (go get) crawler incl. web cache
|
91
104
|
test_files: []
|
data/lib/webget/webclient.rb
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
|
2
|
-
class Webclient
|
3
|
-
|
4
|
-
class Response # nested class - wrap Net::HTTP::Response
|
5
|
-
def initialize( response )
|
6
|
-
@response = response
|
7
|
-
end
|
8
|
-
def raw() @response; end
|
9
|
-
|
10
|
-
|
11
|
-
def text
|
12
|
-
# note: Net::HTTP will NOT set encoding UTF-8 etc.
|
13
|
-
# will be set to ASCII-8BIT == BINARY == Encoding Unknown; Raw Bytes Here
|
14
|
-
# thus, set/force encoding to utf-8
|
15
|
-
text = @response.body.to_s
|
16
|
-
text = text.force_encoding( Encoding::UTF_8 )
|
17
|
-
text
|
18
|
-
end
|
19
|
-
|
20
|
-
## convenience helper; returns parsed json data
|
21
|
-
def json() JSON.parse( text ); end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
class Headers # nested (nested) class
|
26
|
-
def initialize( response )
|
27
|
-
@response = response
|
28
|
-
end
|
29
|
-
def each( &blk )
|
30
|
-
@response.each_header do |key, value| # Iterate all response headers
|
31
|
-
blk.call( key, value )
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
def headers() @headers ||= Headers.new( @response ); end
|
36
|
-
|
37
|
-
class Status # nested (nested) class
|
38
|
-
def initialize( response )
|
39
|
-
@response = response
|
40
|
-
end
|
41
|
-
def code() @response.code.to_i; end
|
42
|
-
def ok?() code == 200; end
|
43
|
-
def nok?() code != 200; end
|
44
|
-
def message() @response.message; end
|
45
|
-
end
|
46
|
-
def status() @status ||= Status.new( @response ); end
|
47
|
-
end # (nested) class Response
|
48
|
-
|
49
|
-
|
50
|
-
def self.get( url, headers: {} )
|
51
|
-
|
52
|
-
uri = URI.parse( url )
|
53
|
-
http = Net::HTTP.new( uri.host, uri.port )
|
54
|
-
|
55
|
-
if uri.instance_of? URI::HTTPS
|
56
|
-
http.use_ssl = true
|
57
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
58
|
-
end
|
59
|
-
|
60
|
-
request = Net::HTTP::Get.new( uri.request_uri )
|
61
|
-
|
62
|
-
### add (custom) headers if any
|
63
|
-
## check/todo: is there are more idiomatic way for Net::HTTP ???
|
64
|
-
## use
|
65
|
-
## request = Net::HTTP::Get.new( uri.request_uri, headers )
|
66
|
-
## why? why not?
|
67
|
-
## instead of e.g.
|
68
|
-
## request['X-Auth-Token'] = 'xxxxxxx'
|
69
|
-
## request['User-Agent'] = 'ruby'
|
70
|
-
## request['Accept'] = '*/*'
|
71
|
-
if headers && headers.size > 0
|
72
|
-
headers.each do |key,value|
|
73
|
-
request[ key ] = value
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
|
78
|
-
response = http.request( request )
|
79
|
-
|
80
|
-
## note: return "unified" wrapped response
|
81
|
-
Response.new( response )
|
82
|
-
end # method self.get
|
83
|
-
|
84
|
-
end # class Webclient
|
85
|
-
|