traktor-nml 0.3.0 → 0.3.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: a975f0344949062aa901da4cfb09178e10877377
4
- data.tar.gz: 325b02f803405a3a7dc7015a0b5f4c79cd09d1bd
3
+ metadata.gz: 5b69694ab7e2fcb358f6709df5079766e5d26ee0
4
+ data.tar.gz: 15e2ff584d90cdf1b22a986089dfadb8d9498e16
5
5
  SHA512:
6
- metadata.gz: 213163283d378e4d088ff1ce248323590e50c0c9de164bcc723b9b66f2477ac97023a9b032069a8aa203bd14cc57e4f6589a8c57124c0965dd28adfb354b6f50
7
- data.tar.gz: a18161acdadb9157f9e89a1bfde78c6ec1c16f2b987f425aa2643347b375bfe7cc96ebe8f14a43042fd414dee4d994dc5d9c05042c4fb6cc8a4966e756eddd43
6
+ metadata.gz: a36890adb542f1b1c248ba65d16a7f5c7025e8f8f9c2671246a56b1266d7535b52a6f23e963f555daec06813cfe81217369bb0124a5621eb9da7bf15eb88ce6d
7
+ data.tar.gz: 36e5ea1b29b862de6fb7f0d51d96d0264482d138477a6c7b543c8c3e8ddf92df720c6ba73e137bcc1d1ba7d3db47e9bac6f300922f747d4f05bd6fdb98226870
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'traktor/nml'
4
+
5
+ require 'optparse'
6
+
7
+ opt = OptionParser.new
8
+ out_format = ""
9
+
10
+ opt.version = Traktor::NML::VERSION
11
+ opt.on('-f FORMAT', '--format FORMAT', 'Specify output format') do |f|
12
+ out_format = f
13
+ end
14
+
15
+ opt.parse! ARGV
16
+
17
+ abort 'please specify NML file to process' if ARGV.empty?
18
+
19
+ ARGV.each do |file|
20
+ Traktor::NML.load(file).each_with_index do |track, i|
21
+ puts(out_format.split(/(%[a-zA-Z])/).map do |f|
22
+ case f
23
+ when '%t'
24
+ track.title
25
+ when '%a'
26
+ track.artist
27
+ when '%d'
28
+ track.album[:name]
29
+ when '%i'
30
+ track.album[:track]
31
+ when '%I'
32
+ i+1
33
+ when '%p'
34
+ track.primarykey
35
+ when '%g'
36
+ track.genre
37
+ when '%l'
38
+ track.label
39
+ when '%D'
40
+ track.release_date
41
+ when '%T'
42
+ track.playtime
43
+ when '%b'
44
+ track.bpm
45
+ when '%k'
46
+ track.key
47
+ when '%K'
48
+ track.musical_key
49
+ else
50
+ f
51
+ end
52
+ end.join)
53
+ end
54
+ end
@@ -44,9 +44,9 @@ module Traktor
44
44
  end
45
45
 
46
46
  def track_from_primarykey(primarykey)
47
- @collection.select do |track|
47
+ @collection.find do |track|
48
48
  track.primarykey == primarykey
49
- end.first
49
+ end
50
50
  end
51
51
 
52
52
  def length
@@ -1,5 +1,5 @@
1
1
  module Traktor
2
2
  module NML
3
- VERSION = "0.3.0"
3
+ VERSION = "0.3.1"
4
4
  end
5
5
  end
@@ -33,6 +33,10 @@ describe Traktor::NML do
33
33
  it 'is Enumerable' do
34
34
  expect(@playlist.map{|pl| pl.title }.length).to eq 40
35
35
  end
36
+
37
+ it 'is directly accessed to elements via []' do
38
+ expect(@playlist[10].genre).to eq 'Electro House'
39
+ end
36
40
  end
37
41
 
38
42
  describe Traktor::NML::Collection do
@@ -47,5 +51,52 @@ describe Traktor::NML do
47
51
  it 'is Enumerable' do
48
52
  expect(@file.collection.map{|pl| pl.title }.length).to eq 40
49
53
  end
54
+
55
+ it 'is directly accessed to elements via []' do
56
+ expect(@file.collection[10].genre).to eq 'Progressive House'
57
+ end
58
+ end
59
+
60
+ describe Traktor::NML::Track do
61
+ before do
62
+ @playlist = Traktor::NML.load @path_nml_win
63
+ @track = @playlist[3]
64
+ end
65
+
66
+ describe 'accessor' do
67
+ it 'works as method' do
68
+ expect(@track.title).to eq "Drop (Original Mix)"
69
+ end
70
+
71
+ it 'works as [String]' do
72
+ expect(@track["title"]).to eq "Drop (Original Mix)"
73
+ end
74
+
75
+ it 'works as [Symbol]' do
76
+ expect(@track[:title]).to eq "Drop (Original Mix)"
77
+ end
78
+ end
79
+ end
80
+
81
+ describe Traktor::NML::Cue do
82
+ before do
83
+ @playlist = Traktor::NML.load @path_nml_win
84
+ @cues = @playlist[3].cues
85
+ @cue = @cues[0]
86
+ end
87
+
88
+ describe 'accessor' do
89
+ it 'works as method' do
90
+ expect(@cue.name).to eq "AutoGrid"
91
+ end
92
+
93
+ it 'works as [String]' do
94
+ expect(@cue["name"]).to eq "AutoGrid"
95
+ end
96
+
97
+ it 'works as [Symbol]' do
98
+ expect(@cue[:name]).to eq "AutoGrid"
99
+ end
100
+ end
50
101
  end
51
102
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traktor-nml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - polamjag
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-11 00:00:00.000000000 Z
11
+ date: 2015-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oga
@@ -83,7 +83,8 @@ dependencies:
83
83
  description: Parse Native Instruments Traktor's nml playlist file
84
84
  email:
85
85
  - s@polamjag.info
86
- executables: []
86
+ executables:
87
+ - printnml
87
88
  extensions: []
88
89
  extra_rdoc_files: []
89
90
  files:
@@ -94,6 +95,7 @@ files:
94
95
  - LICENSE.txt
95
96
  - README.md
96
97
  - Rakefile
98
+ - bin/printnml
97
99
  - circle.yml
98
100
  - lib/traktor/nml.rb
99
101
  - lib/traktor/nml/collection.rb