playa 0.0.4 → 0.0.5

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: 4878ba1ffdd6bac5e65efca51700fb2c4eb04c78
4
- data.tar.gz: 857acc9d3e9d1b0d9467626887a1ce6925628ddc
3
+ metadata.gz: a82f51bf8b609feea4159e92b17c023125c5d8c2
4
+ data.tar.gz: 5694dd5c5e3286ada63ad34db283dec1f00dab81
5
5
  SHA512:
6
- metadata.gz: 4a38780c433bb4ab05fa20b7abd5439876ba05d953b6f2f6c3e5ea2a7b4370d7001649bb20cf81f7c2e12ed39ad24ceb0e5fd40424835a59e2b380481e6dc8d4
7
- data.tar.gz: 6a0dda0911e38eaec891fc39582d869705408cf5b6ff7437b740741e1b09f4810a2078100751fb338af3255f4214d8f88f3d13818b14bb3cc4bece1919f1d928
6
+ metadata.gz: 0b71f4158b50a56b9d8caed65954e54c63ab701ae2a740785df6f71c3fef34357015b777426ea5fee7912e8eec20b410335c755c190cae3c3ae842a4f0e75f8b
7
+ data.tar.gz: f1fb8b7b45a8d2b0104ee09284217bf8e64ccf9c49676d1e6dc9d76c9c0a7b04766f80f155baacf51b45c7b8d247ceb1abdcf8d254251431b88cf83b3336bafb
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
+ [![Code Climate](https://codeclimate.com/github/gavinlaking/playa.png)](https://codeclimate.com/github/gavinlaking/playa)
2
+ [![Build Status](https://travis-ci.org/gavinlaking/playa.svg?branch=master)](https://travis-ci.org/gavinlaking/playa)
3
+
1
4
  # Playa
2
5
 
3
- Plays mp3s from a directory. An example app using Vedeu.
6
+ Plays mp3s from a directory using Ruby. An example app using Vedeu.
4
7
 
5
8
 
6
9
  ## Requirements
@@ -24,8 +27,14 @@ Plays mp3s from a directory. An example app using Vedeu.
24
27
 
25
28
  ## Usage
26
29
 
30
+ Play all .mp3 files in the current working directory:
31
+
27
32
  playa
28
33
 
34
+ or, specify a directory to play from:
35
+
36
+ playa /path/to/mp3s
37
+
29
38
 
30
39
  ## Contributing
31
40
 
data/bin/playa CHANGED
@@ -10,6 +10,6 @@ require 'playa'
10
10
 
11
11
  args = ARGV.dup
12
12
 
13
- play_directory = args.empty? || args.nil? ? Dir.pwd : args
13
+ play_directory = args.empty? || args.nil? ? [Dir.pwd] : args
14
14
 
15
15
  Playa::Application.start(play_directory)
@@ -3,14 +3,14 @@ module Playa
3
3
  include Vedeu
4
4
 
5
5
  def initialize(args = [])
6
+ @player = Player.new
7
+
6
8
  event :update do
7
9
  @view = View.render(menu.items)
8
10
  end
9
11
 
10
12
  event :select do |track|
11
- player.stop
12
-
13
- @_player = Player.play(track)
13
+ trigger(:play, track)
14
14
  end
15
15
 
16
16
  event :complete do
@@ -20,9 +20,9 @@ module Playa
20
20
 
21
21
  event :key do |key|
22
22
  case key
23
- when :left then player.rewind
24
- when :right then player.forward
25
- when :space then player.toggle
23
+ when :left then trigger(:rewind)
24
+ when :right then trigger(:forward)
25
+ when ' ' then trigger(:toggle)
26
26
  when :up then trigger(:menu_prev)
27
27
  when :down then trigger(:menu_next)
28
28
  when 'q' then trigger(:_exit_)
@@ -48,9 +48,5 @@ module Playa
48
48
  def tracks
49
49
  @_tracks ||= TrackCollection.new(args).tracks
50
50
  end
51
-
52
- def player
53
- @_player ||= Player.new
54
- end
55
51
  end
56
52
  end
data/lib/playa/player.rb CHANGED
@@ -2,20 +2,19 @@ require 'audite'
2
2
 
3
3
  module Playa
4
4
  class Player
5
- attr_reader :track
5
+ include Vedeu
6
6
 
7
- def self.play(track)
8
- new(track).start
9
- end
10
-
11
- def initialize(track = nil)
12
- @track = track
13
- end
7
+ def initialize
8
+ event(:forward) { forward if playing? }
9
+ event(:rewind) { rewind if playing? }
10
+ event(:toggle) { toggle }
11
+ event(:play) do |track|
12
+ stop if playing?
14
13
 
15
- def start
16
- open
14
+ open(track)
17
15
 
18
- play
16
+ play
17
+ end
19
18
  end
20
19
 
21
20
  def play
@@ -35,7 +34,11 @@ module Playa
35
34
  end
36
35
 
37
36
  def toggle
38
- player.toggle
37
+ if playing?
38
+ stop
39
+ else
40
+ play
41
+ end
39
42
  end
40
43
 
41
44
  def playing?
@@ -52,7 +55,7 @@ module Playa
52
55
 
53
56
  private
54
57
 
55
- def open
58
+ def open(track)
56
59
  player.load(track.filename)
57
60
  end
58
61
 
data/lib/playa/view.rb CHANGED
@@ -9,7 +9,7 @@ module Playa
9
9
  end
10
10
 
11
11
  def render
12
- Vedeu::Parser.parse(['playlist', playlist])
12
+ Vedeu::Parser.parse([ interface, playlist ])
13
13
  end
14
14
 
15
15
  private
@@ -17,7 +17,11 @@ module Playa
17
17
  attr_reader :menu
18
18
 
19
19
  def playlist
20
- menu.map { |sel, cur, item| [sel, cur, item.title] }
20
+ menu.map { |sel, cur, item| [ sel, cur, item.title ] }
21
+ end
22
+
23
+ def interface
24
+ 'playlist'
21
25
  end
22
26
  end
23
27
  end
data/playa.gemspec CHANGED
@@ -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.4'
7
+ spec.version = '0.0.5'
8
8
  spec.authors = ['Gavin Laking']
9
9
  spec.email = ['gavinlaking@gmail.com']
10
10
  spec.summary = 'Plays mp3s from a directory.'
@@ -28,5 +28,5 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  spec.add_dependency 'audite', '0.3.0'
30
30
  spec.add_dependency 'ruby-mp3info', '0.8.4'
31
- spec.add_dependency 'vedeu', '0.0.41'
31
+ spec.add_dependency 'vedeu', '0.0.42'
32
32
  end
@@ -3,6 +3,10 @@ require 'playa/controller'
3
3
 
4
4
  module Playa
5
5
  describe Controller do
6
-
6
+ describe '#initialize' do
7
+ it 'returns an instance of itself' do
8
+ Controller.new.must_be_instance_of(Controller)
9
+ end
10
+ end
7
11
  end
8
12
  end
@@ -3,5 +3,10 @@ require 'playa/player'
3
3
 
4
4
  module Playa
5
5
  describe Player do
6
+ describe '#initialize' do
7
+ it 'returns an instance of itself' do
8
+ Player.new.must_be_instance_of(Player)
9
+ end
10
+ end
6
11
  end
7
12
  end
@@ -3,6 +3,12 @@ require 'playa/track_collection'
3
3
 
4
4
  module Playa
5
5
  describe TrackCollection do
6
+ describe '#initialize' do
7
+ it 'returns an instance of itself' do
8
+ TrackCollection.new.must_be_instance_of(TrackCollection)
9
+ end
10
+ end
11
+
6
12
  describe '#tracks' do
7
13
  it 'returns a collection of Track objects' do
8
14
  collection = TrackCollection.new
@@ -12,6 +18,32 @@ module Playa
12
18
  end
13
19
 
14
20
  describe '#files' do
21
+ it 'returns an empty list of files when the directory ' \
22
+ 'contains no mp3s' do
23
+ collection = TrackCollection.new(['/some/path'])
24
+ Dir.stub(:glob, []) do
25
+ collection.files.must_be_empty
26
+ end
27
+ end
28
+
29
+ it 'returns only the mp3s when the directory contains ' \
30
+ 'multiple file types' do
31
+ files = [
32
+ '/some/path/dance.mp3',
33
+ '/some/path/README.txt',
34
+ '/some/path/dubstep.mp3'
35
+ ]
36
+ collection = TrackCollection.new(['/some/path'])
37
+ Dir.stub(:glob, files) do
38
+ File.stub(:file?, true) do
39
+ collection.files.must_equal([
40
+ '/some/path/dance.mp3',
41
+ '/some/path/dubstep.mp3'
42
+ ])
43
+ end
44
+ end
45
+ end
46
+
15
47
  it 'returns a list of files for the specified directory' do
16
48
  files = [
17
49
  '/some/path/dance.mp3',
@@ -19,7 +51,6 @@ module Playa
19
51
  '/some/path/dubstep.mp3'
20
52
  ]
21
53
  collection = TrackCollection.new
22
-
23
54
  Dir.stub(:glob, files) do
24
55
  File.stub(:file?, true) do
25
56
  collection.files.must_equal(files)
@@ -22,6 +22,12 @@ module Playa
22
22
  end
23
23
  let(:track) { Track.new(file) }
24
24
 
25
+ describe '#initialize' do
26
+ it 'returns an instance of itself' do
27
+ Track.new(file).must_be_instance_of(Track)
28
+ end
29
+ end
30
+
25
31
  describe '#attributes' do
26
32
  it 'returns a collection of attributes' do
27
33
  Mp3Info.stub(:open, mp3info) do
@@ -3,6 +3,11 @@ require 'playa/view'
3
3
 
4
4
  module Playa
5
5
  describe View do
6
-
6
+ describe '#initialize' do
7
+ it 'returns an instance of itself' do
8
+ menu = []
9
+ View.new(menu).must_be_instance_of(View)
10
+ end
11
+ end
7
12
  end
8
13
  end
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.4
4
+ version: 0.0.5
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-07-26 00:00:00.000000000 Z
11
+ date: 2014-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -156,14 +156,14 @@ dependencies:
156
156
  requirements:
157
157
  - - '='
158
158
  - !ruby/object:Gem::Version
159
- version: 0.0.41
159
+ version: 0.0.42
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - '='
165
165
  - !ruby/object:Gem::Version
166
- version: 0.0.41
166
+ version: 0.0.42
167
167
  description: An example app using Vedeu.
168
168
  email:
169
169
  - gavinlaking@gmail.com