blockers-cli-app 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/run +5 -0
- data/bin/setup +8 -0
- data/blockers.gemspec +29 -0
- data/config/environment.rb +7 -0
- data/lib/blockers.rb +6 -0
- data/lib/blockers/blocker.rb +39 -0
- data/lib/blockers/cli.rb +56 -0
- data/lib/blockers/version.rb +3 -0
- data/spec.md +9 -0
- metadata +146 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 78a7c5b273fb418035d416874fa2d629424b7dbf
|
4
|
+
data.tar.gz: 2e92544adc2153167de3086917532415b849b828
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8935a616db16fd65168ddc4f4a07438fd4c8eeaf869c917f714ee7d93d73f76f99a7b9c531f14987fc8de824298c9c3d50b63a767e0105e980766e746cbe23bb
|
7
|
+
data.tar.gz: a8c87785944a3ed9c5826c511ce19b0b83ce0a67e6aacfa307bd702a6eb588dfa11c3292a384bf4421202166dfdf92abafe8e22c26e52db121d7acfc7abfbae5
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 <szeidman>
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# blockers-cli-app
|
2
|
+
|
3
|
+
A CLI to get information about ice hockey goalie blockers for sale on GoalieMonkey.com
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'blockers-cli-app'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install blockers-cli-app
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
Run `run` after installing the gem.
|
25
|
+
|
26
|
+
## Development
|
27
|
+
|
28
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
29
|
+
|
30
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/<szeidman>/blockers.
|
35
|
+
|
36
|
+
## License
|
37
|
+
|
38
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
39
|
+
=======
|
40
|
+
A CLI to get information about ice hockey goalie blockers for sale on GoalieMonkey.com
|
41
|
+
>>>>>>> 7083a02035a23ad61761d9aa3c67499b283ceacb
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "blockers"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/run
ADDED
data/bin/setup
ADDED
data/blockers.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "blockers/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "blockers-cli-app"
|
8
|
+
spec.version = Blockers::VERSION
|
9
|
+
spec.authors = ["<szeidman>"]
|
10
|
+
spec.email = ["<sam.zeidman@gmail.com>"]
|
11
|
+
|
12
|
+
spec.summary = %q{Looks up the 20 cheapest senior blockers from goaliemonkey.com.}
|
13
|
+
spec.homepage = "https://github.com/szeidman/blockers-cli-app"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib", "lib/blockers"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
26
|
+
spec.add_development_dependency "nokogiri"
|
27
|
+
spec.add_development_dependency "pry"
|
28
|
+
spec.add_development_dependency "open-uri"
|
29
|
+
end
|
data/lib/blockers.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
class Blockers::Blocker
|
2
|
+
|
3
|
+
attr_accessor :name, :url, :price
|
4
|
+
|
5
|
+
@@all = []
|
6
|
+
|
7
|
+
def self.all
|
8
|
+
@@all
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.delete
|
12
|
+
@@all.clear
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(name, url, price)
|
16
|
+
@name = name
|
17
|
+
@url = url
|
18
|
+
@price = price
|
19
|
+
@@all << self
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.find(index)
|
23
|
+
self.all[index]
|
24
|
+
end
|
25
|
+
|
26
|
+
def name
|
27
|
+
@name
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.scrape
|
31
|
+
doc = Nokogiri::HTML(open('http://www.goaliemonkey.com/equipment/blockers/sr-goalie-blockers/sort-by/price/sort-direction/asc.html'))
|
32
|
+
doc.css("li.item.span3").each do |item|
|
33
|
+
name = item.css("div.caption h2.product-name a").text.gsub("Goalie Blocker", "")
|
34
|
+
url = item.css("div.caption h2.product-name a").attribute("href").value
|
35
|
+
price = item.css("div.price-box p.regular-price span.regular-price span.price").text
|
36
|
+
self.new(name, url, price)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/blockers/cli.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
class Blockers::CLI
|
2
|
+
|
3
|
+
def display
|
4
|
+
monkeys = "🐵 " * 15
|
5
|
+
sticks = "🏒 " * 15
|
6
|
+
puts monkeys + "\n" * 2
|
7
|
+
puts "Finally a program for you, someone who wants to see the 20 cheapest senior-sized blockers at GoalieMonkey.com without necessarily looking at pictures of them." + "\n" * 2
|
8
|
+
puts sticks + "\n" * 2
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
def blocker_list
|
13
|
+
puts "Here are the blockers (cheapest one first):\n\n"
|
14
|
+
Blockers::Blocker.all.each_with_index do |blocker, i|
|
15
|
+
puts "#{i + 1}. #{blocker.name}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def blocker_info(item)
|
20
|
+
puts "\n🐒🐒 🐒🐒 🐒🐒 🐒🐒 🐒🐒"
|
21
|
+
puts "\nYou chose the #{item.name.strip.chomp(".")}."
|
22
|
+
puts "It's listed for #{item.price}."
|
23
|
+
puts "Buy it here: \n#{item.url}"
|
24
|
+
puts "\n🐒🐒 🏒🏒 🐒🐒 🏒🏒 🐒🐒"
|
25
|
+
puts "\nTo regenerate the list, type 'list'.\nTo exit, type 'exit'."
|
26
|
+
input = gets.strip.downcase
|
27
|
+
while input != "exit" && input != "list"
|
28
|
+
puts "🙉 Invalid response; to return to the list, type 'list.'\nTo exit, type 'exit'."
|
29
|
+
input = gets.strip.downcase
|
30
|
+
end
|
31
|
+
if input == "exit"
|
32
|
+
puts "🙈 So long. Keep blocking the pucks. 🙈"
|
33
|
+
elsif input == "list"
|
34
|
+
Blockers::Blocker.delete
|
35
|
+
commence
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def commence
|
40
|
+
Blockers::Blocker.scrape
|
41
|
+
display
|
42
|
+
blocker_list
|
43
|
+
input = nil
|
44
|
+
puts "\n🏒 🐵 🏒 🏒 🐵 🐵 🐵 🏒 🏒 🏒 🏒 🏒 🏒 🏒 🏒 🏒 🏒 🐵 🐵 🐵 🏒 🏒 🐵 🏒"
|
45
|
+
puts "\nEnter a blocker's number (1-20) for more info:"
|
46
|
+
input = gets.strip.to_i
|
47
|
+
while !input.between?(1, 20)
|
48
|
+
puts "🙊 Invalid response; please enter the number (1-20) for which you'd like to see more info: "
|
49
|
+
input = gets.strip.to_i
|
50
|
+
end
|
51
|
+
index = input - 1
|
52
|
+
item = Blockers::Blocker.find(index)
|
53
|
+
blocker_info(item)
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
data/spec.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# Specifications for the CLI Assessment
|
2
|
+
|
3
|
+
Specs:
|
4
|
+
- [x] Have a CLI for interfacing with the application
|
5
|
+
cli.rb tested and runs
|
6
|
+
- [x] Pull data from an external source
|
7
|
+
blocker.rb scrapes from goaliemonkey.com
|
8
|
+
- [x] Implement both list and detail views
|
9
|
+
Initial list of 20 appears on CLI, then focuses on info for one entry.
|
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: blockers-cli-app
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "<szeidman>"
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-05-19 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.15'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.15'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.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: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: nokogiri
|
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
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: open-uri
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- "<sam.zeidman@gmail.com>"
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- ".travis.yml"
|
107
|
+
- Gemfile
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- bin/console
|
112
|
+
- bin/run
|
113
|
+
- bin/setup
|
114
|
+
- blockers.gemspec
|
115
|
+
- config/environment.rb
|
116
|
+
- lib/blockers.rb
|
117
|
+
- lib/blockers/blocker.rb
|
118
|
+
- lib/blockers/cli.rb
|
119
|
+
- lib/blockers/version.rb
|
120
|
+
- spec.md
|
121
|
+
homepage: https://github.com/szeidman/blockers-cli-app
|
122
|
+
licenses:
|
123
|
+
- MIT
|
124
|
+
metadata: {}
|
125
|
+
post_install_message:
|
126
|
+
rdoc_options: []
|
127
|
+
require_paths:
|
128
|
+
- lib
|
129
|
+
- lib/blockers
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
requirements: []
|
141
|
+
rubyforge_project:
|
142
|
+
rubygems_version: 2.6.11
|
143
|
+
signing_key:
|
144
|
+
specification_version: 4
|
145
|
+
summary: Looks up the 20 cheapest senior blockers from goaliemonkey.com.
|
146
|
+
test_files: []
|