imine 0.1.2
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 +14 -0
- data/README.txt +57 -0
- data/Rakefile +17 -0
- data/bin/imine +5 -0
- data/lib/discog.rb +52 -0
- data/lib/imine.rb +116 -0
- data/lib/output.rb +81 -0
- data/lib/track.rb +11 -0
- data/test/small_lib.xml +1306 -0
- data/test/test_discog.rb +74 -0
- data/test/test_imine.rb +125 -0
- data/test/test_output.rb +69 -0
- data/test/test_track.rb +20 -0
- metadata +102 -0
data/test/test_discog.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
#!/usr/bin/env ruby -w
|
2
|
+
|
3
|
+
$: << 'lib'
|
4
|
+
|
5
|
+
require 'test/unit'
|
6
|
+
require 'discog'
|
7
|
+
|
8
|
+
##
|
9
|
+
# Student Name: Brandon Caplan
|
10
|
+
# Homework Week: 8
|
11
|
+
#
|
12
|
+
#
|
13
|
+
|
14
|
+
class TestDiscog < Test::Unit::TestCase
|
15
|
+
|
16
|
+
@@massive = Discog.new("Massive Attack")
|
17
|
+
@@bad = Discog.new("jose gonzoles")
|
18
|
+
@@radiohead = Discog.new("radiohead")
|
19
|
+
|
20
|
+
|
21
|
+
def test_get_good_artist
|
22
|
+
assert_equal "Radiohead", @@radiohead.name
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_get_bad_artist
|
26
|
+
assert_nothing_raised do
|
27
|
+
Discog.new("jose gonzoles")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_getting_bad_artist_has_blank_name
|
32
|
+
assert_equal "", @@bad.name
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_getting_bad_artist_has_blank_profile
|
36
|
+
assert_equal "", @@bad.profile
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_getting_bad_artist_has_blank_realname
|
40
|
+
assert_equal "", @@bad.realname
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_getting_bad_artist_has_blank_members
|
44
|
+
assert_equal [], @@bad.members
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_xml_not_gzipped
|
48
|
+
assert_nothing_raised do
|
49
|
+
Discog.new("bb king")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_xml_not_gzipped_gets_info
|
54
|
+
artist = Discog.new("bb king")
|
55
|
+
|
56
|
+
assert_equal "BB King", artist.name
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
def test_profile
|
61
|
+
actual = @@massive.profile
|
62
|
+
expected = "Massive Attack temporarily changed their group name to 'Massive' during the 1991 Gulf War"
|
63
|
+
|
64
|
+
assert_equal expected, actual
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_realname
|
68
|
+
actual = @@massive.realname
|
69
|
+
expected = 'Robert "3D" del Naja, Grant "Daddy G" Marshall and Andrew "Mushroom" Vowles'
|
70
|
+
|
71
|
+
assert_equal expected, actual
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
data/test/test_imine.rb
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
#!/usr/bin/env ruby -w
|
2
|
+
|
3
|
+
$: << 'lib'
|
4
|
+
|
5
|
+
require 'test/unit'
|
6
|
+
require 'imine'
|
7
|
+
|
8
|
+
##
|
9
|
+
# Student Name: Brandon Caplan
|
10
|
+
# Homework Week: 8
|
11
|
+
#
|
12
|
+
#
|
13
|
+
|
14
|
+
class TestImine < Test::Unit::TestCase
|
15
|
+
@@file = Imine.new('./test/small_lib.xml')
|
16
|
+
|
17
|
+
def test_date_is_time
|
18
|
+
actual = @@file.tracks.first.date_added.class
|
19
|
+
expected = Time
|
20
|
+
|
21
|
+
assert_equal expected, actual
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_integer_is_fixnum
|
25
|
+
actual = @@file.tracks.first.total_time.class
|
26
|
+
expected = Fixnum
|
27
|
+
|
28
|
+
assert_equal expected, actual
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_other_is_string
|
32
|
+
actual = @@file.tracks.first.name.class
|
33
|
+
expected = String
|
34
|
+
|
35
|
+
assert_equal expected, actual
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_count_by_field
|
39
|
+
actual = @@file.count_by_field :album
|
40
|
+
expected = 20
|
41
|
+
|
42
|
+
assert_equal expected, actual
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_number_of_albums
|
46
|
+
actual = @@file.number_of_albums
|
47
|
+
expected = 20
|
48
|
+
|
49
|
+
assert_equal expected, actual
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_number_of_artists
|
53
|
+
actual = @@file.number_of_artists
|
54
|
+
expected = 12
|
55
|
+
|
56
|
+
assert_equal expected, actual
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_number_of_tracks
|
60
|
+
actual = @@file.number_of_tracks
|
61
|
+
expected = 41
|
62
|
+
|
63
|
+
assert_equal expected, actual
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_most_played
|
67
|
+
actual = @@file.most_played
|
68
|
+
expected = [["Kick In The Eye", 24, 80, "Bauhaus"],
|
69
|
+
["Lazy Eye", 22, 0, "Silversun Pickups"],
|
70
|
+
["Lagartija Nick", 22, 100, "Bauhaus"],
|
71
|
+
["Hollow Hills", 20, 100, "Bauhaus"],
|
72
|
+
["How Blue Can You Get?", 20, 100, "B.B. King"],
|
73
|
+
["The Thrill Is Gone", 20, 80, "B.B. King"],
|
74
|
+
["Sweet Sixteen", 20, 100, "B.B. King"],
|
75
|
+
["In Fear Of Fear", 19, 80, "Bauhaus"],
|
76
|
+
["Song 2", 16, 0, "Blur"],
|
77
|
+
["Worry, Worry, Worry", 13, 80, "B.B. King"]]
|
78
|
+
|
79
|
+
assert_equal expected, actual
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_total_playtime
|
83
|
+
actual = @@file.total_playtime
|
84
|
+
expected = 9078532
|
85
|
+
|
86
|
+
assert_equal expected, actual
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_top_year
|
90
|
+
actual = @@file.top_year
|
91
|
+
expected = 1970
|
92
|
+
|
93
|
+
assert_equal expected, actual
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_get_stars
|
97
|
+
actual = @@file.get_stars(40)
|
98
|
+
expected = 2
|
99
|
+
|
100
|
+
assert_equal expected, actual
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_get_zero_stars
|
104
|
+
actual = @@file.get_stars(0)
|
105
|
+
expected = 0
|
106
|
+
|
107
|
+
assert_equal expected, actual
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
def test_get_stars_visual
|
112
|
+
actual = @@file.get_stars(80, :visual)
|
113
|
+
expected = "****"
|
114
|
+
|
115
|
+
assert_equal expected, actual
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_get_zero_stars_visual
|
119
|
+
actual = @@file.get_stars(0, :visual)
|
120
|
+
expected = ""
|
121
|
+
|
122
|
+
assert_equal expected, actual
|
123
|
+
|
124
|
+
end
|
125
|
+
end
|
data/test/test_output.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
#!/usr/bin/env ruby -w
|
2
|
+
|
3
|
+
$: << 'lib'
|
4
|
+
|
5
|
+
require 'test/unit'
|
6
|
+
require 'output'
|
7
|
+
|
8
|
+
##
|
9
|
+
# Student Name: Brandon Caplan
|
10
|
+
# Homework Week: 8
|
11
|
+
#
|
12
|
+
#
|
13
|
+
|
14
|
+
class TestOutput < Test::Unit::TestCase
|
15
|
+
|
16
|
+
@@massive = Discog.new("Massive Attack")
|
17
|
+
@@jose = Discog.new("Jose Gonzales")
|
18
|
+
@@moby = Discog.new("Moby")
|
19
|
+
|
20
|
+
def setup
|
21
|
+
@out = StringIO.new
|
22
|
+
$stdout = @out
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_no_input
|
26
|
+
Output.run([])
|
27
|
+
|
28
|
+
actual = @out.string
|
29
|
+
expected = "USAGE: imine [path to itunes xml] [number of top tracks to list (optional, defaults to 10)]\n"
|
30
|
+
|
31
|
+
assert_equal expected, actual
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_convert_time
|
35
|
+
actual = Output.convert_time(123456789)
|
36
|
+
expected = { :days => 1,
|
37
|
+
:hours => 10,
|
38
|
+
:minutes => 17,
|
39
|
+
:seconds => 37, }
|
40
|
+
|
41
|
+
assert_equal expected, actual
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_members_multiple_members
|
45
|
+
actual = Output.members(@@massive)
|
46
|
+
expected = ["Andrew Vowles", "Grant Marshall", "and Robert Del Naja"]
|
47
|
+
|
48
|
+
assert_equal expected, actual
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_members_known_by_real_name
|
52
|
+
actual = Output.members(@@jose)
|
53
|
+
expected = ["Jose Gonzales"]
|
54
|
+
|
55
|
+
assert_equal expected, actual
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_members_known_by_moniker_one_member
|
59
|
+
actual = Output.members(@@moby)
|
60
|
+
expected = ["Richard Melville Hall"]
|
61
|
+
|
62
|
+
assert_equal expected, actual
|
63
|
+
end
|
64
|
+
|
65
|
+
def teardown
|
66
|
+
$stdout = STDOUT
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
data/test/test_track.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby -w
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'track'
|
5
|
+
|
6
|
+
##
|
7
|
+
# Student Name: Brandon Caplan
|
8
|
+
# Homework Week: 8
|
9
|
+
#
|
10
|
+
#
|
11
|
+
|
12
|
+
class TestTrack < Test::Unit::TestCase
|
13
|
+
def test_attribute
|
14
|
+
@track = Track.new({:name => "Track Name"})
|
15
|
+
actual = @track.name
|
16
|
+
expected = "Track Name"
|
17
|
+
|
18
|
+
assert_equal expected, actual
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: imine
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brandon Caplan
|
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: nokogiri
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.8.3
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: term-ansicolor
|
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.3
|
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.7.0
|
44
|
+
version:
|
45
|
+
description: Parses an iTunes XML file and provides useful data. Also includes a command-line tool that presents the data.
|
46
|
+
email:
|
47
|
+
- maelmann@gmail.com
|
48
|
+
executables:
|
49
|
+
- imine
|
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/imine
|
62
|
+
- lib/discog.rb
|
63
|
+
- lib/imine.rb
|
64
|
+
- lib/output.rb
|
65
|
+
- lib/track.rb
|
66
|
+
- test/small_lib.xml
|
67
|
+
- test/test_discog.rb
|
68
|
+
- test/test_imine.rb
|
69
|
+
- test/test_output.rb
|
70
|
+
- test/test_track.rb
|
71
|
+
has_rdoc: true
|
72
|
+
homepage: http://rubyforge.org/projects/uwruby
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options:
|
75
|
+
- --main
|
76
|
+
- README.txt
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: "0"
|
84
|
+
version:
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: "0"
|
90
|
+
version:
|
91
|
+
requirements: []
|
92
|
+
|
93
|
+
rubyforge_project: uwruby
|
94
|
+
rubygems_version: 1.2.0
|
95
|
+
signing_key:
|
96
|
+
specification_version: 2
|
97
|
+
summary: Parses an iTunes XML file and provides useful data
|
98
|
+
test_files:
|
99
|
+
- test/test_discog.rb
|
100
|
+
- test/test_imine.rb
|
101
|
+
- test/test_output.rb
|
102
|
+
- test/test_track.rb
|