barato 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/barato.rb +3 -2
  3. data/spec/tests.rb +4 -0
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 18cfcd5413158aa1c30025d1468f0a8da0e8dc58
4
- data.tar.gz: 0f4e88068ea36b5c6f10d4516fe19dd6c6e5127c
3
+ metadata.gz: 0c55a198cca4b86943d45269ad605254aafabe53
4
+ data.tar.gz: ce671f05a670af9801f2e23c9461720237a2e329
5
5
  SHA512:
6
- metadata.gz: a724d3e38194e1a7f25fa2f1891df90c8ef54d23f4cb1bacb9d48028333b2943fb84072cda9ac76540cee3b583a57b8ccee7913f71c3a3228b8039d8ae5d1fac
7
- data.tar.gz: 628be3bbf9cd3b4ef512eb098f46ca6e0d9798ab3aa912690a3392d2fad217fadcffc918c6dac498891d22fdf7c697e56405f7df475cb3143362337c08c9f90d
6
+ metadata.gz: 11f7809e81341be01080995f3e892b1a4ec866b2e2a339f35f17c9c653a9d9bccaea16083ee6dbcb4f503619f8fc8623a5a39f2f7aaea9541e5ecfdf3cb9eae8
7
+ data.tar.gz: 035c514b42f628b9f471db50986836f1974385e980c5eec16ce0544bdd43019888343c3c8c55f7b892209c92c264474b24cca7a58cf8b282a5802735c567ed01
@@ -1,7 +1,7 @@
1
1
  require 'net/http/persistent'
2
2
  require 'uri'
3
3
 
4
- # This class simply takes in a URL and has the ability to parse it for information (headers, etc per the Net::HTTP::Persistent module) # and will make a new get request to the URL every 20 minutes to keep it 'alive'.
4
+ # This class simply takes in a URL and has the ability to parse it for information (headers, etc per the Net::HTTP::Persistent module) and will make a new get request to the URL every 20 minutes to keep it 'alive'. It will make an initial request when the object is initialized, then feed the object to the timer to be repeated every X seconds. It is set to 20 minutes by default.
5
5
 
6
6
  class Barato
7
7
  attr_accessor :response, :http, :uri
@@ -9,6 +9,7 @@ attr_accessor :response, :http, :uri
9
9
  def initialize(url)
10
10
  @uri = URI("#{url}")
11
11
  @http = Net::HTTP::Persistent.new(uri)
12
+ @response = http.request(@uri)
12
13
  end
13
14
 
14
15
  def working_response?
@@ -21,7 +22,7 @@ attr_accessor :response, :http, :uri
21
22
 
22
23
  def run
23
24
  Thread.new do
24
- while true
25
+ while self.working_response? == true
25
26
  @response = http.request(@uri)
26
27
  sleep 1200
27
28
  end
@@ -7,6 +7,10 @@ describe 'initial setup' do
7
7
  @test_subject = Barato.new('http://www.google.com')
8
8
  end
9
9
 
10
+ it 'should have a 200 OK http response' do
11
+ expect(@test_subject.working_response?).to be_true
12
+ end
13
+
10
14
  it 'should have a url' do
11
15
  @test_subject.http.name.host.eql?("www.google.com")
12
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barato
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Sawyer