dmapparser 0.0.1 → 0.0.2

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
2
  SHA1:
3
- metadata.gz: b4f0392efe8fbb5cb490326f252de2ba2ad14320
4
- data.tar.gz: 83521f2817e52ffa041ae04097e41106fc23920d
3
+ metadata.gz: 8f70493e234f76cac85f3a07af469d45eefe839c
4
+ data.tar.gz: 4a3ae53c0f24a30d0fbd7552c4b2a1abfa6d0cec
5
5
  SHA512:
6
- metadata.gz: 4e6d311c7458783399f658271061e26e3fb7716bf9487159148f6c39d49b911ee14fc62cf676f3d91920587618d59f741bd0b84efa1b12c4da732206891243c7
7
- data.tar.gz: 538395db0d8f903ee3f141e9bfeb53f3e4829ab313551060e6a2f291b55a3558a48a1921bbe0235b834efa24cfa41c35ee0fec2fcf2708c2781af2e9cb69bad4
6
+ metadata.gz: 46c2fc9701f4b715acf4f9a168c713834d249a37a270ecaceb556a5ba5c18a57dfcc041c03eb5e5e32a2861c4c61111b4548c6f2a21ff1ea2584456c1c44091e
7
+ data.tar.gz: 79ed8bd31dd10179e8d912ab83a02c85a59fa47d739a0474c70b2d273152ca624eafaa7ee3357e11b0da5553db01c963b455fccd48b3daf659a3710ed346be1f
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.1.0
5
+ - ruby-head
6
+ - jruby-head
7
+ matrix:
8
+ allow_failures:
9
+ - rvm: ruby-head
10
+ - rvm: jruby-head
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # DMAPParser
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/dmapparser.png)](http://badge.fury.io/rb/dmapparser) [![Dependency Status](https://gemnasium.com/jurriaan/dmapparser.png)](https://gemnasium.com/jurriaan/dmapparser)
3
+ [![Gem Version](https://badge.fury.io/rb/dmapparser.png)](http://badge.fury.io/rb/dmapparser) [![Dependency Status](https://gemnasium.com/jurriaan/dmapparser.png)](https://gemnasium.com/jurriaan/dmapparser) [![Coverage Status](https://coveralls.io/repos/jurriaan/dmapparser/badge.png)](https://coveralls.io/r/jurriaan/dmapparser) [![Build Status](https://travis-ci.org/jurriaan/docparser.png?branch=master)](https://travis-ci.org/jurriaan/dmapparser)
4
4
 
5
- Parses DMAP data
5
+ Parses DMAP data.
6
6
 
7
7
  ## Installation
8
8
 
data/bin/dmapparser CHANGED
@@ -1,4 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'dmapparser'
4
- puts DMAPParser::Parser.parse(ARGF.to_io).inspect
4
+ if ARGV.size > 0
5
+ puts DMAPParser::Parser.parse(ARGF.to_io).inspect
6
+ else
7
+ puts "Usage: #{$PROGRAM_NAME} filename"
8
+ end
data/dmapparser.gemspec CHANGED
@@ -9,15 +9,19 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ['Jurriaan Pruis']
10
10
  spec.email = ['email@jurriaanpruis.nl']
11
11
  spec.summary = %q{Parses DMAP data}
12
- spec.homepage = ''
12
+ spec.homepage = 'https://github.com/jurriaan/dmapparser'
13
13
  spec.license = 'MIT'
14
+ spec.platform = Gem::Platform::RUBY
14
15
 
15
16
  spec.files = `git ls-files -z`.split("\x0")
16
17
  spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
17
18
  spec.test_files = spec.files.grep(/^(test|spec|features)\//)
18
19
  spec.require_paths = ['lib']
20
+ spec.extra_rdoc_files = ['README.md', 'LICENSE']
19
21
 
20
22
  spec.add_development_dependency 'bundler', '~> 1.5'
21
23
  spec.add_development_dependency 'yard'
22
24
  spec.add_development_dependency 'rake'
25
+
26
+ spec.required_ruby_version = '>= 2.0.0'
23
27
  end
@@ -87,9 +87,12 @@ module DMAPParser
87
87
  end
88
88
 
89
89
  def bin_to_string(data)
90
- data.force_encoding('utf-8')
90
+ data.force_encoding(Encoding::UTF_8)
91
+ end
92
+
93
+ def string_to_bin(data)
94
+ data.force_encoding(Encoding::BINARY)
91
95
  end
92
- alias_method :string_to_bin, :bin_to_string
93
96
 
94
97
  alias_method :uint16_to_bin, :short_to_bin
95
98
  alias_method :uint32_to_bin, :int_to_bin
@@ -14,7 +14,7 @@ module DMAPParser
14
14
  def initialize(response)
15
15
  @response = response
16
16
  @response = StringIO.new(response) unless @response.is_a? IO
17
- @response.set_encoding(Encoding::UTF_8) # Use unicode
17
+ @response.set_encoding(Encoding::BINARY) # Use unicode
18
18
  end
19
19
 
20
20
  def parse
@@ -12,7 +12,7 @@ module DMAPParser
12
12
  def to_dmap
13
13
  value = convert_value(self.value)
14
14
  length = [value.length].pack('N')
15
- (type.tag.to_s + length + value).force_encoding('utf-8')
15
+ (type.tag.to_s + length + value).force_encoding(Encoding::BINARY)
16
16
  end
17
17
 
18
18
  private
@@ -13,7 +13,6 @@ module DMAPParser
13
13
 
14
14
  def get_value(key)
15
15
  return value[key] if key.is_a? Fixnum
16
-
17
16
  tag = get_tag(key)
18
17
 
19
18
  if tag.type.container?
@@ -1,4 +1,4 @@
1
1
  # DMAPParser handles the parsing of DMAP data
2
2
  module DMAPParser
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
  end
@@ -3,7 +3,7 @@ require_relative '../../test_helper'
3
3
  describe DMAPParser::Builder do
4
4
  before do
5
5
  @pair_data = DMAPParser::Builder.cmpa do
6
- cmpg 'AABBCCDDEE'
6
+ cmpg '4E0573EF9BB80682'
7
7
  cmnm 'Name'
8
8
  cmty 'iPod'
9
9
  end
@@ -18,7 +18,7 @@ describe DMAPParser::Builder do
18
18
  it 'should raise an exception if tags are put inside non-containers' do
19
19
  lambda do
20
20
  DMAPParser::Builder.cmnm do
21
- cmpg 'AABBCCDDEE'
21
+ cmpg '4E0573EF9BB80682'
22
22
  cmty 'iPod'
23
23
  end
24
24
  end.must_raise RuntimeError
@@ -29,7 +29,7 @@ describe DMAPParser::Builder do
29
29
  end
30
30
 
31
31
  it 'should store the correct values' do
32
- @pair_data.cmpg.must_equal 'AABBCCDDEE'
32
+ @pair_data.cmpg.must_equal '4E0573EF9BB80682'
33
33
  @pair_data.cmnm.must_equal 'Name'
34
34
  @pair_data.cmty.must_equal 'iPod'
35
35
  end
@@ -67,4 +67,18 @@ describe DMAPParser::Builder do
67
67
  dmap = nested.to_dmap
68
68
  DMAPParser::Parser.parse(dmap).to_dmap.must_equal(dmap)
69
69
  end
70
+
71
+ it 'should correctly encode hexadecimal strings' do
72
+ dmap = DMAPParser::Builder.cmpa do
73
+ cmpg '4E0573EF9BB80682'
74
+ end.to_dmap
75
+ byte_string = [78, 5, 115, 239, 155, 184, 6, 130]
76
+ dmap.bytes[-8..-1].must_equal(byte_string)
77
+ dmap_reparsed = DMAPParser::Parser.parse(dmap).to_dmap
78
+ dmap_reparsed.bytes[-8..-1].must_equal(byte_string)
79
+ end
80
+
81
+ it 'should output binary strings' do
82
+ @pair_data.to_dmap.encoding.must_equal(Encoding::BINARY)
83
+ end
70
84
  end
@@ -20,6 +20,7 @@ describe DMAPParser::Parser do
20
20
 
21
21
  it 'should ignore padding' do
22
22
  dmap = support_file('simple.dmap').read
23
+ dmap.force_encoding(Encoding::BINARY)
23
24
  padded = DMAPParser::Parser.parse(dmap + 'I AM PADDING!!11!!')
24
25
  padded.to_dmap.must_equal dmap
25
26
  end
@@ -58,4 +59,10 @@ describe DMAPParser::Parser do
58
59
  data.jurp.must_equal 0x1337
59
60
  end
60
61
 
62
+ it 'should parse strings as UTF-8' do
63
+ dmap = DMAPParser::Builder.cmpa do
64
+ cmnm '4E0573EF9BB80682'
65
+ end.to_dmap
66
+ DMAPParser::Parser.parse(dmap).cmnm.encoding.must_equal(Encoding::UTF_8)
67
+ end
61
68
  end
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.0.1
4
+ version: 0.0.2
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-02-03 00:00:00.000000000 Z
11
+ date: 2014-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,10 +58,14 @@ email:
58
58
  executables:
59
59
  - dmapparser
60
60
  extensions: []
61
- extra_rdoc_files: []
61
+ extra_rdoc_files:
62
+ - README.md
63
+ - LICENSE
62
64
  files:
65
+ - ".coveralls.yml"
63
66
  - ".gitignore"
64
67
  - ".rubocop.yml"
68
+ - ".travis.yml"
65
69
  - Gemfile
66
70
  - LICENSE
67
71
  - README.md
@@ -85,7 +89,7 @@ files:
85
89
  - test/support/content_codes.dmap
86
90
  - test/support/simple.dmap
87
91
  - test/test_helper.rb
88
- homepage: ''
92
+ homepage: https://github.com/jurriaan/dmapparser
89
93
  licenses:
90
94
  - MIT
91
95
  metadata: {}
@@ -97,7 +101,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
97
101
  requirements:
98
102
  - - ">="
99
103
  - !ruby/object:Gem::Version
100
- version: '0'
104
+ version: 2.0.0
101
105
  required_rubygems_version: !ruby/object:Gem::Requirement
102
106
  requirements:
103
107
  - - ">="
@@ -105,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
109
  version: '0'
106
110
  requirements: []
107
111
  rubyforge_project:
108
- rubygems_version: 2.2.0
112
+ rubygems_version: 2.2.2
109
113
  signing_key:
110
114
  specification_version: 4
111
115
  summary: Parses DMAP data