snes_finder_cli_app 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ba2e8e61fc18198cdd2c19ec4fce36ffed42b38c
4
+ data.tar.gz: 15f0b36bf360e8a9ae458ada595ef00b8762147e
5
+ SHA512:
6
+ metadata.gz: 19ad8034e48a88cb3c1f350d5a35e4613a98c9f2c02d88a4b38bd556f29a88eb41e52a3e0f926e31274793ef885ad99cedce162fd7c0915f342daa665951d427
7
+ data.tar.gz: 8bddcbd89a3c52fbbeb11d9f1f91676bd718ec97660f0032344c553bd3e51fa48da660ef3b4be5d5449be16b223f798da6ee4adaba66507ffac9647fe46a2106
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.14.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in snes_finder_cli_app.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Dan Blondell
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,38 @@
1
+ # SnesFinderCliApp
2
+
3
+ SNES Finder checks Best Buy, Amazon, and Target to see if they have Nintendo's SNES Classic in stock or available for pre-order.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'snes_finder_cli_app'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install snes_finder_cli_app
20
+
21
+ ## Usage
22
+
23
+ To use it, just run the app – `bin/snes-finder`. It gets going right away and has some simple follow up steps, if you want them.
24
+
25
+ ## Development
26
+
27
+ 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.
28
+
29
+ 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).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/danblondell/snes_finder_cli_app.
34
+
35
+
36
+ ## License
37
+
38
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "snes_finder_cli_app"
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/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/bin/snes-finder ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "snes_finder_cli_app"
5
+
6
+ SnesFinderCliApp::CLI.new.call
@@ -0,0 +1,56 @@
1
+ class SnesFinderCliApp::CLI
2
+ def initialize
3
+ @bestbuy = SnesFinderCliApp::BestBuy.new
4
+ @amazon = SnesFinderCliApp::Amazon.new
5
+ @target = SnesFinderCliApp::Target.new
6
+ end
7
+
8
+ def call
9
+ puts "\nLet's see if the SNES Classic is in available for purchase."
10
+
11
+ puts "\nChecking Best Buy. This might take a minute..."
12
+ bestbuy = @bestbuy.scraper
13
+ puts "Now checking Amazon..."
14
+ amazon = @amazon.scraper
15
+ puts "Checking Target now, just a bit longer..."
16
+ target = @target.scraper
17
+
18
+ puts "\nHere are the current listings for SNES Classic"
19
+ puts "1. Best Buy - #{bestbuy}"
20
+ puts "2. Amazon - #{amazon}"
21
+ puts "3. Target - #{target}"
22
+
23
+ puts "\nType the number of the link you are interested in, or type refresh or exit."
24
+
25
+ now_what
26
+ end
27
+
28
+ def now_what
29
+
30
+ input = gets.strip
31
+
32
+ if input.downcase == "exit"
33
+ puts "Come again soon!"
34
+ elsif input.downcase == "refresh"
35
+ call
36
+ elsif input.to_i == 1
37
+ puts "\n#{@bestbuy.more_info}"
38
+ puts "\n#{@bestbuy.url}\n"
39
+ puts "\nAnything else?"
40
+ now_what
41
+ elsif input.to_i == 2
42
+ puts "\n#{@amazon.more_info}"
43
+ puts "\n#{@amazon.url}\n"
44
+ puts "\nAnything else?"
45
+ now_what
46
+ elsif input.to_i == 3
47
+ puts "\n#{@target.more_info}"
48
+ puts "\n#{@target.url}\n"
49
+ puts "\nAnything else?"
50
+ now_what
51
+ else
52
+ puts "Type either 1-3, refresh, or exit."
53
+ now_what
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,67 @@
1
+ class SnesFinderCliApp::BestBuy
2
+ attr_accessor :url, :doc, :status, :more_info
3
+
4
+ def initialize
5
+ @url = "https://www.bestbuy.com/site/nintendo-entertainment-system-snes-classic-edition/5919830.p?skuId=5919830"
6
+ end
7
+
8
+ def scraper
9
+
10
+ browser = Watir::Browser.new :chrome, headless: true
11
+ browser.goto @url
12
+
13
+ @doc = Nokogiri::HTML.parse(browser.html)
14
+
15
+ browser.close
16
+
17
+ @more_info = @doc.css("#long-description").text
18
+
19
+ @status = @doc.css(".cart-button").text
20
+ end
21
+ end
22
+
23
+
24
+
25
+ class SnesFinderCliApp::Amazon
26
+ attr_accessor :url, :doc, :status, :more_info
27
+
28
+ def initialize
29
+ @url = "https://www.amazon.com/Super-NES-Classic/dp/B0721GGGS9/ref=sr_1_1?ie=UTF8&qid=1503878302&sr=8-1&keywords=snes+classic"
30
+ end
31
+
32
+ def scraper
33
+ browser = Watir::Browser.new :chrome, headless: true
34
+ browser.goto @url
35
+
36
+ @doc = Nokogiri::HTML.parse(browser.html)
37
+
38
+ browser.close
39
+
40
+ @more_info = @doc.css("#feature-bullets").text.gsub(/\t/,"").gsub(/\n{2,}/,"\n").strip
41
+
42
+ @doc.css("#add-to-cart-button").empty? ? @status = "Out of Stock" : @status = @doc.css("#add-to-cart-button").attribute("value").value
43
+ end
44
+ end
45
+
46
+
47
+
48
+ class SnesFinderCliApp::Target
49
+ attr_accessor :url, :doc, :status, :more_info
50
+
51
+ def initialize
52
+ @url = "https://www.target.com/p/nintendo-174-super-nes-classic-edition/-/A-52826093#lnk=sametab"
53
+ end
54
+
55
+ def scraper
56
+ browser = Watir::Browser.new :chrome, headless: true
57
+ browser.goto @url
58
+
59
+ @doc = Nokogiri::HTML.parse(browser.html)
60
+
61
+ browser.close
62
+
63
+ @more_info = @doc.css(".accordionCard").text.gsub(/\s{2,}/,"\n").capitalize
64
+
65
+ @status = @doc.css("#AddToCartAreaId .add-to-cart-wrap .btn-primary").text.strip.capitalize
66
+ end
67
+ end
@@ -0,0 +1,3 @@
1
+ module SnesFinderCliApp
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,19 @@
1
+ require 'open-uri'
2
+ require 'nokogiri'
3
+ require 'pry'
4
+
5
+ require 'webdrivers'
6
+ require 'watir'
7
+
8
+ require "snes_finder_cli_app/version"
9
+ require "snes_finder_cli_app/cli"
10
+ require 'snes_finder_cli_app/snes_finder'
11
+
12
+
13
+
14
+
15
+ ## provided by template delete if not needed
16
+ # module SnesFinderCliApp
17
+ # # Your code goes here...
18
+ #
19
+ # end
@@ -0,0 +1,41 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'snes_finder_cli_app/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "snes_finder_cli_app"
8
+ spec.version = SnesFinderCliApp::VERSION
9
+ spec.authors = ["Dan Blondell"]
10
+ spec.email = ["danblondell@gmail.com"]
11
+ spec.summary = "CLI app that checks major electronics retailers to see if SNES Classic is in stock or available for pre-order"
12
+ spec.homepage = "https://github.com/danblondell/snes_finder_cli_app"
13
+ spec.license = "MIT"
14
+
15
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
16
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
17
+ # if spec.respond_to?(:metadata)
18
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
19
+ # else
20
+ # raise "RubyGems 2.0 or newer is required to protect against " \
21
+ # "public gem pushes."
22
+ # end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
25
+ f.match(%r{^(test|spec|features)/})
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_development_dependency "bundler", "~> 1.14"
32
+ spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_development_dependency "rspec", "~> 3.0"
34
+ spec.add_development_dependency "pry"
35
+
36
+ spec.add_dependency "nokogiri"
37
+
38
+ spec.add_dependency 'watir', '~> 6.7', '>= 6.7.3'
39
+ spec.add_dependency "webdrivers", "~> 3.0"
40
+
41
+ end
data/spec.md ADDED
@@ -0,0 +1,36 @@
1
+ CLI app that searches several electronics store websites and checks if the SNES Classic is in stock for preorder or purchase
2
+
3
+ ## specs
4
+ [x] CLI:
5
+
6
+ [x] checks status
7
+
8
+ [x] asks if you want to recheck
9
+
10
+ [x] prints url of requested site
11
+
12
+ [x] Correctly states status of "In Stock" / "Pre-Order" / "Out of Stock"
13
+
14
+ [x] snes_finder:
15
+
16
+ [x] Checks BestBuy
17
+ https://www.bestbuy.com/site/nintendo-entertainment-system-snes-classic-edition/5919830.p?skuId=5919830
18
+
19
+ [x] Checks Amazon
20
+ https://www.amazon.com/Super-NES-Classic/dp/B0721GGGS9/ref=sr_1_1?ie=UTF8&qid=1503868738&sr=8-1&keywords=snes+classic
21
+
22
+ [x] Checks Target
23
+ https://www.target.com/p/nintendo-174-super-nes-classic-edition/-/A-52826093#lnk=sametab
24
+
25
+ [x] The data provided must go at least one level deep, generally by showing the user a list of available data and then being able to drill down into a specific item.
26
+
27
+ [x] Add a description of the SNES classic pulled from site
28
+
29
+ ## also to do
30
+ [x] Write README
31
+
32
+ [x] Create 30 min screen capture
33
+
34
+ [x] Create video demo of app with voiceover
35
+
36
+ [x] Write a blog post about the project and process
metadata ADDED
@@ -0,0 +1,167 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: snes_finder_cli_app
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dan Blondell
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-08-28 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.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
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: pry
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: nokogiri
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
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: watir
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '6.7'
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 6.7.3
93
+ type: :runtime
94
+ prerelease: false
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '6.7'
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 6.7.3
103
+ - !ruby/object:Gem::Dependency
104
+ name: webdrivers
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '3.0'
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '3.0'
117
+ description:
118
+ email:
119
+ - danblondell@gmail.com
120
+ executables: []
121
+ extensions: []
122
+ extra_rdoc_files: []
123
+ files:
124
+ - ".DS_Store"
125
+ - ".gitignore"
126
+ - ".rspec"
127
+ - ".travis.yml"
128
+ - Gemfile
129
+ - LICENSE.txt
130
+ - README.md
131
+ - Rakefile
132
+ - bin/console
133
+ - bin/setup
134
+ - bin/snes-finder
135
+ - lib/snes_finder_cli_app.rb
136
+ - lib/snes_finder_cli_app/cli.rb
137
+ - lib/snes_finder_cli_app/snes_finder.rb
138
+ - lib/snes_finder_cli_app/version.rb
139
+ - snes_finder_cli_app.gemspec
140
+ - spec.md
141
+ - video walkthroughs/snes-finder video walkthrough.mp4
142
+ homepage: https://github.com/danblondell/snes_finder_cli_app
143
+ licenses:
144
+ - MIT
145
+ metadata: {}
146
+ post_install_message:
147
+ rdoc_options: []
148
+ require_paths:
149
+ - lib
150
+ required_ruby_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ required_rubygems_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ requirements: []
161
+ rubyforge_project:
162
+ rubygems_version: 2.6.12
163
+ signing_key:
164
+ specification_version: 4
165
+ summary: CLI app that checks major electronics retailers to see if SNES Classic is
166
+ in stock or available for pre-order
167
+ test_files: []