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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec52af43b94624ba574121ddc20c67122af07443
4
- data.tar.gz: 58d118d71ca4c3ca733cb260982a668dd1405a2d
3
+ metadata.gz: b70c3bfe6d1699d4188e4d292b7d9f1badc8aaed
4
+ data.tar.gz: ef3012af9999bc63f321b1344e6415c8fbfac95e
5
5
  SHA512:
6
- metadata.gz: a523a8b581d190db8b59d995c0b28ffdc31b1a1d656a79f65e3bb347a7359eec8d9a6518ae2c2ce4c8bd7491198a81cfe2d7ebc6ee5c8fede44d604379a81205
7
- data.tar.gz: e3987aa9562a81a22efbf3cb45f09d7293cb67c97de027b96b70725d32fe63deac4020f79d6709dfb37c7c690de4ade0ad768cd739ca5d25dda86c25558430a2
6
+ metadata.gz: e455521d01e239cb096bad590b60dd0350800b2e830be73190097e057534c0e83a23935b9fbe311c23fa9e9a58f2f1f3b85725c9b5c17c90c60149c3d9247fd5
7
+ data.tar.gz: 51efa62d5f04ba555c2f3a587dad18b24b183ec3e40ea9270d755d1fd6a9d5b020ce151f1ea4695e8e36039d5a019063bc333af7d2a7b6f088bcf89c938ed5ec
@@ -5,6 +5,7 @@ require 'json'
5
5
  require 'warehouse/client'
6
6
  require 'warehouse/configuration'
7
7
  require 'warehouse/registers_followers'
8
+ require 'warehouse/fetches_follow_history'
8
9
  require 'warehouse/checks_follow_history'
9
10
 
10
11
  module GrowViral
@@ -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
@@ -11,7 +11,7 @@ module GrowViral
11
11
  case env.to_sym
12
12
  when :test
13
13
  when :development
14
- ENV["GROWVIRAL_WAREHOUSE_HOST"] || "http://localhost:3000"
14
+ ENV["GROWVIRAL_WAREHOUSE_HOST"] || "http://localhost:3001"
15
15
  when :production
16
16
  ENV["GROWVIRAL_WAREHOUSE_HOST"]
17
17
  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
+
@@ -1,5 +1,5 @@
1
1
  module GrowViral
2
2
  module Warehouse
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
@@ -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.has_follow_history?("string", 2312422) }
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.has_follow_history?(837373, "string") }
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.has_follow_history?(uid, following_uid)
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.has_follow_history?(uid, following_uid)
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
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-23 00:00:00.000000000 Z
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: