airplay 1.0.2 → 1.0.3

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 75a8e290e50f4041dbc8e11f04e7d251089eb5fc
4
+ data.tar.gz: 373a3cac124b0d0ae1c6ef84c3be92efbdb571aa
5
+ SHA512:
6
+ metadata.gz: 97485baf2965f80a3bc5c72680306312d9caecc756f7f2512c6901c0cf31fe8740714ce362dbb8807c4d384641f8931a2fbc68552bb3bb5f21a8b26d764f2ffe
7
+ data.tar.gz: f62352ac1f675c802b68e8a2d647b32dd17c2d2a7c667092f37db34129096ab0420bfb2a1535c9daaab5f78efd2b26c50c0b1bd6eae552982c0bb164e1e5c977
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  pkg
2
+ .env
@@ -1,8 +1,12 @@
1
1
  language: ruby
2
2
  rvm:
3
- - "1.9.3"
4
- - "2.0.0"
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.0
5
6
  before_install:
6
- - "sudo apt-get -qq update"
7
- - "sudo apt-get -qq install rdnssd libavahi-compat-libdnssd-dev"
8
- script: bundle exec rake spec
7
+ - sudo apt-get -qq update
8
+ - sudo apt-get -qq install rdnssd libavahi-compat-libdnssd-dev
9
+ script: bundle exec rake
10
+ env:
11
+ global:
12
+ secure: PDEIoCg7nim32QGeJKvWcpcTEB0jOSfrH+v5ebrO4ioqznUfoaf1qypWNHrXYY4hINA+L5Tm6HXAPah2OhFkBxZzIlKgWlH1MIx5y6Q7PyBN6MTZMw1GN7sTm+zy9z79ytjdtepI4rlKVSxhAwl3Uid7mNliZx6T8eOP634Rg9s=
data/Gemfile CHANGED
@@ -1,9 +1,6 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gemspec name: 'airplay'
4
+ gemspec name: 'airplay-cli'
4
5
 
5
6
  gem "rake"
6
-
7
- group :development do
8
- gem "debugger"
9
- end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- airplay (1.0.2)
4
+ airplay (1.0.3)
5
5
  CFPropertyList (~> 2.2.0)
6
6
  celluloid (>= 0.15.0)
7
7
  cuba (~> 3.1.0)
@@ -12,32 +12,30 @@ PATH
12
12
  net-http-digest_auth (~> 1.2.1)
13
13
  net-ptth (= 0.0.17)
14
14
  reel-rack (~> 0.1.0)
15
+ airplay-cli (1.0.2)
16
+ airplay (= 1.0.3)
17
+ clap (~> 1.0.0)
18
+ ruby-progressbar (~> 1.2.0)
15
19
 
16
20
  GEM
17
21
  remote: http://rubygems.org/
18
22
  specs:
19
- CFPropertyList (2.2.3)
23
+ CFPropertyList (2.2.6)
20
24
  celluloid (0.15.2)
21
25
  timers (~> 1.1.0)
22
26
  celluloid-io (0.15.0)
23
27
  celluloid (>= 0.15.0)
24
28
  nio4r (>= 0.5.0)
25
- columnize (0.3.6)
26
- cuba (3.1.0)
29
+ clap (1.0.0)
30
+ cuba (3.1.1)
27
31
  rack
28
- debugger (1.6.2)
29
- columnize (>= 0.3.1)
30
- debugger-linecache (~> 1.2.0)
31
- debugger-ruby_core_source (~> 1.2.3)
32
- debugger-linecache (1.2.0)
33
- debugger-ruby_core_source (1.2.3)
34
32
  dnssd (2.0)
35
33
  fakeweb (1.3.0)
36
34
  given_core (3.0.0)
37
35
  sorcerer (>= 0.3.7)
38
36
  http (0.5.0)
39
37
  http_parser.rb
40
- http_parser.rb (0.6.0.beta.2)
38
+ http_parser.rb (0.6.0)
41
39
  log4r (1.1.10)
42
40
  micromachine (1.0.4)
43
41
  mime-types (2.0)
@@ -50,7 +48,7 @@ GEM
50
48
  celluloid-io (>= 0.15.0)
51
49
  http_parser.rb (>= 0.6.0.beta.2)
52
50
  rack (>= 1.4.5)
53
- nio4r (0.5.0)
51
+ nio4r (1.0.0)
54
52
  rack (1.5.2)
55
53
  rake (10.1.0)
56
54
  reel (0.4.0)
@@ -62,10 +60,11 @@ GEM
62
60
  reel-rack (0.1.0)
63
61
  rack (>= 1.4.0)
64
62
  reel (>= 0.4.0)
63
+ ruby-progressbar (1.2.0)
65
64
  sorcerer (1.0.2)
66
65
  timers (1.1.0)
67
66
  vcr (2.4.0)
68
- websocket_parser (0.1.4)
67
+ websocket_parser (0.1.5)
69
68
  http
70
69
 
71
70
  PLATFORMS
@@ -73,7 +72,7 @@ PLATFORMS
73
72
 
74
73
  DEPENDENCIES
75
74
  airplay!
76
- debugger
75
+ airplay-cli!
77
76
  fakeweb (~> 1.3.0)
78
77
  minitest (~> 4.4.0)
79
78
  minitest-given (~> 3.0.0)
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Airplay
2
2
 
3
3
  [![Code Climate](https://codeclimate.com/github/elcuervo/airplay.png)](https://codeclimate.com/github/elcuervo/airplay)
4
+ [![Build Status](https://travis-ci.org/elcuervo/airplay.png?branch=master)](https://travis-ci.org/elcuervo/airplay)
4
5
 
5
6
  ![Airplay](doc/img/logo.png)
6
7
 
@@ -13,13 +14,24 @@ You can contribute with code, bugs or feature requests.
13
14
 
14
15
  The development of the gem takes time and there's a lot of research and hardware
15
16
  tests to make all of this. If you want to contribute please consider donating as
16
- much as you want in: https://gumroad.com/l/airplay
17
+ much as you want in: [Paypal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HE867B8J6ARQ4) or [Gumroad](https://gumroad.com/l/airplay)
17
18
 
18
19
  ## Help
19
20
 
20
21
  * irc feenode: #airplay
21
22
  * twitter: http://twitter.com/airplayrb
22
23
 
24
+ # Table of Contents
25
+
26
+ * [Contribute](#contribute)
27
+ * [Installation](#installation)
28
+ * [Usage](#usage)
29
+ * [CLI](#cli-1)
30
+ * [Library](#library-1)
31
+ * [Testing](#testing)
32
+ * [Documentation](#documentation)
33
+ * [Contributors](#contributors)
34
+
23
35
  ## Installation
24
36
 
25
37
  ### Library
@@ -70,7 +82,7 @@ Airplay.configure do |config|
70
82
  config.log_level # Log4r levels (Default: Log4r::ERROR)
71
83
  config.autodiscover # Allows to search for nodes (Default: true)
72
84
  config.host # In which host to bind the server (Default: 0.0.0.0)
73
- config.port # In which port to bind the server (Default: 1337)
85
+ config.port # In which port to bind the server (Default: will find one)
74
86
  config.output # Where to log (Default: Log4r::Outputter.stdout)
75
87
  end
76
88
  ```
@@ -85,12 +97,15 @@ Airplay.devices.each do |device|
85
97
  end
86
98
  ```
87
99
 
88
- #### Accesing and Grouping
100
+ #### Accessing and Grouping
89
101
 
90
102
  ```ruby
91
103
  # You can access a known device easily
92
104
  device = Airplay["Apple TV"]
93
105
 
106
+ # And add the password of the device if needed
107
+ device.password = "my super secret password"
108
+
94
109
  # Or you can group known devices to have them do a given action together
95
110
  Airplay.group["Backyard"] << Airplay["Apple TV"]
96
111
  Airplay.group["Backyard"] << Airplay["Room TV"]
@@ -168,6 +183,8 @@ player.pause
168
183
  player.resume
169
184
  player.stop
170
185
  player.scrub
186
+ player.info
187
+ player.seek
171
188
 
172
189
  # Access the playback time per second
173
190
  player.progress -> progress {
@@ -175,6 +192,21 @@ player.progress -> progress {
175
192
  }
176
193
  ```
177
194
 
195
+ # Testing
196
+
197
+ Now there are two types of tests: Regular unit tests and integration tests.
198
+ Thanks to the magic of the internet and a raspberry pi there are integration
199
+ tests with a real Apple TV that is currently accessible.
200
+
201
+ ![Block TV](doc/img/block_tv.jpg)
202
+
203
+ The Apple TV is password protected to avoid issues with the tests but is
204
+ configured in Travis CI. For that reason you won't be able to run those tests if
205
+ you don't have an Apple TV.
206
+
207
+ Run unit tests with: `rake test:unit` and integration ones with: `rake test:integration`
208
+ You can run all of them together with: `rake test:all`
209
+
178
210
  ## Documentation
179
211
 
180
212
  All the documentation of the README can be found in the `doc` folder.
@@ -184,5 +216,6 @@ To generate an updated README based on the contents of `doc` please use `rake do
184
216
 
185
217
  * [sodabrew](http://github.com/sodabrew)
186
218
  * [pote](http://github.com/pote)
187
- * [janogonzalez](http://github.com/janogonzalez) - Who allowed me to release 1.0
188
- from startech conf <3
219
+
220
+ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/elcuervo/airplay/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
221
+
data/Rakefile CHANGED
@@ -5,11 +5,6 @@ require "fileutils"
5
5
  require "airplay/version"
6
6
  require "airplay/cli/version"
7
7
 
8
- Rake::TestTask.new("spec") do |t|
9
- t.libs << "test"
10
- t.pattern = "test/**/*_test.rb"
11
- end
12
-
13
8
  class RuleBuilder
14
9
  attr_reader :task, :info
15
10
 
@@ -74,17 +69,33 @@ class RuleBuilder
74
69
  end
75
70
  end
76
71
 
72
+
73
+
77
74
  builder = RuleBuilder.new(task: method(:task))
78
75
  namespace :build, &builder.construct(:build)
79
76
  namespace :install, &builder.construct(:install)
80
77
  namespace :release, &builder.construct(:release)
81
78
 
82
- task :default => [:test]
83
- task :test => [:spec]
79
+ Rake::TestTask.new("test:all") do |t|
80
+ t.libs << "test"
81
+ t.pattern = "test/**/*_test.rb"
82
+ end
83
+
84
+ Rake::TestTask.new("test:unit") do |t|
85
+ t.libs << "test"
86
+ t.pattern = "test/unit/**/*_test.rb"
87
+ end
88
+
89
+ Rake::TestTask.new("test:integration") do |t|
90
+ t.libs << "test"
91
+ t.pattern = "test/integration**/*_test.rb"
92
+ end
93
+
94
+ task :default => "test:all"
84
95
 
85
96
  namespace :doc do
86
97
  task :generate do
87
- structure = %w(header installation usage documentation contributors)
98
+ structure = %w(header toc installation usage testing documentation contributors bitdeli)
88
99
 
89
100
  File.open("README.md", "w+") do |f|
90
101
  structure.each { |part| f << File.read("doc/#{part}.md") + "\n" }
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.homepage = "http://github.com/elcuervo/airplay"
14
14
  s.files = %w(bin/air lib/airplay/cli.rb)
15
15
 
16
- s.add_dependency("airplay", "= 1.0.2")
16
+ s.add_dependency("airplay", "= 1.0.3")
17
17
  s.add_dependency("clap", "~> 1.0.0")
18
18
  s.add_dependency("ruby-progressbar", "~> 1.2.0")
19
19
  end
data/bin/air CHANGED
@@ -7,24 +7,34 @@ require "airplay/cli/version"
7
7
  begin
8
8
  Clap.run ARGV,
9
9
  "--device" => lambda { |device_name| @device = Airplay[device_name] },
10
+ "--url" => lambda { |url| @url = url },
10
11
  "--wait" => lambda { |sec| @wait = sec.to_i },
11
12
  "--interactive" => lambda { @interactive = true },
13
+ "--password" => lambda { |password| @password = password },
12
14
 
13
15
  "help" => Airplay::CLI.method(:help),
14
16
 
15
17
  "list" => Airplay::CLI.method(:list),
16
18
 
19
+ "doctor" => Airplay::CLI.method(:doctor),
20
+
17
21
  "version" => Airplay::CLI.method(:version),
18
22
 
19
23
  "play" => lambda { |video|
20
- options = { device: @device || Airplay.devices.first }
24
+ options = {
25
+ device: @device || Airplay.devices.first,
26
+ password: @password || false,
27
+ url: @url || false
28
+ }
21
29
  Airplay::CLI.play(video, options)
22
30
  },
23
31
 
24
32
  "view" => lambda { |file|
25
33
  options = {
26
- device: @device || Airplay.devices.first,
34
+ device: @device || @url ? false : Airplay.devices.first,
27
35
  interactive: @interactive || false,
36
+ password: @password || false,
37
+ url: @url || false,
28
38
  wait: @wait || 3
29
39
  }
30
40
  Airplay::CLI.view(file, options)
@@ -0,0 +1 @@
1
+ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/elcuervo/airplay/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
@@ -1,6 +1,7 @@
1
1
  # Airplay
2
2
 
3
3
  [![Code Climate](https://codeclimate.com/github/elcuervo/airplay.png)](https://codeclimate.com/github/elcuervo/airplay)
4
+ [![Build Status](https://travis-ci.org/elcuervo/airplay.png?branch=master)](https://travis-ci.org/elcuervo/airplay)
4
5
 
5
6
  ![Airplay](doc/img/logo.png)
6
7
 
@@ -13,7 +14,7 @@ You can contribute with code, bugs or feature requests.
13
14
 
14
15
  The development of the gem takes time and there's a lot of research and hardware
15
16
  tests to make all of this. If you want to contribute please consider donating as
16
- much as you want in: https://gumroad.com/l/airplay
17
+ much as you want in: [Paypal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HE867B8J6ARQ4) or [Gumroad](https://gumroad.com/l/airplay)
17
18
 
18
19
  ## Help
19
20
 
Binary file
@@ -2,8 +2,8 @@
2
2
 
3
3
  ### Library
4
4
 
5
- `gem install airplay --pre`
5
+ `gem install airplay`
6
6
 
7
7
  ## CLI
8
8
 
9
- `gem install airplay-cli --pre`
9
+ `gem install airplay-cli`
@@ -0,0 +1,14 @@
1
+ # Testing
2
+
3
+ Now there are two types of tests: Regular unit tests and integration tests.
4
+ Thanks to the magic of the internet and a raspberry pi there are integration
5
+ tests with a real Apple TV that is currently accessible.
6
+
7
+ ![Block TV](doc/img/block_tv.jpg)
8
+
9
+ The Apple TV is password protected to avoid issues with the tests but is
10
+ configured in Travis CI. For that reason you won't be able to run those tests if
11
+ you don't have an Apple TV.
12
+
13
+ Run unit tests with: `rake test:unit` and integration ones with: `rake test:integration`
14
+ You can run all of them together with: `rake test:all`
@@ -0,0 +1,10 @@
1
+ # Table of Contents
2
+
3
+ * [Contribute](#contribute)
4
+ * [Installation](#installation)
5
+ * [Usage](#usage)
6
+ * [CLI](#cli-1)
7
+ * [Library](#library-1)
8
+ * [Testing](#testing)
9
+ * [Documentation](#documentation)
10
+ * [Contributors](#contributors)
@@ -38,7 +38,7 @@ Airplay.configure do |config|
38
38
  config.log_level # Log4r levels (Default: Log4r::ERROR)
39
39
  config.autodiscover # Allows to search for nodes (Default: true)
40
40
  config.host # In which host to bind the server (Default: 0.0.0.0)
41
- config.port # In which port to bind the server (Default: 1337)
41
+ config.port # In which port to bind the server (Default: will find one)
42
42
  config.output # Where to log (Default: Log4r::Outputter.stdout)
43
43
  end
44
44
  ```
@@ -53,12 +53,15 @@ Airplay.devices.each do |device|
53
53
  end
54
54
  ```
55
55
 
56
- #### Accesing and Grouping
56
+ #### Accessing and Grouping
57
57
 
58
58
  ```ruby
59
59
  # You can access a known device easily
60
60
  device = Airplay["Apple TV"]
61
61
 
62
+ # And add the password of the device if needed
63
+ device.password = "my super secret password"
64
+
62
65
  # Or you can group known devices to have them do a given action together
63
66
  Airplay.group["Backyard"] << Airplay["Apple TV"]
64
67
  Airplay.group["Backyard"] << Airplay["Room TV"]
@@ -136,6 +139,8 @@ player.pause
136
139
  player.resume
137
140
  player.stop
138
141
  player.scrub
142
+ player.info
143
+ player.seek
139
144
 
140
145
  # Access the playback time per second
141
146
  player.progress -> progress {
@@ -52,7 +52,11 @@ module Airplay
52
52
  address = get_device_address(resolved)
53
53
  type = get_type(resolved.text_record)
54
54
 
55
- add_device(node.name, address, type)
55
+ device = create_device(node.name, address, type)
56
+ device.text_records = resolved.text_record
57
+
58
+ devices << device
59
+
56
60
  resolved.flags.more_coming?
57
61
  end
58
62
 
@@ -95,15 +99,15 @@ module Airplay
95
99
  target
96
100
  end
97
101
 
98
- # Private: Creates and adds a device to the pool
102
+ # Private: Creates a device
99
103
  #
100
104
  # name - The device name
101
105
  # address - The device address
102
106
  #
103
107
  # Returns nothing
104
108
  #
105
- def add_device(name, address, type)
106
- devices << Device.new(
109
+ def create_device(name, address, type)
110
+ Device.new(
107
111
  name: name.gsub(/\u00a0/, ' '),
108
112
  address: address,
109
113
  type: type
@@ -1,6 +1,7 @@
1
1
  require "ruby-progressbar"
2
2
  require "airplay"
3
3
  require "airplay/cli/image_viewer"
4
+ require "airplay/cli/doctor"
4
5
 
5
6
  # Public: Airplay core module
6
7
  #
@@ -28,12 +29,15 @@ module Airplay
28
29
  version - The current airplay-cli version.
29
30
  play - Plays a local or remote video.
30
31
  view - Shows an image or a folder of images, can be an url.
32
+ doctor - Shows some debug information to trace bugs.
31
33
 
32
34
  Options:
33
35
 
34
36
  --device - Name of the device where it should be played (Default: The first one)
35
37
  --wait - The wait time for playing an slideshow (Default: 3)
36
38
  --interactive - Control the slideshow using left and right arrows.
39
+ --password - Adds the device password
40
+ --url - Allows you to specify an Apple TV url
37
41
 
38
42
  EOS
39
43
  end
@@ -47,6 +51,8 @@ module Airplay
47
51
  puts <<-EOS.gsub(/^\s{12}/,'')
48
52
  * #{device.name} (#{device.info.model} running #{device.info.os_version})
49
53
  ip: #{device.ip}
54
+ mac: #{device.id}
55
+ password?: #{device.password? ? "yes" : "no"}
50
56
  type: #{device.type}
51
57
  resolution: #{device.info.resolution}
52
58
 
@@ -64,6 +70,12 @@ module Airplay
64
70
  #
65
71
  def play(video, options)
66
72
  device = options[:device]
73
+ password = options[:password]
74
+ url = options[:url]
75
+
76
+ Airplay.devices.add("Apple TV", url) if url
77
+ device.password = password if password
78
+
67
79
  player = device.play(video)
68
80
  puts "Playing #{video}"
69
81
  bar = ProgressBar.create(
@@ -78,6 +90,20 @@ module Airplay
78
90
  player.wait
79
91
  end
80
92
 
93
+ def doctor
94
+ puts <<-EOS.gsub!(" "*10, "")
95
+
96
+ This will run some basic tests on your network trying to find errors
97
+ and debug information to help fix them.
98
+
99
+ EOS
100
+
101
+ who = Airplay::CLI::Doctor.new
102
+
103
+ puts "Running dns-sd tests:"
104
+ who.information
105
+ end
106
+
81
107
  # Public: Show an image given a device
82
108
  #
83
109
  # file_or_dir - The url, file path or folder path to the image/s
@@ -90,6 +116,15 @@ module Airplay
90
116
  #
91
117
  def view(file_or_dir, options)
92
118
  device = options[:device]
119
+ password = options[:password]
120
+ url = options[:url]
121
+
122
+ if url
123
+ Airplay.configure { |c| c.autodiscover = false }
124
+ device = Airplay.devices.add("Apple TV", url)
125
+ end
126
+ device.password = password if password
127
+
93
128
  viewer = ImageViewer.new(device, options)
94
129
 
95
130
  if File.directory?(file_or_dir)