steamdeals-cli-gem 0.1.4 → 1.0.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 +4 -4
- data/lib/steam_deals/cli.rb +45 -16
- data/lib/steam_deals/deal.rb +44 -14
- data/lib/steam_deals/version.rb +1 -1
- metadata +30 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: caa9a39d3f78d3e1ec50995cce8e06514cedce32
|
|
4
|
+
data.tar.gz: 3d16e726455354b738caee6e347cf0324ce9ed37
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dcd45098a8898a0c86ae4e71ecaeaed60d96ebf648d0f53ccf3e48e893caeed8708422c04c2056d6ec985c822303015e51d4666c5dfd46c47f5b58ef9610144a
|
|
7
|
+
data.tar.gz: 9763d98bfc2b0c6f2e1454561ac544329df1bca8bc3642630a231384cd14ad6b23b105fd91c8bea5e41dc1282d533d87b2b4c9986cc61ac8caf466fc5bf75d82
|
data/lib/steam_deals/cli.rb
CHANGED
|
@@ -1,42 +1,62 @@
|
|
|
1
1
|
class SteamDeals::CLI
|
|
2
2
|
|
|
3
3
|
def start
|
|
4
|
+
clear_terminal
|
|
4
5
|
input = ""
|
|
6
|
+
SteamDeals::Deal.scrape_sections
|
|
7
|
+
sections_length = SteamDeals::Deal.sections.length
|
|
5
8
|
while input != "exit"
|
|
6
9
|
puts "\nWhich Sale would you like to see?"
|
|
7
10
|
puts "---------------------------------"
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
SteamDeals::Deal.sections.each_with_index do |section, index|
|
|
12
|
+
puts "#{index+1}. #{section[:name]}\n"
|
|
13
|
+
end
|
|
10
14
|
puts "(Or type 'exit' to end program)\n"
|
|
15
|
+
|
|
11
16
|
input = gets.strip.downcase
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
display_daily_deals
|
|
15
|
-
when "2"
|
|
16
|
-
display_weeklong_deals
|
|
17
|
-
when "exit"
|
|
17
|
+
|
|
18
|
+
if input == "exit"
|
|
18
19
|
puts "\nGoodbye!"
|
|
20
|
+
elsif input.scan("/\D+/").length > 0
|
|
21
|
+
clear_terminal
|
|
22
|
+
puts "Invalid input. Please try again\n"
|
|
23
|
+
elsif input.to_i > sections_length || input.to_i < 1
|
|
24
|
+
clear_terminal
|
|
25
|
+
puts "Number out of range. Please try again\n"
|
|
19
26
|
else
|
|
20
|
-
|
|
27
|
+
display_section_deals(SteamDeals::Deal.section_at(input.to_i))
|
|
21
28
|
end
|
|
22
29
|
end
|
|
23
30
|
end
|
|
24
31
|
|
|
32
|
+
def display_section_deals(section)
|
|
33
|
+
clear_terminal
|
|
34
|
+
puts "Now retrieving #{section[:name]}. Please be patient."
|
|
35
|
+
SteamDeals::Deal.scrape_section_apps(section)
|
|
36
|
+
puts "\nHere are the apps listed for today's #{section[:name]}"
|
|
37
|
+
show_game_list
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
#removal later
|
|
25
41
|
def display_daily_deals
|
|
26
|
-
|
|
42
|
+
clear_terminal
|
|
43
|
+
puts "\nNow retrieving Daily Deals. Please be patient\n"
|
|
27
44
|
SteamDeals::Deal.scrape_daily_deals
|
|
28
45
|
puts "\nHere are the apps listed for today's Steam Daily Deals"
|
|
29
46
|
show_game_list
|
|
30
47
|
end
|
|
31
48
|
|
|
49
|
+
#removal later
|
|
32
50
|
def display_weeklong_deals
|
|
33
|
-
|
|
51
|
+
clear_terminal
|
|
52
|
+
puts "\nNow retrieving Weeklong Deals. Please be patient\n"
|
|
34
53
|
SteamDeals::Deal.scrape_weeklong_deals
|
|
35
54
|
puts "Here are the apps listed for today's Steam Weeklong Deals"
|
|
36
55
|
show_game_list
|
|
37
56
|
end
|
|
38
57
|
|
|
39
58
|
def display_details(game)
|
|
59
|
+
clear_terminal
|
|
40
60
|
input = ""
|
|
41
61
|
while input != "exit"
|
|
42
62
|
puts ""
|
|
@@ -54,25 +74,27 @@ class SteamDeals::CLI
|
|
|
54
74
|
show_app_details(game)
|
|
55
75
|
when "exit"
|
|
56
76
|
puts "\nReturning to menu\n"
|
|
77
|
+
clear_terminal
|
|
57
78
|
else
|
|
58
79
|
puts "\nInvalid input. Try again.\n"
|
|
59
80
|
end
|
|
60
|
-
|
|
61
81
|
end
|
|
62
82
|
end
|
|
63
83
|
|
|
64
84
|
def show_sale_details(game)
|
|
85
|
+
clear_terminal
|
|
65
86
|
puts "Loading sale details...\n\n"
|
|
66
87
|
puts "Here are the sale details"
|
|
67
88
|
puts "-------------------------"
|
|
68
89
|
puts "Name : #{game.name}"
|
|
69
|
-
puts "Discount : #{game.discount}"
|
|
90
|
+
puts "Discount : #{game.discount}, #{game.highest_discount}"
|
|
70
91
|
puts "Sale Price : #{game.price}"
|
|
71
92
|
puts "--------------------------"
|
|
72
93
|
puts ""
|
|
73
94
|
end
|
|
74
95
|
|
|
75
96
|
def show_app_details(game)
|
|
97
|
+
clear_terminal
|
|
76
98
|
puts "Loading Game Details...\n\n"
|
|
77
99
|
game.scrape_add_details
|
|
78
100
|
puts "Here are the app details"
|
|
@@ -91,10 +113,12 @@ class SteamDeals::CLI
|
|
|
91
113
|
end
|
|
92
114
|
|
|
93
115
|
def show_game_list
|
|
116
|
+
clear_terminal
|
|
94
117
|
input = ""
|
|
95
118
|
while input != "exit"
|
|
96
|
-
puts "
|
|
97
|
-
|
|
119
|
+
puts "Here are the apps..."
|
|
120
|
+
puts "---------------------------------------------------"
|
|
121
|
+
SteamDeals::Deal.apps.each.with_index(1) do |app, index|
|
|
98
122
|
puts "#{index}. #{app.name}"
|
|
99
123
|
end
|
|
100
124
|
puts " "
|
|
@@ -103,16 +127,21 @@ class SteamDeals::CLI
|
|
|
103
127
|
input = gets.chomp.downcase
|
|
104
128
|
|
|
105
129
|
if input.downcase == "exit"
|
|
130
|
+
clear_terminal
|
|
106
131
|
puts "\nReturning to previous menu\n"
|
|
107
132
|
elsif input.to_i > 0 && game = SteamDeals::Deal.app_at(input.to_i)
|
|
108
133
|
display_details(game)
|
|
109
134
|
else
|
|
135
|
+
clear_terminal
|
|
110
136
|
puts "\nInvalid input. Try again.\n"
|
|
111
137
|
puts "Reloading..."
|
|
112
138
|
sleep(1)
|
|
113
139
|
end
|
|
114
|
-
|
|
115
140
|
end
|
|
116
141
|
end
|
|
117
142
|
|
|
143
|
+
def clear_terminal
|
|
144
|
+
puts "\e[H\e[2J"
|
|
145
|
+
end
|
|
146
|
+
|
|
118
147
|
end
|
data/lib/steam_deals/deal.rb
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
require 'pry'
|
|
1
2
|
class SteamDeals::Deal
|
|
2
3
|
|
|
3
|
-
@@
|
|
4
|
+
@@apps = []
|
|
5
|
+
@@sections = []
|
|
4
6
|
|
|
5
|
-
attr_accessor :name, :discount, :price, :details_url, :app_type, :developer, :publisher, :supported_os, :app_desc
|
|
7
|
+
attr_accessor :name, :discount, :price, :details_url, :app_type, :developer, :publisher, :supported_os, :app_desc, :highest_discount
|
|
6
8
|
|
|
7
|
-
def initialize(name = "", url = "", discount = "", price = "")
|
|
9
|
+
def initialize(name = "", url = "", discount = "", price = "", highest_discount = "")
|
|
8
10
|
@name = name
|
|
9
11
|
@details_url = url
|
|
10
12
|
@discount = discount
|
|
13
|
+
@highest_discount = highest_discount
|
|
11
14
|
@price = price
|
|
12
15
|
@developer = "N/A"
|
|
13
16
|
@publisher = "N/A"
|
|
@@ -15,29 +18,56 @@ class SteamDeals::Deal
|
|
|
15
18
|
@app_desc = "N/A"
|
|
16
19
|
end
|
|
17
20
|
|
|
21
|
+
def self.scrape_sections
|
|
22
|
+
@@sections.clear
|
|
23
|
+
doc = Nokogiri::HTML(open("https://steamdb.info/sales/"))
|
|
24
|
+
section_css = doc.css(".sales-section")
|
|
25
|
+
while section_css.length > 0
|
|
26
|
+
target_section = section_css.shift
|
|
27
|
+
section_name = target_section.css(".pre-table-title a").text
|
|
28
|
+
@@sections << {name: section_name, css: target_section}
|
|
29
|
+
end
|
|
30
|
+
self.sections
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
#removal later
|
|
18
34
|
def self.scrape_weeklong_deals
|
|
19
|
-
@@
|
|
35
|
+
@@apps.clear
|
|
20
36
|
doc = Nokogiri::HTML(open("https://steamdb.info/sales/"))
|
|
21
37
|
app_list = doc.css("#sales-section-weeklong-deals .table-sales .appimg")
|
|
22
38
|
scrape_initial_details(app_list)
|
|
23
|
-
self.
|
|
39
|
+
self.apps
|
|
24
40
|
end
|
|
25
41
|
|
|
26
|
-
|
|
42
|
+
#removal later
|
|
27
43
|
def self.scrape_daily_deals
|
|
28
44
|
@@all.clear
|
|
29
45
|
doc = Nokogiri::HTML(open("https://steamdb.info/sales/"))
|
|
30
46
|
app_list = doc.css("#sales-section-daily-deal .table-sales .appimg")
|
|
31
47
|
scrape_initial_details(app_list)
|
|
32
|
-
self.
|
|
48
|
+
self.apps
|
|
33
49
|
end
|
|
34
50
|
|
|
35
|
-
def self.
|
|
36
|
-
@@
|
|
51
|
+
def self.apps
|
|
52
|
+
@@apps
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def self.sections
|
|
56
|
+
@@sections
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def self.section_at(num)
|
|
60
|
+
@@sections[num-1]
|
|
37
61
|
end
|
|
38
62
|
|
|
39
63
|
def self.app_at(num)
|
|
40
|
-
@@
|
|
64
|
+
@@apps[num-1]
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def self.scrape_section_apps(section)
|
|
68
|
+
@@apps.clear
|
|
69
|
+
app_list = section[:css].css(".table-sales .appimg")
|
|
70
|
+
scrape_initial_details(app_list)
|
|
41
71
|
end
|
|
42
72
|
|
|
43
73
|
|
|
@@ -45,11 +75,11 @@ class SteamDeals::Deal
|
|
|
45
75
|
app_list.each do |app|
|
|
46
76
|
app_name = app.css("a.b")[0].text
|
|
47
77
|
app_url ="https://steamdb.info/#{app.css("a.b")[0]["href"]}"
|
|
48
|
-
discount = app.css("
|
|
49
|
-
|
|
78
|
+
discount = app.css("td")[3].text
|
|
79
|
+
highest_discount = app.css("td")[2].css(".highest-discount").text
|
|
50
80
|
price = "#{app.css("td")[4].text}"
|
|
51
|
-
game = SteamDeals::Deal.new(app_name,app_url,discount,price)
|
|
52
|
-
@@
|
|
81
|
+
game = SteamDeals::Deal.new(app_name, app_url, discount, price, highest_discount)
|
|
82
|
+
@@apps << game
|
|
53
83
|
end
|
|
54
84
|
end
|
|
55
85
|
|
data/lib/steam_deals/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: steamdeals-cli-gem
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Justin Thomas
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-09-
|
|
11
|
+
date: 2016-09-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -110,6 +110,34 @@ dependencies:
|
|
|
110
110
|
- - ">="
|
|
111
111
|
- !ruby/object:Gem::Version
|
|
112
112
|
version: 0.10.3
|
|
113
|
+
- !ruby/object:Gem::Dependency
|
|
114
|
+
name: vcr
|
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
|
116
|
+
requirements:
|
|
117
|
+
- - ">="
|
|
118
|
+
- !ruby/object:Gem::Version
|
|
119
|
+
version: '0'
|
|
120
|
+
type: :development
|
|
121
|
+
prerelease: false
|
|
122
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
123
|
+
requirements:
|
|
124
|
+
- - ">="
|
|
125
|
+
- !ruby/object:Gem::Version
|
|
126
|
+
version: '0'
|
|
127
|
+
- !ruby/object:Gem::Dependency
|
|
128
|
+
name: webmock
|
|
129
|
+
requirement: !ruby/object:Gem::Requirement
|
|
130
|
+
requirements:
|
|
131
|
+
- - ">="
|
|
132
|
+
- !ruby/object:Gem::Version
|
|
133
|
+
version: '0'
|
|
134
|
+
type: :development
|
|
135
|
+
prerelease: false
|
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
137
|
+
requirements:
|
|
138
|
+
- - ">="
|
|
139
|
+
- !ruby/object:Gem::Version
|
|
140
|
+
version: '0'
|
|
113
141
|
description: Scrape steamdb.info for daily steam deals, provides name, sale price,
|
|
114
142
|
sale discount, and minor descriptions
|
|
115
143
|
email:
|