fetcher 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/{History.markdown → HISTORY.md} +0 -0
- data/Manifest.txt +4 -2
- data/{README.markdown → README.md} +0 -0
- data/Rakefile +4 -4
- data/lib/fetcher.rb +7 -1
- data/lib/fetcher/version.rb +1 -1
- data/test/helper.rb +15 -0
- data/test/test_get.rb +41 -0
- metadata +16 -12
data/.gemtest
ADDED
File without changes
|
File without changes
|
data/Manifest.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
HISTORY.md
|
2
2
|
Manifest.txt
|
3
|
-
README.
|
3
|
+
README.md
|
4
4
|
Rakefile
|
5
5
|
bin/fetch
|
6
6
|
lib/fetcher.rb
|
@@ -8,3 +8,5 @@ lib/fetcher/cli/opts.rb
|
|
8
8
|
lib/fetcher/cli/runner.rb
|
9
9
|
lib/fetcher/version.rb
|
10
10
|
lib/fetcher/worker.rb
|
11
|
+
test/helper.rb
|
12
|
+
test/test_get.rb
|
File without changes
|
data/Rakefile
CHANGED
@@ -2,9 +2,9 @@ require 'hoe'
|
|
2
2
|
require './lib/fetcher/version.rb'
|
3
3
|
|
4
4
|
Hoe.spec 'fetcher' do
|
5
|
-
|
5
|
+
|
6
6
|
self.version = Fetcher::VERSION
|
7
|
-
|
7
|
+
|
8
8
|
self.summary = 'fetcher - Fetch Text Documents or Binary Blobs via HTTP, HTTPS'
|
9
9
|
self.description = summary
|
10
10
|
|
@@ -14,8 +14,8 @@ Hoe.spec 'fetcher' do
|
|
14
14
|
self.email = 'webslideshow@googlegroups.com'
|
15
15
|
|
16
16
|
# switch extension to .markdown for gihub formatting
|
17
|
-
self.readme_file = 'README.
|
18
|
-
self.history_file = '
|
17
|
+
self.readme_file = 'README.md'
|
18
|
+
self.history_file = 'HISTORY.md'
|
19
19
|
|
20
20
|
self.extra_deps = [
|
21
21
|
['logutils', '>= 0.6']
|
data/lib/fetcher.rb
CHANGED
@@ -33,9 +33,14 @@ module Fetcher
|
|
33
33
|
|
34
34
|
# version string for generator meta tag (includes ruby version)
|
35
35
|
def self.banner
|
36
|
-
"fetcher
|
36
|
+
"fetcher/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
37
37
|
end
|
38
38
|
|
39
|
+
def self.root
|
40
|
+
"#{File.expand_path( File.dirname(File.dirname(__FILE__)) )}"
|
41
|
+
end
|
42
|
+
|
43
|
+
|
39
44
|
def self.main
|
40
45
|
|
41
46
|
## NB: only load (require) cli code if called
|
@@ -53,6 +58,7 @@ module Fetcher
|
|
53
58
|
Runner.new.run(args)
|
54
59
|
end
|
55
60
|
|
61
|
+
#############################
|
56
62
|
# convenience shortcuts
|
57
63
|
|
58
64
|
def self.copy( src, dest )
|
data/lib/fetcher/version.rb
CHANGED
data/test/helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
## $:.unshift(File.dirname(__FILE__))
|
3
|
+
|
4
|
+
## minitest setup
|
5
|
+
|
6
|
+
# require 'minitest/unit'
|
7
|
+
require 'minitest/autorun'
|
8
|
+
|
9
|
+
# include MiniTest::Unit # lets us use TestCase instead of MiniTest::Unit::TestCase
|
10
|
+
|
11
|
+
|
12
|
+
## our own code
|
13
|
+
|
14
|
+
require 'fetcher'
|
15
|
+
|
data/test/test_get.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'helper'
|
4
|
+
|
5
|
+
class TestGet < MiniTest::Unit::TestCase
|
6
|
+
|
7
|
+
def test_get
|
8
|
+
url = 'https://raw.github.com/rubylibs/fetcher/master/README.md'
|
9
|
+
worker = Fetcher::Worker.new
|
10
|
+
res = worker.get( url )
|
11
|
+
pp res
|
12
|
+
|
13
|
+
assert_equal '200', res.code # note: returned code is a string e.g. '200' not 200
|
14
|
+
assert_equal 'OK', res.message
|
15
|
+
assert_equal 'text/plain', res.content_type
|
16
|
+
assert_equal File.read( './README.md' ), res.body # local README.md should match remote README.md
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_get_with_socket_error
|
20
|
+
url = 'http://pragdave.blogs.pragprog.com/pragdave/atom.xml'
|
21
|
+
worker = Fetcher::Worker.new
|
22
|
+
|
23
|
+
# note: will raise SocketError -- getaddrinfo: Name or service not known
|
24
|
+
assert_raises( SocketError ) do
|
25
|
+
res = worker.get( url )
|
26
|
+
pp res
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_get_not_found
|
31
|
+
url = 'http://blog.engineyard.com/category/ruby/feed'
|
32
|
+
worker = Fetcher::Worker.new
|
33
|
+
res = worker.get( url )
|
34
|
+
pp res
|
35
|
+
|
36
|
+
# note: feed link/url no longer exists, thus, 404 -- not found
|
37
|
+
assert_equal '404', res.code
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
end # class TestCopy
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fetcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-02-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: logutils
|
16
|
-
requirement: &
|
16
|
+
requirement: &81882710 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0.6'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *81882710
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rdoc
|
27
|
-
requirement: &
|
27
|
+
requirement: &81882450 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '3.10'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *81882450
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: hoe
|
38
|
-
requirement: &
|
38
|
+
requirement: &81882190 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '3.3'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *81882190
|
47
47
|
description: fetcher - Fetch Text Documents or Binary Blobs via HTTP, HTTPS
|
48
48
|
email: webslideshow@googlegroups.com
|
49
49
|
executables:
|
@@ -52,9 +52,9 @@ extensions: []
|
|
52
52
|
extra_rdoc_files:
|
53
53
|
- Manifest.txt
|
54
54
|
files:
|
55
|
-
-
|
55
|
+
- HISTORY.md
|
56
56
|
- Manifest.txt
|
57
|
-
- README.
|
57
|
+
- README.md
|
58
58
|
- Rakefile
|
59
59
|
- bin/fetch
|
60
60
|
- lib/fetcher.rb
|
@@ -62,13 +62,16 @@ files:
|
|
62
62
|
- lib/fetcher/cli/runner.rb
|
63
63
|
- lib/fetcher/version.rb
|
64
64
|
- lib/fetcher/worker.rb
|
65
|
+
- test/helper.rb
|
66
|
+
- test/test_get.rb
|
67
|
+
- .gemtest
|
65
68
|
homepage: https://github.com/rubylibs/fetcher
|
66
69
|
licenses:
|
67
70
|
- Public Domain
|
68
71
|
post_install_message:
|
69
72
|
rdoc_options:
|
70
73
|
- --main
|
71
|
-
- README.
|
74
|
+
- README.md
|
72
75
|
require_paths:
|
73
76
|
- lib
|
74
77
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -89,4 +92,5 @@ rubygems_version: 1.8.17
|
|
89
92
|
signing_key:
|
90
93
|
specification_version: 3
|
91
94
|
summary: fetcher - Fetch Text Documents or Binary Blobs via HTTP, HTTPS
|
92
|
-
test_files:
|
95
|
+
test_files:
|
96
|
+
- test/test_get.rb
|