steam_deals_cli 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -5
- data/README.md +9 -4
- data/bin/console +1 -1
- data/bin/steam_deals_cli +1 -1
- data/config/environment.rb +7 -0
- data/lib/steam_deals_cli.rb +1 -8
- data/lib/steam_deals_cli/cli.rb +51 -14
- data/lib/steam_deals_cli/deals_scraper.rb +3 -8
- data/lib/steam_deals_cli/steam_deals.rb +27 -11
- data/lib/steam_deals_cli/version.rb +1 -1
- data/spec.md +1 -1
- data/steam_deals_cli-0.1.0.gem +0 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4420bd56f27f9250c8f8a736819a9f488f762ba0
|
4
|
+
data.tar.gz: 7fd0c224d1fdc87787b854dd6b14c3bf67c1f30b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f3821e801cded4b51817ed54a25ca6d21ab1cadfee9249ae0a5439f288d105ad7dbfa6ded2b3950e55e84a2188993541d84e04977c4a4c3bf58a669f5ad5c88
|
7
|
+
data.tar.gz: 30eb0f1e817574c5db6c027cc9e5de15db38cede223cbe769c83f19d22490a3763431a4270a3451d758d0166d84183a63489811092e0c25dd7eb17d6388d05e2
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
steam_deals_cli (0.1.
|
4
|
+
steam_deals_cli (0.1.1)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -36,11 +36,11 @@ PLATFORMS
|
|
36
36
|
|
37
37
|
DEPENDENCIES
|
38
38
|
bundler (~> 1.16)
|
39
|
-
nokogiri
|
40
|
-
open_uri_redirections
|
41
|
-
pry
|
39
|
+
nokogiri (~> 1.8, >= 1.8.1)
|
40
|
+
open_uri_redirections (~> 0.2.1)
|
41
|
+
pry (~> 0.11.3)
|
42
42
|
rake (~> 10.0)
|
43
|
-
rspec
|
43
|
+
rspec (~> 3.7)
|
44
44
|
steam_deals_cli!
|
45
45
|
|
46
46
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
<<<<<<< HEAD
|
2
1
|
# SteamDealsCli
|
3
2
|
|
4
|
-
|
3
|
+
This Ruby Gem outputs the current deals on Steam organized by the type of deal.
|
4
|
+
Weeklong Deals; last all week.
|
5
|
+
Weekend Deals; last as long as the weekend.
|
6
|
+
Daily Deals; last for only a day.
|
7
|
+
Special Promotions; Offered when you own the original game or when a developer is feeling awesome :)
|
5
8
|
|
6
|
-
TODO: Delete this and the text above, and describe your gem
|
7
9
|
|
8
10
|
## Installation
|
9
11
|
|
@@ -23,7 +25,10 @@ Or install it yourself as:
|
|
23
25
|
|
24
26
|
## Usage
|
25
27
|
|
26
|
-
|
28
|
+
Type the below and follow the on screen prompts.
|
29
|
+
```ruby
|
30
|
+
CLI.new.call
|
31
|
+
```
|
27
32
|
|
28
33
|
## Development
|
29
34
|
|
data/bin/console
CHANGED
data/bin/steam_deals_cli
CHANGED
data/lib/steam_deals_cli.rb
CHANGED
@@ -1,11 +1,4 @@
|
|
1
|
-
|
2
|
-
require "steam_deals_cli/steam_deals"
|
3
|
-
require "steam_deals_cli/cli"
|
4
|
-
|
5
|
-
require 'pry'
|
6
|
-
require 'nokogiri'
|
7
|
-
require 'open-uri'
|
8
|
-
|
1
|
+
require_relative '../config/environment'
|
9
2
|
|
10
3
|
module SteamDealsCli
|
11
4
|
# Your code goes here...
|
data/lib/steam_deals_cli/cli.rb
CHANGED
@@ -1,34 +1,36 @@
|
|
1
|
-
|
2
|
-
require_relative './steam_deals.rb'
|
3
|
-
|
4
|
-
class SteamDealsCli::CLI
|
1
|
+
class CLI
|
5
2
|
|
6
3
|
def call
|
7
|
-
|
4
|
+
Deals_Scraper.new.make_deals
|
8
5
|
puts "Welcome to Steam's current sales!"
|
9
6
|
start
|
10
7
|
end
|
11
8
|
|
12
9
|
def start
|
13
10
|
puts "-----------------------------------------"
|
14
|
-
puts "\nWhich would you like to see? There are currently #{
|
15
|
-
puts "
|
11
|
+
puts "\nWhich would you like to see? There are currently #{Deals_Scraper.new.current_deals_count} products on sale."
|
12
|
+
puts "\nHow would you like to see them sorted? Would you like to view the Weeklong Deals, Special Promotoions, Daily Deals, or Weekend Deals "
|
16
13
|
information
|
17
14
|
end
|
18
15
|
|
19
16
|
def information
|
17
|
+
puts ""
|
20
18
|
puts "Ex. For Weeklong Deals, type '1'"
|
21
19
|
puts "If you'd like to exit, type '5'"
|
22
20
|
input = gets.to_i
|
23
21
|
|
24
22
|
if input == 1
|
25
|
-
|
23
|
+
print_discounts(Steam_Deals.weeklong_deals)
|
24
|
+
more_info(Steam_Deals.weeklong_deals)
|
26
25
|
elsif input == 2
|
27
|
-
|
26
|
+
print_discounts(Steam_Deals.special_promos)
|
27
|
+
more_info(Steam_Deals.special_promos)
|
28
28
|
elsif input == 3
|
29
|
-
|
29
|
+
print_discounts(Steam_Deals.daily_deals)
|
30
|
+
more_info(Steam_Deals.daily_deals)
|
30
31
|
elsif input == 4
|
31
|
-
|
32
|
+
print_discounts(Steam_Deals.weekend_deals)
|
33
|
+
more_info(Steam_Deals.weekend_deals)
|
32
34
|
elsif input == 5
|
33
35
|
puts "Thanks! If you'd like to see more deals com'on back!"
|
34
36
|
else
|
@@ -37,15 +39,50 @@ class SteamDealsCli::CLI
|
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
40
|
-
def
|
41
|
-
games.
|
42
|
+
def print_discounts(games)
|
43
|
+
games.each_with_index do |game, index|
|
42
44
|
puts "----------------------------"
|
43
45
|
puts ""
|
46
|
+
puts "#{index+1}."
|
44
47
|
puts "Game: #{game.name}"
|
45
|
-
puts "Discounted Price:
|
48
|
+
puts "Discounted Price: #{game.discounted_price}"
|
46
49
|
puts "% Off: #{game.price_discount}"
|
47
50
|
puts ""
|
48
51
|
end
|
49
52
|
end
|
50
53
|
|
54
|
+
def more_info(list)
|
55
|
+
puts "Would you like to see more info on any of the games on the list?"
|
56
|
+
puts "Yes to continue and No to end the program."
|
57
|
+
info_request = gets.chomp
|
58
|
+
if info_request.downcase == "yes"
|
59
|
+
puts ""
|
60
|
+
puts "Which would you like to know more about?"
|
61
|
+
input = gets.to_i
|
62
|
+
puts ""
|
63
|
+
puts "#{list[input-1].name}"
|
64
|
+
Steam_Deals.additional_info(list[input-1])
|
65
|
+
added_info(list[input-1])
|
66
|
+
more_info(list)
|
67
|
+
elsif info_request.downcase == "no"
|
68
|
+
puts "Thanks! If you'd like to see more deals com'on back!"
|
69
|
+
elsif info_request.downcase == "eggs"
|
70
|
+
puts "Easter"
|
71
|
+
else
|
72
|
+
puts "#{info_request} is invalid. Please try again."
|
73
|
+
more_info(list)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def added_info(game)
|
78
|
+
puts "----------------------------"
|
79
|
+
puts "Game: #{game.name}"
|
80
|
+
puts "Developer: #{game.developer}"
|
81
|
+
puts "Publisher: #{game.publisher}"
|
82
|
+
puts "Discounted Price: #{game.discounted_price}"
|
83
|
+
puts "% Off: #{game.price_discount}"
|
84
|
+
puts "Original Price: #{game.original_price}"
|
85
|
+
puts "Game URL: #{game.widget}"
|
86
|
+
puts "----------------------------"
|
87
|
+
end
|
51
88
|
end
|
@@ -1,11 +1,7 @@
|
|
1
|
-
|
2
|
-
require 'nokogiri'
|
3
|
-
require_relative './steam_deals.rb'
|
4
|
-
|
5
|
-
class SteamDealsCli::Deals_Scraper
|
1
|
+
class Deals_Scraper
|
6
2
|
|
7
3
|
def get_page
|
8
|
-
Nokogiri::HTML(open("https://steamdb.info/sales
|
4
|
+
Nokogiri::HTML(open("https://steamdb.info/sales"))
|
9
5
|
end
|
10
6
|
|
11
7
|
def current_deals_count
|
@@ -18,8 +14,7 @@ class SteamDealsCli::Deals_Scraper
|
|
18
14
|
|
19
15
|
def make_deals
|
20
16
|
scrape_deals.each do |deal|
|
21
|
-
|
17
|
+
Steam_Deals.deals_from_page(deal)
|
22
18
|
end
|
23
19
|
end
|
24
|
-
|
25
20
|
end
|
@@ -1,30 +1,37 @@
|
|
1
|
-
|
2
|
-
require 'nokogiri'
|
3
|
-
require_relative './deals_scraper.rb'
|
1
|
+
class Steam_Deals
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
attr_accessor :name, :price_discount , :category, :discounted_price
|
8
|
-
|
9
|
-
@@all = []
|
3
|
+
attr_accessor :name, :price_discount , :category, :discounted_price, :url, :publisher, :developer, :widget, :id_num, :original_price
|
4
|
+
@@all = []
|
10
5
|
|
11
6
|
def self.deals_from_page(deal)
|
12
7
|
self.new(
|
13
8
|
deal.css("a.b").text,
|
14
9
|
deal.css("td").children[11].text,
|
15
10
|
deal.css("td").children[12].text,
|
16
|
-
deal.css(".category").text
|
11
|
+
deal.css(".category").text,
|
12
|
+
deal.css("a.b").attribute("href").value
|
17
13
|
)
|
18
14
|
end
|
19
|
-
|
20
|
-
def initialize(name, price_discount, discounted_price, category)
|
15
|
+
#deal.css("a.b").attribute("href").value => "/app/3230"
|
16
|
+
def initialize(name, price_discount, discounted_price, category, url)
|
21
17
|
@name = name
|
22
18
|
@price_discount = price_discount
|
23
19
|
@discounted_price = discounted_price
|
24
20
|
@category = category
|
21
|
+
@id_num = url
|
22
|
+
@url = Steam_Deals.url_creation(url)
|
23
|
+
@widget =Steam_Deals.widget_creation(id_num)
|
25
24
|
@@all << self
|
26
25
|
end
|
27
26
|
|
27
|
+
def self.url_creation(url)
|
28
|
+
app_url = "https://steamdb.info#{url}"
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.widget_creation(id_num)
|
32
|
+
widget = "http://store.steampowered.com#{id_num}"
|
33
|
+
end
|
34
|
+
|
28
35
|
def self.all
|
29
36
|
@@all
|
30
37
|
end
|
@@ -45,7 +52,16 @@ class SteamDealsCli::Steam_Deals
|
|
45
52
|
self.all.select{|game| game.category == "Daily Deal"}
|
46
53
|
end
|
47
54
|
|
55
|
+
def self.additional_info(game)
|
56
|
+
details = Nokogiri::HTML(open(game.url))
|
57
|
+
game.developer = details.css("tbody tr td").children[8].text
|
58
|
+
game.publisher = details .css("tbody tr td").children[11].text
|
59
|
+
widget = Nokogiri::HTML(open(game.widget))
|
60
|
+
game.original_price = widget.css("div.discount_original_price").first.text
|
61
|
+
end
|
48
62
|
end
|
63
|
+
#Developer: .css("tbody tr td").children[8] => Heart Machine
|
64
|
+
#Publisher: .css("tbody tr td").children[11] => Heart Machine
|
49
65
|
|
50
66
|
#name: deal.css("a.b").text => Earth 2160
|
51
67
|
#category: deal.css(".category").text => Weeklong Deal
|
data/spec.md
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: steam_deals_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hmelo1
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -117,6 +117,7 @@ files:
|
|
117
117
|
- bin/console
|
118
118
|
- bin/setup
|
119
119
|
- bin/steam_deals_cli
|
120
|
+
- config/environment.rb
|
120
121
|
- lib/steam_deals_cli.rb
|
121
122
|
- lib/steam_deals_cli/cli.rb
|
122
123
|
- lib/steam_deals_cli/deals_scraper.rb
|
@@ -124,6 +125,7 @@ files:
|
|
124
125
|
- lib/steam_deals_cli/version.rb
|
125
126
|
- planning_notes.txt
|
126
127
|
- spec.md
|
128
|
+
- steam_deals_cli-0.1.0.gem
|
127
129
|
- steam_deals_cli.gemspec
|
128
130
|
homepage: https://github.com/hmelo1/steam_deals_cli.git
|
129
131
|
licenses:
|