hallon 0.13.0 → 0.14.0

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.
Files changed (44) hide show
  1. data/CHANGELOG.md +43 -1
  2. data/Gemfile +0 -2
  3. data/LICENSE.txt +1 -1
  4. data/README.markdown +94 -44
  5. data/examples/playing_audio.rb +4 -5
  6. data/lib/hallon.rb +20 -0
  7. data/lib/hallon/album.rb +13 -12
  8. data/lib/hallon/album_browse.rb +1 -0
  9. data/lib/hallon/artist.rb +13 -12
  10. data/lib/hallon/artist_browse.rb +1 -0
  11. data/lib/hallon/base.rb +2 -0
  12. data/lib/hallon/image.rb +18 -10
  13. data/lib/hallon/loadable.rb +24 -0
  14. data/lib/hallon/observable.rb +1 -1
  15. data/lib/hallon/observable/playlist.rb +10 -16
  16. data/lib/hallon/observable/playlist_container.rb +12 -6
  17. data/lib/hallon/player.rb +3 -3
  18. data/lib/hallon/playlist.rb +34 -11
  19. data/lib/hallon/playlist_container.rb +10 -4
  20. data/lib/hallon/search.rb +1 -0
  21. data/lib/hallon/session.rb +2 -2
  22. data/lib/hallon/toplist.rb +17 -12
  23. data/lib/hallon/track.rb +1 -0
  24. data/lib/hallon/user.rb +48 -11
  25. data/lib/hallon/version.rb +1 -1
  26. data/spec/hallon/album_browse_spec.rb +2 -0
  27. data/spec/hallon/album_spec.rb +14 -7
  28. data/spec/hallon/artist_browse_spec.rb +2 -0
  29. data/spec/hallon/artist_spec.rb +14 -8
  30. data/spec/hallon/hallon_spec.rb +12 -0
  31. data/spec/hallon/image_spec.rb +18 -9
  32. data/spec/hallon/loadable_spec.rb +46 -0
  33. data/spec/hallon/observable/playlist_spec.rb +11 -5
  34. data/spec/hallon/observable_spec.rb +6 -0
  35. data/spec/hallon/playlist_container_spec.rb +6 -0
  36. data/spec/hallon/playlist_spec.rb +21 -4
  37. data/spec/hallon/search_spec.rb +2 -0
  38. data/spec/hallon/toplist_spec.rb +40 -23
  39. data/spec/hallon/track_spec.rb +2 -0
  40. data/spec/hallon/user_post_spec.rb +75 -0
  41. data/spec/hallon/user_spec.rb +7 -11
  42. data/spec/spec_helper.rb +2 -2
  43. metadata +20 -16
  44. data/examples/audio_driver.rb +0 -55
@@ -0,0 +1,75 @@
1
+ # coding: utf-8
2
+
3
+ describe Hallon::User::Post do
4
+ it { described_class.should include Hallon::Loadable }
5
+
6
+ let(:tracks) do
7
+ [].tap do |tracks|
8
+ tracks << Hallon::Track.new(mock_track)
9
+ tracks << Hallon::Track.new(mock_track_two)
10
+ end
11
+ end
12
+
13
+ let(:post) do
14
+ stub_session { Hallon::User::Post.create("burgestrand", "These be some tight tracks, yo!", tracks) }
15
+ end
16
+
17
+ describe ".new" do
18
+ it "should be private" do
19
+ Hallon::User::Post.should_not respond_to :new
20
+ end
21
+ end
22
+
23
+ describe ".create" do
24
+ it "should return nil if the inboxpost failed" do
25
+ Spotify.should_receive(:inbox_post_tracks).and_return(null_pointer)
26
+ post.should be_nil
27
+ end
28
+
29
+ it "should allow you to post a single track" do
30
+ post = stub_session { Hallon::User::Post.create("burgestrand", nil, tracks[0]) }
31
+ post.tracks.should eq tracks[0, 1]
32
+ end
33
+ end
34
+
35
+ describe "#status" do
36
+ it "should return the inbox post status" do
37
+ post.status.should be :ok
38
+ end
39
+ end
40
+
41
+ describe "#tracks" do
42
+ it "should return an array of tracks posted" do
43
+ post.tracks.should eq tracks
44
+ end
45
+ end
46
+
47
+ describe "#loaded?" do
48
+ it "should return true only if the status is ok" do
49
+ post.should_receive(:status).and_return(:is_loading)
50
+ post.should_not be_loaded
51
+ end
52
+
53
+ it "should be true if the inbox post operation has completed" do
54
+ post.should be_loaded
55
+ end
56
+ end
57
+
58
+ describe "#message" do
59
+ it "should return the message sent with the post" do
60
+ post.message.should eq "These be some tight tracks, yo!"
61
+ end
62
+ end
63
+
64
+ describe "#recipient" do
65
+ it "should return the recipient" do
66
+ post.recipient.should eq Hallon::User.new("burgestrand")
67
+ end
68
+ end
69
+
70
+ describe "#recipient_name" do
71
+ it "should return the username of the post recipient" do
72
+ post.recipient_name.should eq "burgestrand"
73
+ end
74
+ end
75
+ end
@@ -1,5 +1,7 @@
1
1
  # coding: utf-8
2
2
  describe Hallon::User do
3
+ it { described_class.should include Hallon::Loadable }
4
+
3
5
  it_should_behave_like "a Linkable object" do
4
6
  let(:spotify_uri) { "spotify:user:burgestrand" }
5
7
  let(:custom_object) { "burgestrand" }
@@ -30,23 +32,17 @@ describe Hallon::User do
30
32
  let(:post) { mock_session { user.post(tracks) } }
31
33
  let(:tracks) { instantiate(Hallon::Track, mock_track, mock_track_two) }
32
34
 
33
- it "should have an error status" do
34
- post.status.should eq :ok
35
- end
36
-
37
35
  it "should post to the correct user" do
38
- Spotify.should_receive(:inbox_post_tracks).with(any_args, user.name, any_args, any_args, any_args, any_args, any_args).and_return(null_pointer)
39
- mock_session { user.post(tracks) }
36
+ post.recipient_name.should eq user.name
40
37
  end
41
38
 
42
- it "should use given message if available" do
43
- Spotify.should_receive(:inbox_post_tracks).with(any_args, any_args, any_args, any_args, "Hello there", any_args, any_args).and_return(null_pointer)
44
- mock_session { user.post("Hello there", tracks) }
39
+ it "should post with the given message" do
40
+ post.message.should be_nil
41
+ stub_session { user.post("Hey ho!", tracks) }.message.should eq "Hey ho!"
45
42
  end
46
43
 
47
44
  it "should return nil on failure" do
48
- Spotify.should_receive(:inbox_post_tracks).and_return(null_pointer)
49
- mock_session { user.post([]).should be_nil }
45
+ stub_session { user.post([]).should be_nil }
50
46
  end
51
47
  end
52
48
 
data/spec/spec_helper.rb CHANGED
@@ -39,12 +39,12 @@ RSpec.configure do |config|
39
39
 
40
40
  def stub_session(target = nil)
41
41
  if target
42
- target.stub(:session).and_return(session)
42
+ target.any_instance.stub(:session).and_return(session)
43
43
  else
44
44
  Hallon::Session.stub(:instance).and_return(session)
45
45
  end
46
46
 
47
- target.tap { yield if block_given? }
47
+ target || (yield if block_given?)
48
48
  end
49
49
 
50
50
  def pointer_array_with(*args)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hallon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.14.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-05 00:00:00.000000000 Z
12
+ date: 2012-02-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ref
16
- requirement: &70259239927580 !ruby/object:Gem::Requirement
16
+ requirement: &70180063490240 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70259239927580
24
+ version_requirements: *70180063490240
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: spotify
27
- requirement: &70259239926980 !ruby/object:Gem::Requirement
27
+ requirement: &70180063489400 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 10.3.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70259239926980
35
+ version_requirements: *70180063489400
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70259239926460 !ruby/object:Gem::Requirement
38
+ requirement: &70180063487500 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0.8'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70259239926460
46
+ version_requirements: *70180063487500
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &70259239926000 !ruby/object:Gem::Requirement
49
+ requirement: &70180063485340 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '2'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70259239926000
57
+ version_requirements: *70180063485340
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: yard
60
- requirement: &70259239925600 !ruby/object:Gem::Requirement
60
+ requirement: &70180063484620 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70259239925600
68
+ version_requirements: *70180063484620
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rdiscount
71
- requirement: &70259239925140 !ruby/object:Gem::Requirement
71
+ requirement: &70180063483960 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70259239925140
79
+ version_requirements: *70180063483960
80
80
  description:
81
81
  email: kim@burgestrand.se
82
82
  executables: []
@@ -97,7 +97,6 @@ files:
97
97
  - Rakefile
98
98
  - dev/login.rb
99
99
  - examples/adding_tracks_to_playlist.rb
100
- - examples/audio_driver.rb
101
100
  - examples/logging_in.rb
102
101
  - examples/playing_audio.rb
103
102
  - examples/printing_link_information.rb
@@ -118,6 +117,7 @@ files:
118
117
  - lib/hallon/image.rb
119
118
  - lib/hallon/link.rb
120
119
  - lib/hallon/linkable.rb
120
+ - lib/hallon/loadable.rb
121
121
  - lib/hallon/observable.rb
122
122
  - lib/hallon/observable/album_browse.rb
123
123
  - lib/hallon/observable/artist_browse.rb
@@ -153,6 +153,7 @@ files:
153
153
  - spec/hallon/image_spec.rb
154
154
  - spec/hallon/link_spec.rb
155
155
  - spec/hallon/linkable_spec.rb
156
+ - spec/hallon/loadable_spec.rb
156
157
  - spec/hallon/observable/album_browse_spec.rb
157
158
  - spec/hallon/observable/artist_browse_spec.rb
158
159
  - spec/hallon/observable/image_spec.rb
@@ -171,6 +172,7 @@ files:
171
172
  - spec/hallon/spotify_spec.rb
172
173
  - spec/hallon/toplist_spec.rb
173
174
  - spec/hallon/track_spec.rb
175
+ - spec/hallon/user_post_spec.rb
174
176
  - spec/hallon/user_spec.rb
175
177
  - spec/mockspotify.rb
176
178
  - spec/mockspotify/.gitignore
@@ -230,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
232
  version: '0'
231
233
  requirements: []
232
234
  rubyforge_project:
233
- rubygems_version: 1.8.15
235
+ rubygems_version: 1.8.17
234
236
  signing_key:
235
237
  specification_version: 3
236
238
  summary: Hallon allows you to write Ruby applications utilizing the official Spotify
@@ -251,6 +253,7 @@ test_files:
251
253
  - spec/hallon/image_spec.rb
252
254
  - spec/hallon/link_spec.rb
253
255
  - spec/hallon/linkable_spec.rb
256
+ - spec/hallon/loadable_spec.rb
254
257
  - spec/hallon/observable/album_browse_spec.rb
255
258
  - spec/hallon/observable/artist_browse_spec.rb
256
259
  - spec/hallon/observable/image_spec.rb
@@ -269,6 +272,7 @@ test_files:
269
272
  - spec/hallon/spotify_spec.rb
270
273
  - spec/hallon/toplist_spec.rb
271
274
  - spec/hallon/track_spec.rb
275
+ - spec/hallon/user_post_spec.rb
272
276
  - spec/hallon/user_spec.rb
273
277
  - spec/mockspotify.rb
274
278
  - spec/mockspotify/.gitignore
@@ -1,55 +0,0 @@
1
- # coding: utf-8
2
- require 'monitor'
3
-
4
- begin
5
- require 'coreaudio'
6
- rescue LoadError
7
- abort <<-ERROR
8
- This example requires the ruby-coreaudio gem.
9
-
10
- See: http://rubygems.org/gems/coreaudio
11
- ERROR
12
- end
13
-
14
- puts <<-INFO
15
- **************************************************************
16
-
17
- Keep in mind, you’re now using the CoreAudio driver, part
18
- of Hallon examples. This driver does not buffer data, so
19
- even the slightest hickup in Ruby will make the playback
20
- stutter. The reason is that this CoreAudio driver does not
21
- buffer data internally.
22
-
23
- **************************************************************
24
- INFO
25
-
26
- module Hallon
27
- class CoreAudio
28
- attr_reader :output
29
- protected :output
30
-
31
- def initialize(format)
32
- @device = ::CoreAudio.default_output_device
33
- @output = @device.output_buffer(format[:rate] * 3)
34
- @format = format
35
- end
36
-
37
- attr_accessor :format
38
-
39
- def stream
40
- loop { output << yield }
41
- end
42
-
43
- def play
44
- output.start
45
- end
46
-
47
- def stop
48
- output.stop
49
- end
50
-
51
- def pause
52
- output.stop
53
- end
54
- end
55
- end