looperman_samples 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +8 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +45 -0
- data/LICENSE.txt +21 -0
- data/Notes.md +33 -0
- data/README.md +41 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/looperman_samples +6 -0
- data/bin/setup +8 -0
- data/lib/looperman_samples/cli.rb +75 -0
- data/lib/looperman_samples/concerns/findable.rb +24 -0
- data/lib/looperman_samples/creator.rb +42 -0
- data/lib/looperman_samples/sample.rb +58 -0
- data/lib/looperman_samples/sample_scraper.rb +53 -0
- data/lib/looperman_samples/version.rb +3 -0
- data/lib/looperman_samples.rb +14 -0
- data/looperman_samples.gemspec +36 -0
- metadata +134 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 992a177d456ea1f5ed7f23c13901cbdb9f19b837c402d9f7b38b4094a06c5038
|
4
|
+
data.tar.gz: f2dd53b140003f44ab2878d6ec0fa6a8390be7eb69ba884563a991447a2f3709
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 65302a08e11985c26ce84af7036b16268ffb67a4dafbaa8339f2b021fc415b4789dd9638d50af6ece5ac61d5cf78e62ee635b86c5ee63a94976125d6f51abf01
|
7
|
+
data.tar.gz: f91720e44bb6fbc617eb457d6fd8119e370ea2845626b9f7bb572dfabed8d93d185d4a6179bd427ea49a65748c4185609eee40b5d73f18b036daf90100da6ac8
|
data/.DS_Store
ADDED
Binary file
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at 'harleymteden@gmail.com'. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
looperman_samples (0.1.0)
|
5
|
+
nokogiri
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
coderay (1.1.2)
|
11
|
+
diff-lcs (1.3)
|
12
|
+
method_source (0.9.0)
|
13
|
+
mini_portile2 (2.3.0)
|
14
|
+
nokogiri (1.8.4)
|
15
|
+
mini_portile2 (~> 2.3.0)
|
16
|
+
pry (0.11.3)
|
17
|
+
coderay (~> 1.1.0)
|
18
|
+
method_source (~> 0.9.0)
|
19
|
+
rake (10.4.2)
|
20
|
+
rspec (3.8.0)
|
21
|
+
rspec-core (~> 3.8.0)
|
22
|
+
rspec-expectations (~> 3.8.0)
|
23
|
+
rspec-mocks (~> 3.8.0)
|
24
|
+
rspec-core (3.8.0)
|
25
|
+
rspec-support (~> 3.8.0)
|
26
|
+
rspec-expectations (3.8.1)
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
+
rspec-support (~> 3.8.0)
|
29
|
+
rspec-mocks (3.8.0)
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
+
rspec-support (~> 3.8.0)
|
32
|
+
rspec-support (3.8.0)
|
33
|
+
|
34
|
+
PLATFORMS
|
35
|
+
ruby
|
36
|
+
|
37
|
+
DEPENDENCIES
|
38
|
+
bundler (~> 1.16)
|
39
|
+
looperman_samples!
|
40
|
+
pry (~> 0)
|
41
|
+
rake (~> 10.0)
|
42
|
+
rspec (~> 3.2)
|
43
|
+
|
44
|
+
BUNDLED WITH
|
45
|
+
1.16.6
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 'Harley Rayner'
|
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/Notes.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
GEM outline:
|
2
|
+
every time the user scrapes samples, they're saved permanently in the samples class. the sample class will therefore hold an ever-increasing number of samples that the user can browse, play, download etc.
|
3
|
+
|
4
|
+
CLI:
|
5
|
+
1. there are x new samples today. how would you like to browse?
|
6
|
+
|
7
|
+
1. browse samples by key
|
8
|
+
2. browse samples by tempo
|
9
|
+
3. browse samples by number of downloads
|
10
|
+
|
11
|
+
|
12
|
+
2. returns a list of samples sorted in the order chosen - which sample would you like to play (push the number or push and hold the number for continuous play)?
|
13
|
+
|
14
|
+
1. “808 nightmare” - 1A
|
15
|
+
2. “mom’s spaghetti” - 1A
|
16
|
+
|
17
|
+
|
18
|
+
3. currently playing “mom's spaghetti” by emin3m
|
19
|
+
|
20
|
+
5. type “download” to download the current file, "next" go to the next sample, "back" to go to the previous sample or "list" to return to list view. type "exit" to quit. Or type "creator" to see more from the creator of this sample.
|
21
|
+
|
22
|
+
if user types download, download commences,
|
23
|
+
if user types next, the next track will load
|
24
|
+
if user types back, the last track will load
|
25
|
+
if user types creator, a list of all of the creators samples will load
|
26
|
+
|
27
|
+
|
28
|
+
Classes:
|
29
|
+
sample_scraper class - scrapes samples from a given web page
|
30
|
+
sample class - creates object given the output from the sample_scraper class (hash of data).
|
31
|
+
- has a name, has a creator, has a title, has a key, has a download_count, has a url, has a bpm
|
32
|
+
creator class - one creator can have many samples
|
33
|
+
cli class - runs all the business logic
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# LoopermanSamples
|
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/splice_soundpacks`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'looperman_samples'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install looperman-samples
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
After installation
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
|
+
|
29
|
+
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).
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/'harleyharl'/splice_soundpacks. 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.
|
34
|
+
|
35
|
+
## License
|
36
|
+
|
37
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
38
|
+
|
39
|
+
## Code of Conduct
|
40
|
+
|
41
|
+
Everyone interacting in the LoopermanSamples project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/harleyharl/looperman_samples/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "looperman_samples"
|
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(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# our CLI controller
|
2
|
+
|
3
|
+
class LoopermanSamples::CLI
|
4
|
+
|
5
|
+
def call
|
6
|
+
LoopermanSamples::SampleScraper.scrape_samples
|
7
|
+
main_menu
|
8
|
+
play
|
9
|
+
goodbye
|
10
|
+
end
|
11
|
+
|
12
|
+
def main_menu
|
13
|
+
puts "There are 25 new samples today. how would you like to browse?"
|
14
|
+
puts "1. browse samples by key"
|
15
|
+
puts "2. browse samples by tempo"
|
16
|
+
puts "3. browse samples by download count"
|
17
|
+
input = gets.strip
|
18
|
+
if input == "1"
|
19
|
+
LoopermanSamples::Sample.list_samples_by_key
|
20
|
+
$sample_list = LoopermanSamples::Sample.all.sort {|a, b| a.key <=> b.key}
|
21
|
+
elsif input == "2"
|
22
|
+
LoopermanSamples::Sample.list_samples_by_tempo
|
23
|
+
$sample_list = LoopermanSamples::Sample.all.sort {|a, b| b.bpm.to_i <=> a.bpm.to_i}
|
24
|
+
elsif input == "3"
|
25
|
+
LoopermanSamples::Sample.list_samples_by_download_count
|
26
|
+
$sample_list = LoopermanSamples::Sample.all.sort {|a, b| b.download_count.to_i <=> a.download_count.to_i}
|
27
|
+
else
|
28
|
+
puts "sorry, not sure what you want"
|
29
|
+
main_menu
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# controls the play sequence
|
34
|
+
def play
|
35
|
+
input = nil
|
36
|
+
loop do
|
37
|
+
puts "please enter the number of the sample you'd like to listen to or type exit:"
|
38
|
+
input = gets.strip
|
39
|
+
if input.to_i < $sample_list.size + 1 && input.to_i > 0
|
40
|
+
# binding.pry
|
41
|
+
sample = $sample_list[input.to_i - 1]
|
42
|
+
puts "You're listening to #{sample.title} by #{sample.creator.name}"
|
43
|
+
puts "would you like to hear more from #{sample.creator.name}? (type yes or no)"
|
44
|
+
input = gets.strip
|
45
|
+
if input == "yes"
|
46
|
+
more_samples_by_creator(sample)
|
47
|
+
elsif input == "no"
|
48
|
+
main_menu
|
49
|
+
end
|
50
|
+
# puts "Ok!"
|
51
|
+
elsif input.to_i > LoopermanSamples::Sample.all.size
|
52
|
+
puts "please enter a lower number"
|
53
|
+
else
|
54
|
+
break
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def more_samples_by_creator(sample)
|
60
|
+
# sets $samples_by_creator to equal a collection of samples by given creator
|
61
|
+
LoopermanSamples::SampleScraper.scrape_more_samples_by_creator(sample.creator)
|
62
|
+
# displays a numbered list of those samples
|
63
|
+
LoopermanSamples::Creator.list_all_samples_by_creator #what is this
|
64
|
+
# sets the sample list to be used in play mode
|
65
|
+
$sample_list = $samples_by_creator
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
def goodbye
|
71
|
+
puts "see you tomorrow for more samples!"
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Concerns
|
2
|
+
module Findable
|
3
|
+
def find_by_name(thing_name)
|
4
|
+
# detect stops on the first thing it finds that matches the condition and returns that value
|
5
|
+
self.all.detect do |thing|
|
6
|
+
thing.name == thing_name
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def find_or_create_by_name(thing_name)
|
11
|
+
if self.find_by_name(thing_name) == nil #if the song isn't in there
|
12
|
+
self.create(thing_name) #make a new song
|
13
|
+
else self.find_by_name(thing_name) != nil #if the song is in there
|
14
|
+
self.find_by_name(thing_name) # find it and return it
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def find_all_by_creator(creator)
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module LoopermanSamples
|
2
|
+
|
3
|
+
class Creator
|
4
|
+
|
5
|
+
attr_accessor :name, :samples
|
6
|
+
|
7
|
+
# creator class - a creator has a name and can have many samples
|
8
|
+
@@creators = []
|
9
|
+
|
10
|
+
def self.all
|
11
|
+
@@creators
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(name = nil)
|
15
|
+
@name = name
|
16
|
+
@samples = []
|
17
|
+
@@creators << self
|
18
|
+
end
|
19
|
+
|
20
|
+
# def samples
|
21
|
+
# Sample.all.select do |sample|
|
22
|
+
# sample.creator = self
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
|
26
|
+
#adds the sample into the creator's repertoire
|
27
|
+
def add_sample(sample)
|
28
|
+
sample.creator = self unless sample.creator
|
29
|
+
self.samples << sample unless self.samples.include?(sample)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.list_all_samples_by_creator
|
33
|
+
# binding.pry
|
34
|
+
$samples_by_creator.each_with_index do |sample, index|
|
35
|
+
puts "#{index + 1}." + " #{sample.title}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# require_relative './concerns/findable.rb'
|
2
|
+
|
3
|
+
module LoopermanSamples
|
4
|
+
class Sample
|
5
|
+
|
6
|
+
# extend Concerns::Findable
|
7
|
+
# responsible for knowing about all of the samples
|
8
|
+
|
9
|
+
attr_accessor :title, :key, :download_count, :url, :creator, :bpm, :genre
|
10
|
+
@@all = []
|
11
|
+
|
12
|
+
def self.all
|
13
|
+
@@all
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(title = nil, creator = nil, genre = nil)
|
17
|
+
@title = title
|
18
|
+
self.creator = creator if creator
|
19
|
+
self.genre = genre if genre
|
20
|
+
end
|
21
|
+
|
22
|
+
def creator=(creator)
|
23
|
+
@creator = creator
|
24
|
+
creator.add_sample(self)
|
25
|
+
end
|
26
|
+
|
27
|
+
def genre=(genre)
|
28
|
+
@genre = genre
|
29
|
+
creator.add_genre(self)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.list_samples_by_key
|
33
|
+
#sort the samples by key and return as a numbered list
|
34
|
+
samples_sorted_by_key = LoopermanSamples::Sample.all.sort {|a, b| a.key <=> b.key}
|
35
|
+
samples_sorted_by_key.each_with_index do |item, index|
|
36
|
+
puts "#{index + 1}." + " #{item.title} - " + "#{item.key}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.list_samples_by_tempo
|
41
|
+
#sort the samples by tempo(bpm) and return as a numbered list
|
42
|
+
samples_sorted_by_tempo = LoopermanSamples::Sample.all.sort {|a, b| b.bpm.to_i <=> a.bpm.to_i}
|
43
|
+
samples_sorted_by_tempo.each_with_index do |item, index|
|
44
|
+
puts "#{index + 1}." + " #{item.title}" + "- #{item.bpm}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.list_samples_by_download_count
|
49
|
+
#sort the samples by download count and return as a numbered list
|
50
|
+
samples_sorted_by_download_count = LoopermanSamples::Sample.all.sort {|a, b| b.download_count.to_i <=> a.download_count.to_i}
|
51
|
+
samples_sorted_by_download_count.each_with_index do |item, index|
|
52
|
+
puts "#{index + 1}." + " #{item.title}" + " - #{item.download_count} downloads"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
|
2
|
+
module LoopermanSamples
|
3
|
+
class SampleScraper
|
4
|
+
|
5
|
+
# uses nokogiri's output to instantiate sample and creator objects and assign them attributes, then establishes the sample-creator relationship
|
6
|
+
# there will be 25 samples from the front page of looperman
|
7
|
+
|
8
|
+
def self.scrape_samples
|
9
|
+
doc = Nokogiri::HTML(open("https://www.looperman.com/loops?page=1&order=downloads&dir=d&when=1")) #goes to search for most downloaded in past 24 hours
|
10
|
+
doc.css("div#body-content").css("div div.player-wrapper").each do |sample_bundle|
|
11
|
+
#instantiates new sample and provides it with scraped attributes
|
12
|
+
the_sample = Sample.new
|
13
|
+
the_sample.title = sample_bundle.css(".player-title").text
|
14
|
+
the_sample.url = sample_bundle.css("div .player-stats-wrapper").css("a").attr("href").text
|
15
|
+
the_sample.download_count = sample_bundle.css("div .player-stats-wrapper").css(".stats-downloads").text
|
16
|
+
#instantiates a new sample and establishes sample-creator relationship
|
17
|
+
sample_creator = Creator.new
|
18
|
+
sample_creator.name = sample_bundle.css(".player-sub-title").css(".icon-user").text
|
19
|
+
the_sample.creator = sample_creator
|
20
|
+
#dives into the sample's url to retrieve "bpm" and "key" tags
|
21
|
+
sample_page = Nokogiri::HTML(open(the_sample.url))
|
22
|
+
the_sample.bpm = sample_page.css("div .tag-wrapper a").text.match(/\d\d\d\s(bpm)/).to_s
|
23
|
+
the_sample.key = sample_page.css("div .tag-wrapper a").text.match(/(Key)\s[:]\s\w/).to_s
|
24
|
+
#makes key either "unknown" or single letter
|
25
|
+
if the_sample.key == "Key : U"
|
26
|
+
the_sample.key = "Key unknown"
|
27
|
+
else
|
28
|
+
the_sample.key = the_sample.key.sub(/(Key)\s[:]\s/, "")
|
29
|
+
end
|
30
|
+
#inserts the sample into the Sample.all array
|
31
|
+
Sample.all << the_sample
|
32
|
+
end
|
33
|
+
Sample.all
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.scrape_more_samples_by_creator(sample_creator)
|
37
|
+
# binding.pry
|
38
|
+
$samples_by_creator = []
|
39
|
+
doc = Nokogiri::HTML(open("https://www.looperman.com/loops?mid=#{sample_creator.name}"))
|
40
|
+
doc.css("div#body-content").css("div div.player-wrapper").each do |sample_bundle|
|
41
|
+
the_sample = Sample.new
|
42
|
+
the_sample.title = sample_bundle.css(".player-title").text
|
43
|
+
# binding.pry
|
44
|
+
the_sample.creator = sample_creator
|
45
|
+
#overwrites each time CLI used
|
46
|
+
$samples_by_creator << the_sample
|
47
|
+
$samples_by_creator
|
48
|
+
# sample
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# require "open-uri"
|
2
|
+
# require "nokogiri"
|
3
|
+
# require "pry"
|
4
|
+
require_relative "./looperman_samples/version"
|
5
|
+
require_relative "./looperman_samples/cli"
|
6
|
+
require_relative "./looperman_samples/sample"
|
7
|
+
require_relative "./looperman_samples/sample_scraper"
|
8
|
+
require_relative "./looperman_samples/creator"
|
9
|
+
|
10
|
+
class LoopermanSamples
|
11
|
+
def self.hi
|
12
|
+
puts "Hello world!"
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "looperman_samples/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "looperman_samples"
|
8
|
+
spec.version = LoopermanSamples::VERSION
|
9
|
+
spec.authors = ["'Harley Rayner'"]
|
10
|
+
spec.email = ["'harleymteden@gmail.com'"]
|
11
|
+
|
12
|
+
spec.summary = %q{"this is a ruby gem CLI for scraping samples from looperman"}
|
13
|
+
spec.description = %q{.}
|
14
|
+
spec.homepage = "https://github.com/harleyharl/looperman_samples"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
end
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_development_dependency "rspec", "~> 3.2"
|
30
|
+
|
31
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
32
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
33
|
+
spec.add_development_dependency "pry", '~> 0'
|
34
|
+
|
35
|
+
spec.add_dependency "nokogiri"
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: looperman_samples
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "'Harley Rayner'"
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-04-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.2'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.16'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.16'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.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'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '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: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: "."
|
84
|
+
email:
|
85
|
+
- "'harleymteden@gmail.com'"
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".DS_Store"
|
91
|
+
- ".gitignore"
|
92
|
+
- CODE_OF_CONDUCT.md
|
93
|
+
- Gemfile
|
94
|
+
- Gemfile.lock
|
95
|
+
- LICENSE.txt
|
96
|
+
- Notes.md
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- bin/console
|
100
|
+
- bin/looperman_samples
|
101
|
+
- bin/setup
|
102
|
+
- lib/looperman_samples.rb
|
103
|
+
- lib/looperman_samples/cli.rb
|
104
|
+
- lib/looperman_samples/concerns/findable.rb
|
105
|
+
- lib/looperman_samples/creator.rb
|
106
|
+
- lib/looperman_samples/sample.rb
|
107
|
+
- lib/looperman_samples/sample_scraper.rb
|
108
|
+
- lib/looperman_samples/version.rb
|
109
|
+
- looperman_samples.gemspec
|
110
|
+
homepage: https://github.com/harleyharl/looperman_samples
|
111
|
+
licenses:
|
112
|
+
- MIT
|
113
|
+
metadata: {}
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 2.7.8
|
131
|
+
signing_key:
|
132
|
+
specification_version: 4
|
133
|
+
summary: '"this is a ruby gem CLI for scraping samples from looperman"'
|
134
|
+
test_files: []
|