rbpod 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,14 @@
1
+ /* track_collection.h */
2
+
3
+ #ifndef RBPOD_TRACK_COLLECTION_H
4
+ #define RBPOD_TRACK_COLLECTION_H
5
+
6
+ #include "track.h"
7
+
8
+ RUBY_EXTERN VALUE mRbPodTrackCollection;
9
+
10
+ void Init_rbpod_track_collection(void);
11
+
12
+ inline VALUE rbpod_track_collection_create(VALUE parent, GList *items);
13
+
14
+ #endif /* RBPOD_TRACK_COLLECTION_H */
data/lib/rbpod/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RbPod
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/rbpod.gemspec CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.add_development_dependency 'bundler', '~> 1.3'
26
26
  spec.add_development_dependency 'rspec', '~> 2.14'
27
+ spec.add_development_dependency 'rdoc', '~> 4.0'
27
28
 
28
29
  spec.add_development_dependency 'rake-compiler', '~> 0.8'
29
30
  spec.add_development_dependency 'rake'
@@ -0,0 +1,39 @@
1
+ describe RbPod::Collection do
2
+ before do
3
+ @block = proc { |item| nil }
4
+ @collection = RbPod::Collection.new
5
+ end
6
+
7
+ describe '.self' do
8
+ it 'should include Enumerable' do
9
+ @collection.class.should include(Enumerable)
10
+ end
11
+ end
12
+
13
+ describe '#initialize' do
14
+ it 'should be a Collection instance' do
15
+ @collection.should be_instance_of(RbPod::Collection)
16
+ end
17
+ end
18
+
19
+ describe '#each' do
20
+ it 'should yield to a block and return nil' do
21
+ @collection.each(&@block).should be_nil
22
+ end
23
+
24
+ it 'should return an Enumerator without a block' do
25
+ @collection.each.should be_kind_of(Enumerator)
26
+ end
27
+ end
28
+
29
+ describe '#length' do
30
+ it 'should be zero' do
31
+ @collection.length.should eq(0)
32
+ end
33
+
34
+ it 'should be aliased to #size' do
35
+ @collection.should respond_to(:size)
36
+ @collection.size.should eq(0)
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,98 @@
1
+ describe RbPod::Database do
2
+ context 'Overall' do
3
+ describe '.create!' do
4
+ it 'should create an empty default database and load it' do
5
+ within_temporary_directory do |directory|
6
+ RbPod::Database.create!(directory).should be_instance_of(RbPod::Database)
7
+ end
8
+ end
9
+
10
+ it 'should throw an error when given an invalid mount point.' do
11
+ proc { RbPod::Database.create!('') }.should raise_error RbPod::Error
12
+ end
13
+
14
+ it 'should throw an error when given an invalid device name.' do
15
+ within_temporary_directory do |directory|
16
+ proc { RbPod::Database.create!(directory, '') }.should raise_error RbPod::Error
17
+ end
18
+ end
19
+
20
+ it 'should throw an error when given an invalid model number.' do
21
+ within_temporary_directory do |directory|
22
+ proc { RbPod::Database.create!(directory, nil, '') }.should raise_error RbPod::Error
23
+ end
24
+ end
25
+ end
26
+
27
+ describe '#initialize' do
28
+ it 'should fail to load a directory without an iPod structure' do
29
+ within_temporary_directory do |directory|
30
+ proc { @database = RbPod::Database.new(directory) }.should raise_error RbPod::Error
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ context 'Given a blank database' do
37
+ before do
38
+ @directory = within_temporary_directory
39
+ @database = RbPod::Database.create!(@directory)
40
+ end
41
+
42
+ after do
43
+ # This is a godawful hack.
44
+ FileUtils.remove_entry_secure(@directory)
45
+ end
46
+
47
+ describe '#initialize' do
48
+ it 'should return a Database instance' do
49
+ @database.should be_instance_of(RbPod::Database)
50
+ end
51
+ end
52
+
53
+ describe '#mountpoint' do
54
+ it 'should match the mount point it was loaded from' do
55
+ @database.mountpoint.should == @directory
56
+ end
57
+ end
58
+
59
+ describe '#filename' do
60
+ it 'should be an existing iTunes database on the file system' do
61
+ File.exists?(@database.filename).should be_true
62
+ end
63
+ end
64
+
65
+ describe '#device' do
66
+ it 'should return a Device instance' do
67
+ @database.device.should be_instance_of(RbPod::Device)
68
+ end
69
+ end
70
+
71
+ describe '#synchronized?' do
72
+ it 'should be marked as synchronized' do
73
+ @database.should be_synchronized
74
+ end
75
+ end
76
+
77
+ describe '#tracks' do
78
+ it 'should return a collection' do
79
+ @database.tracks.should be_instance_of(RbPod::Collection)
80
+ end
81
+
82
+ it 'should have an empty set of tracks' do
83
+ @database.tracks.length.should == 0
84
+ end
85
+ end
86
+
87
+ describe '#playlists' do
88
+ it 'should return a collection' do
89
+ @database.playlists.should be_instance_of(RbPod::Collection)
90
+ end
91
+
92
+ it 'should have a single master playlist' do
93
+ @database.playlists.length.should eq(1)
94
+ @database.playlists.first.should be_master_playlist
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,83 @@
1
+ describe RbPod::Device do
2
+ context 'On a device backed by a blank database' do
3
+ before do
4
+ @directory = within_temporary_directory
5
+ database = RbPod::Database.create!(@directory)
6
+ @device = database.device
7
+ end
8
+
9
+ after do
10
+ # This is a godawful hack.
11
+ FileUtils.remove_entry_secure(@directory)
12
+ end
13
+
14
+ describe '#initialize' do
15
+ it 'should be a private method' do
16
+ @device.singleton_class.private_methods(false).should include(:initialize)
17
+ end
18
+ end
19
+
20
+ describe '#[]' do
21
+ it 'should return a nil value' do
22
+ @device['ModelNumStr'].should be_nil
23
+ end
24
+
25
+ it 'should return nil with an invalid key' do
26
+ @device['NonExistentValue'].should be_nil
27
+ end
28
+
29
+ it 'should return nil when unsetting a key' do
30
+ @device['NotARealKey'] = nil
31
+ @device['NotARealKey'].should be_nil
32
+ end
33
+ end
34
+
35
+ describe '#save!' do
36
+ it 'should return nil' do
37
+ @device.save!.should eq(nil)
38
+ end
39
+ end
40
+
41
+ describe '#uuid' do
42
+ it 'should be nil' do
43
+ @device.uuid.should eq(nil)
44
+ end
45
+ end
46
+
47
+ describe '#capacity' do
48
+ it 'should be zero' do
49
+ @device.capacity.should be_kind_of(Float)
50
+ @device.capacity.should eq(0.0)
51
+ end
52
+ end
53
+
54
+ describe '#generation' do
55
+ it 'should be "Unknown"' do
56
+ @device.generation.should be_kind_of(String)
57
+ @device.generation.should eq('Unknown')
58
+ end
59
+ end
60
+
61
+ describe '#model_name' do
62
+ it 'should be "Invalid"' do
63
+ @device.model_name.should be_kind_of(String)
64
+ @device.model_name.should eq('Invalid')
65
+ end
66
+ end
67
+
68
+ describe '#model_number' do
69
+ it 'should be "Invalid"' do
70
+ @device.model_number.should be_kind_of(String)
71
+ @device.model_number.should eq('Invalid')
72
+ end
73
+ end
74
+
75
+ %w[photos videos artwork podcasts chapter_images].each do |feature|
76
+ describe "#supports_#{feature}?" do
77
+ it 'should be false' do
78
+ @device.send("supports_#{feature}?").should be_false
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,3 @@
1
+ describe RbPod::Playlist do
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ describe RbPod do
2
+ # Nothing yet.
3
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,12 @@
1
1
  require 'rspec'
2
2
  require 'rbpod'
3
+ require 'tmpdir'
3
4
 
4
5
  RSpec.configure do |config|
5
6
  config.color_enabled = true
6
7
  config.formatter = 'documentation'
7
8
  end
9
+
10
+ def within_temporary_directory(&block)
11
+ Dir.mktmpdir(&block)
12
+ end
@@ -0,0 +1,3 @@
1
+ describe RbPod::Track do
2
+
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbpod
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-26 00:00:00.000000000 Z
12
+ date: 2013-11-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -43,6 +43,22 @@ dependencies:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
45
  version: '2.14'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rdoc
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '4.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '4.0'
46
62
  - !ruby/object:Gem::Dependency
47
63
  name: rake-compiler
48
64
  requirement: !ruby/object:Gem::Requirement
@@ -101,6 +117,7 @@ extensions:
101
117
  extra_rdoc_files: []
102
118
  files:
103
119
  - .gitignore
120
+ - .rspec
104
121
  - Gemfile
105
122
  - LICENSE.txt
106
123
  - README.md
@@ -115,14 +132,24 @@ files:
115
132
  - ext/rbpod/extconf.rb
116
133
  - ext/rbpod/playlist.c
117
134
  - ext/rbpod/playlist.h
135
+ - ext/rbpod/playlist_collection.c
136
+ - ext/rbpod/playlist_collection.h
118
137
  - ext/rbpod/rbpod.c
119
138
  - ext/rbpod/rbpod.h
120
139
  - ext/rbpod/track.c
121
140
  - ext/rbpod/track.h
141
+ - ext/rbpod/track_collection.c
142
+ - ext/rbpod/track_collection.h
122
143
  - lib/rbpod.rb
123
144
  - lib/rbpod/version.rb
124
145
  - rbpod.gemspec
146
+ - spec/collection_spec.rb
147
+ - spec/database_spec.rb
148
+ - spec/device_spec.rb
149
+ - spec/playlist_spec.rb
150
+ - spec/rbpod_spec.rb
125
151
  - spec/spec_helper.rb
152
+ - spec/track_spec.rb
126
153
  homepage: https://github.com/jmkeyes/rbpod
127
154
  licenses:
128
155
  - MIT
@@ -138,7 +165,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
165
  version: '0'
139
166
  segments:
140
167
  - 0
141
- hash: 658402081
168
+ hash: -447256177
142
169
  required_rubygems_version: !ruby/object:Gem::Requirement
143
170
  none: false
144
171
  requirements:
@@ -147,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
174
  version: '0'
148
175
  segments:
149
176
  - 0
150
- hash: 658402081
177
+ hash: -447256177
151
178
  requirements:
152
179
  - libgpod-1.0
153
180
  rubyforge_project:
@@ -156,4 +183,10 @@ signing_key:
156
183
  specification_version: 3
157
184
  summary: Ruby bindings to the libgpod library.
158
185
  test_files:
186
+ - spec/collection_spec.rb
187
+ - spec/database_spec.rb
188
+ - spec/device_spec.rb
189
+ - spec/playlist_spec.rb
190
+ - spec/rbpod_spec.rb
159
191
  - spec/spec_helper.rb
192
+ - spec/track_spec.rb