art_throughout_the_years 0.2.0 → 0.3.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/config/environment.rb +2 -0
- data/lib/cli.rb +51 -41
- data/lib/scraper.rb +8 -6
- data/lib/works_of_art.rb +9 -5
- metadata +31 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d1801fc1f2c289ebd44d3cc181b2c4e0fc7a56283fe2f43795b2c17c6d054c8
|
4
|
+
data.tar.gz: 49ee02f3f2ffdc15b97adf5d66b545581a068d9fb497c7c3bf888917d265943a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5483bc8579ec37c8c81047c549f571d9774073fb4d30ee9e230fb496fcdf1c99dbe76761b591cdcb9337724e32d16453c7adb0b645a7dc8ca7911371ec24799c
|
7
|
+
data.tar.gz: 880731aed1cbe4804fd0da112c6dd0977b9dc7873a66bc4c155c8f1861a8ad4b880f3d26741dbd760ee8285e83b1725625109012876d048f841333552a43fbfc
|
data/config/environment.rb
CHANGED
data/lib/cli.rb
CHANGED
@@ -1,53 +1,63 @@
|
|
1
1
|
class ArtThroughoutTheYears::CLI
|
2
|
-
|
3
|
-
def call
|
4
|
-
ArtThroughoutTheYears::Scraper.scrape_art
|
5
|
-
start
|
6
|
-
list_pieces
|
7
|
-
print_artwork
|
8
|
-
end
|
9
2
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
3
|
+
def call
|
4
|
+
ArtThroughoutTheYears::Scraper.scrape_art
|
5
|
+
start
|
6
|
+
list_pieces
|
7
|
+
print_artwork
|
8
|
+
end
|
15
9
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
10
|
+
def start
|
11
|
+
puts ""
|
12
|
+
puts "-------- ~The Most Popular Paintings in History~ --------".bold.underline.green
|
13
|
+
puts ""
|
14
|
+
end
|
15
|
+
|
16
|
+
def list_pieces
|
17
|
+
puts "To see a list of works of art type list.".bold.italic.blue
|
18
|
+
input = gets.strip
|
19
|
+
if input =="list"
|
20
|
+
puts ""
|
21
|
+
works = ArtThroughoutTheYears::WorksofArt.all.each.with_index(1) do |work, index|
|
22
|
+
puts "#{index}) #{work.title}".cyan
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def print_artwork
|
28
|
+
puts "Please enter the number of the listed work you would like to view or exit.".bold.italic.blue
|
29
|
+
input = gets.strip
|
30
|
+
if input.to_i < 24
|
31
|
+
work = ArtThroughoutTheYears::WorksofArt.find(input.to_i)
|
32
|
+
puts ""
|
33
|
+
puts "Work: --#{work.title.bold.cyan}--"
|
34
|
+
puts ""
|
35
|
+
puts "Information: --#{work.description}--"
|
36
|
+
puts ""
|
37
|
+
next_choice
|
38
|
+
elsif input == "exit"
|
39
|
+
puts "Thank you for visiting!".bold.italic.blue
|
40
|
+
else input.to_i > 23
|
41
|
+
puts "Please enter a valid number of listed work."
|
42
|
+
print_artwork
|
28
43
|
end
|
29
44
|
end
|
30
45
|
|
31
|
-
def
|
32
|
-
puts ""
|
33
|
-
puts "Please enter the number of the listed work you would like to view."
|
46
|
+
def next_choice
|
47
|
+
puts "Please enter another number of the listed work or enter exit to leave the program.".bold.italic.blue
|
34
48
|
input = gets.strip
|
35
|
-
if input
|
36
|
-
|
37
|
-
puts ""
|
38
|
-
puts "-------------- #{artwork.title_artist_year} --------------"
|
39
|
-
puts ""
|
40
|
-
puts "Information: #{artwork.description}"
|
41
|
-
puts ""
|
42
|
-
print_artwork
|
43
|
-
elsif input == "Exit"
|
49
|
+
if input.to_i < 24
|
50
|
+
work = ArtThroughoutTheYears::WorksofArt.find(input.to_i)
|
44
51
|
puts ""
|
45
|
-
puts "
|
52
|
+
puts "Work: --#{work.title.bold.cyan}--"
|
46
53
|
puts ""
|
47
|
-
|
54
|
+
puts "Information: --#{work.description}--"
|
48
55
|
puts ""
|
49
|
-
|
50
|
-
|
56
|
+
next_choice
|
57
|
+
elsif input == "exit"
|
58
|
+
puts "Thank you for visiting, have a nice day!".bold.italic.blue
|
59
|
+
else
|
60
|
+
next_choice
|
51
61
|
end
|
52
62
|
end
|
53
|
-
end
|
63
|
+
end
|
data/lib/scraper.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
+
require 'pry'
|
1
2
|
class ArtThroughoutTheYears::Scraper
|
2
3
|
|
3
4
|
def self.scrape_art
|
4
5
|
doc = Nokogiri::HTML(open("https://www.timeout.com/newyork/art/top-famous-paintings-in-art-history-ranked"))
|
5
|
-
doc.css('
|
6
|
-
|
7
|
-
|
8
|
-
description =
|
9
|
-
ArtThroughoutTheYears::WorksofArt.new(
|
6
|
+
doc.css('article .listCard').each do |art_node|
|
7
|
+
|
8
|
+
title = art_node.css('h3').text.strip
|
9
|
+
description = art_node.css("p").text.strip
|
10
|
+
ArtThroughoutTheYears::WorksofArt.new(title, description)
|
10
11
|
end
|
11
12
|
end
|
12
|
-
end
|
13
|
+
end
|
14
|
+
|
data/lib/works_of_art.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
class ArtThroughoutTheYears::WorksofArt
|
2
|
-
attr_accessor :
|
2
|
+
attr_accessor :title, :description
|
3
3
|
|
4
4
|
@@all = []
|
5
|
-
def initialize(
|
6
|
-
@
|
5
|
+
def initialize(title=nil, description=nil)
|
6
|
+
@title = title
|
7
7
|
@description = description
|
8
8
|
@@all << self
|
9
9
|
end
|
@@ -12,7 +12,11 @@ class ArtThroughoutTheYears::WorksofArt
|
|
12
12
|
@@all
|
13
13
|
end
|
14
14
|
|
15
|
-
def self.
|
16
|
-
|
15
|
+
def self.new_from_index_page(r)
|
16
|
+
self.new(art.css("div.MFP-Home-Content-Artwork-Text").text)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.find(id)
|
20
|
+
@@all[id-1]
|
17
21
|
end
|
18
22
|
end
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: art_throughout_the_years
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "'Christina Gonzalez'"
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colorize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: bundler
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
128
|
- !ruby/object:Gem::Version
|
101
129
|
version: '0'
|
102
130
|
requirements: []
|
103
|
-
rubygems_version: 3.
|
131
|
+
rubygems_version: 3.0.3
|
104
132
|
signing_key:
|
105
133
|
specification_version: 4
|
106
134
|
summary: Art Throughout The Years
|