barato 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +20 -0
- data/lib/barato.rb +30 -0
- data/spec/tests.rb +13 -0
- metadata +47 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 18cfcd5413158aa1c30025d1468f0a8da0e8dc58
|
4
|
+
data.tar.gz: 0f4e88068ea36b5c6f10d4516fe19dd6c6e5127c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a724d3e38194e1a7f25fa2f1891df90c8ef54d23f4cb1bacb9d48028333b2943fb84072cda9ac76540cee3b583a57b8ccee7913f71c3a3228b8039d8ae5d1fac
|
7
|
+
data.tar.gz: 628be3bbf9cd3b4ef512eb098f46ca6e0d9798ab3aa912690a3392d2fad217fadcffc918c6dac498891d22fdf7c697e56405f7df475cb3143362337c08c9f90d
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.2.5)
|
5
|
+
net-http-persistent (2.9.4)
|
6
|
+
rspec (2.14.1)
|
7
|
+
rspec-core (~> 2.14.0)
|
8
|
+
rspec-expectations (~> 2.14.0)
|
9
|
+
rspec-mocks (~> 2.14.0)
|
10
|
+
rspec-core (2.14.7)
|
11
|
+
rspec-expectations (2.14.5)
|
12
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
13
|
+
rspec-mocks (2.14.5)
|
14
|
+
|
15
|
+
PLATFORMS
|
16
|
+
ruby
|
17
|
+
|
18
|
+
DEPENDENCIES
|
19
|
+
net-http-persistent
|
20
|
+
rspec
|
data/lib/barato.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'net/http/persistent'
|
2
|
+
require 'uri'
|
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'.
|
5
|
+
|
6
|
+
class Barato
|
7
|
+
attr_accessor :response, :http, :uri
|
8
|
+
|
9
|
+
def initialize(url)
|
10
|
+
@uri = URI("#{url}")
|
11
|
+
@http = Net::HTTP::Persistent.new(uri)
|
12
|
+
end
|
13
|
+
|
14
|
+
def working_response?
|
15
|
+
if @response.msg.eql?("OK")
|
16
|
+
return true
|
17
|
+
else
|
18
|
+
"Did not receive a 200 OK response"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def run
|
23
|
+
Thread.new do
|
24
|
+
while true
|
25
|
+
@response = http.request(@uri)
|
26
|
+
sleep 1200
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/spec/tests.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require_relative '../lib/barato'
|
3
|
+
|
4
|
+
describe 'initial setup' do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@test_subject = Barato.new('http://www.google.com')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should have a url' do
|
11
|
+
@test_subject.http.name.host.eql?("www.google.com")
|
12
|
+
end
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: barato
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joseph Sawyer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-01 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Easily retrieve a URL on a timer
|
14
|
+
email: joseph@thehopefulwebdev.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/barato.rb
|
20
|
+
- spec/tests.rb
|
21
|
+
- Gemfile
|
22
|
+
- Gemfile.lock
|
23
|
+
homepage: https://github.com/zkay/barato
|
24
|
+
licenses: []
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.1.11
|
43
|
+
signing_key:
|
44
|
+
specification_version: 3
|
45
|
+
summary: Timer to retrieve URL(s)
|
46
|
+
test_files:
|
47
|
+
- spec/tests.rb
|