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 +4 -4
- data/Rakefile +4 -1
- data/lib/playlist/ext/content_at.rb +7 -0
- data/lib/playlist/format/xspf.rb +9 -11
- data/lib/playlist/version.rb +1 -1
- data/playlist.gemspec +2 -0
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab6e547a9828f6e2039b5341e7f5dd44b82ffb88
|
4
|
+
data.tar.gz: c702f580f913a2907dcb14a81721f05e3a657f2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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]
|
data/lib/playlist/format/xspf.rb
CHANGED
@@ -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 =
|
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 =
|
39
|
-
track.title =
|
40
|
-
track.location =
|
41
|
-
if (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
|
data/lib/playlist/version.rb
CHANGED
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.
|
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
|