game_gem 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
+ SHA256:
3
+ metadata.gz: f4fb65665604a0674ea2de9735e4e3d9c1600f1ecd89717179f7a896f91149a9
4
+ data.tar.gz: b6e5929f5e97524acc03bc843af613e23bd9a41cb632bc3b87e4144d11203d7f
5
+ SHA512:
6
+ metadata.gz: 8290d2f1ca2e20ea764372d7dff2507d4819460932448d9faf97e3f700f81703bb62aeb5a2de38b798d969b7677f4981cb116f4a39bc7db8e38adb5b13c3e4c3
7
+ data.tar.gz: c03771b8913d9409ca06ae4eaf3ab0c4774e831a8ccfd256c429cbe5a03b58e689c4e47e0992d02dabdfd00368b887dc3dbb6f24a4e580b73d52ec5f3ed22f62
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "examples/now-playing-cli-gem"]
2
+ path = examples/now-playing-cli-gem
3
+ url = git@github.com:learn-co-curriculum/now-playing-cli-gem.git
data/.learn ADDED
@@ -0,0 +1,8 @@
1
+ tags:
2
+ - cli
3
+ - gem
4
+ - oo
5
+ languages:
6
+ - ruby
7
+ resources:
8
+ live_assessment: true
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,37 @@
1
+ # Contributing to Learn.co Curriculum
2
+
3
+ We're really exited that you're about to contribute to the [open curriculum](https://learn.co/content-license) on [Learn.co](https://learn.co). If this is your first time contributing, please continue reading to learn how to make the most meaningful and useful impact possible.
4
+
5
+ ## Raising an Issue to Encourage a Contribution
6
+
7
+ If you notice a problem with the curriculum that you believe needs improvement
8
+ but you're unable to make the change yourself, you should raise a Github issue
9
+ containing a clear description of the problem. Include relevant snippets of
10
+ the content and/or screenshots if applicable. Curriculum owners regularly review
11
+ issue lists and your issue will be prioritized and addressed as appropriate.
12
+
13
+ ## Submitting a Pull Request to Suggest an Improvement
14
+
15
+ If you see an opportunity for improvement and can make the change yourself go
16
+ ahead and use a typical git workflow to make it happen:
17
+
18
+ * Fork this curriculum repository
19
+ * Make the change on your fork, with descriptive commits in the standard format
20
+ * Open a Pull Request against this repo
21
+
22
+ A curriculum owner will review your change and approve or comment on it in due
23
+ course.
24
+
25
+ # Why Contribute?
26
+
27
+ Curriculum on Learn is publicly and freely available under Learn's
28
+ [Educational Content License](https://learn.co/content-license). By
29
+ embracing an open-source contribution model, our goal is for the curriculum
30
+ on Learn to become, in time, the best educational content the world has
31
+ ever seen.
32
+
33
+ We need help from the community of Learners to maintain and improve the
34
+ educational content. Everything from fixing typos, to correcting
35
+ out-dated information, to improving exposition, to adding better examples,
36
+ to fixing tests—all contributions to making the curriculum more effective are
37
+ welcome.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/VictoriaMeng/video-games-cli-gem" }
4
+
5
+ # gem 'require_all'
6
+ #
7
+ # group :development do
8
+ # gem "pry"
9
+ # end
10
+
11
+ # Specify your gem's dependencies in game_gem.gemspec
12
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,47 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ game_gem (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.2)
10
+ diff-lcs (1.3)
11
+ method_source (0.9.0)
12
+ mini_portile2 (2.3.0)
13
+ nokogiri (1.8.2)
14
+ mini_portile2 (~> 2.3.0)
15
+ pry (0.11.3)
16
+ coderay (~> 1.1.0)
17
+ method_source (~> 0.9.0)
18
+ rake (10.5.0)
19
+ require_all (2.0.0)
20
+ rspec (3.7.0)
21
+ rspec-core (~> 3.7.0)
22
+ rspec-expectations (~> 3.7.0)
23
+ rspec-mocks (~> 3.7.0)
24
+ rspec-core (3.7.1)
25
+ rspec-support (~> 3.7.0)
26
+ rspec-expectations (3.7.0)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.7.0)
29
+ rspec-mocks (3.7.0)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.7.0)
32
+ rspec-support (3.7.1)
33
+
34
+ PLATFORMS
35
+ ruby
36
+
37
+ DEPENDENCIES
38
+ bundler (~> 1.16)
39
+ game_gem!
40
+ nokogiri
41
+ pry
42
+ rake (~> 10.0)
43
+ require_all
44
+ rspec
45
+
46
+ BUNDLED WITH
47
+ 1.16.1
data/LICENSE.md ADDED
@@ -0,0 +1,7 @@
1
+ #Learn.co Educational Content License
2
+
3
+ Copyright (c) 2015 Flatiron School, Inc
4
+
5
+ The Flatiron School, Inc. owns this Educational Content. However, the Flatiron School supports the development and availability of educational materials in the public domain. Therefore, the Flatiron School grants Users of the Flatiron Educational Content set forth in this repository certain rights to reuse, build upon and share such Educational Content subject to the terms of the Educational Content License set forth [here](http://learn.co/content-license) (http://learn.co/content-license). You must read carefully the terms and conditions contained in the Educational Content License as such terms govern access to and use of the Educational Content.
6
+
7
+ Flatiron School is willing to allow you access to and use of the Educational Content only on the condition that you accept all of the terms and conditions contained in the Educational Content License set forth [here](http://learn.co/content-license) (http://learn.co/content-license). By accessing and/or using the Educational Content, you are agreeing to all of the terms and conditions contained in the Educational Content License. If you do not agree to any or all of the terms of the Educational Content License, you are prohibited from accessing, reviewing or using in any way the Educational Content.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # GameGem
2
+
3
+ This CLI Gem scrapes a list of the top 30 games from the Steam "Top-Sellers" list (URL at http://store.steampowered.com/) and prints them out to the console.
4
+
5
+ Once the list if printed, users may view games from the list by entering the game's number. This allows them to view the final discounted price of each game.
6
+
7
+ Then, they may return to the main menu and view other games from the list or exit the app.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'game_gem'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install game_gem
24
+
25
+ ## Usage
26
+
27
+ Enter (1-30) to view game details at the main menu.
28
+
29
+ When viewing a game's specific details, enter 'y' to to view another game, or 'n' to quit the app.
30
+
31
+ ## Development
32
+
33
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
34
+
35
+ 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).
36
+
37
+ ## Contributing
38
+
39
+ Bug reports and pull requests are welcome on GitHub at https://github.com/'VictoriaMeng'/game_gem.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "game_gem"
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
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/game_gem.rb'
4
+
5
+ GameCli.new.run
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/game_gem.gemspec ADDED
@@ -0,0 +1,32 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "game_gem/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "game_gem"
8
+ spec.version = GameGem::VERSION
9
+ spec.authors = ["'Victoria Meng'"]
10
+ spec.email = ["'nights1ststar@protonmail.com'"]
11
+
12
+ spec.summary = %q{Scrapes and prints top-selling video games on Steam}
13
+ spec.description = %q{Scrapes and prints top-selling video games on Steam}
14
+ spec.homepage = "https://github.com/VictoriaMeng/video-games-cli-gem"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+
19
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
20
+ f.match(%r{^(test|spec|features)/})
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.16"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rspec"
29
+ spec.add_development_dependency "pry"
30
+ spec.add_development_dependency "require_all"
31
+ spec.add_development_dependency "nokogiri"
32
+ end
data/lib/game_gem.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'bundler'
2
+ require 'require_all'
3
+ require 'pry'
4
+ require 'nokogiri'
5
+ require "open-uri"
6
+
7
+ Bundler.require
8
+
9
+ require_all 'lib'
@@ -0,0 +1,18 @@
1
+ class Game
2
+ attr_accessor :name, :price
3
+
4
+ @@all = []
5
+
6
+ def initialize(attributes)
7
+ attributes.each { |key, value| self.send("#{key}=", value) }
8
+ end
9
+
10
+ def self.mass_create(games)
11
+ games.each { |game| @@all << Game.new(game) if !game[:name].empty? }
12
+ end
13
+
14
+ def self.all
15
+ @@all
16
+ end
17
+
18
+ end
@@ -0,0 +1,88 @@
1
+ require_relative 'game.rb'
2
+
3
+ class GameCli
4
+ def initialize
5
+ game_hashes
6
+ end
7
+
8
+ def say_hi
9
+ puts "Welcome to Steam Top-Sellers."
10
+ end
11
+
12
+ def show_instructions
13
+ puts "Enter (1-30) to see game details or 'q' to quit."
14
+ end
15
+
16
+ def show_list
17
+ Game.all.each_with_index do |game, index|
18
+ puts "#{index + 1}. #{game.name}"
19
+ end
20
+ end
21
+
22
+ def game_hashes
23
+ Game.mass_create(GameScraper.new.run)
24
+ end
25
+
26
+ def valid_number?(input)
27
+ ("1".."30").to_a.include?(input)
28
+ end
29
+
30
+ def quit?(input)
31
+ %w(quit q exit e).include?(input.downcase)
32
+ end
33
+
34
+ def valid_menu_option?(input)
35
+ valid_number?(input) || quit?(input)
36
+ end
37
+
38
+ def get_input
39
+ input = ""
40
+ until valid_menu_option?(input)
41
+ show_instructions
42
+ show_list
43
+ input = gets.strip
44
+ end
45
+ input
46
+ end
47
+
48
+ def show_game(input)
49
+ game = Game.all[input.to_i - 1]
50
+ puts "Name: #{game.name}"
51
+ puts "Price: #{game.price}"
52
+ end
53
+
54
+ def yes_no?(input)
55
+ %w(y n yes no).include?(input.downcase)
56
+ end
57
+
58
+ def yes?(input)
59
+ %w(y yes).include?(input.downcase)
60
+ end
61
+
62
+ def show_continue_message
63
+ puts "See another game? (y/n)"
64
+ end
65
+
66
+ def continue?
67
+ input = ""
68
+ until yes_no?(input)
69
+ show_continue_message
70
+ input = gets.strip
71
+ end
72
+ yes?(input)
73
+ end
74
+
75
+ def say_bye
76
+ puts "Thanks for using GameGem!"
77
+ end
78
+
79
+ def run
80
+ say_hi
81
+ loop do
82
+ input = get_input
83
+ quit?(input) ? break : show_game(input)
84
+ break if !continue?
85
+ end
86
+ say_bye
87
+ end
88
+ end
@@ -0,0 +1,17 @@
1
+ class GameScraper
2
+
3
+ def initialize
4
+ @html = Nokogiri::HTML(open("http://store.steampowered.com/"))
5
+ @games_html = @html.css("#tab_topsellers_content a")
6
+ end
7
+
8
+ def run
9
+ @games_html.map do |game|
10
+ fields = {}
11
+ fields[:name] = game.css(".tab_item_name").text
12
+ fields[:price] = game.css(".discount_final_price").text
13
+ fields
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,3 @@
1
+ module GameGem
2
+ VERSION = "0.1.0"
3
+ end
data/spec.md ADDED
@@ -0,0 +1,11 @@
1
+ # Specifications for the CLI Assessment
2
+
3
+ Specs:
4
+ - [x] Have a CLI for interfacing with the application
5
+ - Running ./bin/run after installing the gem successfuly runs the app.
6
+ - [X] Pull data from an external source
7
+ - The app scrapes data from http://store.steampowered.com/
8
+ - CSS selectors used are "#tab_topsellers_content a", ".tab_item_name", and ".discount_final_price".
9
+ - [X] Implement both list and detail views
10
+ - Main menu brings up list of top 30 best-selling games.
11
+ - Entering 1-30 selects game from list to view prices.
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: game_gem
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - "'Victoria Meng'"
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-04-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.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
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: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '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: require_all
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: nokogiri
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: Scrapes and prints top-selling video games on Steam
98
+ email:
99
+ - "'nights1ststar@protonmail.com'"
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".gitmodules"
106
+ - ".learn"
107
+ - CONTRIBUTING.md
108
+ - Gemfile
109
+ - Gemfile.lock
110
+ - LICENSE.md
111
+ - README.md
112
+ - Rakefile
113
+ - bin/console
114
+ - bin/run
115
+ - bin/setup
116
+ - game_gem.gemspec
117
+ - lib/game_gem.rb
118
+ - lib/game_gem/game.rb
119
+ - lib/game_gem/gamecli.rb
120
+ - lib/game_gem/gamescraper.rb
121
+ - lib/game_gem/version.rb
122
+ - spec.md
123
+ homepage: https://github.com/VictoriaMeng/video-games-cli-gem
124
+ licenses: []
125
+ metadata: {}
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
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.7.6
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: Scrapes and prints top-selling video games on Steam
146
+ test_files: []