playa 0.0.11 → 0.0.12

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 41fc80a18e93a859e9f9221df9a3a9f65d6b5cda
4
- data.tar.gz: 042ef6c6eb0883feb60ee44d84e23231151fb6d3
3
+ metadata.gz: 61b17361d49a438953990aef19248ce27bdeda1c
4
+ data.tar.gz: 4bd50d9e494bfa86021b47b24a955bcba9e5b9ed
5
5
  SHA512:
6
- metadata.gz: 293c17584453ed20368f5aa828913843182564d0202c064d1a60b5e899b46c4581e79abc074543513433a9f3eb13e41c8f6a2aa453202bdf5212c9fae8941f56
7
- data.tar.gz: 0054741fc230d61cd994c81c3d4303d999493f8dedc9390981982c6a2edb03f14d23ba797457a628c2542512bd1808341fc04c900fa7a62eb85455ebadb2f1f4
6
+ metadata.gz: 51ea45f264d1273c7368f6c53144ab0adc7911017fdccbf26ae4c81ad62bd7071d82c544f86f75278446dca66c7a0e6edbfca5a86370ab65894b816ed1f90817
7
+ data.tar.gz: 6484d655d7d6eeac01ab527205e8eca41192f25ae13b739c16cb335f4a3f7adb90c6f649b01f0ad017910ffd03d3662092a96b03aa146755ce308de968c8dcc7
data/Gemfile CHANGED
@@ -1,3 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ gem 'rubydeps'
6
+ gem 'vedeu', path: '~/Source/vedeu'
7
+
data/README.md CHANGED
@@ -40,7 +40,7 @@ or, specify a directory to play from:
40
40
 
41
41
  ## Contributing
42
42
 
43
- 1. Fork it ( https://github.com/gavinlaking/playa/fork )
43
+ 1. Fork it ( http://github.com/gavinlaking/playa/fork )
44
44
  2. Clone it
45
45
  3. `bundle`
46
46
  4. `rake` or `bundle exec guard`
@@ -48,4 +48,4 @@ or, specify a directory to play from:
48
48
  6. Write some tests, write some code, have some fun
49
49
  7. Commit your changes (`git commit -am 'Add some feature'`)
50
50
  8. Push to the branch (`git push origin my-new-feature`)
51
- 9. Create a new Pull Request
51
+ 9. Create a new pull request
@@ -10,12 +10,22 @@ module Playa
10
10
  class Application
11
11
  include Vedeu
12
12
 
13
- playlist = interface 'playlist' do
13
+ interface 'help' do
14
+ centred true
15
+ colour foreground: '#ffffff', background: '#000000'
16
+ cursor false
17
+ group 'help'
18
+ height 9
19
+ width 60
20
+ end
21
+
22
+ interface 'playlist' do
14
23
  colour foreground: '#afd700', background: '#000000'
15
24
  cursor false
16
25
  width 60
17
26
  height 5
18
27
  centred true
28
+ group 'player'
19
29
  end
20
30
 
21
31
  interface 'progress' do
@@ -23,10 +33,11 @@ module Playa
23
33
  cursor false
24
34
  width 60
25
35
  height 1
26
- y playlist.north(2)
27
- x playlist.left
36
+ y use('playlist').north(2)
37
+ x use('playlist').left
28
38
  centred false
29
39
  delay 1.0
40
+ group 'player'
30
41
  end
31
42
 
32
43
  interface 'status' do
@@ -34,15 +45,19 @@ module Playa
34
45
  cursor false
35
46
  width 60
36
47
  height 1
37
- y playlist.south(1)
38
- x playlist.left
48
+ y use('playlist').south(1)
49
+ x use('playlist').left
39
50
  centred false
51
+ group 'player'
40
52
  end
41
53
 
42
54
  def self.start(args = [])
43
55
  Controller.new(args)
44
56
 
45
57
  Vedeu::Launcher.new(args).execute!
58
+ rescue Errno::EMFILE
59
+ puts "Playa does not support this number of files."
60
+ puts "Please see https://github.com/gavinlaking/playa/issues/11"
46
61
  end
47
62
  end
48
63
  end
@@ -1,6 +1,8 @@
1
+ require 'playa/views/help_view'
1
2
  require 'playa/views/playlist_view'
2
3
  require 'playa/views/progress_view'
3
4
  require 'playa/views/status_view'
5
+ require 'playa/views/startup_view'
4
6
 
5
7
  module Playa
6
8
  class Controller
@@ -9,6 +11,36 @@ module Playa
9
11
  def initialize(args = [])
10
12
  @player = Player.new
11
13
 
14
+ event :_initialize_ do
15
+ trigger(:show_startup)
16
+ end
17
+
18
+ event :show_startup do
19
+ trigger(:_clear_)
20
+
21
+ StartupView.render
22
+
23
+ trigger(:_refresh_group_player_)
24
+ end
25
+
26
+ event :show_help do
27
+ trigger(:_clear_)
28
+
29
+ HelpView.render
30
+
31
+ trigger(:_refresh_help_)
32
+ end
33
+
34
+ event :show_player do
35
+ trigger(:_clear_)
36
+
37
+ PlaylistView.render(menu)
38
+ StatusView.render
39
+ ProgressView.render(@player)
40
+
41
+ trigger(:_refresh_group_player_)
42
+ end
43
+
12
44
  event :update do
13
45
  PlaylistView.render(menu)
14
46
  trigger(:_refresh_playlist_)
@@ -32,26 +64,30 @@ module Playa
32
64
 
33
65
  event :key do |key|
34
66
  case key
35
- when :left then trigger(:rewind)
36
- when :right then trigger(:forward)
67
+ when :left, 'h' then trigger(:rewind)
68
+ when :right, 'l' then trigger(:forward)
37
69
  when ' ' then trigger(:toggle)
38
- when :up then trigger(:menu_prev)
39
- when :down then trigger(:menu_next)
40
- when 'q' then trigger(:_exit_)
70
+ when :up, 'k' then
71
+ trigger(:menu_prev)
72
+ trigger(:update)
73
+ when :down, 'j' then
74
+ trigger(:menu_next)
75
+ trigger(:update)
76
+ when '?' then trigger(:show_help)
77
+ when 'p', 's' then trigger(:show_player)
78
+ when 'q' then trigger(:_exit_)
41
79
  when :enter
42
80
  trigger(:menu_select)
43
81
  trigger(:select, menu.current_item)
82
+ trigger(:update)
44
83
  end
45
- trigger(:update)
46
84
  end
47
85
 
48
86
  @player.events.on(:position_change) { trigger(:progress_update) }
49
87
  @player.events.on(:complete) { trigger(:complete) }
50
88
 
51
- @args = args
52
- @playlist_view = PlaylistView.render(menu)
53
- @status_view = StatusView.render
54
- @progress_view = ProgressView.render(@player)
89
+ @args = args
90
+ trigger(:show_startup)
55
91
  end
56
92
 
57
93
  private
@@ -0,0 +1,22 @@
1
+ module Playa
2
+ module Helpers
3
+ def duration(track)
4
+ human(track.duration.ceil)
5
+ end
6
+
7
+ def remaining(track, player)
8
+ human((track.duration - player.counter).floor)
9
+ end
10
+
11
+ private
12
+
13
+ def human(seconds)
14
+ mm, ss = seconds.divmod(60)
15
+ hh, mm = mm.divmod(60)
16
+ mins = mm.to_s.rjust(2, '0')
17
+ secs = ss.to_s.rjust(2, '0')
18
+
19
+ [mins, secs].join(":")
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,11 @@
1
+ module Playa
2
+ class HelpView < Vedeu::View
3
+ def output
4
+ view 'help' do
5
+ line do
6
+ text 'Help!'
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,23 +1,90 @@
1
+ require 'playa/helpers'
2
+
1
3
  module Playa
2
4
  class PlaylistView < Vedeu::View
5
+ include Playa::Helpers
6
+
3
7
  def output
4
8
  view 'playlist' do
5
9
  self.object.view.each do |sel, cur, item|
6
10
  if sel && cur
7
- line { text "\u{25B6}> #{item.title}" }
11
+ line do
12
+ stream do
13
+ width title_width(item)
14
+ text "\u{25B6}> #{item.title}"
15
+ end
16
+
17
+ stream do
18
+ width timer_width(item)
19
+ text "#{timer(item)}"
20
+ align :right
21
+ end
22
+ end
8
23
 
9
24
  elsif cur
10
- line { text " > #{item.title}" }
25
+ line do
26
+ stream do
27
+ width title_width(item)
28
+ text " > #{item.title}"
29
+ end
30
+
31
+ stream do
32
+ width timer_width(item)
33
+ text "#{timer(item)}"
34
+ align :right
35
+ end
36
+ end
11
37
 
12
38
  elsif sel
13
- line { text "\u{25B6} #{item.title}" }
39
+ line do
40
+ stream do
41
+ width title_width(item)
42
+ text "\u{25B6} #{item.title}"
43
+ end
44
+
45
+ stream do
46
+ width timer_width(item)
47
+ text "#{timer(item)}"
48
+ align :right
49
+ end
50
+ end
14
51
 
15
52
  else
16
- line { text " #{item.title}" }
53
+ line do
54
+ stream do
55
+ width title_width(item)
56
+ text " #{item.title}"
57
+ end
58
+
59
+ stream do
60
+ width timer_width(item)
61
+ text "#{timer(item)}"
62
+ align :right
63
+ end
64
+ end
17
65
 
18
66
  end
19
67
  end
20
68
  end
21
69
  end
70
+
71
+ private
72
+
73
+ def title_width(item)
74
+ view_width - timer_width(item) - 1
75
+ end
76
+
77
+ def timer_width(item)
78
+ timer(item).size + 1
79
+ end
80
+
81
+ def timer(item)
82
+ duration(item)
83
+ end
84
+
85
+ def view_width
86
+ @_width ||= Vedeu.use('playlist').width
87
+ end
88
+
22
89
  end
23
90
  end
@@ -1,5 +1,9 @@
1
+ require 'playa/helpers'
2
+
1
3
  module Playa
2
4
  class ProgressView < Vedeu::View
5
+ include Playa::Helpers
6
+
3
7
  def output
4
8
  if object.track
5
9
  track_loaded
@@ -53,18 +57,11 @@ module Playa
53
57
  end
54
58
 
55
59
  def timer
56
- remaining = (object.track.duration - object.counter).floor
57
- mm, ss = remaining.divmod(60)
58
- hh, mm = mm.divmod(60)
59
- mins = mm.to_s.rjust(2, '0')
60
- secs = ss.to_s.rjust(2, '0')
61
-
62
- [mins, secs].join(":")
60
+ remaining(object.track, object)
63
61
  end
64
62
 
65
- # TODO: playa knows too much here...
66
63
  def view_width
67
- @_width ||= Vedeu.with('progress').geometry.width
64
+ @_width ||= Vedeu.use('progress').width
68
65
  end
69
66
  end
70
67
  end
@@ -0,0 +1,23 @@
1
+ module Playa
2
+ class StartupView < Vedeu::View
3
+ def output
4
+ views do
5
+ view 'progress' do
6
+ line do
7
+ text 'Welcome to Playa.'
8
+ end
9
+ end
10
+ view 'playlist' do
11
+ line do
12
+ text 'An mp3 player in your console.'
13
+ end
14
+ end
15
+ view 'status' do
16
+ line do
17
+ text 'Press `s` to begin.'
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -5,7 +5,7 @@ module Playa
5
5
  line do
6
6
  stream do
7
7
  colour foreground: '#ff0000'
8
- text "\u{25B2}"
8
+ text " \u{25B2}"
9
9
  end
10
10
  stream do
11
11
  colour foreground: '#ffffff'
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'playa'
7
- spec.version = '0.0.11'
7
+ spec.version = '0.0.12'
8
8
  spec.authors = ['Gavin Laking']
9
9
  spec.email = ['gavinlaking@gmail.com']
10
10
  spec.summary = 'Plays mp3s from a directory.'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-08 00:00:00.000000000 Z
11
+ date: 2014-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -196,11 +196,14 @@ files:
196
196
  - bin/playa
197
197
  - lib/playa.rb
198
198
  - lib/playa/controller.rb
199
+ - lib/playa/helpers.rb
199
200
  - lib/playa/player.rb
200
201
  - lib/playa/track.rb
201
202
  - lib/playa/track_collection.rb
203
+ - lib/playa/views/help_view.rb
202
204
  - lib/playa/views/playlist_view.rb
203
205
  - lib/playa/views/progress_view.rb
206
+ - lib/playa/views/startup_view.rb
204
207
  - lib/playa/views/status_view.rb
205
208
  - playa.gemspec
206
209
  - screenshot.png