cultome_player 2.0.0 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +24 -79
  3. data/Rakefile +38 -4
  4. data/bin/cultome_player +16 -4
  5. data/config/environment.yml +4 -0
  6. data/cultome_player.gemspec +8 -1
  7. data/lib/cultome_player.rb +45 -19
  8. data/lib/cultome_player/command/language.rb +3 -4
  9. data/lib/cultome_player/command/processor.rb +9 -7
  10. data/lib/cultome_player/command/reader.rb +11 -2
  11. data/lib/cultome_player/environment.rb +21 -13
  12. data/lib/cultome_player/events.rb +7 -7
  13. data/lib/cultome_player/objects/album.rb +9 -2
  14. data/lib/cultome_player/objects/artist.rb +9 -2
  15. data/lib/cultome_player/objects/command.rb +10 -1
  16. data/lib/cultome_player/objects/drive.rb +4 -1
  17. data/lib/cultome_player/objects/genre.rb +4 -1
  18. data/lib/cultome_player/objects/parameter.rb +21 -1
  19. data/lib/cultome_player/objects/response.rb +5 -1
  20. data/lib/cultome_player/objects/song.rb +9 -4
  21. data/lib/cultome_player/player/adapter/mpg123.rb +3 -4
  22. data/lib/cultome_player/player/interactive.rb +67 -11
  23. data/lib/cultome_player/player/interface/basic.rb +13 -9
  24. data/lib/cultome_player/player/interface/extended.rb +26 -12
  25. data/lib/cultome_player/player/interface/helper.rb +73 -9
  26. data/lib/cultome_player/plugins.rb +44 -18
  27. data/lib/cultome_player/plugins/alias.rb +85 -0
  28. data/lib/cultome_player/plugins/gestures.rb +90 -0
  29. data/lib/cultome_player/plugins/help.rb +4 -4
  30. data/lib/cultome_player/plugins/keyboard_special_keys.rb +22 -0
  31. data/lib/cultome_player/plugins/points.rb +51 -0
  32. data/lib/cultome_player/utils.rb +117 -7
  33. data/lib/cultome_player/version.rb +1 -1
  34. data/xbindkeys/xbindkeysrc +12 -0
  35. metadata +37 -89
  36. data/.coveralls.yml +0 -1
  37. data/.gitignore +0 -24
  38. data/.rspec +0 -2
  39. data/.travis.yml +0 -7
  40. data/db/001_create_schema.rb +0 -58
  41. data/spec/config.yml +0 -0
  42. data/spec/cultome_player/command/processor_spec.rb +0 -168
  43. data/spec/cultome_player/command/reader_spec.rb +0 -45
  44. data/spec/cultome_player/cultome_player_spec.rb +0 -17
  45. data/spec/cultome_player/environment_spec.rb +0 -65
  46. data/spec/cultome_player/events_spec.rb +0 -22
  47. data/spec/cultome_player/media_spec.rb +0 -41
  48. data/spec/cultome_player/player/adapter/mpg123_spec.rb +0 -82
  49. data/spec/cultome_player/player/interface/basic_spec.rb +0 -168
  50. data/spec/cultome_player/player/interface/extended/connect_spec.rb +0 -117
  51. data/spec/cultome_player/player/interface/extended/search_spec.rb +0 -90
  52. data/spec/cultome_player/player/interface/extended/show_spec.rb +0 -36
  53. data/spec/cultome_player/player/interface/extended/shuffle_spec.rb +0 -26
  54. data/spec/cultome_player/player/interface/extended_spec.rb +0 -136
  55. data/spec/cultome_player/player/interface/helper_spec.rb +0 -63
  56. data/spec/cultome_player/player/interface_spec.rb +0 -17
  57. data/spec/cultome_player/player/playlist_spec.rb +0 -301
  58. data/spec/cultome_player/plugins/help_spec.rb +0 -21
  59. data/spec/cultome_player/plugins_spec.rb +0 -19
  60. data/spec/cultome_player/utils_spec.rb +0 -15
  61. data/spec/spec_helper.rb +0 -108
  62. data/spec/test/uno/dos/dos.mp3 +0 -0
  63. data/spec/test/uno/dos/tres/tres.mp3 +0 -0
  64. data/spec/test/uno/uno.mp3 +0 -0
  65. data/tasks/console.rake +0 -19
  66. data/tasks/db.rake +0 -19
  67. data/tasks/run.rake +0 -7
@@ -1,36 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe CultomePlayer::Player::Interface::Extended do
4
- let(:t){ TestClass.new }
5
- context 'when no playlist is active and no parameters' do
6
- it 'shows a message saying so, and giving instructions to play' do
7
- r = t.execute 'show'
8
- r.message.should eq "Nothing to show yet. Try with 'play' first."
9
- end
10
- end
11
-
12
- context 'with and active playlist and playback' do
13
- before :each do
14
- t.execute "connect '#{test_folder}' => test"
15
- t.execute 'play'
16
- end
17
-
18
- it 'without parameters shows the current song' do
19
- r = t.execute 'show'
20
- r.message.should match /^:::: Song: .+? (\\ Artist: .+? \\ Album: .+? )?::::$/
21
- r.message.should match /[\d]{2}:[\d]{2} \|[#_]+?\| [\d]{2}:[\d]{2}/
22
- end
23
-
24
- context 'with object parameter' do
25
- it 'library' do
26
- r = t.execute 'show @library'
27
- r.list.should_not be_empty
28
- end
29
-
30
- it 'song' do
31
- r = t.execute 'show @song'
32
- r.message.should match /:::: Song: .+? (\\ Artist: .+? )?(\\ Album: .+? )?::::\n?/
33
- end
34
- end
35
- end
36
- end
@@ -1,26 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe CultomePlayer::Player::Interface::Extended do
4
- let(:t){ TestClass.new }
5
-
6
- context '#shuffle' do
7
- it 'check shuffle status' do
8
- r = t.execute('shuffle')
9
- r.message.should eq "No shuffling"
10
- r.shuffling.should be_false
11
- end
12
-
13
- it 'turn on the shuffle' do
14
- t.should_not be_shuffling
15
- t.execute('shuffle on')
16
- t.should be_shuffling
17
- end
18
-
19
- it 'turn off shuffle' do
20
- t.execute('shuffle on')
21
- t.should be_shuffling
22
- t.execute('shuffle off')
23
- t.should_not be_shuffling
24
- end
25
- end
26
- end
@@ -1,136 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe CultomePlayer::Player::Interface::Extended do
4
- let(:t){ TestClass.new }
5
-
6
- it 'repeats a song from the beginning' do
7
- t.should_receive(:send_to_player).with(/^jump 0$/)
8
- t.repeat(nil)
9
- end
10
-
11
- describe 'search' do
12
- it 'respond to description_search' do
13
- t.should respond_to(:description_search)
14
- end
15
-
16
- it 'respond to usage_search' do
17
- t.should respond_to(:usage_search)
18
- end
19
-
20
- it 'respond with Response object' do
21
- t.execute("search on").should be_instance_of Response
22
- end
23
- end
24
-
25
- describe 'show' do
26
- it 'respond to description_show' do
27
- t.should respond_to(:description_show)
28
- end
29
-
30
- it 'respond to usage_show' do
31
- t.should respond_to(:usage_show)
32
- end
33
-
34
- it 'respond with Response object' do
35
- t.execute("show").should be_instance_of Response
36
- end
37
- end
38
-
39
- describe 'enqueue' do
40
- it 'respond to description_enqueue' do
41
- t.should respond_to(:description_enqueue)
42
- end
43
-
44
- it 'respond to usage_enqueue' do
45
- t.should respond_to(:usage_enqueue)
46
- end
47
-
48
- it 'respond with Response object' do
49
- t.execute("enqueue on").should be_instance_of Response
50
- end
51
- end
52
-
53
- describe 'shuffle' do
54
- it 'respond to description_shuffle' do
55
- t.should respond_to(:description_shuffle)
56
- end
57
-
58
- it 'respond to usage_shuffle' do
59
- t.should respond_to(:usage_shuffle)
60
- end
61
-
62
- it 'respond with Response object' do
63
- t.execute("shuffle on").should be_instance_of Response
64
- end
65
- end
66
-
67
- describe 'connect' do
68
- it 'respond to description_connect' do
69
- t.should respond_to(:description_connect)
70
- end
71
-
72
- it 'respond to usage_connect' do
73
- t.should respond_to(:usage_connect)
74
- end
75
-
76
- it 'respond with Response object' do
77
- t.execute("connect drive").should be_instance_of Response
78
- end
79
- end
80
-
81
- describe 'disconnect' do
82
- it 'respond to description_disconnect' do
83
- t.should respond_to(:description_disconnect)
84
- end
85
-
86
- it 'respond to usage_disconnect' do
87
- t.should respond_to(:usage_disconnect)
88
- end
89
-
90
- it 'respond with Response object' do
91
- t.execute("disconnect drive").should be_instance_of Response
92
- end
93
- end
94
-
95
- describe 'ff' do
96
- it 'respond to description_ff' do
97
- t.should respond_to(:description_ff)
98
- end
99
-
100
- it 'respond to usage_ff' do
101
- t.should respond_to(:usage_ff)
102
- end
103
-
104
- it 'respond with Response object' do
105
- t.execute("ff").should be_instance_of Response
106
- end
107
- end
108
-
109
- describe 'fb' do
110
- it 'respond to description_fb' do
111
- t.should respond_to(:description_fb)
112
- end
113
-
114
- it 'respond to usage_fb' do
115
- t.should respond_to(:usage_fb)
116
- end
117
-
118
- it 'respond with Response object' do
119
- t.execute("fb").should be_instance_of Response
120
- end
121
- end
122
-
123
- describe 'repeat' do
124
- it 'respond to description_repeat' do
125
- t.should respond_to(:description_repeat)
126
- end
127
-
128
- it 'respond to usage_repeat' do
129
- t.should respond_to(:usage_repeat)
130
- end
131
-
132
- it 'respond with Response object' do
133
- t.execute("repeat").should be_instance_of Response
134
- end
135
- end
136
- end
@@ -1,63 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe CultomePlayer::Player::Interface::Helper do
4
- let(:t){ TestClass.new }
5
-
6
- it 'raise an error if processing a unknown object' do
7
- expect{ t.process_for_search([Parameter.new({type: :object, value: 'unknown'})]) }.to raise_error 'invalid search:unknown type'
8
- end
9
-
10
- it 'create a progress bar' do
11
- t.get_progress_bar(55, 200, 10).should eq "|##________|"
12
- t.get_progress_bar(55, 100, 10).should eq "|#####_____|"
13
- t.get_progress_bar(55, 100, 20).should eq "|###########_________|"
14
- end
15
-
16
- it 'create a progress bar with labels in both sides' do
17
- t.get_progress_bar_with_labels(5, 10, 10, "left", "right").should eq "left |#####_____| right"
18
- t.get_progress_bar_with_labels(5, 10, 10, "left").should eq "left |#####_____|"
19
- t.get_progress_bar_with_labels(5, 10, 10, "", "right").should eq "|#####_____| right"
20
- end
21
-
22
- it 'format seconds to minutos:seconds' do
23
- t.format_secs(4).should eq "00:04"
24
- t.format_secs(75).should eq "01:15"
25
- t.format_secs(65).should eq "01:05"
26
- end
27
-
28
- describe '#process_object_for_search' do
29
- it 'returns sql criteria and values for object type artist' do
30
- artist = double("artist", name: "artist_name")
31
- t.should_receive(:current_artist).and_return(artist)
32
-
33
- q,v = t.send(:process_object_for_search, [Parameter.new({type: :object, value: :artist})] )
34
- q.should eq 'artists.name = ?'
35
- v.should eq ["artist_name"]
36
- end
37
-
38
- it 'returns sql criteria and values for object type album' do
39
- album = double("album", name: "album_name")
40
- t.should_receive(:current_album).and_return(album)
41
-
42
- q,v = t.send(:process_object_for_search, [Parameter.new({type: :object, value: :album})] )
43
- q.should eq 'albums.name = ?'
44
- v.should eq ["album_name"]
45
- end
46
-
47
- it 'returns sql criteria and values for object type song' do
48
- song = double("song", name: "song_name")
49
- t.should_receive(:current_song).and_return(song)
50
-
51
- q,v = t.send(:process_object_for_search, [Parameter.new({type: :object, value: :song})] )
52
- q.should eq 'songs.name = ?'
53
- v.should eq ["song_name"]
54
- end
55
-
56
- it 'returns sql criteria and values for object type library' do
57
- q,v = t.send(:process_object_for_search, [Parameter.new({type: :object, value: :library})] )
58
- q.should eq 'songs.id > 0'
59
- v.should be_empty
60
- end
61
- end
62
-
63
- end
@@ -1,17 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe CultomePlayer::Player::Interface do
4
- let(:t){ TestClass.new }
5
-
6
- it 'respond to basic commands' do
7
- [:play , :pause , :stop , :next , :prev , :quit].each do |cmd|
8
- t.should respond_to cmd
9
- end
10
- end
11
-
12
- it 'respond to extended commands' do
13
- [:show , :enqueue , :search , :shuffle , :connect , :disconnect , :ff , :fb].each do |cmd|
14
- t.should respond_to cmd
15
- end
16
- end
17
- end
@@ -1,301 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe CultomePlayer::Player::Playlist do
4
- let(:p){ CultomePlayer::Player::Playlist::Playlists.new }
5
-
6
- it 'add a new playlist' do
7
- p.should be_empty
8
- p.register(:playlist)
9
- p.should have(1).item
10
- end
11
-
12
- it 'raise error if trying to use a unregistered playlist' do
13
- expect{ p[:playlist] }.to raise_error('unknown playlist:playlist is not registered' )
14
- end
15
-
16
- context 'with a playlist registered' do
17
- before :each do
18
- p.register(:playlist)
19
- end
20
-
21
- it 'should return playlists object' do
22
- p[:playlist].should be_instance_of CultomePlayer::Player::Playlist::Playlists
23
- end
24
-
25
- it 'raise and error if traying to register a previous registered playlist' do
26
- expect{ p.register(:playlist) }.to raise_error('invalid registry:playlist already registered')
27
- end
28
-
29
- it 'get a playlist by name' do
30
- p[:playlist].should have(1).item
31
- p[:playlist].first.should_not be_nil
32
- end
33
-
34
- it 'add an element to an existing playlist' do
35
- p[:playlist].first.should be_empty
36
- p[:playlist] << "eleme"
37
- p[:playlist].first.should have(1).item
38
- p[:playlist] << "eleme"
39
- p[:playlist].first.should have(2).item
40
- end
41
-
42
- it 'replace the content of a playlist' do
43
- p[:playlist].first.should be_empty
44
- p[:playlist] << "eleme"
45
- p[:playlist] << "eleme"
46
- p[:playlist].first.should have(2).item
47
- p[:playlist] <= %w{uno dos tres cuatro}
48
- p[:playlist].first.should have(4).item
49
- end
50
-
51
- it 'raise an error if trying to get the next song in an empty list' do
52
- expect{ p[:playlist].next }.to raise_error 'playlist empty:no songs in playlists'
53
- end
54
-
55
- it 'change shuffle status' do
56
- p[:playlist].should_not be_shuffling
57
- p[:playlist].shuffle
58
- p[:playlist].should be_shuffling
59
- p[:playlist].order
60
- p[:playlist].should_not be_shuffling
61
- end
62
-
63
- context 'with a full playlist' do
64
- before :each do
65
- p[:playlist] <= %w{uno dos tres cuatro}
66
- end
67
-
68
- it 'shuffle the content of the playlist' do
69
- p[:playlist].first.should eq %w{uno dos tres cuatro}
70
- p[:playlist].shuffle
71
- p[:playlist].shuffle if p[:playlist].first == %w{uno dos tres cuatro}
72
- p[:playlist].first.should_not eq %w{uno dos tres cuatro}
73
- end
74
-
75
- it 'get an element by index' do
76
- p[:playlist].at(0).should eq "uno"
77
- p[:playlist].at(3).should eq "cuatro"
78
- end
79
-
80
- it 'order the content of the playlist' do
81
- p[:playlist].order
82
- p[:playlist].first.should eq %w{cuatro dos tres uno}
83
- end
84
-
85
- it 'updated the play index' do
86
- expect{ p[:playlist].next }.to change{ p[:playlist].play_index }.by(1)
87
- end
88
-
89
- it 'reset the play order when ordered' do
90
- p[:playlist].next
91
- p[:playlist].play_index.should eq 0
92
- p[:playlist].next
93
- p[:playlist].play_index.should eq 1
94
-
95
- p[:playlist].order
96
-
97
- p[:playlist].next
98
- p[:playlist].play_index.should eq 0
99
- end
100
-
101
- it 'reset the play order when shuffled' do
102
- p[:playlist].next
103
- p[:playlist].play_index.should eq 0
104
- p[:playlist].next
105
- p[:playlist].play_index.should eq 1
106
-
107
- p[:playlist].shuffle
108
-
109
- p[:playlist].next
110
- p[:playlist].play_index.should eq 0
111
- end
112
-
113
- it 'repeat the list if repeat is active' do
114
- p[:playlist].repeat?.should be_true
115
- p[:playlist].next.should eq "uno"
116
- p[:playlist].next
117
- p[:playlist].next
118
- p[:playlist].next.should eq "cuatro"
119
- p[:playlist].next.should eq "uno"
120
- end
121
-
122
- it 'raise an error if traying to retrive an ended playlist' do
123
- p[:playlist].repeat false
124
- p[:playlist].repeat?.should be_false
125
- p[:playlist].next.should eq "uno"
126
- p[:playlist].next
127
- p[:playlist].next
128
- p[:playlist].next.should eq "cuatro"
129
- expect{ p[:playlist].next }.to raise_error("playlist empty:no songs in playlists")
130
- end
131
-
132
- it 'return nil if checking current song but playlist has not be played' do
133
- p[:playlist].current.should be_nil
134
- end
135
-
136
- it 'return the current song in playlist' do
137
- p[:playlist].next.should eq "uno"
138
- p[:playlist].current.should eq "uno"
139
- end
140
-
141
- it 'removes and return the next song from the playlist' do
142
- p[:playlist].should have(4).songs
143
- p[:playlist].remove_next.should eq "uno"
144
- p[:playlist].should have(3).songs
145
- p[:playlist].remove_next.should eq "dos"
146
- p[:playlist].should have(2).songs
147
- end
148
-
149
- it 'iterate over every song' do
150
- pl = ":"
151
- p[:playlist].each_song do |s|
152
- pl << s.to_s
153
- end
154
- pl.should eq ":unodostrescuatro"
155
- end
156
-
157
- it 'check if there are songs remaining in the playlist' do
158
- p[:playlist].repeat(false)
159
- p[:playlist].repeat?.should be_false
160
- p[:playlist].next?.should be_true
161
- p[:playlist].next
162
- p[:playlist].next
163
- p[:playlist].next
164
- p[:playlist].next
165
- p[:playlist].next?.should be_false
166
- end
167
-
168
- it 'pop the last element inserted' do
169
- p[:playlist].should have(4).songs
170
- p[:playlist] << 'cinco'
171
- p[:playlist].should have(5).songs
172
- p[:playlist].pop.should eq 'cinco'
173
- p[:playlist].pop.should eq 'cuatro'
174
- p[:playlist].should have(3).songs
175
- end
176
-
177
- it 'rewind the playlist' do
178
- p[:playlist].next.should eq 'uno'
179
- p[:playlist].next.should eq 'dos'
180
- p[:playlist].next.should eq 'tres'
181
- p[:playlist].next.should eq 'cuatro'
182
- p[:playlist].current.should eq 'cuatro'
183
- p[:playlist].rewind_by(1).should eq 'tres'
184
- p[:playlist].current.should eq 'tres'
185
- p[:playlist].rewind_by(2).should eq 'uno'
186
- p[:playlist].current.should eq 'uno'
187
- end
188
- end
189
- end
190
-
191
- context 'with multiple playlist registered' do
192
- before :each do
193
- p.register(:uno)
194
- p.register(:dos)
195
- end
196
-
197
- it 'get multiples playlists by name' do
198
- p[:uno, :dos].should have(2).item
199
- end
200
-
201
- it 'add an element to more than one existing playlists' do
202
- p[:uno, :dos].each{|p| p.should be_empty }
203
- p[:uno, :dos] << "elem"
204
- p[:uno, :dos].each{|p| p.should have(1).item }
205
- end
206
-
207
- it 'replace the content of more than one existing playlists' do
208
- p[:uno, :dos].each{|p| p.should be_empty }
209
- p[:uno, :dos] << "elem"
210
- p[:uno, :dos] << "elem"
211
- p[:uno, :dos].each{|p| p.should have(2).item }
212
- p[:uno, :dos].each{|p| p.should eq ["elem", "elem"] }
213
- p[:uno, :dos] <= %w{uno dos tres cuatro}
214
- p[:uno, :dos].each{|p| p.should have(4).item }
215
- p[:uno, :dos].each{|p| p.should eq %w{uno dos tres cuatro} }
216
- end
217
-
218
- it 'return elements in aparence order' do
219
- p.register(:tres)
220
- p[:uno] << "uno"
221
- p[:dos] << "dos"
222
- p[:tres] << "tres"
223
-
224
- p[:uno, :dos, :tres].next.should eq %w{uno dos tres}
225
- end
226
-
227
- it 'return nil if checking current song but playlist has not be played' do
228
- p[:uno, :dos].current.should be_nil
229
- p[:uno] << "uno"
230
- p[:uno].next
231
- expect{ p[:uno, :dos].current }.to raise_error "no current:no current song in one of the playlists"
232
- end
233
-
234
- it 'return the current song in playlist' do
235
- p[:uno] << "uno"
236
- p[:dos] << "tres"
237
- p[:uno, :dos].next.should eq ["uno", "tres"]
238
- p[:uno, :dos].current.should eq ["uno", "tres"]
239
- end
240
-
241
- it 'raise an error if getting the next of an empty playlist' do
242
- p[:uno] << "uno"
243
- expect{ p[:uno, :dos].next }.to raise_error 'playlist empty:no songs in one of the playlists'
244
- end
245
-
246
- it 'iterate over every song' do
247
- p[:uno] << "uno"
248
- p[:dos] << "dos"
249
- pl = ":"
250
- p.each_song do |s,idx|
251
- pl << "#{idx}#{s.to_s}"
252
- end
253
- pl.should eq ":1uno2dos"
254
- end
255
-
256
- it 'check if there are songs remaining in the playlists' do
257
- p[:uno, :dos].repeat false
258
- p[:uno, :dos].repeat?.should eq [false, false]
259
- p[:uno, :dos] << 'uno'
260
- p[:uno] << 'dos'
261
- p[:uno].next?.should be_true
262
- p[:dos].next?.should be_true
263
- p[:uno, :dos].next?.should eq [true, true]
264
- p[:uno, :dos].next
265
- p[:uno, :dos].next?.should eq [true, false]
266
- end
267
-
268
- it 'change shuffle status' do
269
- p[:uno, :dos].shuffling?.should eq [false, false]
270
- p[:uno, :dos].shuffle
271
- p[:uno, :dos].shuffling?.should eq [true, true]
272
- p[:uno, :dos].order
273
- p[:uno, :dos].shuffling?.should eq [false, false]
274
- end
275
-
276
-
277
- it 'pop the last element inserted' do
278
- p[:uno].should have(0).songs
279
- p[:dos].should have(0).songs
280
- p[:uno] << 'cinco'
281
- p[:dos] << 'seis'
282
- p[:uno].should have(1).songs
283
- p[:dos].should have(1).songs
284
- p[:uno, :dos].pop.should eq ['cinco', 'seis']
285
- p[:uno].should have(0).songs
286
- p[:dos].should have(0).songs
287
- end
288
-
289
- it 'rewind the playlists' do
290
- p[:uno] << 'uno'
291
- p[:uno] << 'dos'
292
- p[:dos] << 'tres'
293
- p[:dos] << 'cuatro'
294
-
295
- p[:uno, :dos].next.should eq ['uno', 'tres']
296
- p[:uno, :dos].next.should eq ['dos', 'cuatro']
297
- p[:uno, :dos].current.should eq ['dos', 'cuatro']
298
- p[:uno, :dos].rewind_by(1).should eq ['uno', 'tres']
299
- end
300
- end
301
- end