playlist 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cbc27126439999045463cfa6de6ba50f75eb1864
4
- data.tar.gz: 03110b81cb035d0b4b2685a64bc1fd41c8d4f414
3
+ metadata.gz: ab6e547a9828f6e2039b5341e7f5dd44b82ffb88
4
+ data.tar.gz: c702f580f913a2907dcb14a81721f05e3a657f2d
5
5
  SHA512:
6
- metadata.gz: 56fe2477c106da8550f666694fc90185c496ad74eb42ff2ab03f695e4f8063b150ae31c8019fc1f11bdee0b192fbbbcbadd555137037df74c47c38399260c09a
7
- data.tar.gz: 77d78fb8dd7f5d802407ed1058f54de4264c18549278d7c91b426981319b6f6b63a06ea2f83dff37f34b13bde2d51c8f4ea123b3ca754797e23a56b76b1fef61
6
+ metadata.gz: 0eb2e0c87173ed061c0ae69ed9d9dead42d72fcb0f2bffa037aafa35ea18d44d58d1ae1dd2d37a8a051a5802cf27b0d161f64d22b0aa424a3ed0b1069711f982
7
+ data.tar.gz: 3097b9ebc71bbae24aa26701558617fd7cf429f45427e03fbd3da90ac0d3cccd262e54a5bdf95e0d4ee04eadab9a474b31285a54ce1735505097b673b8c922c1
data/Rakefile CHANGED
@@ -5,6 +5,9 @@ require 'yard'
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
  RuboCop::RakeTask.new
8
- YARD::Rake::YardocTask.new
8
+ YARD::Rake::YardocTask.new do |t|
9
+ t.files = ['lib/**/*.rb']
10
+ t.options = ['--exclude', 'lib/playlist/ext']
11
+ end
9
12
 
10
13
  task :default => [:spec, :rubocop, :yard]
@@ -0,0 +1,7 @@
1
+ # Monkey patch to add a #content_at method
2
+ class Nokogiri::XML::Node
3
+ def content_at(*args)
4
+ node = at(*args)
5
+ node.content unless node.nil?
6
+ end
7
+ end
@@ -1,5 +1,9 @@
1
1
  require 'nokogiri'
2
2
 
3
+ unless Nokogiri::XML::Node.respond_to?(:content_at)
4
+ require 'playlist/ext/content_at.rb'
5
+ end
6
+
3
7
  # Module to parse and generate XSPF playlists
4
8
  module Playlist::Format::XSPF
5
9
  class << self
@@ -9,7 +13,7 @@ module Playlist::Format::XSPF
9
13
  def parse(input)
10
14
  Playlist.new do |playlist|
11
15
  doc = Nokogiri::XML(input)
12
- playlist.title = inner_text_or_nil(doc, '/xmlns:playlist/xmlns:title')
16
+ playlist.title = doc.content_at('/xmlns:playlist/xmlns:title')
13
17
  doc.xpath('/xmlns:playlist/xmlns:trackList/xmlns:track').each do |track|
14
18
  playlist.tracks << parse_track(track)
15
19
  end
@@ -35,10 +39,10 @@ module Playlist::Format::XSPF
35
39
 
36
40
  def parse_track(doc)
37
41
  Playlist::Track.new do |track|
38
- track.creator = inner_text_or_nil(doc, 'xmlns:creator')
39
- track.title = inner_text_or_nil(doc, 'xmlns:title')
40
- track.location = inner_text_or_nil(doc, 'xmlns:location')
41
- if (duration = inner_text_or_nil(doc, 'xmlns:duration'))
42
+ track.creator = doc.content_at('./xmlns:creator')
43
+ track.title = doc.content_at('./xmlns:title')
44
+ track.location = doc.content_at('./xmlns:location')
45
+ if (duration = doc.content_at('./xmlns:duration'))
42
46
  track.duration = duration.to_f / 1000
43
47
  end
44
48
  end
@@ -52,11 +56,5 @@ module Playlist::Format::XSPF
52
56
  xml.duration((track.duration * 1000).to_i) unless track.duration.nil?
53
57
  end
54
58
  end
55
-
56
- ## FIXME: how to do this better?
57
- def inner_text_or_nil(doc, path)
58
- element = doc.at_xpath(path)
59
- element.inner_text unless element.nil?
60
- end
61
59
  end
62
60
  end
@@ -1,4 +1,4 @@
1
1
  class Playlist
2
2
  # The version number of the Playlist Ruby gem
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  end
data/playlist.gemspec CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ['lib']
20
20
 
21
+ spec.add_dependency 'nokogiri', '~> 1.8.4'
22
+
21
23
  spec.add_development_dependency 'bundler', '> 1.13'
22
24
  spec.add_development_dependency 'equivalent-xml', '~> 0.6.0'
23
25
  spec.add_development_dependency 'rake', '~> 10.2.2'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playlist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Humfrey
@@ -10,6 +10,20 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2018-07-16 00:00:00.000000000 Z
12
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.8.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.8.4
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -124,6 +138,7 @@ files:
124
138
  - Rakefile
125
139
  - lib/playlist.rb
126
140
  - lib/playlist/contributor.rb
141
+ - lib/playlist/ext/content_at.rb
127
142
  - lib/playlist/format.rb
128
143
  - lib/playlist/format/m3u.rb
129
144
  - lib/playlist/format/simple_text.rb