dblugeon-rb-eyetv 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ .DS_STORE
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 dblugeon
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,41 @@
1
+ = rb-eyetv
2
+
3
+ This library provides ruby classes to control the EyeTV Application.
4
+ You can launch the EyeTV apllication, explore recordings, channels or programs.
5
+
6
+ == Note on Patches/Pull Requests
7
+
8
+ * Fork the project.
9
+ * Make your feature addition or bug fix.
10
+ * Add tests for it. This is important so I don't break it in a
11
+ future version unintentionally.
12
+ * Commit, do not mess with rakefile, version, or history.
13
+ (if you want to have your own version, that is fine but
14
+ bump version in a commit by itself I can ignore when I pull)
15
+ * Send me a pull request. Bonus points for topic branches.
16
+
17
+ == Example : print the name of channels
18
+ sudo gem install rb-eyetv
19
+
20
+ require 'eyetv'
21
+ include EyeTV
22
+ instance = EyeTV::EyeTV.new
23
+ instance.channels.each do |chan|
24
+ puts chan.name
25
+ end
26
+
27
+ will return :
28
+ France 2
29
+ France 3
30
+ France 5
31
+ M6
32
+ ARTE
33
+ W9
34
+ NT1
35
+ LCP
36
+ France 3
37
+ ARTE HD FR
38
+
39
+ == Copyright
40
+
41
+ Copyright (c) 2009 dblugeon. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,61 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "rb-eyetv"
8
+ gem.summary = %Q{This library provides ruby classes to control the EyeTV Application}
9
+ gem.description = %Q{
10
+ This library provides ruby classes to control the EyeTV Application.
11
+ You can launch the EyeTV apllication, explore recordings, channels or
12
+ programs
13
+ }
14
+ gem.email = "damienblugeon@gmail.com"
15
+ gem.homepage = "http://github.com/dblugeon/rb-eyetv"
16
+ gem.authors = ["dblugeon"]
17
+ gem.add_development_dependency "thoughtbot-shoulda"
18
+ gem.add_development_dependency 'rb-appscript','= 0.5.3'
19
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
20
+ end
21
+ rescue LoadError
22
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
23
+ end
24
+
25
+ require 'rake/testtask'
26
+ Rake::TestTask.new(:test) do |test|
27
+ test.libs << 'lib' << 'test'
28
+ test.pattern = 'test/**/*_test.rb'
29
+ test.verbose = true
30
+ end
31
+
32
+ begin
33
+ require 'rcov/rcovtask'
34
+ Rcov::RcovTask.new do |test|
35
+ test.libs << 'test'
36
+ test.pattern = 'test/**/*_test.rb'
37
+ test.verbose = true
38
+ end
39
+ rescue LoadError
40
+ task :rcov do
41
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
42
+ end
43
+ end
44
+
45
+ task :test => :check_dependencies
46
+
47
+ task :default => :test
48
+
49
+ require 'rake/rdoctask'
50
+ Rake::RDocTask.new do |rdoc|
51
+ if File.exist?('VERSION')
52
+ version = File.read('VERSION')
53
+ else
54
+ version = ""
55
+ end
56
+
57
+ rdoc.rdoc_dir = 'rdoc'
58
+ rdoc.title = "rb-eyetv #{version}"
59
+ rdoc.rdoc_files.include('README*')
60
+ rdoc.rdoc_files.include('lib/**/*.rb')
61
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.2
data/lib/channel.rb ADDED
@@ -0,0 +1,54 @@
1
+ #This module permit to control the EyeTV application with applescript bridge
2
+ module EyeTV
3
+ #This is the class channel of EyeTv
4
+ #You can (des)activate an channel
5
+ class Channel
6
+ attr_reader :channel_number
7
+
8
+ def initialize(chan_ref)
9
+ raise "must no nil object" if(not chan_ref)
10
+ @chan_ref = chan_ref
11
+ end
12
+
13
+ def name
14
+ @chan_ref.name.get
15
+ end
16
+
17
+ def name=(new_name)
18
+ @chan_ref.name.set(new_name)
19
+ end
20
+
21
+ def channel_number
22
+ @chan_ref.channel_number.get
23
+ end
24
+
25
+ def channel_number=(new_channel_number)
26
+ @chan_ref.channel_number.set(new_channel_number)
27
+ end
28
+
29
+ # return true if action is possible
30
+ def enabled=(value)
31
+ if @chan_ref && value !=nil
32
+ @chan_ref.enabled.set(value)
33
+ true
34
+ else
35
+ false
36
+ end
37
+ end
38
+
39
+ def enabled?
40
+ if @chan_ref
41
+ @enabled = @chan_ref.enabled.get
42
+ end
43
+ @enabled
44
+ end
45
+
46
+ def delete
47
+ @chan_ref.delete
48
+ end
49
+
50
+ def to_s
51
+ self.channel_number().to_s.concat(" ").concat(self.name()).concat(" ").concat(self.enabled?.to_s)
52
+ end
53
+ end
54
+ end
data/lib/eyetv.rb ADDED
@@ -0,0 +1,108 @@
1
+ require 'rubygems'
2
+ require "appscript"
3
+ require 'Channel'
4
+ require 'Program'
5
+ require 'Recording'
6
+ include Appscript
7
+
8
+ #This module permit to control the EyeTV application with applescript bridge
9
+ module EyeTV
10
+ #This is the main Class of this module
11
+ class EyeTV
12
+
13
+ def initialize
14
+ @instance = app('EyeTV')
15
+ unless @instance.is_running?
16
+ launch
17
+ end
18
+ end
19
+
20
+ def channels
21
+ chans = []
22
+ @instance.channels.get.each do |chan|
23
+ chans.push(Channel.new(chan))
24
+ end
25
+ chans
26
+ end
27
+
28
+ def programs
29
+ programs_tab = []
30
+ @instance.programs.get.each do |prog|
31
+ programs_tab.push(Program.new(prog))
32
+ end
33
+ programs_tab
34
+ end
35
+
36
+ def recordings
37
+ recordings =[]
38
+ @instance.recordings.get.each do |recording|
39
+ recordings.push(Recording.new(recording))
40
+ end
41
+ recordings
42
+ end
43
+
44
+ #close EyeTV Application
45
+ def quit
46
+ @instance.quit
47
+ end
48
+
49
+ #launch EyeTV application
50
+ def launch
51
+ @instance.launch
52
+ end
53
+
54
+ #restart the EyeTV
55
+ def restart
56
+ @instance.quit
57
+ @instance.launch
58
+ end
59
+
60
+ #flag indicate if EyeTv record an Program
61
+ def is_recording?
62
+ @instance.is_recording.get
63
+ end
64
+
65
+ def current_channel_number
66
+ @intance.current_channel.get
67
+ end
68
+
69
+ #return an channel, program or recording with the id
70
+ #work with following symbols : :channel :program :recording
71
+ def find_by_id(type, id)
72
+ if id != nil
73
+ case type
74
+ when :channel
75
+ channels.find{|chan| chan.channel_number == id}
76
+ when :program
77
+ programs.find{|obj| obj.uid == id}
78
+ when :recording
79
+ recordings.find{|obj| obj.uid == id}
80
+ end
81
+ end
82
+ end
83
+ end
84
+
85
+ if __FILE__ == $0
86
+ puts "start Eyetv"
87
+ etv = EyeTV.new
88
+ puts "channels numbers : #{etv.channels.size}"
89
+ etv.channels.each do |chan|
90
+ if chan.enabled?
91
+ chan.enabled = false
92
+ puts "#{chan} désactivé"
93
+ else
94
+ chan.enabled = true
95
+ puts "#{chan} activé"
96
+ end
97
+ end
98
+ etv.programs.each do |program|
99
+ puts program
100
+ end
101
+
102
+ etv.recordings.each do |record|
103
+ puts record
104
+ end
105
+ puts "enregistrement en cours : #{etv.is_recording?}"
106
+ puts "done"
107
+ end
108
+ end
data/lib/program.rb ADDED
@@ -0,0 +1,99 @@
1
+ #This module permit to control the EyeTV application with applescript bridge
2
+ module EyeTV
3
+ #This class represents an instnace of schedule Program on EyeTV
4
+ class Program
5
+
6
+ @@repeats_possible = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday","never","none","daily","weekdays","weekends"]
7
+
8
+ def initialize(program_instance)
9
+ @program_ref = program_instance
10
+ end
11
+
12
+ def uid
13
+ @program_ref.unique_ID.get
14
+ end
15
+
16
+ def start_time
17
+ @program_ref.start_time.get
18
+ end
19
+
20
+ def start_time=(new_start_time)
21
+ raise "Must be an datetime objet" if(not new_start_time.is_a?(Date) and not new_start_time.is_a?(DateTime))
22
+ @program_ref.start_time.set(new_start_time)
23
+ end
24
+
25
+ def duration
26
+ @program_ref.duration.get
27
+ end
28
+
29
+ def duration=(new_duration)
30
+ @program_ref.duration.set(new_duration)
31
+ end
32
+
33
+ def title
34
+ @program_ref.title.get
35
+ end
36
+
37
+ def title=(new_title)
38
+ @program_ref.title.set(new_title)
39
+ end
40
+
41
+ def description
42
+ @program_ref.description.get
43
+ end
44
+
45
+ def description=(new_description)
46
+ @program_ref.description.set(new_description)
47
+ end
48
+
49
+ def channel_number
50
+ @program_ref.channel_number.get
51
+ end
52
+
53
+ def channel_number=(new_channel_number)
54
+ @program_ref.channel_number.set(new_channel_number)
55
+ end
56
+
57
+ def input_source
58
+ @program_ref.input_source.get
59
+ end
60
+
61
+ def input_source=(new_input_source)
62
+ @program_ref.input_source.set(new_input_source)
63
+ end
64
+
65
+ def repeats
66
+ @program_ref.repeats.get
67
+ end
68
+
69
+ def repeats=(new_repeats)
70
+ raise "bad value for repeats" if not @@repeats_possible.include?(new_repeats)
71
+ @program_ref.repeats.set(new_repeats)
72
+ end
73
+
74
+ def quality
75
+ @program_ref.quality.get
76
+ end
77
+
78
+ def quality(new_quality)
79
+ @program_ref.quality.set(new_quality)
80
+ end
81
+
82
+ def enabled?
83
+ @program_ref.enabled.get
84
+ end
85
+
86
+ def enabled(value)
87
+ @program_ref.enabled.set(value)
88
+ end
89
+
90
+ def delete
91
+ @program_ref.delete
92
+ end
93
+
94
+ def to_s
95
+ self.title.concat("; start : ").concat(self.start_time.to_s).concat("; duration : ").
96
+ concat(self.duration.to_s).concat("; on channel : ").concat(self.channel_number.to_s)
97
+ end
98
+ end
99
+ end
data/lib/recording.rb ADDED
@@ -0,0 +1,113 @@
1
+ #This module permit to control the EyeTV application with applescript bridge
2
+ module EyeTV
3
+ #This class represents an recording (audio or video) product by EyeTV
4
+ class Recording
5
+ def initialize(recording_ref)
6
+ @recording_ref = recording_ref
7
+ end
8
+
9
+ def busy?
10
+ @recording_ref.busy.get
11
+ end
12
+
13
+ def start_time
14
+ @recording_ref.start_time.get
15
+ end
16
+
17
+ def duration
18
+ @recording_ref.duration.get
19
+ end
20
+
21
+ def title
22
+ @recording_ref.title.get
23
+ end
24
+
25
+ def title=(title)
26
+ @recording_ref.title.set(title)
27
+ end
28
+
29
+ def description
30
+ @recording_ref.description.get
31
+ end
32
+
33
+ def description=(new_description)
34
+ @recording_ref.description.set(new_description)
35
+ end
36
+
37
+ def channel_number
38
+ @recording_ref.channel_number.get
39
+ end
40
+
41
+ def station_name
42
+ @recording_ref.station_name.get
43
+ end
44
+
45
+ def input_source
46
+ @recording_ref.input_source.get
47
+ end
48
+
49
+ def repeats
50
+ @recording_ref.repeats.get
51
+ end
52
+
53
+ def quality
54
+ @recording_ref.quality.get
55
+ end
56
+
57
+ def prepad_time
58
+ @recording_ref.prepad_time.get
59
+ end
60
+
61
+ def postpad_time
62
+ @recording_ref.postpad_time.get
63
+ end
64
+
65
+ def actual_start
66
+ @recording_ref.actual_start.get
67
+ end
68
+
69
+ def actual_duration
70
+ @recording_ref.actual_duration.get
71
+ end
72
+
73
+ def playback_position
74
+ @recording_ref.actual_duration.get
75
+ end
76
+
77
+ def playback_position=(new_playback_position)
78
+ @recording_ref.actual_duration.set(new_playback_position)
79
+ end
80
+
81
+ def name
82
+ @recording_ref.name.get
83
+ end
84
+
85
+ def name=(value)
86
+ @recording_ref.name.set(value)
87
+ end
88
+
89
+ def uid
90
+ @recording_ref.unique_ID.get
91
+ end
92
+
93
+ def location
94
+ @recording_ref.location.get
95
+ end
96
+
97
+ def preview_picture
98
+ @recording_ref.preview_picture.get
99
+ end
100
+
101
+ def markers
102
+ @recording_ref.markers.get
103
+ end
104
+
105
+ def delete
106
+ @recording_ref.delete
107
+ end
108
+
109
+ def to_s
110
+ "uid : ".concat(self.uid.to_s).concat("; title : ").concat(self.title)
111
+ end
112
+ end
113
+ end
data/rb-eyetv.gemspec ADDED
@@ -0,0 +1,63 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{rb-eyetv}
8
+ s.version = "0.0.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["dblugeon"]
12
+ s.date = %q{2009-09-06}
13
+ s.description = %q{
14
+ This library provides ruby classes to control the EyeTV Application.
15
+ You can launch the EyeTV apllication, explore recordings, channels or
16
+ programs
17
+ }
18
+ s.email = %q{damienblugeon@gmail.com}
19
+ s.extra_rdoc_files = [
20
+ "LICENSE",
21
+ "README.rdoc"
22
+ ]
23
+ s.files = [
24
+ ".document",
25
+ ".gitignore",
26
+ "LICENSE",
27
+ "README.rdoc",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "lib/channel.rb",
31
+ "lib/eyetv.rb",
32
+ "lib/program.rb",
33
+ "lib/recording.rb",
34
+ "rb-eyetv.gemspec",
35
+ "test/eyetv_test.rb",
36
+ "test/test_helper.rb"
37
+ ]
38
+ s.homepage = %q{http://github.com/dblugeon/rb-eyetv}
39
+ s.rdoc_options = ["--charset=UTF-8"]
40
+ s.require_paths = ["lib"]
41
+ s.rubygems_version = %q{1.3.5}
42
+ s.summary = %q{This library provides ruby classes to control the EyeTV Application}
43
+ s.test_files = [
44
+ "test/eyetv_test.rb",
45
+ "test/test_helper.rb"
46
+ ]
47
+
48
+ if s.respond_to? :specification_version then
49
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
50
+ s.specification_version = 3
51
+
52
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
53
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
54
+ s.add_development_dependency(%q<rb-appscript>, ["= 0.5.3"])
55
+ else
56
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
57
+ s.add_dependency(%q<rb-appscript>, ["= 0.5.3"])
58
+ end
59
+ else
60
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
61
+ s.add_dependency(%q<rb-appscript>, ["= 0.5.3"])
62
+ end
63
+ end
@@ -0,0 +1,37 @@
1
+ require 'test_helper'
2
+ include EyeTV
3
+
4
+ class RbEyetvTest < Test::Unit::TestCase
5
+ context "EyeTV application" do
6
+ setup do
7
+ @instance = EyeTV::EyeTV.new
8
+ end
9
+ should "not recording" do
10
+ assert !(@instance.is_recording?)
11
+ end
12
+
13
+ should "find an channel or nil" do
14
+ if !(@instance.channels.empty?)
15
+ uid = @instance.channels[0].channel_number
16
+ chan = @instance.find_by_id(:channel, uid)
17
+ assert chan.instance_of?(EyeTV::Channel), "actual class = #{chan.class.to_s}"
18
+ end
19
+ end
20
+
21
+ should "find an recording or nil" do
22
+ if !(@instance.recordings.empty?)
23
+ uid = @instance.recordings[0].uid
24
+ record = @instance.find_by_id(:recording, uid)
25
+ assert record.instance_of?(EyeTV::Recording), "actual class = #{record.class.to_s}"
26
+ end
27
+ end
28
+
29
+ should "find an program or nil" do
30
+ if !(@instance.programs.empty?)
31
+ uid = @instance.programs[0].uid
32
+ program = @instance.find_by_id(:program, uid)
33
+ assert program.instance_of?(EyeTV::Program), "actual class = #{program.class.to_s}"
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'eyetv'
8
+
9
+ class Test::Unit::TestCase
10
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dblugeon-rb-eyetv
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - dblugeon
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-09-06 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: thoughtbot-shoulda
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rb-appscript
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.5.3
34
+ version:
35
+ description: This library provides ruby classes to control the EyeTV Application. You can launch the EyeTV apllication, explore recordings, channels or programs
36
+ email: damienblugeon@gmail.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - LICENSE
43
+ - README.rdoc
44
+ files:
45
+ - .document
46
+ - .gitignore
47
+ - LICENSE
48
+ - README.rdoc
49
+ - Rakefile
50
+ - VERSION
51
+ - lib/channel.rb
52
+ - lib/eyetv.rb
53
+ - lib/program.rb
54
+ - lib/recording.rb
55
+ - rb-eyetv.gemspec
56
+ - test/eyetv_test.rb
57
+ - test/test_helper.rb
58
+ has_rdoc: false
59
+ homepage: http://github.com/dblugeon/rb-eyetv
60
+ licenses:
61
+ post_install_message:
62
+ rdoc_options:
63
+ - --charset=UTF-8
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: "0"
71
+ version:
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: "0"
77
+ version:
78
+ requirements: []
79
+
80
+ rubyforge_project:
81
+ rubygems_version: 1.3.5
82
+ signing_key:
83
+ specification_version: 3
84
+ summary: This library provides ruby classes to control the EyeTV Application
85
+ test_files:
86
+ - test/eyetv_test.rb
87
+ - test/test_helper.rb