art_throughout_the_years 0.2.0 → 0.3.0

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: fb396ae7fb49549030b6ac87b1afff55bcbd5ac02daa54cc619fe27e40f30e22
4
- data.tar.gz: efaae192519c07131612f74d7b074f26e3e9abb41bb8339c9eb8dcf79f750127
3
+ metadata.gz: 1d1801fc1f2c289ebd44d3cc181b2c4e0fc7a56283fe2f43795b2c17c6d054c8
4
+ data.tar.gz: 49ee02f3f2ffdc15b97adf5d66b545581a068d9fb497c7c3bf888917d265943a
5
5
  SHA512:
6
- metadata.gz: d3ba00910a6eaabb7baf87924f14ccfbede128ab57e47b93f0d232d146766a198efc440552eadba26b90ae202ca76c11e071fd5696c7f31ca3c8ed25425f3eda
7
- data.tar.gz: 82003ac3e823346ea5f749b5ae963fc72f98a23910613864feb46dd00894ab002e5a316af61694873ac5a13c2c1692508552b17749f8b0735bba576134c9355c
6
+ metadata.gz: 5483bc8579ec37c8c81047c549f571d9774073fb4d30ee9e230fb496fcdf1c99dbe76761b591cdcb9337724e32d16453c7adb0b645a7dc8ca7911371ec24799c
7
+ data.tar.gz: 880731aed1cbe4804fd0da112c6dd0977b9dc7873a66bc4c155c8f1861a8ad4b880f3d26741dbd760ee8285e83b1725625109012876d048f841333552a43fbfc
@@ -1,5 +1,7 @@
1
1
  require 'nokogiri'
2
2
  require 'open-uri'
3
+ require 'pry'
4
+ require 'colorize'
3
5
 
4
6
  require_relative '../lib/scraper'
5
7
  require_relative '../lib/works_of_art'
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
- def start
11
- puts ""
12
- puts "************* ~The Most Popular Paintings Throughout History~ *************"
13
- puts ""
14
- end
3
+ def call
4
+ ArtThroughoutTheYears::Scraper.scrape_art
5
+ start
6
+ list_pieces
7
+ print_artwork
8
+ end
15
9
 
16
- def list_pieces
17
- puts "Please enter 'list' to view the list of painting below"
18
- puts ""
19
- input = gets.strip
20
- if input == "list"
21
- puts ""
22
- pieces = ArtThroughoutTheYears::WorksofArt.all
23
- pieces.each.with_index(1) {|piece, index| puts "#{index} #{piece.title_artist_year}"}
24
- else input == "exit"
25
- system "clear"
26
- exit
27
- list_pieces
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 print_artwork
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 > 0
36
- artwork = ArtThroughoutTheYears::WorksofArt.find_by_index(input.to_i - 1)
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 "Thank you for visiting, have a good day!"
52
+ puts "Work: --#{work.title.bold.cyan}--"
46
53
  puts ""
47
- else
54
+ puts "Information: --#{work.description}--"
48
55
  puts ""
49
- puts "View the list below"
50
- list_pieces
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
@@ -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('div.main_content.md-col-7.md-offset-1.xs-relative.xs-pt4.md-pt0').each do |art|
6
-
7
- title_artist_year = art.css("span.title-underline.theme-underline-static").text
8
- description = art.css("div.xs-text-7.xs-line-height-6.xs-text-charcoal").text
9
- ArtThroughoutTheYears::WorksofArt.new(index, title_artist_year, description)
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
+
@@ -1,9 +1,9 @@
1
1
  class ArtThroughoutTheYears::WorksofArt
2
- attr_accessor :title_artist_year, :description
2
+ attr_accessor :title, :description
3
3
 
4
4
  @@all = []
5
- def initialize(title_artist_year, description)
6
- @title_artist_year = title_artist_year
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.find_by_index(index)
16
- @@all[index]
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.2.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: 2019-12-27 00:00:00.000000000 Z
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.1.2
131
+ rubygems_version: 3.0.3
104
132
  signing_key:
105
133
  specification_version: 4
106
134
  summary: Art Throughout The Years