itility 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/Manifest.txt +10 -0
- data/README.txt +52 -0
- data/Rakefile +18 -0
- data/bin/itility +6 -0
- data/lib/itility.rb +125 -0
- data/lib/track.rb +14 -0
- data/test/small_lib.xml +1306 -0
- data/test/test_itility.rb +51 -0
- data/test/test_track.rb +47 -0
- metadata +96 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/usr/bin/env ruby -w
|
2
|
+
|
3
|
+
$: << 'lib'
|
4
|
+
|
5
|
+
require 'test/unit'
|
6
|
+
require 'itility.rb'
|
7
|
+
|
8
|
+
class TestItility < Test::Unit::TestCase
|
9
|
+
@@show = Itility.new
|
10
|
+
@@raw = @@show.all_tracks("test/small_lib.xml")
|
11
|
+
|
12
|
+
def test_number_of_albums
|
13
|
+
actual = @@show.album_count @@raw
|
14
|
+
expected = 20
|
15
|
+
assert_equal actual,expected
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_number_of_artists
|
19
|
+
actual = @@show.artist_count @@raw
|
20
|
+
expected = 12
|
21
|
+
assert_equal actual,expected
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_time_total
|
25
|
+
actual = @@show.time_total @@raw
|
26
|
+
expected = 9078532
|
27
|
+
assert_equal actual,expected
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_top_5_tracks
|
31
|
+
record = @@show.top_tracks_by_played @@raw, 1
|
32
|
+
actual = [record[0].artist, record[0].name, record[0].album]
|
33
|
+
expected = ["Bauhaus", "Kick In The Eye", "1979-1983 Volume Two"]
|
34
|
+
assert_equal actual,expected
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_find_similar_artist
|
38
|
+
record = @@show.top_tracks_by_played @@raw, 2
|
39
|
+
actual = @@show.find_similar_artist record
|
40
|
+
expected = ["Christian Death", "Siouxsie and the Banshees", "Alien Sex Fiend", "The Sisters of Mercy", "Peter Murphy", "Silversun Pickups", "Autolux", "Asobi Seksu", "Film School", "Swervedriver"]
|
41
|
+
assert_equal actual,expected
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_find_similar_song
|
45
|
+
record = @@show.top_tracks_by_played @@raw, 2
|
46
|
+
actual = @@show.find_similar_song record
|
47
|
+
expected = ["Siouxsie and the Banshees - Spellbound", "Siouxsie and the Banshees - Happy House", "Virgin Prunes - Baby Turns Blue", "Alien Sex Fiend - Ignore the Machine", "The Sisters of Mercy - A Rock And A Hard Place"]
|
48
|
+
assert_equal actual,expected
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
data/test/test_track.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
$: << 'lib'
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'track.rb'
|
5
|
+
|
6
|
+
class TestTrack < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@song = Track.new(2824,{:name => "Louise",:artist => "Clan Of Xymox",:total_time => 317805,:album => "Medusa",:play_count => 42})
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_track_id
|
12
|
+
actual = @song.track_id
|
13
|
+
expected = 2824
|
14
|
+
assert_equal expected, actual
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_track_title
|
18
|
+
actual = @song.name
|
19
|
+
expected = "Louise"
|
20
|
+
assert_equal expected, actual
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_track_artist
|
24
|
+
actual = @song.artist
|
25
|
+
expected = "Clan Of Xymox"
|
26
|
+
assert_equal expected, actual
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_track_time
|
30
|
+
actual = @song.total_time
|
31
|
+
expected = 317805
|
32
|
+
assert_equal expected, actual
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_track_album
|
36
|
+
actual = @song.album
|
37
|
+
expected = "Medusa"
|
38
|
+
assert_equal expected, actual
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_track_play_count
|
42
|
+
actual = @song.play_count
|
43
|
+
expected = 42
|
44
|
+
assert_equal expected, actual
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: itility
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ron McKown
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-12-17 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: duration
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.1.0
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: nokogiri
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.6
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: hoe
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.8.0
|
44
|
+
version:
|
45
|
+
description: This simple itility parses your itunes library XML file and outputs song statistics. It also provides artist recommendations based on songs with the highest play count.
|
46
|
+
email:
|
47
|
+
- ron@ventura.nu
|
48
|
+
executables:
|
49
|
+
- itility
|
50
|
+
extensions: []
|
51
|
+
|
52
|
+
extra_rdoc_files:
|
53
|
+
- History.txt
|
54
|
+
- Manifest.txt
|
55
|
+
- README.txt
|
56
|
+
files:
|
57
|
+
- History.txt
|
58
|
+
- Manifest.txt
|
59
|
+
- README.txt
|
60
|
+
- Rakefile
|
61
|
+
- bin/itility
|
62
|
+
- lib/itility.rb
|
63
|
+
- lib/track.rb
|
64
|
+
- test/small_lib.xml
|
65
|
+
- test/test_itility.rb
|
66
|
+
- test/test_track.rb
|
67
|
+
has_rdoc: true
|
68
|
+
homepage: http://rubygems.org/projects/uwruby
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options:
|
71
|
+
- --main
|
72
|
+
- README.txt
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: "0"
|
80
|
+
version:
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: "0"
|
86
|
+
version:
|
87
|
+
requirements: []
|
88
|
+
|
89
|
+
rubyforge_project: uwruby
|
90
|
+
rubygems_version: 1.2.0
|
91
|
+
signing_key:
|
92
|
+
specification_version: 2
|
93
|
+
summary: This simple itility parses your itunes library XML file and outputs song statistics
|
94
|
+
test_files:
|
95
|
+
- test/test_itility.rb
|
96
|
+
- test/test_track.rb
|