growviral-warehouse 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/growviral/warehouse.rb +1 -0
- data/lib/warehouse/client.rb +9 -0
- data/lib/warehouse/configuration.rb +1 -1
- data/lib/warehouse/fetches_follow_history.rb +27 -0
- data/lib/warehouse/version.rb +1 -1
- data/test/checks_follow_history_test.rb +4 -4
- data/test/fetches_follow_history_test.rb +19 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b70c3bfe6d1699d4188e4d292b7d9f1badc8aaed
|
4
|
+
data.tar.gz: ef3012af9999bc63f321b1344e6415c8fbfac95e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e455521d01e239cb096bad590b60dd0350800b2e830be73190097e057534c0e83a23935b9fbe311c23fa9e9a58f2f1f3b85725c9b5c17c90c60149c3d9247fd5
|
7
|
+
data.tar.gz: 51efa62d5f04ba555c2f3a587dad18b24b183ec3e40ea9270d755d1fd6a9d5b020ce151f1ea4695e8e36039d5a019063bc333af7d2a7b6f088bcf89c938ed5ec
|
data/lib/growviral/warehouse.rb
CHANGED
data/lib/warehouse/client.rb
CHANGED
@@ -11,7 +11,16 @@ module GrowViral
|
|
11
11
|
RegistersFollows.register(uid, following_uid, config: config)
|
12
12
|
end
|
13
13
|
|
14
|
+
def follow_history(uid)
|
15
|
+
FetchesFollowHistory.fetch(uid, config: config)
|
16
|
+
end
|
17
|
+
|
14
18
|
def has_follow_history?(uid, following_uid)
|
19
|
+
p "has_folow_history? is deprecated. Use has_existing_relationship?"
|
20
|
+
ChecksFollowHistory.exists?(uid, following_uid, config: config)
|
21
|
+
end
|
22
|
+
|
23
|
+
def has_existing_relationship?(uid, following_uid)
|
15
24
|
ChecksFollowHistory.exists?(uid, following_uid, config: config)
|
16
25
|
end
|
17
26
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module GrowViral
|
2
|
+
module Warehouse
|
3
|
+
class FetchesFollowHistory
|
4
|
+
def self.fetch(*args)
|
5
|
+
new(*args).fetch
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_reader :uid, :config
|
9
|
+
def initialize(uid, deps)
|
10
|
+
raise HandleNotUidError unless uid.is_a? Numeric
|
11
|
+
|
12
|
+
@uid = uid
|
13
|
+
@config = deps[:config]
|
14
|
+
end
|
15
|
+
|
16
|
+
def fetch
|
17
|
+
response = Net::HTTP.get_response(uri)
|
18
|
+
JSON.parse(response.body)
|
19
|
+
end
|
20
|
+
|
21
|
+
def uri
|
22
|
+
@uri ||= URI.parse("#{config.host}/follow_history?uid=#{uid}")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
data/lib/warehouse/version.rb
CHANGED
@@ -3,12 +3,12 @@ require_relative 'test_helper'
|
|
3
3
|
class ChecksFollowHistoryTest < Minitest::Test
|
4
4
|
def test_raises_for_a_handle
|
5
5
|
client = GrowViral::Warehouse::Client.new(:development)
|
6
|
-
assert_raises(GrowViral::HandleNotUidError) { client.
|
6
|
+
assert_raises(GrowViral::HandleNotUidError) { client.has_existing_relationship?("string", 2312422) }
|
7
7
|
end
|
8
8
|
|
9
9
|
def test_raises_for_a_following_handle
|
10
10
|
client = GrowViral::Warehouse::Client.new(:development)
|
11
|
-
assert_raises(GrowViral::HandleNotUidError) { client.
|
11
|
+
assert_raises(GrowViral::HandleNotUidError) { client.has_existing_relationship?(837373, "string") }
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_true_for_200
|
@@ -20,7 +20,7 @@ class ChecksFollowHistoryTest < Minitest::Test
|
|
20
20
|
Net::HTTP.expects(:get_response).with(uri).returns(mock(code: '200'))
|
21
21
|
|
22
22
|
client = GrowViral::Warehouse::Client.new(:development)
|
23
|
-
assert client.
|
23
|
+
assert client.has_existing_relationship?(uid, following_uid)
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_false_for_404
|
@@ -32,6 +32,6 @@ class ChecksFollowHistoryTest < Minitest::Test
|
|
32
32
|
Net::HTTP.expects(:get_response).with(uri).returns(mock(code: '404'))
|
33
33
|
|
34
34
|
client = GrowViral::Warehouse::Client.new(:development)
|
35
|
-
refute client.
|
35
|
+
refute client.has_existing_relationship?(uid, following_uid)
|
36
36
|
end
|
37
37
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
class FetchesFollowHistoryTest < Minitest::Test
|
4
|
+
def test_raises_for_a_handle
|
5
|
+
client = GrowViral::Warehouse::Client.new(:development)
|
6
|
+
assert_raises(GrowViral::HandleNotUidError) { client.follow_history("string") }
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_returns_output_correctly
|
10
|
+
uid = 328383
|
11
|
+
|
12
|
+
output = { 'foo' => 'bar' }
|
13
|
+
uri = URI.parse("http://localhost:3000/follow_history?uid=#{uid}")
|
14
|
+
Net::HTTP.expects(:get_response).with(uri).returns(mock(body: output.to_json))
|
15
|
+
|
16
|
+
client = GrowViral::Warehouse::Client.new(:development)
|
17
|
+
assert_equal output, client.follow_history(uid)
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: growviral-warehouse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Walker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -84,9 +84,11 @@ files:
|
|
84
84
|
- lib/warehouse/checks_follow_history.rb
|
85
85
|
- lib/warehouse/client.rb
|
86
86
|
- lib/warehouse/configuration.rb
|
87
|
+
- lib/warehouse/fetches_follow_history.rb
|
87
88
|
- lib/warehouse/registers_followers.rb
|
88
89
|
- lib/warehouse/version.rb
|
89
90
|
- test/checks_follow_history_test.rb
|
91
|
+
- test/fetches_follow_history_test.rb
|
90
92
|
- test/registers_followers_test.rb
|
91
93
|
- test/test_helper.rb
|
92
94
|
homepage: ''
|
@@ -115,6 +117,7 @@ specification_version: 4
|
|
115
117
|
summary: A wrapper for the GrowViral warehouse.
|
116
118
|
test_files:
|
117
119
|
- test/checks_follow_history_test.rb
|
120
|
+
- test/fetches_follow_history_test.rb
|
118
121
|
- test/registers_followers_test.rb
|
119
122
|
- test/test_helper.rb
|
120
123
|
has_rdoc:
|