rumble_bundle 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/console +2 -6
- data/lib/rumble_bundle/cli.rb +24 -25
- data/lib/rumble_bundle/scraper.rb +4 -3
- data/lib/rumble_bundle/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cbbb97e4f38fa3191342d6d8072875577f7a925
|
4
|
+
data.tar.gz: 6dcbe80e6391adbdfe235418b33dd0b93d52fd9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9a0d95f33316f8000b54f7ed33a637b2e42a168b428e169a70346e2c81b6017bc89e22dbbb7de0190656630ebe0a8170c52a5cdeac6f2ee08cc09f77889783c
|
7
|
+
data.tar.gz: bff8b3d35d15b9aab216b8793c445a03c8a1125c9ac2946e33065c4abc36ef6c7bd2cf334fcf1330b733cf7e93bf0bd7eb6f6d942c971abd74b9e28ccb67d574
|
data/bin/console
CHANGED
@@ -3,14 +3,10 @@
|
|
3
3
|
require_relative '../config/environment'
|
4
4
|
|
5
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
|
-
|
10
|
-
|
11
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
12
6
|
require "pry"
|
13
7
|
Pry.start
|
14
8
|
|
9
|
+
|
10
|
+
|
15
11
|
# require "irb"
|
16
12
|
# IRB.start(__FILE__)
|
data/lib/rumble_bundle/cli.rb
CHANGED
@@ -2,9 +2,9 @@ class RumbleBundle::CLI
|
|
2
2
|
|
3
3
|
# Scrape site and allow user to begin browsing.
|
4
4
|
def start
|
5
|
-
puts
|
5
|
+
puts
|
6
6
|
puts "Fetching data from HumbleBundle.com..."
|
7
|
-
puts
|
7
|
+
puts
|
8
8
|
|
9
9
|
RumbleBundle::Scraper.new.crawl_site
|
10
10
|
|
@@ -18,10 +18,10 @@ class RumbleBundle::CLI
|
|
18
18
|
|
19
19
|
bundles = RumbleBundle::Bundle.all
|
20
20
|
|
21
|
-
puts
|
21
|
+
puts
|
22
22
|
puts "Enter a bundle's number to learn more, or enter 'help' for more commands."
|
23
23
|
puts "Enter 'quit' to leave the program."
|
24
|
-
puts
|
24
|
+
puts
|
25
25
|
|
26
26
|
# List Bundles in numbered order
|
27
27
|
bundles.each.with_index(1) do |bundle, i|
|
@@ -29,10 +29,10 @@ class RumbleBundle::CLI
|
|
29
29
|
end
|
30
30
|
|
31
31
|
# Get user input
|
32
|
-
puts
|
32
|
+
puts
|
33
33
|
print " "
|
34
34
|
input = gets.strip.downcase
|
35
|
-
puts
|
35
|
+
puts
|
36
36
|
|
37
37
|
# If input is a valid number, display the corresponding Bundle
|
38
38
|
if input.to_i.between?(1, bundles.length)
|
@@ -40,7 +40,7 @@ class RumbleBundle::CLI
|
|
40
40
|
|
41
41
|
# If input is an invalid number, restart #query
|
42
42
|
elsif input.to_i < 0 || input.to_i > bundles.length
|
43
|
-
puts
|
43
|
+
puts
|
44
44
|
puts "Sorry! Please enter a valid number or command."
|
45
45
|
query
|
46
46
|
|
@@ -80,30 +80,31 @@ class RumbleBundle::CLI
|
|
80
80
|
end
|
81
81
|
|
82
82
|
if filtered.any?
|
83
|
-
puts
|
83
|
+
puts
|
84
84
|
puts "Results for: #{valid}"
|
85
85
|
puts "---------------------------------------------------------------"
|
86
86
|
filtered.collect{|p| p.bundle }.uniq.each do |bundle|
|
87
87
|
puts "#{bundle.name} (#{bundle.url})"
|
88
|
-
puts
|
88
|
+
puts
|
89
89
|
bundle.tiers.each do |tier|
|
90
90
|
if filtered.detect{|p| p.tier == tier}
|
91
|
-
puts " #{tier.description}"
|
91
|
+
puts " #{tier.description}"
|
92
|
+
puts
|
92
93
|
filtered.each{|p| display_product(p) if p.tier == tier}
|
93
|
-
puts
|
94
|
+
puts
|
94
95
|
end
|
95
96
|
end
|
96
97
|
end
|
97
98
|
puts "---------------------------------------------------------------"
|
98
99
|
else
|
99
|
-
puts
|
100
|
+
puts
|
100
101
|
puts "Sorry! No results for: #{valid}"
|
101
102
|
puts "---------------------------------------------------------------"
|
102
103
|
puts "---------------------------------------------------------------"
|
103
104
|
end
|
104
105
|
|
105
106
|
else
|
106
|
-
puts
|
107
|
+
puts
|
107
108
|
puts "Sorry! Please enter a valid number or command."
|
108
109
|
query
|
109
110
|
|
@@ -119,19 +120,17 @@ class RumbleBundle::CLI
|
|
119
120
|
def display_bundle(bundle)
|
120
121
|
puts "---------------------------------------------------------------"
|
121
122
|
puts "#{bundle.name} (#{bundle.url})"
|
123
|
+
puts
|
122
124
|
puts "#{bundle.total_msrp}!"
|
123
|
-
puts
|
124
|
-
puts
|
125
|
-
|
126
|
-
|
127
|
-
puts ","
|
128
|
-
end
|
129
|
-
puts " or a Charity of Your Choice"
|
130
|
-
puts "", ""
|
125
|
+
puts
|
126
|
+
puts bundle.charities
|
127
|
+
puts
|
128
|
+
puts
|
131
129
|
bundle.tiers.each do |tier|
|
132
|
-
puts " #{tier.description}"
|
130
|
+
puts " #{tier.description}"
|
131
|
+
puts
|
133
132
|
tier.products.each{|p| display_product(p)}
|
134
|
-
puts
|
133
|
+
puts
|
135
134
|
end
|
136
135
|
puts "---------------------------------------------------------------"
|
137
136
|
|
@@ -143,9 +142,9 @@ class RumbleBundle::CLI
|
|
143
142
|
print " (#{product.platforms.join(", ")})" if product.platforms.any?
|
144
143
|
print " (DRM-Free!)" if product.drm_free
|
145
144
|
print " (w/Steam Key!)" if product.steam_key
|
146
|
-
puts
|
145
|
+
puts
|
147
146
|
puts " #{product.subtitle}" if product.subtitle
|
148
|
-
puts
|
147
|
+
puts
|
149
148
|
end
|
150
149
|
|
151
150
|
# Display help
|
@@ -4,7 +4,7 @@ class RumbleBundle::Scraper
|
|
4
4
|
# Set URLs used as starting points for scraping
|
5
5
|
@base_url = 'https://www.humblebundle.com'
|
6
6
|
@main_pages = [
|
7
|
-
'https://www.humblebundle.com/',
|
7
|
+
'https://www.humblebundle.com/software-bundle/',
|
8
8
|
'https://www.humblebundle.com/books/',
|
9
9
|
'https://www.humblebundle.com/mobile/']
|
10
10
|
end
|
@@ -44,7 +44,7 @@ class RumbleBundle::Scraper
|
|
44
44
|
|
45
45
|
bundle.name = html.css("title").text.chomp("(pay what you want and help charity)").strip
|
46
46
|
|
47
|
-
bundle.charities = html.css(".
|
47
|
+
bundle.charities = html.css(".hb-giftbox ~ div > .hr-tagline-popup").text.strip
|
48
48
|
|
49
49
|
bundle.total_msrp = html.css('.hr-tagline-text').detect{|e| e.text.include?("worth")}.text.strip
|
50
50
|
|
@@ -77,7 +77,8 @@ class RumbleBundle::Scraper
|
|
77
77
|
|
78
78
|
end
|
79
79
|
|
80
|
-
end
|
80
|
+
end unless html.at('button:contains("This Bundle is Over!")')
|
81
|
+
|
81
82
|
end
|
82
83
|
|
83
84
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rumble_bundle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noah Summers
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|