beatport_play-scraper 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e75138c2d5f1402ec10f217b80e0f104fa249096
4
+ data.tar.gz: 3936bcd093310fc2027637fedc18beedaeaaa792
5
+ SHA512:
6
+ metadata.gz: 5be6070deead4274d9e48c7101bb49a6d8dfb5f5ad549f2aaf9cbd0ccb38c0f8ece4453bee3e4661c53b2fec5b68ba9b073f3fd24469d3460a4b4c5bf20915da
7
+ data.tar.gz: 68ad6ca817778e87c22246c505a5cf77a721c7d2b95e017d46ade0f313fba6c9ebf55bfe7cb45bcb01b7a4d33420c3c321501423b16b1fca823131b30697e287
data/.gitignore ADDED
@@ -0,0 +1,61 @@
1
+ # Created by http://www.gitignore.io
2
+
3
+ ### Linux ###
4
+ *~
5
+
6
+ # KDE directory preferences
7
+ .directory
8
+
9
+
10
+ ### Ruby ###
11
+ *.gem
12
+ *.rbc
13
+ /.config
14
+ /coverage/
15
+ /InstalledFiles
16
+ /pkg/
17
+ /spec/reports/
18
+ /test/tmp/
19
+ /test/version_tmp/
20
+ /tmp/
21
+
22
+ ## Specific to RubyMotion:
23
+ .dat*
24
+ .repl_history
25
+ build/
26
+
27
+ ## Documentation cache and generated files:
28
+ /.yardoc/
29
+ /_yardoc/
30
+ /doc/
31
+ /rdoc/
32
+
33
+ ## Environment normalisation:
34
+ /.bundle/
35
+ /lib/bundler/man/
36
+
37
+ # for a library or gem, you might want to ignore these files since the code is
38
+ # intended to run in multiple environments; otherwise, check them in:
39
+ Gemfile.lock
40
+ .ruby-version
41
+ .ruby-gemset
42
+
43
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
44
+ .rvmrc
45
+
46
+
47
+ ### OSX ###
48
+ .DS_Store
49
+ .AppleDouble
50
+ .LSOverride
51
+
52
+ # Icon must ends with two \r.
53
+ Icon
54
+
55
+
56
+ # Thumbnails
57
+ ._*
58
+
59
+ # Files that might appear on external disk
60
+ .Spotlight-V100
61
+ .Trashes
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/README.md ADDED
@@ -0,0 +1,24 @@
1
+ BeatportPlay-Scraper
2
+ ---
3
+
4
+ Gets the song names from the Beatport Top 10.
5
+
6
+ # Install
7
+
8
+ `gem install beatport_play-scraper`
9
+
10
+ # Usage
11
+
12
+ ```ruby
13
+ require 'beatport_play-scraper'
14
+
15
+ BeatportPlay::Scraper.get_top_10 # Returns an Enumerable with 10 strings.
16
+ ```
17
+
18
+ # Input
19
+
20
+ HTML string from [beatport.com](beatport.com/).
21
+
22
+ # Output
23
+
24
+ An enumerable of the Beatport Top 10 song titles as strings.
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'beatport_play-scraper/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'beatport_play-scraper'
8
+ spec.version = BeatportPlay::Scraper::VERSION
9
+ spec.authors = ['crzrcn']
10
+ spec.email = ['fernanlink@gmail.com']
11
+ spec.description = %q{A scraper for the Beatport Top 10}
12
+ spec.summary = %q{A scraper for the Beatport Top 10 that returns song names}
13
+ spec.homepage = 'https://github.com/crzrcn/BeatportPlay-Scraper'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_runtime_dependency 'nokogiri', '~> 1.6', '>= 1.6.1'
22
+
23
+ spec.add_development_dependency 'rspec', '~> 2.14', '>= 2.14.1'
24
+ end
@@ -0,0 +1,24 @@
1
+ require 'nokogiri'
2
+ require 'open-uri'
3
+ require 'json'
4
+
5
+ module BeatportPlay
6
+ module Scraper
7
+ # Returns an enumerable containing the title of each song in the Beatport Top 10.
8
+ def self.get_top_10
9
+ song_titles = []
10
+
11
+ doc = Nokogiri::HTML(open('http://beatport.com'))
12
+
13
+ # Every Beatport Top 10 song has a div.playWrapper that has a child
14
+ # span.play-queue.play-queue-medium element with a json-data attribute that
15
+ # contains all the song data.
16
+ doc.css('div.playWrapper > span.play-queue.play-queue-medium').each do |song|
17
+ # In here we have access to the 'data-json' attribute of each song.
18
+ song_titles << JSON.parse(song['data-json'])['title']
19
+ end
20
+
21
+ song_titles
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,5 @@
1
+ module BeatportPlay
2
+ module Scraper
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ require 'beatport_play-scraper/scraper'
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+ require 'beatport_play-scraper'
3
+
4
+ describe 'BeatportPlay-Scraper' do
5
+ it 'scrapes the HTML of beatport.com, and returns a collection with the song names in Beatport Top 10' do
6
+ songs = BeatportPlay::Scraper.get_top_10
7
+
8
+ if not songs.is_a? Enumerable and songs.length == 10
9
+ return false
10
+ else
11
+ songs.each do |s|
12
+ if not s.is_a? String
13
+ return false
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,17 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+
12
+ # Run specs in random order to surface order dependencies. If you find an
13
+ # order dependency and want to debug it, you can fix the order by providing
14
+ # the seed, which is printed after each run.
15
+ # --seed 1234
16
+ config.order = 'random'
17
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: beatport_play-scraper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - crzrcn
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.6.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.6'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.6.1
33
+ - !ruby/object:Gem::Dependency
34
+ name: rspec
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '2.14'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 2.14.1
43
+ type: :development
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '2.14'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 2.14.1
53
+ description: A scraper for the Beatport Top 10
54
+ email:
55
+ - fernanlink@gmail.com
56
+ executables: []
57
+ extensions: []
58
+ extra_rdoc_files: []
59
+ files:
60
+ - ".gitignore"
61
+ - Gemfile
62
+ - README.md
63
+ - beatport_play-scraper.gemspec
64
+ - lib/beatport_play-scraper.rb
65
+ - lib/beatport_play-scraper/scraper.rb
66
+ - lib/beatport_play-scraper/version.rb
67
+ - spec/scraper_spec.rb
68
+ - spec/spec_helper.rb
69
+ homepage: https://github.com/crzrcn/BeatportPlay-Scraper
70
+ licenses:
71
+ - MIT
72
+ metadata: {}
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 2.2.2
90
+ signing_key:
91
+ specification_version: 4
92
+ summary: A scraper for the Beatport Top 10 that returns song names
93
+ test_files:
94
+ - spec/scraper_spec.rb
95
+ - spec/spec_helper.rb