nickludlam-ruby-mythtv 0.2.0 → 0.3.0

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,3 +1,8 @@
1
+ == 0.3.0 (2009-02-18)
2
+
3
+ * Replaced old database code with one based on ActiveRecord, which is now a dependency
4
+ * Changed test code
5
+
1
6
  == 0.2.0 (2008-09-29)
2
7
 
3
8
  * Bumped to version 0.2 as we now support proper editing of recording schedules, and speaking multiple versions of the database schema
data/Rakefile CHANGED
@@ -1,32 +1,37 @@
1
1
  require 'rubygems'
2
- Gem::manage_gems
3
2
  require 'rake/gempackagetask'
4
3
  require 'rake/testtask'
5
4
 
6
5
  spec = Gem::Specification.new do |s|
7
- s.name = %q{ruby-mythtv}
8
- s.version = "0.2.0"
6
+ s.name = 'ruby-mythtv'
7
+ s.version = '0.3.0'
9
8
 
10
9
  s.specification_version = 2 if s.respond_to? :specification_version=
11
10
 
12
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
13
- s.authors = ["Nick Ludlam"]
14
- s.date = %q{2008-07-27}
15
- s.description = %q{Ruby implementation of the MythTV communication protocol}
11
+ s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
12
+ s.date = %q{2009-02-18}
13
+ s.description = %q{Ruby implementation of the MythTV communication protocol, and interface to the MythTV database}
14
+ s.authors = [ 'Nick Ludlam' ]
16
15
  s.email = %q{nick@recoil.org}
17
- s.extra_rdoc_files = ["History.txt", "License.txt", "README.txt"]
18
- s.files = ["History.txt", "License.txt", "README.txt", "Rakefile", "lib/ruby-mythtv.rb", "lib/mythtv/backend.rb", "lib/mythtv/channel.rb", "lib/mythtv/database.rb", "lib/mythtv/program.rb", "lib/mythtv/protocol.rb", "lib/mythtv/recording.rb", "lib/mythtv/recording_schedule.rb", "lib/mythtv/utils.rb", "test/test_backend.rb", "test/test_db.rb", "test/test_helper.rb"]
16
+ s.extra_rdoc_files = [ 'History.txt', 'License.txt', 'README.txt', 'Todo.txt' ]
17
+ s.files = [ 'History.txt', 'License.txt', 'README.txt', 'Rakefile', 'Todo.txt' ] + Dir["lib/*.rb"] + Dir["lib/mythtv/*.rb"] + Dir["test/*.rb"]
19
18
  s.has_rdoc = true
20
19
  s.homepage = %q{http://github.com/nickludlam/ruby-mythtv/}
21
- s.rdoc_options = ["--main", "README.txt"]
22
- s.require_paths = ["lib"]
20
+ s.rdoc_options = ['--main', 'README.txt']
21
+ s.require_paths = ['lib']
23
22
  s.rubyforge_project = %q{ruby-mythtv}
24
- s.rubygems_version = %q{0.2.0}
23
+ s.rubygems_version = %q{0.3.0}
24
+
25
+ s.add_dependency('mysql')
26
+ s.add_dependency('activerecord')
27
+ s.add_dependency('composite_primary_keys')
28
+
25
29
  s.summary = %q{Ruby implementation of the MythTV backend protocol}
26
- s.test_files = ["test/test_backend.rb", "test/test_helper.rb"]
30
+ s.test_files = Dir["test/*.rb"]
27
31
  end
28
32
 
29
33
  Rake::GemPackageTask.new(spec) do |pkg|
34
+ pkg.need_zip = true
30
35
  pkg.need_tar = true
31
36
  end
32
37
 
@@ -35,18 +40,22 @@ task :build => "pkg/#{spec.name}-#{spec.version}.gem" do
35
40
  end
36
41
 
37
42
  desc "Run basic unit tests"
38
- Rake::TestTask.new("test_units") do |t|
43
+ Rake::TestTask.new("test") do |t|
39
44
  t.pattern = ENV["TESTFILES"] || ['test/test_backend.rb', 'test/test_db.rb']
40
45
  t.verbose = true
41
46
  t.warning = true
42
47
  end
43
48
 
44
- task :test => :test_units
45
-
46
- Rake::TestTask.new('test_db') do |t|
49
+ Rake::TestTask.new('test:db') do |t|
47
50
  t.pattern = ['test/test_db.rb']
48
51
  t.verbose = true
49
52
  end
53
+
54
+ Rake::TestTask.new('test:backend') do |t|
55
+ t.pattern = ['test/test_backend.rb']
56
+ t.verbose = true
57
+ end
58
+
50
59
 
51
60
  desc "Run unit tests as default"
52
- task :default => :test_units
61
+ task :default => :test
data/Todo.txt CHANGED
@@ -1,6 +1,7 @@
1
- - Implement the Recorder class, and associated functions (see existing MythTV Python module)
2
- - Look at how we obtain the channel icon by streaming a backend file (see existing MythTV Perl module)
3
- - Support Ruby 1.9
4
- - Support seeking with the MythTV::Backend#stream() method
5
- - Look at how we need to pass the DB instance to each constructor for Channel, Program and RecordingSchedule. Automate the link back to db instance?
6
- - Make use of the ENUMS placed in RecordingSchedule to help with validation of various columns
1
+ == Todo
2
+
3
+ * Implement the Recorder class, and associated functions (see existing MythTV Python module)
4
+ * Look at how we obtain the channel icon by streaming a backend file (see existing MythTV Perl module)
5
+ * Support Ruby 1.9
6
+ * Support seeking with the MythTV::Backend#stream() method
7
+ * Make use of the ENUMS placed in RecordingSchedule to help with validation of various columns
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nickludlam-ruby-mythtv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Ludlam
@@ -9,11 +9,12 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-29 00:00:00 -07:00
12
+ date: 2009-02-18 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: mysql
17
+ type: :runtime
17
18
  version_requirement:
18
19
  version_requirements: !ruby/object:Gem::Requirement
19
20
  requirements:
@@ -21,7 +22,27 @@ dependencies:
21
22
  - !ruby/object:Gem::Version
22
23
  version: "0"
23
24
  version:
24
- description: Ruby implementation of the MythTV communication protocol
25
+ - !ruby/object:Gem::Dependency
26
+ name: activerecord
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: composite_primary_keys
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ description: Ruby implementation of the MythTV communication protocol, and interface to the MythTV database
25
46
  email: nick@recoil.org
26
47
  executables: []
27
48
 
@@ -31,24 +52,12 @@ extra_rdoc_files:
31
52
  - History.txt
32
53
  - License.txt
33
54
  - README.txt
55
+ - Todo.txt
34
56
  files:
35
57
  - History.txt
36
58
  - License.txt
37
59
  - README.txt
38
60
  - Rakefile
39
- - lib/ruby-mythtv.rb
40
- - mythtv/backend.rb
41
- - mythtv/channel.rb
42
- - mythtv/database.rb
43
- - mythtv/program.rb
44
- - mythtv/protocol.rb
45
- - mythtv/recording.rb
46
- - mythtv/recording_schedule.rb
47
- - mythtv/utils.rb
48
- - test/test_backend.rb
49
- - test/test_db.rb
50
- - test/test_helper.rb
51
- - test_stream.rb
52
61
  - Todo.txt
53
62
  has_rdoc: true
54
63
  homepage: http://github.com/nickludlam/ruby-mythtv/
@@ -77,7 +86,5 @@ rubygems_version: 1.2.0
77
86
  signing_key:
78
87
  specification_version: 2
79
88
  summary: Ruby implementation of the MythTV backend protocol
80
- test_files:
81
- - test/test_helper.rb
82
- - test/test_backend.rb
83
- - test/test_db.rb
89
+ test_files: []
90
+
@@ -1,52 +0,0 @@
1
- # The MIT License
2
- #
3
- # Copyright (c) 2008 Nick Ludlam
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
22
-
23
- module MythTV
24
- VERSION = '0.2.0'
25
-
26
- def self.connect(options)
27
- backend = connect_backend(options)
28
- database = connect_database(options)
29
-
30
- [backend, database]
31
- end
32
-
33
- def self.connect_backend(options)
34
- Backend.new(options)
35
- end
36
-
37
- def self.connect_database(options)
38
- Database.new(options)
39
- end
40
-
41
- end
42
-
43
- $:.unshift(File.dirname(__FILE__))
44
-
45
- require 'mythtv/channel.rb'
46
- require 'mythtv/program.rb'
47
- require 'mythtv/protocol.rb'
48
- require 'mythtv/recording.rb'
49
- require 'mythtv/recording_schedule.rb'
50
- require 'mythtv/utils.rb'
51
- require 'mythtv/database.rb'
52
- require 'mythtv/backend.rb'
@@ -1,63 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- class TestBackend < Test::Unit::TestCase
4
- def setup
5
- abort("\n\tERROR: You must set the environment variable MYTHTV_BACKEND to the name of your MythTV backend server\n\n") unless ENV['MYTHTV_BACKEND']
6
- @backend = MythTV.connect_backend(:host => ENV['MYTHTV_BACKEND'])
7
- end
8
-
9
- def teardown
10
- @backend.close
11
- end
12
-
13
- # Assuming the system is up for more than 0 seconds!
14
- def test_connection
15
- uptime = @backend.query_uptime
16
- assert uptime > 0
17
- end
18
-
19
- # Assuming there is at least one recording on the test server
20
- def test_get_recordings
21
- recordings = @backend.query_recordings
22
- assert recordings.length > 0
23
- assert_kind_of MythTV::Recording, recordings[0]
24
- end
25
-
26
- # Assuming there is at least one scheduled recording on the test server
27
- def test_get_scheduled
28
- scheduled = @backend.query_scheduled
29
- assert scheduled.length > 0
30
- assert_kind_of MythTV::Recording, scheduled[0]
31
- end
32
-
33
- # Test the generation of a preview image
34
- def test_make_preview_image
35
- recordings = @backend.query_recordings
36
-
37
- recording = recordings[0]
38
- test_image = @backend.preview_image(recording, :secs_in => 1)
39
- assert test_image.length > 0
40
-
41
- # Define an array of the decimal values of the PNG magic number
42
- png_sig = [137, 80, 78, 71, 13, 10, 26, 10]
43
- test_image_sig = (0..7).collect { |i| test_image[i] }
44
-
45
- assert_equal test_image_sig, png_sig
46
- end
47
-
48
- # def test_process_guide_xml
49
- # guide_data = @backend.get_program_guide
50
- #
51
- # channels = MythTV::Backend.process_guide_xml(guide_data)
52
- # end
53
-
54
- # Don't run this by default as it takes a while. Possibly limit to 100kB?
55
- #def test_download
56
- # recordings = @backend.query_recordings
57
- #
58
- # recording = recordings[-2]
59
- # @backend.download(recording)
60
- #end
61
-
62
-
63
- end
@@ -1,134 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- class TestDatabase < Test::Unit::TestCase
4
- def setup
5
- abort("\n\tmyERROR: You must set the environment variable MYTHTV_DB to the name of your MythTV database server\n\n") unless ENV['MYTHTV_DB']
6
- abort("\n\tmyERROR: You must set the environment variable MYTHTV_PW to the name of your MythTV database server\n\n") unless ENV['MYTHTV_PW']
7
- @db = MythTV.connect_database(:host => ENV['MYTHTV_DB'],
8
- :database_password => ENV['MYTHTV_PW'],
9
- :log_level => Logger::DEBUG)
10
- end
11
-
12
- def teardown
13
- @db.close
14
- end
15
-
16
- # Check the DBSchemaVer key in the settings table as our first check
17
- # It should always be present
18
- def test_get_setting
19
- schema_version = @db.get_setting('DBSchemaVer')
20
- assert schema_version.to_i > 0
21
- end
22
-
23
- # Check the DBSchemaVer, once queried, is in the setting cache
24
- def test_get_setting_cache
25
- schema_version = @db.get_setting('DBSchemaVer')
26
- assert @db.setting_cache['DBSchemaVer_'].to_i > 0
27
- end
28
-
29
- def test_list_channels
30
- channels = @db.list_channels
31
-
32
- assert_kind_of Array, channels
33
- assert channels.length > 0
34
- assert_kind_of MythTV::Channel, channels[0]
35
- assert channels[0].chanid > 0
36
- end
37
-
38
- # Test we can pull back a single channel when
39
- # specifying a :chanid
40
- def test_list_single_chanid
41
- first_channel_list = @db.list_channels
42
- wanted_chanid = first_channel_list[0].chanid
43
-
44
- second_channel_list = @db.list_channels(:chanid => wanted_chanid)
45
- assert_equal 1, second_channel_list.length
46
-
47
- channel = second_channel_list[0]
48
- assert_kind_of MythTV::Channel, channel
49
- assert_equal channel.chanid, wanted_chanid
50
- end
51
-
52
- def test_list_multiple_chanids
53
- first_channel_list = @db.list_channels
54
- first_five = first_channel_list.slice(0..4)
55
- wanted_chanids = first_five.map { |x| x.chanid }
56
-
57
- second_channel_list = @db.list_channels(:chanid => wanted_chanids)
58
- assert_equal 5, second_channel_list.length
59
- second_channel_list
60
- end
61
-
62
- def test_list_programs
63
- programs = @db.list_programs(:limit => 10)
64
-
65
- assert_equal 10, programs.length
66
- end
67
-
68
- def test_list_programs_with_search
69
- programs = @db.list_programs(:conditions => ['title LIKE ?', "%"],
70
- :limit => 5)
71
- assert programs.length > 0
72
- end
73
-
74
- def test_list_programs_with_starttime_range
75
- # Programs in the next two hours
76
- programs = @db.list_programs(:conditions => ['starttime BETWEEN ? AND ?', Time.now, Time.now + 7200],
77
- :limit => 1)
78
-
79
- assert_equal 1, programs.length
80
- end
81
-
82
- def test_program_links_to_channel
83
- programs = @db.list_programs(:conditions => ['title LIKE ?', "%"], :limit => 1)
84
- program_channel = programs[0].channel
85
- assert_kind_of MythTV::Channel, program_channel
86
- end
87
-
88
- def test_new_schedule
89
- # Get list of schedules for later reference
90
- num_schedules = @db.list_recording_schedules
91
- programs = @db.list_programs(:conditions => ['starttime BETWEEN ? AND ?', Time.now + 3600, Time.now + 7200],
92
- :limit => 1)
93
-
94
- # Convert our first program selected into a recording schedule
95
- new_schedule = MythTV::RecordingSchedule.new(programs[0], @db)
96
- new_schedule.save
97
-
98
- # Get new list
99
- new_num_schedules = @db.list_recording_schedules
100
- # Assert that we now have one more schedule
101
- assert_equal num_schedules.length + 1, new_num_schedules.length
102
-
103
- assert new_schedule.recordid > 0
104
-
105
- destroy_result = new_schedule.destroy()
106
- assert destroy_result
107
- end
108
-
109
- def test_new_and_modify_schedule
110
- # Get list of schedules for later reference
111
- num_schedules = @db.list_recording_schedules
112
- programs = @db.list_programs(:conditions => ['starttime BETWEEN ? AND ?', Time.now + 3600, Time.now + 7200],
113
- :limit => 1)
114
-
115
- # Convert our first program selected into a recording schedule
116
- new_schedule = MythTV::RecordingSchedule.new(programs[0], @db)
117
- new_schedule.save
118
-
119
- new_schedule.type = 4
120
- new_schedule.save
121
-
122
- test_query = @db.list_recording_schedules(:conditions => ['recordid = ?', new_schedule.recordid])
123
- assert_equal 1, test_query.length
124
-
125
- test_retrieval = test_query[0]
126
-
127
- assert_equal 4, test_retrieval.type
128
-
129
- destroy_result = new_schedule.destroy()
130
- assert destroy_result
131
- end
132
-
133
- end
134
-
@@ -1,3 +0,0 @@
1
- require 'test/unit'
2
- require 'logger'
3
- require File.dirname(__FILE__) + '/../lib/ruby-mythtv'