lomax 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 +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +61 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/run_lomax +8 -0
- data/bin/setup +8 -0
- data/lib/lomax.rb +17 -0
- data/lib/lomax/command_line_interface.rb +157 -0
- data/lib/lomax/place.rb +19 -0
- data/lib/lomax/recording.rb +19 -0
- data/lib/lomax/scraper.rb +105 -0
- data/lib/lomax/version.rb +3 -0
- data/lomax.gemspec +33 -0
- metadata +147 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: c724d91995c1faf03826505e82c363464bf2395f
|
|
4
|
+
data.tar.gz: e3cc2e1194fa4fad34d770aa33fa051ac4f864cc
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: b07dcf44cde5e450e3e19f3447e146413e5c7550994188e4480f533e1fa3a8b797f76aa480abf1c9c5c937952bc8369dc2798beee9b8ec0c10da083ac0b97e76
|
|
7
|
+
data.tar.gz: cd70883df1ff16edb4ee343f0a1d5ab14fab437ecc1edb2dc5bb5d4a7f2647d0d1738081d966ad3f6cd881c3fe163a94f7a1650852e3f6abe9430c6e6bf9ffef
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Contributor Code of Conduct
|
|
2
|
+
|
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
|
7
|
+
|
|
8
|
+
We are committed to making participation in this project a harassment-free
|
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
|
12
|
+
|
|
13
|
+
Examples of unacceptable behavior by participants include:
|
|
14
|
+
|
|
15
|
+
* The use of sexualized language or imagery
|
|
16
|
+
* Personal attacks
|
|
17
|
+
* Trolling or insulting/derogatory comments
|
|
18
|
+
* Public or private harassment
|
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
|
20
|
+
addresses, without explicit permission
|
|
21
|
+
* Other unethical or unprofessional conduct
|
|
22
|
+
|
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
27
|
+
threatening, offensive, or harmful.
|
|
28
|
+
|
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
|
32
|
+
Conduct may be permanently removed from the project team.
|
|
33
|
+
|
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
|
35
|
+
when an individual is representing the project or its community.
|
|
36
|
+
|
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
38
|
+
reported by contacting a project maintainer at nicolefederici@yahoo.com. All
|
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
|
42
|
+
incident.
|
|
43
|
+
|
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
45
|
+
version 1.3.0, available at
|
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
|
47
|
+
|
|
48
|
+
[homepage]: http://contributor-covenant.org
|
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 Nicole Federici
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 nicolefederici
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Lomax
|
|
2
|
+
This gem uses a command line interface to access the Alan Lomax Archive of Michigan Songs, a collection of field recordings of folk music sung by regular people, to display the songs they collected on their Michigan trip. Through this gem, the user can compare the songs in this archive to the complete AllMusic collection of the known recorded music throughout history, in order to discover which of the Lomax recordings were never otherwise recorded.
|
|
3
|
+
|
|
4
|
+
## Installation
|
|
5
|
+
|
|
6
|
+
Add this line to your application's Gemfile:
|
|
7
|
+
|
|
8
|
+
```ruby
|
|
9
|
+
gem 'lomax'
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
And then execute:
|
|
13
|
+
|
|
14
|
+
$ bundle
|
|
15
|
+
|
|
16
|
+
Or install it yourself as:
|
|
17
|
+
|
|
18
|
+
$ gem install lomax
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
1. The user types bin/run_lomax to get the gem running in the command line. This displays a welcome and list of Michigan cities.
|
|
23
|
+
|
|
24
|
+
2. The user chooses from a list of cities, in order to return the Lomax field recordings made there.
|
|
25
|
+
These items are displayed with: title, location, date, artists, and archivists.
|
|
26
|
+
|
|
27
|
+
3. The user chooses either:
|
|
28
|
+
a. a song to investigate further at AllMusic, in order to return all known recordings in the history of recorded music, in chronological order.
|
|
29
|
+
or
|
|
30
|
+
b. to leave the current list of songs and go back to the original list of cities to start again.
|
|
31
|
+
|
|
32
|
+
4. If the user chooses a., they will be taken to a new list of the AllMusic records for that song. Each item will list the title, date, recording artist(s), composer(s), album title, and label in chronological order.
|
|
33
|
+
|
|
34
|
+
5. After viewing this new list, the user will be asked to choose between:
|
|
35
|
+
a. seeing the Lomax recordings from another city in Michigan, which takes the user back to the original list.
|
|
36
|
+
or
|
|
37
|
+
b. leaving the program
|
|
38
|
+
|
|
39
|
+
6. If the user chooses to leave, she is asked if she wants to see all the songs from the Lomax Michigan Archive for which there are no other known recordings in history.
|
|
40
|
+
|
|
41
|
+
7. If the user chooses yes, the gem returns a list of these songs and their identifying information from the catalogue.
|
|
42
|
+
|
|
43
|
+
8. The program says goodbye.
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## Development
|
|
48
|
+
|
|
49
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
50
|
+
|
|
51
|
+
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).
|
|
52
|
+
|
|
53
|
+
## Contributing
|
|
54
|
+
|
|
55
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/nicolefederici/lomax. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
## License
|
|
59
|
+
|
|
60
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
61
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "lomax"
|
|
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
|
data/bin/run_lomax
ADDED
data/bin/setup
ADDED
data/lib/lomax.rb
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require_relative "./lomax/version.rb"
|
|
2
|
+
require_relative "./lomax/scraper.rb"
|
|
3
|
+
require_relative "./lomax/recording.rb"
|
|
4
|
+
require_relative "./lomax/command_line_interface.rb"
|
|
5
|
+
require_relative "./lomax/place.rb"
|
|
6
|
+
require 'nokogiri'
|
|
7
|
+
require 'pry'
|
|
8
|
+
require 'open-uri'
|
|
9
|
+
require 'uri'
|
|
10
|
+
|
|
11
|
+
module Lomax
|
|
12
|
+
# Your code goes here...(this came with the gem bundle..not sure why this is here.)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
#these are the gem's dependencies (nokogiri and pry), and the require relatives are what all has to activate together for the gem to work.
|
|
16
|
+
#they are all the classes called upon by the executable file.
|
|
17
|
+
# this is usually called the config file
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
class Lomax::CommandLineInterface
|
|
2
|
+
|
|
3
|
+
def display_places
|
|
4
|
+
places = Lomax::Scraper.get_places
|
|
5
|
+
places.each do |place|
|
|
6
|
+
puts place.name
|
|
7
|
+
end
|
|
8
|
+
puts
|
|
9
|
+
puts
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def display_recordings(place)
|
|
13
|
+
puts
|
|
14
|
+
puts
|
|
15
|
+
list_of_recordings = []
|
|
16
|
+
recordings = Lomax::Scraper.get_recordings(place)
|
|
17
|
+
recordings.each do |recording|
|
|
18
|
+
puts recording.title, recording.date
|
|
19
|
+
puts recording.contributors, recording.place.name
|
|
20
|
+
puts
|
|
21
|
+
puts
|
|
22
|
+
end
|
|
23
|
+
return recordings
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def valid_song_title?(title,joined_titles)
|
|
27
|
+
flag = true
|
|
28
|
+
while flag == true
|
|
29
|
+
if joined_titles.downcase.include?(title.downcase)
|
|
30
|
+
flag = false
|
|
31
|
+
else
|
|
32
|
+
puts "Please enter a valid song title."
|
|
33
|
+
title = gets.strip
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
return title
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def user_validation
|
|
40
|
+
puts
|
|
41
|
+
display_places
|
|
42
|
+
city_answer = gets.chomp #it is a string
|
|
43
|
+
places_array = Lomax::Place.all
|
|
44
|
+
choice = places_array.detect do |place|
|
|
45
|
+
place.name.downcase == city_answer.downcase
|
|
46
|
+
end
|
|
47
|
+
return choice
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def run
|
|
53
|
+
puts
|
|
54
|
+
puts"Hey! You're at the Library of Congress' Alan Lomax Collection of Michigan Recordings!"
|
|
55
|
+
puts
|
|
56
|
+
puts"Here's a list of the Michigan cities from which Mr.Lomax collected recordings."
|
|
57
|
+
puts
|
|
58
|
+
puts"Type the name of a city to view all the recordings he made there."
|
|
59
|
+
puts
|
|
60
|
+
puts
|
|
61
|
+
|
|
62
|
+
flag = nil
|
|
63
|
+
while flag == nil #these two lines basically say, "if everything remians as it now is..."
|
|
64
|
+
flag = user_validation
|
|
65
|
+
if flag != nil
|
|
66
|
+
recordings = display_recordings(flag)
|
|
67
|
+
titles_array = recordings.collect do|recording|
|
|
68
|
+
recording.title
|
|
69
|
+
end
|
|
70
|
+
joined_titles = titles_array.join(",")
|
|
71
|
+
|
|
72
|
+
puts
|
|
73
|
+
puts
|
|
74
|
+
puts"Would you like to see if there are any other available recordings of one of these songs on record?"
|
|
75
|
+
puts
|
|
76
|
+
puts "If so, I can access All Music's archive to return all the other known recordings of that song, including the artist(s) who recorded it, the album and label it first appeared on, and the year it was first recorded by that artist. And I'll do it in chronological order."
|
|
77
|
+
puts
|
|
78
|
+
puts "Type the name of a song you want to investigate, or type no, if you want to return to the beginning, with the original list of cities."
|
|
79
|
+
puts
|
|
80
|
+
|
|
81
|
+
title = gets.strip
|
|
82
|
+
|
|
83
|
+
if title.downcase == "no"
|
|
84
|
+
run
|
|
85
|
+
else
|
|
86
|
+
|
|
87
|
+
title = valid_song_title?(title,joined_titles)
|
|
88
|
+
|
|
89
|
+
all_music_return = Lomax::Scraper.get_all_music_songs_of(title)
|
|
90
|
+
#returns song hashes array with all the stuff anyone wants to know about other recordings.
|
|
91
|
+
|
|
92
|
+
if all_music_return.length == 0
|
|
93
|
+
puts
|
|
94
|
+
puts "Alan Lomax's field recording is the only available recording of this tune."
|
|
95
|
+
puts
|
|
96
|
+
else
|
|
97
|
+
all_music_return.sort_by! {|hash| hash[:year]}
|
|
98
|
+
all_music_return.each do |item|
|
|
99
|
+
puts "\ntitle: '#{item[:title]}'\nperformers: #{item[:performers]}\ncomposers: #{item[:composers]}\nyear recorded: #{item[:year]}\nalbum: #{item[:album]}\nlabel: #{item[:label]}\n"
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# maybe make an option to choose another song from that city?
|
|
105
|
+
|
|
106
|
+
else
|
|
107
|
+
puts "Alan Lomax didn't record anything in that city, at least not according to the Library of Congress' Collections. Choose a city from the list this time."
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
see_recordings_other_city?
|
|
112
|
+
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def nonce_list
|
|
117
|
+
places = Lomax::Place.all
|
|
118
|
+
places.each do |place|
|
|
119
|
+
recordings = Lomax::Scraper.get_recordings(place)
|
|
120
|
+
recordings.each do |recording|
|
|
121
|
+
title_array = recording.split_recording
|
|
122
|
+
title_array.each do |title_string|
|
|
123
|
+
nonce = Lomax::Scraper.get_li_s(title_string)
|
|
124
|
+
if nonce == true
|
|
125
|
+
puts place.name + " '#{title_string}'"
|
|
126
|
+
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def see_recordings_other_city?
|
|
134
|
+
puts
|
|
135
|
+
puts
|
|
136
|
+
puts "Would you like to see the recordings from another city in Michigan?"
|
|
137
|
+
puts
|
|
138
|
+
|
|
139
|
+
answer = gets.chomp
|
|
140
|
+
|
|
141
|
+
if answer.downcase == "yes"
|
|
142
|
+
run
|
|
143
|
+
else
|
|
144
|
+
puts "Before you go, would you like to see a list of all the nonce songs (songs of which this field recording is the only likely recording ever made) in the Alan Lomax Collection of Michigan Recordings?"
|
|
145
|
+
|
|
146
|
+
answer = gets.chomp
|
|
147
|
+
if answer == "yes"
|
|
148
|
+
nonce_list
|
|
149
|
+
end
|
|
150
|
+
puts
|
|
151
|
+
puts "See you next time, and keep singing!"
|
|
152
|
+
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
end
|
|
157
|
+
|
data/lib/lomax/place.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class Lomax::Place
|
|
2
|
+
|
|
3
|
+
attr_accessor :name, :count, :url, :recordings
|
|
4
|
+
@@all = []
|
|
5
|
+
|
|
6
|
+
def initialize(name,count,url)
|
|
7
|
+
@name = name
|
|
8
|
+
@count = count
|
|
9
|
+
@url = url
|
|
10
|
+
@recordings = []
|
|
11
|
+
@@all << self
|
|
12
|
+
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.all
|
|
16
|
+
@@all
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class Lomax::Recording
|
|
2
|
+
attr_accessor :title, :contributors, :date, :place
|
|
3
|
+
|
|
4
|
+
def initialize(title,contributors,date,place)
|
|
5
|
+
@title = title
|
|
6
|
+
@contributors = contributors
|
|
7
|
+
@date = date
|
|
8
|
+
@place = place
|
|
9
|
+
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def split_recording
|
|
13
|
+
separated_title = self.title.split("; ")
|
|
14
|
+
return separated_title
|
|
15
|
+
#this is an array
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
end
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
class Lomax::Scraper
|
|
2
|
+
|
|
3
|
+
def self.get_places
|
|
4
|
+
doc = Nokogiri::HTML(open('https://www.loc.gov/collections/alan-lomax-in-michigan/index/location/'))
|
|
5
|
+
places_array = []
|
|
6
|
+
doc.css(".index li").each do |item|
|
|
7
|
+
name = item.css("span.label").text
|
|
8
|
+
count = item.css("span.count").text
|
|
9
|
+
url = "https:" + item.css("a")[0]["href"]
|
|
10
|
+
if name != "United States" && name != "Michigan" && name != "Illinois" && name != "Chicago" && name != "Wisconsin"
|
|
11
|
+
places_array << Lomax::Place.new(name,count,url)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
return places_array
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.get_li_s(title_string) #this method returns true if it is a nonce song.
|
|
18
|
+
title = title_string.split(" ").join("+")
|
|
19
|
+
doc = Nokogiri::HTML(open(URI.escape("http://www.allmusic.com/search/songs/" + title)))
|
|
20
|
+
array = doc.css("li.song")
|
|
21
|
+
if array.length == 0
|
|
22
|
+
return true
|
|
23
|
+
else
|
|
24
|
+
return false
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.get_recordings(place)
|
|
29
|
+
doc = Nokogiri::HTML(open(place.url + "&c=150&st=list"))
|
|
30
|
+
recordings_array = []
|
|
31
|
+
doc.css(".search-results.list-view > li").each do |item|
|
|
32
|
+
title = item.css("div.description h2 a").text.strip
|
|
33
|
+
contributors = item.css("ul li.contributor span").text.strip
|
|
34
|
+
date = item.css("ul li.date span").text.strip
|
|
35
|
+
recordings_array << Lomax::Recording.new(title,contributors,date,place)
|
|
36
|
+
end
|
|
37
|
+
place.recordings = recordings_array
|
|
38
|
+
|
|
39
|
+
return recordings_array
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def self.split_composers_performers(array)
|
|
45
|
+
new_array = []
|
|
46
|
+
array.each do |item|
|
|
47
|
+
new_array << item.text.strip
|
|
48
|
+
end
|
|
49
|
+
hey = new_array.join(", ")
|
|
50
|
+
return hey
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def self.get_all_music_songs_of(title_string)
|
|
57
|
+
|
|
58
|
+
title = title_string.split(" ").join("+")
|
|
59
|
+
doc = Nokogiri::HTML(open(URI.escape("http://www.allmusic.com/search/songs/" + title)))
|
|
60
|
+
song_hashes_array = []
|
|
61
|
+
#this is an array of hashes
|
|
62
|
+
doc.css("li.song").each do |item|
|
|
63
|
+
professional_recordings_hash = {}
|
|
64
|
+
performers = item.css("div.performers a")#.text.strip
|
|
65
|
+
perf = self.split_composers_performers(performers)
|
|
66
|
+
composers = item.css("div.composers a")#.text.strip
|
|
67
|
+
comp = self.split_composers_performers(composers)
|
|
68
|
+
url = item.css("div.title a")[0]["href"]
|
|
69
|
+
|
|
70
|
+
#this is the trick for grabbing hfrefs out of the a tags- url is part of the actual tag, so when you select the a tag, you get an array and then you grab the first and only item of the array with [0], and then you ask for the value of the href attr., which is hash notation, in other words, even though div.title a[0] is an array with one thing in it- the url, we still have to use hash notation to access the actual url only, because nokogiri uses hash notation to model the attributes and values in html tags. ******** href is the key, and the url is the value of that key, so if we only want the url stuff, we need to give it the key so it spits out the value for us with no other bullshit, because you have to grab info from within the tag itself with the hrefs.
|
|
71
|
+
|
|
72
|
+
professional_recordings_hash = self.year_album_label(url)
|
|
73
|
+
professional_recordings_hash[:title] = title_string
|
|
74
|
+
professional_recordings_hash[:performers] = perf
|
|
75
|
+
professional_recordings_hash[:composers] = comp
|
|
76
|
+
professional_recordings_hash[:url] = url
|
|
77
|
+
|
|
78
|
+
song_hashes_array << professional_recordings_hash
|
|
79
|
+
end
|
|
80
|
+
return song_hashes_array
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
#this method should take in the url for each song return the year, album title, and label
|
|
86
|
+
def self.year_album_label(url)
|
|
87
|
+
|
|
88
|
+
doc = Nokogiri::HTML(open(url))
|
|
89
|
+
hash = {}
|
|
90
|
+
year = doc.css("tbody tr td.year")[0].text.strip
|
|
91
|
+
album = doc.css("td.artist-album div.title a")[0].text.strip
|
|
92
|
+
label = doc.css("tbody tr td.label")[0].text.strip
|
|
93
|
+
hash[:year] = year
|
|
94
|
+
hash[:album] = album
|
|
95
|
+
hash[:label] = label
|
|
96
|
+
return hash
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
data/lomax.gemspec
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'lomax/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "lomax"
|
|
8
|
+
spec.version = Lomax::VERSION
|
|
9
|
+
spec.authors = ["nicolefederici"]
|
|
10
|
+
spec.email = ["nicolefederici@yahoo.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = "Explores the Alan Lomax Collection of Michigan Songs and checks its collection for novel recordings against the records of AllMusic "
|
|
13
|
+
spec.description = "This gem uses a command line interface to access the Alan Lomax Archive of Michigan Songs, a collection of field recordings of folk music sung by regular people, to display the songs they collected on their Michigan trip. Through this gem, the user can compare the songs in this archive to the complete AllMusic collection of the known recorded music throughout history, in order to discover which of the Lomax recordings were never otherwise recorded."
|
|
14
|
+
spec.homepage = "https://github.com/nicolefederici/lomax"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
if spec.respond_to?(:metadata)
|
|
18
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
|
19
|
+
else
|
|
20
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
24
|
+
spec.bindir = "exe"
|
|
25
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
26
|
+
spec.require_paths = ["lib"]
|
|
27
|
+
|
|
28
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
|
29
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
30
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
31
|
+
spec.add_development_dependency "pry", "~> 0.10.0"
|
|
32
|
+
spec.add_dependency "nokogiri", '~> 1.6', '>= 1.6.6.2'
|
|
33
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: lomax
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- nicolefederici
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-07-08 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.11'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.11'
|
|
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: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.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.10.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.10.0
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: nokogiri
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '1.6'
|
|
76
|
+
- - ">="
|
|
77
|
+
- !ruby/object:Gem::Version
|
|
78
|
+
version: 1.6.6.2
|
|
79
|
+
type: :runtime
|
|
80
|
+
prerelease: false
|
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
82
|
+
requirements:
|
|
83
|
+
- - "~>"
|
|
84
|
+
- !ruby/object:Gem::Version
|
|
85
|
+
version: '1.6'
|
|
86
|
+
- - ">="
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: 1.6.6.2
|
|
89
|
+
description: This gem uses a command line interface to access the Alan Lomax Archive
|
|
90
|
+
of Michigan Songs, a collection of field recordings of folk music sung by regular
|
|
91
|
+
people, to display the songs they collected on their Michigan trip. Through this
|
|
92
|
+
gem, the user can compare the songs in this archive to the complete AllMusic collection
|
|
93
|
+
of the known recorded music throughout history, in order to discover which of the
|
|
94
|
+
Lomax recordings were never otherwise recorded.
|
|
95
|
+
email:
|
|
96
|
+
- nicolefederici@yahoo.com
|
|
97
|
+
executables: []
|
|
98
|
+
extensions: []
|
|
99
|
+
extra_rdoc_files: []
|
|
100
|
+
files:
|
|
101
|
+
- ".gitignore"
|
|
102
|
+
- ".rspec"
|
|
103
|
+
- ".travis.yml"
|
|
104
|
+
- CODE_OF_CONDUCT.md
|
|
105
|
+
- Gemfile
|
|
106
|
+
- LICENSE
|
|
107
|
+
- LICENSE.txt
|
|
108
|
+
- README.md
|
|
109
|
+
- Rakefile
|
|
110
|
+
- bin/console
|
|
111
|
+
- bin/run_lomax
|
|
112
|
+
- bin/setup
|
|
113
|
+
- lib/lomax.rb
|
|
114
|
+
- lib/lomax/command_line_interface.rb
|
|
115
|
+
- lib/lomax/place.rb
|
|
116
|
+
- lib/lomax/recording.rb
|
|
117
|
+
- lib/lomax/scraper.rb
|
|
118
|
+
- lib/lomax/version.rb
|
|
119
|
+
- lomax.gemspec
|
|
120
|
+
homepage: https://github.com/nicolefederici/lomax
|
|
121
|
+
licenses:
|
|
122
|
+
- MIT
|
|
123
|
+
metadata:
|
|
124
|
+
allowed_push_host: https://rubygems.org
|
|
125
|
+
post_install_message:
|
|
126
|
+
rdoc_options: []
|
|
127
|
+
require_paths:
|
|
128
|
+
- lib
|
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
130
|
+
requirements:
|
|
131
|
+
- - ">="
|
|
132
|
+
- !ruby/object:Gem::Version
|
|
133
|
+
version: '0'
|
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - ">="
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '0'
|
|
139
|
+
requirements: []
|
|
140
|
+
rubyforge_project:
|
|
141
|
+
rubygems_version: 2.4.5.1
|
|
142
|
+
signing_key:
|
|
143
|
+
specification_version: 4
|
|
144
|
+
summary: Explores the Alan Lomax Collection of Michigan Songs and checks its collection
|
|
145
|
+
for novel recordings against the records of AllMusic
|
|
146
|
+
test_files: []
|
|
147
|
+
has_rdoc:
|