airplayer 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.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- airplayer (0.0.4)
4
+ airplayer (0.0.5)
5
5
  airplay
6
6
  mime-types
7
7
  rack
@@ -2,11 +2,12 @@ require 'thor'
2
2
 
3
3
  module AirPlayer
4
4
  class App < Thor
5
- desc 'play <URI|FILE|DIR> [-r|--repeat] ', 'Play video(URI or local video file path or video directory)'
6
- method_option :repeat, :aliases => '-r', :desc => 'Repeat play', :type => :boolean
5
+ desc 'play <URI|FILE|DIR> [-r|--repeat] [-s|--shuffle]', 'Play video(URI or local video file path or video directory)'
6
+ method_option :repeat, :aliases => '-r', :desc => 'Repeat play', :type => :boolean
7
+ method_option :shuffle, :aliases => '-s', :desc => 'Shuffle play', :type => :boolean
7
8
  def play(target)
8
9
  controller = Controller.new
9
- Playlist.new.add(target).entries(options.repeat) do |media|
10
+ Playlist.new(options).add(target).entries do |media|
10
11
  controller.play(media)
11
12
  end
12
13
  end
@@ -1,23 +1,28 @@
1
1
  module AirPlayer
2
2
  class Playlist < Array
3
+ def initialize(options = {})
4
+ @shuffle = options['shuffle'] || false
5
+ @repeat = options['repeat'] || false
6
+ end
7
+
3
8
  def add(item)
4
9
  path = File.expand_path(item)
5
10
  Dir.exists?(path) ? concat(media_in(path)) : push(Media.new(item))
6
11
  self
7
12
  end
8
13
 
9
- def entries(repeat = false, &blk)
14
+ def entries(&blk)
10
15
  loop do
16
+ shuffle! if @shuffle
11
17
  send(:each, &blk)
12
- break unless repeat
18
+ break unless @repeat
13
19
  end
14
20
  end
15
21
 
16
22
  private
17
23
  def media_in(path)
18
24
  Dir.entries(path).map do |node|
19
- media_path = File.expand_path(node, path)
20
- Media.new(media_path) if Media.playable? media_path
25
+ Media.new(File.expand_path(node, path)) if Media.playable? node
21
26
  end.compact
22
27
  end
23
28
  end
@@ -1,3 +1,3 @@
1
1
  module AirPlayer
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airplayer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
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: 2012-10-07 00:00:00.000000000 Z
12
+ date: 2012-10-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -183,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
183
183
  version: '0'
184
184
  segments:
185
185
  - 0
186
- hash: 1446557728728225776
186
+ hash: -4077241967162441253
187
187
  required_rubygems_version: !ruby/object:Gem::Requirement
188
188
  none: false
189
189
  requirements:
@@ -192,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
192
  version: '0'
193
193
  segments:
194
194
  - 0
195
- hash: 1446557728728225776
195
+ hash: -4077241967162441253
196
196
  requirements: []
197
197
  rubyforge_project:
198
198
  rubygems_version: 1.8.23