dmapparser 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/Gemfile +2 -2
- data/Rakefile +2 -2
- data/dmapparser.gemspec +2 -2
- data/lib/dmapparser/converter.rb +1 -1
- data/lib/dmapparser/parser.rb +2 -5
- data/lib/dmapparser/tag.rb +1 -1
- data/lib/dmapparser/tag_container.rb +1 -1
- data/lib/dmapparser/tag_definitions.rb +3 -0
- data/lib/dmapparser/version.rb +1 -1
- data/test/.rubocop.yml +3 -1
- data/test/lib/dmapparser/converter_test.rb +25 -25
- data/test/lib/dmapparser/parser_test.rb +2 -2
- data/test/lib/dmapparser/tag_test.rb +1 -1
- data/test/test_helper.rb +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9295540a235dae90cedac55ab52c2ff9a8f56749
|
4
|
+
data.tar.gz: 68afb3fefbd990cad9b67ea302aba4c9173e12ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e0254abb6b650dfb25234c7ab1d056966896048854e33b65dc1235c422ea3322cabef7ea87d6f5d196b75ce3ecd75c02912837b56fa96ee79f669720993366d
|
7
|
+
data.tar.gz: 6506a46b2cf6425876364f32950584baf07b879c180542d5b38d15043f6dc767bc325f38bfbc5d51450a301f33ff80dfddcc2d3e4abf5fb946d0239e477054d9
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -13,9 +13,9 @@ end
|
|
13
13
|
task test: :rubocop
|
14
14
|
|
15
15
|
task :rubocop do
|
16
|
-
puts "Running
|
16
|
+
puts "Running RuboCop #{RuboCop::Version::STRING}"
|
17
17
|
args = FileList['**/*.rb', 'Rakefile', 'dmapparser.gemspec', 'Gemfile']
|
18
|
-
cli =
|
18
|
+
cli = RuboCop::CLI.new
|
19
19
|
cli.run(args)
|
20
20
|
end
|
21
21
|
|
data/dmapparser.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = DMAPParser::VERSION
|
9
9
|
spec.authors = ['Jurriaan Pruis']
|
10
10
|
spec.email = ['email@jurriaanpruis.nl']
|
11
|
-
spec.summary =
|
11
|
+
spec.summary = 'Parses DMAP data'
|
12
12
|
spec.homepage = 'https://github.com/jurriaan/dmapparser'
|
13
13
|
spec.license = 'MIT'
|
14
14
|
spec.platform = Gem::Platform::RUBY
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
spec.extra_rdoc_files = ['README.md', 'LICENSE']
|
21
21
|
|
22
|
-
spec.add_development_dependency 'bundler', '~> 1.
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
23
23
|
spec.add_development_dependency 'yard'
|
24
24
|
spec.add_development_dependency 'rake'
|
25
25
|
|
data/lib/dmapparser/converter.rb
CHANGED
data/lib/dmapparser/parser.rb
CHANGED
@@ -18,8 +18,7 @@ module DMAPParser
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def parse
|
21
|
-
|
22
|
-
fail ParseError if @response.size < 8
|
21
|
+
fail ParseError if @response.nil? || @response.size < 8
|
23
22
|
ret = TagContainer.new(read_key)
|
24
23
|
fail ParseError if ret.type && !ret.type.container?
|
25
24
|
ret.value = parse_container(read_length)
|
@@ -37,9 +36,7 @@ module DMAPParser
|
|
37
36
|
end
|
38
37
|
|
39
38
|
def read_bytes(length)
|
40
|
-
unless bytes_available?(length)
|
41
|
-
fail ParseError, 'Not enough data available'
|
42
|
-
end
|
39
|
+
fail ParseError, 'Not enough data available' unless bytes_available?(length)
|
43
40
|
@response.read(length)
|
44
41
|
end
|
45
42
|
|
data/lib/dmapparser/tag.rb
CHANGED
@@ -38,6 +38,9 @@ module DMAPParser
|
|
38
38
|
tag 'cmgt', :container, 'dmcp.getpropertyresponse'
|
39
39
|
tag 'cmst', :container, 'dmcp.status'
|
40
40
|
tag 'agal', :container, 'daap.albumgrouping'
|
41
|
+
tag 'agar', :container, 'daap.artistgrouping'
|
42
|
+
tag 'agac', :uint32, 'daap.groupalbumcount'
|
43
|
+
tag 'asri', :uint32, 'daap.songartistid'
|
41
44
|
tag 'minm', :string, 'dmap.itemname'
|
42
45
|
tag 'msts', :string, 'dmap.statusstring'
|
43
46
|
tag 'mcna', :string, 'dmap.contentcodesname'
|
data/lib/dmapparser/version.rb
CHANGED
data/test/.rubocop.yml
CHANGED
@@ -3,36 +3,36 @@ require_relative '../../test_helper'
|
|
3
3
|
describe DMAPParser::Converter do
|
4
4
|
it 'should return the original output again' do
|
5
5
|
time = Time.now
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
con = DMAPParser::Converter
|
7
|
+
con.bin_to_date(con.date_to_bin(time)).to_i.must_equal time.to_i
|
8
|
+
con.bin_to_bool(con.bool_to_bin(true)).must_equal true
|
9
|
+
con.bin_to_int(con.int_to_bin(90_000)).must_equal 90_000
|
10
|
+
con.bin_to_byte(con.byte_to_bin(190)).must_equal 190
|
11
|
+
con.bin_to_long(con.long_to_bin(3**25)).must_equal 3**25
|
12
|
+
con.bin_to_version(con.version_to_bin('932.200.3')).must_equal '932.200.3'
|
13
|
+
con.bin_to_short(con.short_to_bin(19_007)).must_equal 19_007
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
it 'should automatically convert numerics' do
|
17
|
-
|
18
|
-
byte =
|
19
|
-
short =
|
20
|
-
int =
|
21
|
-
long =
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
17
|
+
con = DMAPParser::Converter
|
18
|
+
byte = con.byte_to_bin(244)
|
19
|
+
short = con.short_to_bin(244)
|
20
|
+
int = con.int_to_bin(244)
|
21
|
+
long = con.long_to_bin(244)
|
22
|
+
con.data_to_numeric(byte).must_equal(244)
|
23
|
+
con.data_to_numeric(short).must_equal(244)
|
24
|
+
con.data_to_numeric(int).must_equal(244)
|
25
|
+
con.data_to_numeric(long).must_equal(244)
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
it 'should decode unknown types' do
|
29
|
-
|
30
|
-
byte =
|
31
|
-
|
29
|
+
con = DMAPParser::Converter
|
30
|
+
byte = con.byte_to_bin(244)
|
31
|
+
con.decode(:ZZZZ, byte).must_equal 244
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
it 'should encode unknown strings' do
|
35
|
-
|
36
|
-
|
35
|
+
con = DMAPParser::Converter
|
36
|
+
con.encode(:ZZZZ, 'aaa').must_equal 'aaa'
|
37
37
|
end
|
38
38
|
end
|
@@ -4,7 +4,7 @@ describe DMAPParser::Parser do
|
|
4
4
|
it 'should raise a ParserError when given invalid data' do
|
5
5
|
invalid = []
|
6
6
|
20.times do
|
7
|
-
invalid << (0..255).map
|
7
|
+
invalid << (0..255).map(&:chr).join # random data
|
8
8
|
end
|
9
9
|
invalid << "rand\x00\x00\x00\x01" # non correct size
|
10
10
|
invalid << "mcon\x00\x00\x00\x05rand\x09" # wrong tag size
|
@@ -18,7 +18,7 @@ describe DMAPParser::Parser do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'should return nil if the string is empty' do
|
21
|
-
DMAPParser::Parser.parse('').
|
21
|
+
-> { DMAPParser::Parser.parse('') }.must_raise DMAPParser::Parser::ParseError
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'should ignore padding' do
|
@@ -6,7 +6,7 @@ describe DMAPParser::Tag do
|
|
6
6
|
subject.value.must_equal 'Test thing'
|
7
7
|
subject.type.must_equal DMAPParser::TagDefinition[:minm]
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
it 'should be recognizable as a tag' do
|
11
11
|
subject = DMAPParser::Tag.new(:minm, 'Test thing')
|
12
12
|
subject.to_s.must_equal('#<DMAPParser::Tag minm (dmap.itemname: string)>')
|
data/test/test_helper.rb
CHANGED
@@ -2,8 +2,8 @@ require 'simplecov'
|
|
2
2
|
require 'coveralls'
|
3
3
|
Coveralls.wear!
|
4
4
|
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
5
|
-
|
6
|
-
|
5
|
+
SimpleCov::Formatter::HTMLFormatter,
|
6
|
+
Coveralls::SimpleCov::Formatter
|
7
7
|
]
|
8
8
|
SimpleCov.start
|
9
9
|
gem 'minitest'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dmapparser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jurriaan Pruis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.6'
|
20
20
|
type: :development
|
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.
|
26
|
+
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: yard
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
110
|
version: '0'
|
111
111
|
requirements: []
|
112
112
|
rubyforge_project:
|
113
|
-
rubygems_version: 2.
|
113
|
+
rubygems_version: 2.4.4
|
114
114
|
signing_key:
|
115
115
|
specification_version: 4
|
116
116
|
summary: Parses DMAP data
|