hobos 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fcd82bde05ba3071e9b3ee0fecf930158bf222da
4
+ data.tar.gz: 3cd8c9be86a793fbf8bb461f24b9ea0f450cc56d
5
+ SHA512:
6
+ metadata.gz: 1f5f32f4b7d5068b9e04318e96f98f44ca59b79dc602d55b2d467407552cf84b2acf2a1125931537ee067b1ec7969087eb57c0e1a1f944067413f49b5fcdc208
7
+ data.tar.gz: 9347c8cbee5d96b4471ede29ebc5f21596ff7975a0429eef19780ca156a4c13354780cd2276e2f8dab1b55ba477623ffb280f746dbb57a3d5fe95fe5981a2420
data/.gitignore ADDED
@@ -0,0 +1,35 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /vendor/bundle
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ # Gemfile.lock
31
+ # .ruby-version
32
+ # .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # A sample Gemfile
2
+ source "https://rubygems.org"
3
+
4
+ gem 'mechanize'
5
+ gem 'sinatra'
6
+
7
+ group :test, :development do
8
+ gem 'rspec'
9
+ end
10
+
data/Gemfile.lock ADDED
@@ -0,0 +1,56 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.2.5)
5
+ domain_name (0.5.23)
6
+ unf (>= 0.0.5, < 1.0.0)
7
+ http-cookie (1.0.2)
8
+ domain_name (~> 0.5)
9
+ mechanize (2.7.3)
10
+ domain_name (~> 0.5, >= 0.5.1)
11
+ http-cookie (~> 1.0)
12
+ mime-types (~> 2.0)
13
+ net-http-digest_auth (~> 1.1, >= 1.1.1)
14
+ net-http-persistent (~> 2.5, >= 2.5.2)
15
+ nokogiri (~> 1.4)
16
+ ntlm-http (~> 0.1, >= 0.1.1)
17
+ webrobots (>= 0.0.9, < 0.2)
18
+ mime-types (2.4.3)
19
+ mini_portile (0.6.2)
20
+ net-http-digest_auth (1.4)
21
+ net-http-persistent (2.9.4)
22
+ nokogiri (1.6.6.2)
23
+ mini_portile (~> 0.6.0)
24
+ ntlm-http (0.1.1)
25
+ rack (1.6.0)
26
+ rack-protection (1.5.3)
27
+ rack
28
+ rspec (3.1.0)
29
+ rspec-core (~> 3.1.0)
30
+ rspec-expectations (~> 3.1.0)
31
+ rspec-mocks (~> 3.1.0)
32
+ rspec-core (3.1.7)
33
+ rspec-support (~> 3.1.0)
34
+ rspec-expectations (3.1.2)
35
+ diff-lcs (>= 1.2.0, < 2.0)
36
+ rspec-support (~> 3.1.0)
37
+ rspec-mocks (3.1.3)
38
+ rspec-support (~> 3.1.0)
39
+ 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
+ unf (0.1.4)
46
+ unf_ext
47
+ unf_ext (0.0.6)
48
+ webrobots (0.1.1)
49
+
50
+ PLATFORMS
51
+ ruby
52
+
53
+ DEPENDENCIES
54
+ mechanize
55
+ rspec
56
+ sinatra
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 yburyug
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # Hobos
2
+
3
+ A simple wrapper to return hobos.
4
+
5
+ ## Why?
6
+
7
+ Fuck off and read a hobo name.
8
+
9
+ ## Installation:
10
+
11
+ ```BASH
12
+ git clone 'https://www.github.com/rhgraysonii/hobo_api.git'
13
+ cd hobo_api
14
+ gem build hobo_api.gemspec
15
+ gem install hobo_api.gem
16
+ cd ..
17
+ ```
18
+
19
+ And now you can simply look them up by id or at random.
20
+
21
+ ```bash
22
+ $ hobos
23
+ #=> Big-Tipper Silas Fake-Nickel
24
+ $ hobos 1
25
+ # => 'Stewbuilder Dennis'
26
+ ```
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/hobos ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'hobos'
4
+
5
+ api = Hobos::Api.new
6
+
7
+
8
+ if ARGV[0]
9
+ puts api.hobo ARGV[0]
10
+ else
11
+ found_hobo = false
12
+ while !found_hobo
13
+ resp = api.hobo rand(1..700)
14
+ if resp != "{ 'error': { 'message': 'bad UID' } }"
15
+ puts resp
16
+ found_hobo = true
17
+ else
18
+ puts "searching...."
19
+ end
20
+ end
21
+ end
22
+
23
+
24
+
data/hobos.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'hobos/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "hobos"
8
+ spec.version = Hobos::VERSION
9
+ spec.authors = ["Robert H Grayson II"]
10
+ spec.email = ["bobbygrayson@gmail.com"]
11
+ spec.summary = %q{Get your hobo on.}
12
+ spec.description = %q{See summary.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = ["hobos"]
18
+
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.6"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "mechanize"
26
+ end
@@ -0,0 +1,3 @@
1
+ module Hobos
2
+ VERSION = "0.0.1"
3
+ end
data/lib/hobos.rb ADDED
@@ -0,0 +1,37 @@
1
+ require 'mechanize'
2
+ module Hobos
3
+
4
+ class Api
5
+ def initialize
6
+ @browser = Browser.new.browser
7
+ end
8
+
9
+ def hobo uid
10
+ begin
11
+ clean_name(@browser.get("http://www.e-hobo.com/hoboes/#{uid}").at('span').children.last.to_s)
12
+ rescue
13
+ "{ 'error': { 'message': 'bad UID' } }"
14
+ end
15
+ end
16
+
17
+ private
18
+ def clean_name hobo_name
19
+ hobo_name.gsub!(/\d/, '')
20
+ hobo_name.gsub!('#', '')
21
+ hobo_name.gsub!(': ', '')
22
+ hobo_name
23
+ end
24
+ end
25
+
26
+ class Browser
27
+ attr_accessor :browser
28
+ attr_accessor :hobos_list
29
+
30
+ def initialize
31
+ @browser = Mechanize.new
32
+ @hobos_list = @browser.get("http://www.e-hobo.com/hoboes/list/")
33
+ end
34
+ end
35
+
36
+ end
37
+
@@ -0,0 +1,13 @@
1
+ require './lib/hobos'
2
+
3
+ describe Hobos::HoboAPI do
4
+ let(:api) { Hobos::HoboAPI.new }
5
+
6
+ it "returns a hobo name for a given ID" do
7
+ expect(api.hobo 1).to eq 'Stewbuilder Dennis'
8
+ end
9
+
10
+ it "handles bad ids" do
11
+ expect(api.hobo 999).to eq "{ 'error': { 'message': 'bad UID' } }"
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hobos
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Robert H Grayson II
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: mechanize
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: See summary.
70
+ email:
71
+ - bobbygrayson@gmail.com
72
+ executables:
73
+ - hobos
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - LICENSE
81
+ - README.md
82
+ - Rakefile
83
+ - bin/hobos
84
+ - hobos.gemspec
85
+ - lib/hobos.rb
86
+ - lib/hobos/version.rb
87
+ - spec/hobos_spec.rb
88
+ homepage: ''
89
+ licenses:
90
+ - MIT
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubyforge_project:
108
+ rubygems_version: 2.2.2
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: Get your hobo on.
112
+ test_files:
113
+ - spec/hobos_spec.rb
114
+ has_rdoc: