hobos 0.0.6 → 0.0.7

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: 5f29bddcb4e06fe7a1dce9845922a1351fbce5a5
4
- data.tar.gz: 12d4b6c91ca247757a387a91de5789537fa503a7
3
+ metadata.gz: 453fb1c5a47c0ff71f36139d3cc809af33a9f46e
4
+ data.tar.gz: a14f78ba3dfb61f0a509846dc4688df14b9ccc7d
5
5
  SHA512:
6
- metadata.gz: d88e662ebb5ed1ea5775b794efdc574ba620e24fa818695836de739bedbccf6b6187e51275c89306c779da804eca25a42438bae2079a165dc42d56aba0fe7844
7
- data.tar.gz: 355f66aa5912a00caf2aa5d1a6c25d5c4979906ad746a21536ccc3bf14b200418ef7ddc2545a4c61aeff7fd3715a0db746cd9c9fd16701331fb085918c890a08
6
+ metadata.gz: 81be12ad0c25229492af2eef52288b24638e58660652ee81b6ee0afb1effbdb58734bee08611864fba14cfc007447d5abcd2c898f27087ea842ed5303021c4bc
7
+ data.tar.gz: bfbd7cfd031a3cba8394ec03660ffd31e3e9c3f7d8387fac5e66cf66c8baebc0343a0b1de82f3e8515cec4b10ab93a7aab14b942b137505379a87704e8104673
data/Gemfile.lock CHANGED
@@ -1,3 +1,8 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hobos (0.0.6)
5
+
1
6
  GEM
2
7
  remote: https://rubygems.org/
3
8
  specs:
@@ -22,9 +27,7 @@ GEM
22
27
  nokogiri (1.6.6.2)
23
28
  mini_portile (~> 0.6.0)
24
29
  ntlm-http (0.1.1)
25
- rack (1.6.0)
26
- rack-protection (1.5.3)
27
- rack
30
+ rake (10.4.2)
28
31
  rspec (3.1.0)
29
32
  rspec-core (~> 3.1.0)
30
33
  rspec-expectations (~> 3.1.0)
@@ -37,11 +40,6 @@ GEM
37
40
  rspec-mocks (3.1.3)
38
41
  rspec-support (~> 3.1.0)
39
42
  rspec-support (3.1.2)
40
- sinatra (1.4.6)
41
- rack (~> 1.4)
42
- rack-protection (~> 1.4)
43
- tilt (>= 1.3, < 3)
44
- tilt (1.4.1)
45
43
  unf (0.1.4)
46
44
  unf_ext
47
45
  unf_ext (0.0.6)
@@ -51,6 +49,8 @@ PLATFORMS
51
49
  ruby
52
50
 
53
51
  DEPENDENCIES
52
+ bundler (~> 1.6)
53
+ hobos!
54
54
  mechanize
55
+ rake
55
56
  rspec
56
- sinatra
data/lib/hobos/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hobos
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
data/lib/hobos.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'mechanize'
2
2
  module Hobos
3
-
3
+ HOBOS_URL = "http://www.e-hobo.com/hoboes/"
4
4
  class Api
5
5
  def initialize
6
6
  @browser = Browser.new.browser
@@ -10,11 +10,19 @@ module Hobos
10
10
  clean_name(try_hobo(false))
11
11
  end
12
12
 
13
+ def hobo_by_id id
14
+ begin
15
+ clean_name(@browser.get("#{HOBOS_URL}#{id}").at('span').children.last.to_s)
16
+ rescue
17
+ ''
18
+ end
19
+ end
20
+
13
21
  private
14
22
  def try_hobo found_hobo
15
- while !found_hobo
16
- resp = @browser.get("http://www.e-hobo.com/hoboes/#{rand(1..700)}").at('span').children.last.to_s
17
- if resp == "{ 'error': { 'message': 'bad UID' } }"
23
+ unless found_hobo
24
+ resp = @browser.get("#{HOBOS_URL}#{rand(1..700)}").at('span').children.last.to_s
25
+ if resp == ""
18
26
  try_hobo false
19
27
  else
20
28
  found_hobo = true
@@ -37,9 +45,7 @@ module Hobos
37
45
 
38
46
  def initialize
39
47
  @browser = Mechanize.new
40
- @hobos_list = @browser.get("http://www.e-hobo.com/hoboes/list/")
41
48
  end
42
49
  end
43
-
44
50
  end
45
51
 
data/spec/hobos_spec.rb CHANGED
@@ -1,13 +1,17 @@
1
- require './lib/hobos'
1
+ require '../lib/hobos'
2
2
 
3
- describe Hobos::HoboAPI do
4
- let(:api) { Hobos::HoboAPI.new }
3
+ describe Hobos do
4
+ let(:api) { Hobos::Api.new }
5
5
 
6
6
  it "returns a hobo name for a given ID" do
7
- expect(api.hobo 1).to eq 'Stewbuilder Dennis'
7
+ expect(api.hobo_by_id 1).to eq 'Stewbuilder Dennis'
8
8
  end
9
9
 
10
10
  it "handles bad ids" do
11
- expect(api.hobo 999).to eq "{ 'error': { 'message': 'bad UID' } }"
11
+ expect(api.hobo_by_id 999).to eq ""
12
+ end
13
+
14
+ it "returns a random hobo with no id" do
15
+ expect(api.hobo == "").to eq false
12
16
  end
13
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hobos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert H Grayson II
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-12 00:00:00.000000000 Z
11
+ date: 2015-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler