scrape_got 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae29e5087ce0907585158ec6112f9f3464f2a9d24f5c6340185589f9abe61ff8
4
- data.tar.gz: c1a38db328b0a67768136d609a0dae772bee3778d012c5de02df7cb477a8dffd
3
+ metadata.gz: 5871e9a144c33f888653770d112dc0b83bb569c9a17a230efb104940f25197e5
4
+ data.tar.gz: 447b1252e7bb09fe2bab56900c3325d96d5dae7d02476e021211ecab1ab704af
5
5
  SHA512:
6
- metadata.gz: 763104261af7e033088450af38dcfd80b338dc2223754661f754893d73cba87694638759dbdcbd075a6725c1eff6ee7e06b60f078f26fe14e2dd7737a8691489
7
- data.tar.gz: 4a395193ec0657f83fe6881fa4721a04ad6e6fda309f1f2f433a16f0a166946fe6ccdf442aa37dd10ff6722e12486fb4ae855cb53144d2d9a384ea608dfbdd2a
6
+ metadata.gz: 5116def5f330d7599e296c0c66c3cc565923b07465a90d3185fa625bc6110601cac1ea72ff2cdd8e570569811443c6a180bd1d2cd3e4a041d689fc79bd259eef
7
+ data.tar.gz: 75c394ef7cc43fe4098020d7579ddec23592258a8931a1291fb721763d89b8a0b26fcdcb88cfd5820df226034d9eaccf0afc7503eb18d547d3264ac23586522c
@@ -1,14 +1,22 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- scrape_got (0.1.0)
4
+ scrape_got (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  coderay (1.1.3)
10
+ colorize (0.8.1)
10
11
  gem-release (2.1.1)
12
+ httparty (0.18.1)
13
+ mime-types (~> 3.0)
14
+ multi_xml (>= 0.5.2)
11
15
  method_source (1.0.0)
16
+ mime-types (3.3.1)
17
+ mime-types-data (~> 3.2015)
18
+ mime-types-data (3.2020.0512)
19
+ multi_xml (0.6.0)
12
20
  pry (0.13.1)
13
21
  coderay (~> 1.1)
14
22
  method_source (~> 1.0)
@@ -18,7 +26,9 @@ PLATFORMS
18
26
  ruby
19
27
 
20
28
  DEPENDENCIES
29
+ colorize
21
30
  gem-release
31
+ httparty
22
32
  pry
23
33
  rake (~> 12.0)
24
34
  scrape_got!
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # ScrapeGot
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/scrape_got`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Welcome to Scrape_Got, I scrape and I know things!
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ I'm a current student at the [Flatiron School](https://flatironschool.com/) and this is my CLI Project. This CLI gem scrapes data from [An API of Ice and Fire](https://anapioficeandfire.com/). It displays a simple menu to the user and gives them a choice of seeing all the books or 20 houses. This was a fun learning experience and I hope to flesh it out further as my knowledge improves. :P
6
6
 
7
7
  ## Installation
8
8
 
@@ -22,7 +22,7 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ Once the gem is installed enter 'scrape_got' into the command line to start Scrape_Got. The user will be presented with options to follow on screen.
26
26
 
27
27
  ## Development
28
28
 
@@ -32,7 +32,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
32
 
33
33
  ## Contributing
34
34
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/scrape_got.
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ByteSizeMagic/scrape_got.
36
36
 
37
37
 
38
38
  ## License
@@ -1,7 +1,10 @@
1
- require "pry"
2
1
  require_relative "./scrape_got/version"
3
2
  require_relative "./scrape_got/cli"
4
3
  require_relative "./scrape_got/api"
4
+ require_relative "./scrape_got/houses"
5
+ require_relative "./scrape_got/books"
6
+
7
+
5
8
 
6
9
  module ScrapeGot
7
10
  class Error < StandardError; end
@@ -1,3 +1,20 @@
1
- class ScrapeGot::API
1
+ require 'pry'
2
+ require 'httparty'
2
3
 
4
+ module ScrapeGot
5
+ class API
6
+
7
+ def self.get_books
8
+ response = HTTParty.get("https://www.anapioficeandfire.com/api/books?page=1&pageSize=20")
9
+ body = response.body
10
+ @data = JSON.parse(body)
11
+ end
12
+
13
+ def self.get_houses
14
+ response = HTTParty.get("https://www.anapioficeandfire.com/api/houses?page=1&pageSize=20")
15
+ body = response.body
16
+ @data = JSON.parse(body)
17
+ end
18
+
19
+ end
3
20
  end
@@ -0,0 +1,30 @@
1
+ module ScrapeGot
2
+ class Books
3
+
4
+ attr_accessor :name, :number_of_pages, :released
5
+
6
+
7
+ def self.all_books
8
+ @@all_books ||= self.load_books
9
+ end
10
+
11
+ def self.load_books
12
+ API.get_books.collect do |book_hash|
13
+ Books.new(book_hash)
14
+ end
15
+ end
16
+
17
+ def initialize(attributes = {})
18
+ @name = attributes["name"]
19
+ @number_of_pages = attributes["numberOfPages"]
20
+ @released = attributes["released"]
21
+ end
22
+
23
+ def self.print_books
24
+ Books.all_books.each.with_index(1) do |book, index|
25
+ puts "Book #{index}: #{book.name}, released: #{book.released}"
26
+ end
27
+ end
28
+
29
+ end
30
+ end
@@ -1,42 +1,59 @@
1
- class ScrapeGot::CLI
2
- def run
3
- system("clear")
4
- greeting
5
- puts "___________________________\nPlease choose an option: "
6
- @user_input = nil
7
- menu
8
- while @user_input != "exit"
9
- @user_input = gets.strip.downcase
10
- if @user_input == "1"
11
- print_articles
12
- elsif @user_input == "2"
13
- "puts more here"
14
- elsif @user_input == "exit"
15
- break
16
- else
17
- puts "Please enter a menu item number or 'exit' to exit the program"
18
- end
19
- end
20
- binding.pry
21
- end_program
22
- end
1
+ require 'colorize'
23
2
 
24
- def greeting
25
- puts " ... Welcome to ... \nI scrape and I know things!\n "
3
+ module ScrapeGot
4
+ class CLI
26
5
 
27
- end
6
+ def run
7
+ system("clear")
8
+ greeting
9
+ Books.all_books
10
+ Houses.all_houses
11
+
12
+ @user_input = nil
13
+ menu
14
+ while @user_input != "exit"
15
+ @user_input = gets.strip.downcase
16
+ if @user_input == "1"
17
+ puts "List Books:".colorize(:light_yellow)
18
+ Books.print_books
19
+ menu
20
+ elsif @user_input == "2"
21
+ puts "List Houses:".colorize(:light_yellow)
22
+ Houses.print_houses
23
+ menu
24
+ else
25
+ @user_input == "exit" ? break : display_menu_message
26
+ end
27
+ end
28
+ end_program
29
+ end
28
30
 
29
- def menu
30
- puts <<-MENU
31
- 1. List Articles
32
- 2. To see next page of articles.
33
- Enter 'exit' to exit program.
34
- MENU
35
- end
36
-
37
- def end_program
38
- puts "Thanks for checking out I scrape and I know things, see ya soon!"
39
- end
31
+ def greeting
32
+ puts " ... Welcome to ... \n I scrape and I know things!\n ".colorize(:light_yellow)
33
+ end
40
34
 
35
+ def menu
36
+ display_line
37
+ puts "Please choose an option: "
38
+ puts <<-MENU
39
+ 1. List All Books
40
+ 2. List 20 Houses
41
+ MENU
42
+ display_menu_message
43
+ end
41
44
 
45
+ def display_menu_message
46
+ puts "Please enter a menu item number or type " + "exit".colorize(:red) + " to exit the program"
47
+ end
48
+
49
+ def display_line
50
+ puts "___________________________________\n".colorize(:light_yellow)
51
+ end
52
+
53
+ def end_program
54
+ puts "Thanks for checking out I scrape and I know things, see ya soon!".colorize(:light_yellow)
55
+ display_line
56
+ end
57
+
58
+ end
42
59
  end
@@ -0,0 +1,34 @@
1
+ module ScrapeGot
2
+ class Houses
3
+
4
+ attr_accessor :name, :coat, :region, :words
5
+
6
+
7
+ def self.all_houses
8
+ @@all_houses ||= self.load_houses
9
+ end
10
+
11
+ def self.load_houses
12
+ API.get_houses.collect do |houses_hash|
13
+ Houses.new(houses_hash)
14
+ end
15
+ end
16
+
17
+ def initialize(attributes = {})
18
+ @name = attributes["name"]
19
+ @coat = attributes["coatOfArms"]
20
+ @region = attributes["region"]
21
+ @words = attributes["words"]
22
+ end
23
+
24
+ def self.print_houses
25
+ Houses.all_houses.each.with_index(1) do |house, index|
26
+ puts "#{index} #{house.name}: #{house.words}"
27
+ puts "Coat of Arms: #{house.coat}"
28
+ puts "Region: #{house.region}"
29
+ puts "-----------------------------------".colorize(:light_yellow)
30
+ end
31
+ end
32
+
33
+ end
34
+ end
@@ -1,3 +1,3 @@
1
1
  module ScrapeGot
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -1,3 +1,5 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
1
3
  require_relative 'lib/scrape_got/version'
2
4
 
3
5
  Gem::Specification.new do |spec|
@@ -29,4 +31,6 @@ Gem::Specification.new do |spec|
29
31
 
30
32
  spec.add_development_dependency "pry"
31
33
  spec.add_development_dependency "gem-release"
34
+ spec.add_development_dependency "httparty"
35
+ spec.add_development_dependency "colorize"
32
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrape_got
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ByteSizeMagic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-13 00:00:00.000000000 Z
11
+ date: 2020-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: httparty
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: colorize
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'
41
69
  description: I scrape and I know things. Provides a CLI to run and find info about
42
70
  Game of Thrones.
43
71
  email:
@@ -58,7 +86,9 @@ files:
58
86
  - bin/setup
59
87
  - lib/scrape_got.rb
60
88
  - lib/scrape_got/api.rb
89
+ - lib/scrape_got/books.rb
61
90
  - lib/scrape_got/cli.rb
91
+ - lib/scrape_got/houses.rb
62
92
  - lib/scrape_got/version.rb
63
93
  - scrape_got.gemspec
64
94
  homepage: https://github.com/ByteSizeMagic/scrape_got
@@ -83,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
113
  - !ruby/object:Gem::Version
84
114
  version: '0'
85
115
  requirements: []
86
- rubygems_version: 3.1.2
116
+ rubygems_version: 3.0.8
87
117
  signing_key:
88
118
  specification_version: 4
89
119
  summary: Game of Thrones scraping CLI gem