airplay 0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ /pkg
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ task :test do
2
+ require "cutest"
3
+ require "capybara/dsl"
4
+
5
+ Cutest.run(Dir["test/*.rb"])
6
+
7
+ class Cutest::Scope
8
+ include Capybara
9
+ end
10
+ end
11
+
12
+ task :default => :test
data/airplay.gemspec ADDED
@@ -0,0 +1,15 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "airplay"
3
+ s.version = "0.1.1"
4
+ s.summary = "Airplay client"
5
+ s.description = "Send image/video to an airplay enabled device"
6
+ s.authors = ["elcuervo"]
7
+ s.email = ["yo@brunoaguirre.com"]
8
+ s.homepage = "http://github.com/elcuervo/airplay"
9
+ s.files = `git ls-files`.split("\n")
10
+ s.test_files = `git ls-files spec`.split("\n")
11
+
12
+ s.add_dependency("dnssd")
13
+ s.add_development_dependency("cutest")
14
+ s.add_development_dependency("capybara")
15
+ end
@@ -12,21 +12,21 @@ class Airplay::Protocol
12
12
 
13
13
  def make_request(request)
14
14
  response = @http.request(@request)
15
- raise Airplay::Protocol::InvalidRequestError if response.code == 404
15
+ raise Airplay::Protocol::InvalidRequestError if response.code == "404"
16
16
  true
17
17
  end
18
18
 
19
19
  def put(resource, body = nil, headers = {})
20
- @request = Net::HTTP::Put.new resource
21
- @request.body = body
22
- @request.initialize_http_header DEFAULT_HEADERS.merge(headers)
23
- make_request(@request)
20
+ request = Net::HTTP::Put.new resource
21
+ request.body = body
22
+ request.initialize_http_header DEFAULT_HEADERS.merge(headers)
23
+ make_request(request)
24
24
  end
25
25
 
26
26
  def get(resource, headers = {})
27
- @request = Net::HTTP::Get.new resource
28
- @request.initialize_http_header DEFAULT_HEADERS.merge(headers)
29
- make_request(@request)
27
+ request = Net::HTTP::Get.new resource
28
+ request.initialize_http_header DEFAULT_HEADERS.merge(headers)
29
+ make_request(request)
30
30
  end
31
31
 
32
32
  end
@@ -1,7 +1,7 @@
1
1
  class Airplay::Protocol::Image < Airplay::Protocol
2
2
 
3
3
  def resource
4
- "/photos"
4
+ "/photo"
5
5
  end
6
6
 
7
7
  def transitions
@@ -1,3 +1,3 @@
1
1
  module Airplay
2
- VERSION = 0.1
2
+ VERSION = 0.1.1
3
3
  end
data/test/discovery.rb ADDED
@@ -0,0 +1,28 @@
1
+ require File.expand_path("helper", File.dirname(__FILE__))
2
+
3
+ scope do
4
+
5
+ setup do
6
+ @airplay = Airplay::Client.new
7
+ end
8
+
9
+ test "browse for available airplay servers" do
10
+ assert_equal 1, @airplay.servers.size
11
+ end
12
+
13
+ test "find servers by name" do
14
+ airplay = Airplay::Client.new
15
+ assert @airplay.find_by_name("elCuervo").is_a?(Airplay::Node)
16
+ end
17
+
18
+ test "raise on not found" do
19
+ assert_raise Airplay::Client::ServerNotFoundError do
20
+ @airplay.find_by_name("NotARealAirplayServer")
21
+ end
22
+ end
23
+
24
+ test "autoselect if only one server available" do
25
+ assert_equal "elCuervo", @airplay.active_server.name
26
+ end
27
+
28
+ end
Binary file
data/test/helper.rb ADDED
@@ -0,0 +1,4 @@
1
+ $:.unshift(File.expand_path("../lib", File.dirname(__FILE__)))
2
+
3
+ require "airplay"
4
+ require "cutest"
data/test/images.rb ADDED
@@ -0,0 +1,24 @@
1
+ require File.expand_path("helper", File.dirname(__FILE__))
2
+
3
+ scope do
4
+ test "check image protocol class" do
5
+ image_protocol = Airplay::Protocol::Image.new("127.0.0.1")
6
+ assert_equal "/photos", image_protocol.resource
7
+ end
8
+ end
9
+
10
+ scope do
11
+ setup do
12
+ @airplay = Airplay::Client.new
13
+ end
14
+
15
+ test "send an image to the server" do
16
+ @airplay.use("elCuervo")
17
+ assert_equal true, @airplay.send_image("./test/fixtures/image.gif")
18
+ end
19
+
20
+ test "send an image to the server doing a dissolve" do
21
+ @airplay.use("elCuervo")
22
+ assert_equal true, @airplay.send_image("../test/fixtures/image.gif", :dissolve)
23
+ end
24
+ end
data/test/video.rb ADDED
@@ -0,0 +1,11 @@
1
+ require File.expand_path("helper", File.dirname(__FILE__))
2
+
3
+ scope do
4
+ test "check video protocol class" do
5
+ image_protocol = Airplay::Protocol::Video.new("127.0.0.1")
6
+ assert_equal "/play", image_protocol.resource
7
+ end
8
+ end
9
+
10
+ scope do
11
+ end
metadata CHANGED
@@ -1,93 +1,95 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: airplay
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
4
5
  prerelease:
5
- version: "0.1"
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - elcuervo
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-07-05 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2011-08-17 00:00:00.000000000 -03:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
16
  name: dnssd
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &70188897539300 !ruby/object:Gem::Requirement
19
18
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
24
23
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: cutest
28
24
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *70188897539300
26
+ - !ruby/object:Gem::Dependency
27
+ name: cutest
28
+ requirement: &70188897538840 !ruby/object:Gem::Requirement
30
29
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "0"
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
35
34
  type: :development
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: capybara
39
35
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
36
+ version_requirements: *70188897538840
37
+ - !ruby/object:Gem::Dependency
38
+ name: capybara
39
+ requirement: &70188897538340 !ruby/object:Gem::Requirement
41
40
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- version: "0"
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
46
45
  type: :development
47
- version_requirements: *id003
46
+ prerelease: false
47
+ version_requirements: *70188897538340
48
48
  description: Send image/video to an airplay enabled device
49
- email:
49
+ email:
50
50
  - yo@brunoaguirre.com
51
51
  executables: []
52
-
53
52
  extensions: []
54
-
55
53
  extra_rdoc_files: []
56
-
57
- files:
54
+ files:
55
+ - .gitignore
56
+ - Rakefile
57
+ - airplay.gemspec
58
+ - lib/airplay.rb
58
59
  - lib/airplay/client.rb
59
60
  - lib/airplay/node.rb
61
+ - lib/airplay/protocol.rb
60
62
  - lib/airplay/protocol/image.rb
61
63
  - lib/airplay/protocol/video.rb
62
- - lib/airplay/protocol.rb
63
64
  - lib/airplay/version.rb
64
- - lib/airplay.rb
65
+ - test/discovery.rb
66
+ - test/fixtures/image.gif
67
+ - test/helper.rb
68
+ - test/images.rb
69
+ - test/video.rb
70
+ has_rdoc: true
65
71
  homepage: http://github.com/elcuervo/airplay
66
72
  licenses: []
67
-
68
73
  post_install_message:
69
74
  rdoc_options: []
70
-
71
- require_paths:
75
+ require_paths:
72
76
  - lib
73
- required_ruby_version: !ruby/object:Gem::Requirement
77
+ required_ruby_version: !ruby/object:Gem::Requirement
74
78
  none: false
75
- requirements:
76
- - - ">="
77
- - !ruby/object:Gem::Version
78
- version: "0"
79
- required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
84
  none: false
81
- requirements:
82
- - - ">="
83
- - !ruby/object:Gem::Version
84
- version: "0"
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
85
89
  requirements: []
86
-
87
90
  rubyforge_project:
88
- rubygems_version: 1.7.2
91
+ rubygems_version: 1.6.2
89
92
  signing_key:
90
93
  specification_version: 3
91
94
  summary: Airplay client
92
95
  test_files: []
93
-