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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68b7396a6898eeefafa26e430022b49d3b281115
4
- data.tar.gz: d0188b16664b041ca72ba713dafa45aafbf919d5
3
+ metadata.gz: 9295540a235dae90cedac55ab52c2ff9a8f56749
4
+ data.tar.gz: 68afb3fefbd990cad9b67ea302aba4c9173e12ef
5
5
  SHA512:
6
- metadata.gz: 7a339caec989bebaecb8792e3b3ddd09fca8305822a32690bb5da872af5efc68e5362f94781a51279dd8cd3064b88b85a4f8f123ebfa5350c984c5a9a4b2491e
7
- data.tar.gz: d09b9ba744cee11dbe7ea60c49607905aef822d9c61bb23e5352b2c337813a675517e655a54d3673bd2d8de222aadb61053f5aed4bbc935cb2dc2857674c1d20
6
+ metadata.gz: 4e0254abb6b650dfb25234c7ab1d056966896048854e33b65dc1235c422ea3322cabef7ea87d6f5d196b75ce3ecd75c02912837b56fa96ee79f669720993366d
7
+ data.tar.gz: 6506a46b2cf6425876364f32950584baf07b879c180542d5b38d15043f6dc767bc325f38bfbc5d51450a301f33ff80dfddcc2d3e4abf5fb946d0239e477054d9
@@ -0,0 +1,2 @@
1
+ Metrics/LineLength:
2
+ Max: 90
data/Gemfile CHANGED
@@ -4,8 +4,8 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  group :test do
7
- gem 'minitest', '~> 5.3.1'
7
+ gem 'minitest', '~> 5.4.0'
8
8
  gem 'coveralls', require: false
9
- gem 'rubocop', '~> 0.20.0'
9
+ gem 'rubocop', '~> 0.27.1'
10
10
  gem 'simplecov', require: false
11
11
  end
data/Rakefile CHANGED
@@ -13,9 +13,9 @@ end
13
13
  task test: :rubocop
14
14
 
15
15
  task :rubocop do
16
- puts "Running Rubocop #{Rubocop::Version::STRING}"
16
+ puts "Running RuboCop #{RuboCop::Version::STRING}"
17
17
  args = FileList['**/*.rb', 'Rakefile', 'dmapparser.gemspec', 'Gemfile']
18
- cli = Rubocop::CLI.new
18
+ cli = RuboCop::CLI.new
19
19
  cli.run(args)
20
20
  end
21
21
 
@@ -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 = %q(Parses DMAP data)
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.5'
22
+ spec.add_development_dependency 'bundler', '~> 1.6'
23
23
  spec.add_development_dependency 'yard'
24
24
  spec.add_development_dependency 'rake'
25
25
 
@@ -59,7 +59,7 @@ module DMAPParser
59
59
  end
60
60
 
61
61
  def version_to_bin(data)
62
- data.split('.').map { |part| part.to_i }.pack 'nCC'
62
+ data.split('.').map(&:to_i).pack 'nCC'
63
63
  end
64
64
 
65
65
  def hex_to_bin(data)
@@ -18,8 +18,7 @@ module DMAPParser
18
18
  end
19
19
 
20
20
  def parse
21
- return nil if @response.nil? || @response.size == 0
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
 
@@ -4,7 +4,7 @@ module DMAPParser
4
4
  def initialize(type, value)
5
5
  unless type.is_a? TagDefinition
6
6
  type = TagDefinition[type] ||
7
- TagDefinition.new(type, :unknown, "unknown (#{length})")
7
+ TagDefinition.new(type, :unknown, "unknown (#{length})")
8
8
  end
9
9
  super
10
10
  end
@@ -29,7 +29,7 @@ module DMAPParser
29
29
  !get_tag(key).nil?
30
30
  end
31
31
 
32
- def method_missing(method, *arguments, &block)
32
+ def method_missing(method, *_arguments, &_block)
33
33
  if method =~ /(.*)\?$/
34
34
  has?(Regexp.last_match[1])
35
35
  elsif has?(method)
@@ -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'
@@ -1,4 +1,4 @@
1
1
  # DMAPParser handles the parsing of DMAP data
2
2
  module DMAPParser
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
@@ -1,3 +1,5 @@
1
+ inherit_from: ../.rubocop.yml
2
+
1
3
  # Do not introduce global variables.
2
4
  GlobalVars:
3
- Enabled: false
5
+ Enabled: false
@@ -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
- klass = DMAPParser::Converter
7
- klass.bin_to_date(klass.date_to_bin(time)).to_i.must_equal time.to_i
8
- klass.bin_to_bool(klass.bool_to_bin(true)).must_equal true
9
- klass.bin_to_int(klass.int_to_bin(90000)).must_equal 90000
10
- klass.bin_to_byte(klass.byte_to_bin(190)).must_equal 190
11
- klass.bin_to_long(klass.long_to_bin(3**25)).must_equal 3**25
12
- klass.bin_to_version(klass.version_to_bin('1322.200.3')).must_equal '1322.200.3'
13
- klass.bin_to_short(klass.short_to_bin(19007)).must_equal 19007
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
- klass = DMAPParser::Converter
18
- byte = klass.byte_to_bin(244)
19
- short = klass.short_to_bin(244)
20
- int = klass.int_to_bin(244)
21
- long = klass.long_to_bin(244)
22
- klass.data_to_numeric(byte).must_equal(244)
23
- klass.data_to_numeric(short).must_equal(244)
24
- klass.data_to_numeric(int).must_equal(244)
25
- klass.data_to_numeric(long).must_equal(244)
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
- klass = DMAPParser::Converter
30
- byte = klass.byte_to_bin(244)
31
- klass.decode(:ZZZZ, byte).must_equal 244
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
- klass = DMAPParser::Converter
36
- klass.encode(:ZZZZ, 'aaa').must_equal 'aaa'
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 { |c| c.chr }.join # random data
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('').must_equal nil
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)>')
@@ -2,8 +2,8 @@ require 'simplecov'
2
2
  require 'coveralls'
3
3
  Coveralls.wear!
4
4
  SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
5
- SimpleCov::Formatter::HTMLFormatter,
6
- Coveralls::SimpleCov::Formatter
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.1.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-04-03 00:00:00.000000000 Z
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.5'
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.5'
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.2.2
113
+ rubygems_version: 2.4.4
114
114
  signing_key:
115
115
  specification_version: 4
116
116
  summary: Parses DMAP data