fronkin_bandcamp 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8e8ff4fcbb3ca9a1cda11123ecad44248771c43f
4
- data.tar.gz: 8e73aee2de682a3d8526ec8477b0e7f8ee207625
2
+ SHA256:
3
+ metadata.gz: 8c242455993c2dcfa2c41db366c8b6ae5ad9fe869fa1ce9a5385afb8f8439ed1
4
+ data.tar.gz: c5a4f05d25b69f35d43aa175b908c6a7dfff0a92c72ad5ff766b9e06a8b61492
5
5
  SHA512:
6
- metadata.gz: eb48101c98cdeea7c180e8e8e1acee62f4ff5db4c4f952c701b73deab50172627e88eedcbd63564f944169735d27236b0738312865eada0c9e57c171ab6a8519
7
- data.tar.gz: 0d022735c04cccc72e398274d049a432639eec0913f9102bd2e9da4153288fbb5606800d93fde2a68be4400e17d1be0b15fe341dd901aded915f99da02d38afc
6
+ metadata.gz: 2098466e9b5f88602cf1d83f414542f127b39f39c511a86844195eee2c1fc6b8104719555418c3283af3c50ff540bcc3273b923a9727edb7bda5f59a3d412cfc
7
+ data.tar.gz: 9ff2584771d6ed9f9b84fc2cedd5b03439e89b95a26fa9f22972e73139ec4d15eb9e916415852f0077bb1bbb0ce8e4b56b5d8805227dc093cfc93ff5d115847f
data/.travis.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.3.1
4
+ - 2.5.1
5
5
  before_install: gem install bundler -v 1.16.1
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fronkin_bandcamp (0.1.0)
5
- nokogiri (~> 1.8)
4
+ fronkin_bandcamp (0.3.0)
5
+ nokogiri (>= 1.10.4)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -12,9 +12,9 @@ GEM
12
12
  coderay (1.1.2)
13
13
  diff-lcs (1.3)
14
14
  method_source (0.9.0)
15
- mini_portile2 (2.3.0)
16
- nokogiri (1.8.4)
17
- mini_portile2 (~> 2.3.0)
15
+ mini_portile2 (2.4.0)
16
+ nokogiri (1.10.7)
17
+ mini_portile2 (~> 2.4.0)
18
18
  pry (0.11.3)
19
19
  coderay (~> 1.1.0)
20
20
  method_source (~> 0.9.0)
@@ -49,4 +49,4 @@ DEPENDENCIES
49
49
  rspec (~> 3.7)
50
50
 
51
51
  BUNDLED WITH
52
- 1.16.2
52
+ 1.17.1
data/README.md CHANGED
@@ -1,3 +1,6 @@
1
+ [![Build
2
+ Status](https://travis-ci.org/FTLam11/fronkin_bandcamp_scraper.svg?branch=master)](https://travis-ci.org/FTLam11/fronkin_bandcamp_scraper)
3
+
1
4
  # FronkinBandcamp
2
5
 
3
6
  Maybe you thought you'd flop your way to a championship.
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ['lib']
23
23
 
24
- spec.add_dependency 'nokogiri', '~> 1.8'
24
+ spec.add_dependency 'nokogiri', '>= 1.10.4'
25
25
 
26
26
  spec.add_development_dependency 'bundler', '~> 1.16'
27
27
  spec.add_development_dependency 'rake', '~> 10.0'
@@ -1,20 +1,24 @@
1
1
  module FronkinBandcamp
2
+ module CleanAsFuck
3
+ refine String do
4
+ def kleanse
5
+ strip.gsub!(/\n\s+/, ' ')
6
+ end
7
+ end
8
+ end
9
+
10
+ using CleanAsFuck
11
+
2
12
  class Format
3
- attr_accessor :name, :product, :description, :product_images, :price, :is_available
13
+ attr_reader :name, :product, :description, :product_images, :price, :is_available
4
14
 
5
15
  def initialize(choice)
6
- @name = sanitize(choice.css('h3.hd span').text) || 'Subcription'
16
+ @name = choice.css('h3.hd span').text.kleanse || 'Subcription'
7
17
  @product = choice.css('h3.hd div.secondaryText').text.strip
8
- @description = sanitize(choice.css('div.bd').text)
18
+ @description = choice.css('div.bd').text.kleanse
9
19
  @product_images = choice.css('a.popupImage').map { |anchor| anchor.attribute('href').value }
10
- @price = sanitize(choice.css('div.ft h4.main-button').text) || sanitize(choice.css('h4.ft.compound-button').text)
20
+ @price = choice.css('div.ft h4.main-button').text.kleanse || choice.css('h4.ft.compound-button').text.kleanse
11
21
  @is_available = choice.css('div.ft h4.notable').text.strip != 'Sold Out' ? true : false
12
22
  end
13
-
14
- private
15
-
16
- def sanitize(text)
17
- text.strip.gsub!(/\n\s+/, ' ')
18
- end
19
23
  end
20
24
  end
@@ -3,27 +3,26 @@ require 'fronkin_bandcamp/format'
3
3
 
4
4
  module FronkinBandcamp
5
5
  class Release
6
- attr_accessor :doc, :title, :date, :cover, :tracks, :tags, :formats, :fans
6
+ attr_reader :title, :date, :cover, :tracks, :tags, :formats, :fans
7
7
 
8
8
  def initialize(doc)
9
- @doc = doc
10
9
  @title = doc.css('div#name-section h2.trackTitle').text.strip
11
10
  @date = doc.css('div.tralbumData.tralbum-credits meta').attribute('content').value
12
11
  @cover = doc.css('div#tralbumArt a.popupImage').attribute('href').value
13
- @tracks = scrape_tracks
12
+ @tracks = scrape_tracks(doc)
14
13
  @tags = doc.css('div.tralbumData.tralbum-tags a.tag').map(&:text)
15
- @formats = scrape_formats
14
+ @formats = scrape_formats(doc)
16
15
  end
17
16
 
18
17
  private
19
18
 
20
- def scrape_tracks
19
+ def scrape_tracks(doc)
21
20
  track_titles = doc.css('table#track_table td.title-col span[itemprop="name"]').map(&:text)
22
21
  track_durations = doc.css('table#track_table td.title-col span.time').map { |node| node.text.strip }
23
22
  track_titles.zip(track_durations).map.with_index { |t, idx| Track.new(idx + 1, t[0], t[1]) }
24
23
  end
25
24
 
26
- def scrape_formats
25
+ def scrape_formats(doc)
27
26
  format_choices = doc.css('li.buyItem')
28
27
  format_choices.map { |choice| Format.new(choice) }
29
28
  end
@@ -1,3 +1,3 @@
1
1
  module FronkinBandcamp
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fronkin_bandcamp
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
  - Fronk Lom Lom
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-09 00:00:00.000000000 Z
11
+ date: 2020-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.8'
19
+ version: 1.10.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.8'
26
+ version: 1.10.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  version: '0'
157
157
  requirements: []
158
158
  rubyforge_project:
159
- rubygems_version: 2.5.1
159
+ rubygems_version: 2.7.6
160
160
  signing_key:
161
161
  specification_version: 4
162
162
  summary: This gem is a convenient web scraper for Bandcamp releases.