fetch 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +21 -8
- data/Rakefile +1 -1
- data/fetch.gemspec +17 -14
- data/lib/fetch.rb +49 -1
- data/lib/fetch/async.rb +21 -0
- data/lib/fetch/backend.rb +2 -0
- data/lib/fetch/backend/base.rb +15 -0
- data/lib/fetch/backend/typhoeus.rb +43 -0
- data/lib/fetch/base.rb +64 -0
- data/lib/fetch/callbacks.rb +62 -0
- data/lib/fetch/configuration.rb +30 -0
- data/lib/fetch/module.rb +17 -0
- data/lib/fetch/request.rb +156 -0
- data/lib/fetch/simple.rb +21 -0
- data/lib/fetch/version.rb +1 -1
- data/test/callbacks_test.rb +97 -0
- data/test/fetch_test.rb +689 -2
- data/test/simple_test.rb +17 -0
- data/test/test_helper.rb +14 -2
- metadata +64 -8
data/test/simple_test.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class SimpleTest < Minitest::Test
|
4
|
+
def test_simple_fetch
|
5
|
+
stub_request(:get, "http://test.com/one").to_return(body: "got one")
|
6
|
+
actions = []
|
7
|
+
mod = Class.new(Fetch::Module) do
|
8
|
+
include Fetch::Simple
|
9
|
+
url { "http://test.com/one" }
|
10
|
+
process do |body|
|
11
|
+
actions << "process: #{body}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
MockFetcher(mod).new.fetch
|
15
|
+
assert_equal ["process: got one"], actions
|
16
|
+
end
|
17
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -1,2 +1,14 @@
|
|
1
|
-
require "
|
2
|
-
require "
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "webmock/minitest"
|
3
|
+
|
4
|
+
require "fetch"
|
5
|
+
|
6
|
+
# Load support files
|
7
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
8
|
+
|
9
|
+
# Mocked fetcher
|
10
|
+
def MockFetcher(mods)
|
11
|
+
Class.new(Fetch::Base) do
|
12
|
+
modules *mods
|
13
|
+
end
|
14
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fetch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lasse Bunk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: typhoeus
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.6.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.6.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
18
39
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.4'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.20'
|
20
62
|
type: :development
|
21
63
|
prerelease: false
|
22
64
|
version_requirements: !ruby/object:Gem::Requirement
|
23
65
|
requirements:
|
24
|
-
- - "
|
66
|
+
- - ">="
|
25
67
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
68
|
+
version: '1.20'
|
27
69
|
- !ruby/object:Gem::Dependency
|
28
70
|
name: rake
|
29
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,8 +95,20 @@ files:
|
|
53
95
|
- Rakefile
|
54
96
|
- fetch.gemspec
|
55
97
|
- lib/fetch.rb
|
98
|
+
- lib/fetch/async.rb
|
99
|
+
- lib/fetch/backend.rb
|
100
|
+
- lib/fetch/backend/base.rb
|
101
|
+
- lib/fetch/backend/typhoeus.rb
|
102
|
+
- lib/fetch/base.rb
|
103
|
+
- lib/fetch/callbacks.rb
|
104
|
+
- lib/fetch/configuration.rb
|
105
|
+
- lib/fetch/module.rb
|
106
|
+
- lib/fetch/request.rb
|
107
|
+
- lib/fetch/simple.rb
|
56
108
|
- lib/fetch/version.rb
|
109
|
+
- test/callbacks_test.rb
|
57
110
|
- test/fetch_test.rb
|
111
|
+
- test/simple_test.rb
|
58
112
|
- test/test_helper.rb
|
59
113
|
homepage: https://github.com/lassebunk/fetch
|
60
114
|
licenses:
|
@@ -76,10 +130,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
130
|
version: '0'
|
77
131
|
requirements: []
|
78
132
|
rubyforge_project:
|
79
|
-
rubygems_version: 2.2.
|
133
|
+
rubygems_version: 2.2.2
|
80
134
|
signing_key:
|
81
135
|
specification_version: 4
|
82
136
|
summary: Coming
|
83
137
|
test_files:
|
138
|
+
- test/callbacks_test.rb
|
84
139
|
- test/fetch_test.rb
|
140
|
+
- test/simple_test.rb
|
85
141
|
- test/test_helper.rb
|