mozart-symphonies 0.1.1
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 +7 -0
- data/bin/mozart-symphonies +5 -0
- data/config/environment.rb +7 -0
- data/lib/mozart/cli.rb +57 -0
- data/lib/mozart/scraper.rb +54 -0
- data/lib/mozart/symphony.rb +35 -0
- data/lib/mozart/version.rb +3 -0
- data/lib/symphonies.rb +7 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 285f47613acf0b0613a172bc5189b9a3fc3872bb
|
4
|
+
data.tar.gz: 840022ffa5c9f684edaaf7fc38430390dbd65d9d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3412d581c0c5c60664dc8d65be788f96cac6026a197cab1f9d3430d78dd631f8f937c73300c24fa52471f4dbbc4f7e588176e3821b53b282cd885609f1b2e9ce
|
7
|
+
data.tar.gz: 36b5c254b31e19abb8ac3b36ab3526a217e72b580188500a274a738d8813d3fbfb02618696a715cec56146bccfd8d041aa7eba94a15e233bf1432097cad5d672
|
data/lib/mozart/cli.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
class Mozart::CLI
|
2
|
+
|
3
|
+
def call
|
4
|
+
puts ""
|
5
|
+
puts "WELCOME TO THE DESCRIPTION OF SYMPHONIES OF THE WORLD'S GREATEST COMPOSER OF ALL TIME!"
|
6
|
+
puts ""
|
7
|
+
puts "Would you like to see the list of symphonies by Wolfgang Amadeus Mozart? y/n:"
|
8
|
+
input = gets.chomp.downcase
|
9
|
+
if input == "y"
|
10
|
+
puts "\t\n"
|
11
|
+
scraper = Mozart::Symphony.scraper
|
12
|
+
scraper.print_the_title
|
13
|
+
puts " ---------------------------------------------"
|
14
|
+
scraper.scrape_symphonies_index
|
15
|
+
puts ""
|
16
|
+
scraper.print_symphonies_index
|
17
|
+
puts ""
|
18
|
+
start
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def start
|
23
|
+
puts "Please enter the number of the symphony you would like more information on:"
|
24
|
+
input = gets.chomp.to_i
|
25
|
+
if !input.between?(1, 61)
|
26
|
+
puts ""
|
27
|
+
puts "Please enter a number from 1 to 61!"
|
28
|
+
puts ""
|
29
|
+
start
|
30
|
+
end
|
31
|
+
symphony = Mozart::Symphony.find(input)
|
32
|
+
puts "\t\n"
|
33
|
+
puts symphony.name_with_number.upcase
|
34
|
+
puts "\t\n"
|
35
|
+
puts "\t\t\t\t\t\t================== Description of the Symphony =================="
|
36
|
+
puts "\t\n"
|
37
|
+
puts symphony.description
|
38
|
+
puts "\t\n"
|
39
|
+
puts "\t\t\t\t\t\t================================================================="
|
40
|
+
puts "\t\n"
|
41
|
+
puts "Would you like to find out more about another symphony? y/n:"
|
42
|
+
input = gets.chomp.downcase
|
43
|
+
if input == "y"
|
44
|
+
start
|
45
|
+
else
|
46
|
+
puts "\t\n"
|
47
|
+
puts "Thank you for your interest! Have a great day, and welcome again in the future!"
|
48
|
+
puts "\t\n"
|
49
|
+
puts "\t\t\t**************************"
|
50
|
+
puts "\t\n"
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'pry'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'open-uri'
|
4
|
+
|
5
|
+
class Mozart::Scraper
|
6
|
+
|
7
|
+
def get_page
|
8
|
+
Nokogiri::HTML(open('https://en.wikipedia.org/wiki/List_of_symphonies_by_Wolfgang_Amadeus_Mozart'))
|
9
|
+
end
|
10
|
+
|
11
|
+
def print_the_title
|
12
|
+
puts " #{self.get_page.css('h1').text}"
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def scrape_symphonies_index
|
17
|
+
self.get_page.css(".sorttext")[0..60].each { |el| Mozart::Symphony.new("#{el.text}, #{el.css("a").attr("title").text}", "https://en.wikipedia.org" + el.css("a").attr("href").text) }
|
18
|
+
end
|
19
|
+
|
20
|
+
def print_symphonies_index
|
21
|
+
Mozart::Symphony.all.each.with_index do |el, index|
|
22
|
+
puts "#{index+1}.\t#{el.name[/(.*)\s/,1]}"
|
23
|
+
end
|
24
|
+
nil
|
25
|
+
end
|
26
|
+
|
27
|
+
def print_symphonies_urls
|
28
|
+
Mozart::Symphony.all.each.with_index { |el, index| puts "#{index+1}.\t#{el.url}" }
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_symphony_page(url)
|
33
|
+
Nokogiri::HTML(open(url))
|
34
|
+
end
|
35
|
+
|
36
|
+
def scrape_symphony_name_with_number(url)
|
37
|
+
self.get_symphony_page(url).css(".mw-parser-output p b").text
|
38
|
+
end
|
39
|
+
|
40
|
+
def scrape_symphony_description(url)
|
41
|
+
self.get_symphony_page(url).css("p").text
|
42
|
+
end
|
43
|
+
|
44
|
+
# The following methods only scrape first 11 elements:
|
45
|
+
|
46
|
+
# def scrape_keys
|
47
|
+
# self.get_page.css("td").css("a")[0..60].each { |el| puts el.attr("title") }
|
48
|
+
# end
|
49
|
+
|
50
|
+
# def scrape_years
|
51
|
+
# self.get_page.css("td")[0..60].each { |el| puts el.text }
|
52
|
+
# end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class Mozart::Symphony
|
2
|
+
|
3
|
+
attr_accessor :name, :description, :url
|
4
|
+
|
5
|
+
@@all = []
|
6
|
+
|
7
|
+
def initialize(name=nil, url=nil)
|
8
|
+
@name = name
|
9
|
+
@url = url
|
10
|
+
@@all << self
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.all
|
14
|
+
@@all
|
15
|
+
end
|
16
|
+
|
17
|
+
@@scraper = Mozart::Scraper.new
|
18
|
+
|
19
|
+
def self.scraper
|
20
|
+
@@scraper
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.find(number)
|
24
|
+
self.all[number - 1]
|
25
|
+
end
|
26
|
+
|
27
|
+
def name_with_number
|
28
|
+
@@scraper.scrape_symphony_name_with_number(@url)
|
29
|
+
end
|
30
|
+
|
31
|
+
def description
|
32
|
+
@@scraper.scrape_symphony_description(@url)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
data/lib/symphonies.rb
ADDED
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mozart-symphonies
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "'Igor Eskin'"
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-07-31 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.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
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: nokogiri
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.8'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.8'
|
55
|
+
description: |-
|
56
|
+
This application allows the user to scrape and display the complete list of all symphonies
|
57
|
+
by W.A. Mozart as well as descriptions of each symphony's historical background, what instruments the symphony
|
58
|
+
is scored for and other interesting details.
|
59
|
+
email:
|
60
|
+
- "'eskinhd@gmail.com'"
|
61
|
+
executables:
|
62
|
+
- mozart-symphonies
|
63
|
+
extensions: []
|
64
|
+
extra_rdoc_files: []
|
65
|
+
files:
|
66
|
+
- bin/mozart-symphonies
|
67
|
+
- config/environment.rb
|
68
|
+
- lib/mozart/cli.rb
|
69
|
+
- lib/mozart/scraper.rb
|
70
|
+
- lib/mozart/symphony.rb
|
71
|
+
- lib/mozart/version.rb
|
72
|
+
- lib/symphonies.rb
|
73
|
+
homepage: https://github.com/igoreskin/mozart-symphonies-cli-gem
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.6.11
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: List and descriptions of symphonies by Wolfgang Amadeus Mozart from Wikipedia.
|
97
|
+
test_files: []
|