Permalink
Browse files

Add gems to README, beef up 'rake bundle', refactor Platform stuff for

JRuby as well as moving engine process runner to Platform
  • Loading branch information...
1 parent 61aa8e1 commit 6f24b512e0a67f50278fa58a05c6807399fb6183 @paulcbetts committed Jun 8, 2008
Showing with 96 additions and 56 deletions.
  1. +10 −0 README
  2. +6 −1 Rakefile
  3. +1 −0 TODO
  4. +2 −45 lib/engine.rb
  5. +77 −10 lib/platform.rb
View
10 README
@@ -15,6 +15,16 @@ have set up a "Season Pass"-type automatic Bittorrent download of shows, this
means that every day {The Daily Show, 30 Rock, whatever..} automatically gets
sync'ed to your {iPod, Zune, whatever}!
+Gems you'll need:
+ * builder
+ * gettext
+ * ramaze
+
+Misc. gems you might need (building, etc):
+ * RSpec
+ * Rake
+ * RCov
+ * Pallet
To build:
rake && rake ffmpeg # Takes forever, only works on Mac/Linux
View
@@ -141,8 +141,13 @@ end
desc "Create a bundle folder that has all dependencies included"
task :bundle do
- ENV["REQUIRE2LIB_LIBDIR"] = "#{RootDir}/bundle"
+ ENV["REQUIRE2LIB_LIBDIR"] = "#{RootDir}/bundle/lib/yikes"
sh "#{RootDir}/findlibs/main.rb #{RootDir}/lib/main.rb"
+ sh "cp -R #{RootDir}/bin #{RootDir}/bundle/"
+ sh "cp -R #{RootDir}/lib/* #{RootDir}/bundle/lib/yikes"
+ sh "mkdir -p #{RootDir}/bundle/lib/yikes/libexec"
+ sh "cp -R #{RootDir}/libexec/bin #{RootDir}/bundle/lib/yikes/libexec"
+ sh "cp -R #{RootDir}/libexec/lib #{RootDir}/bundle/lib/yikes/libexec"
end
View
1 TODO
@@ -30,3 +30,4 @@ Future:
* Daemon control interface, script to kick off encoder run
* Dir change notifications on Linux, OSX
* Running daemon instant on-demand
+ * Add Amazon ads to page
View
@@ -82,58 +82,15 @@ def get_screenshot(input, output)
module ExternalTranscoder
def transcode(input, output)
cmd = get_transcode_command(input, output)
- run_external_command(cmd)
+ Platform.run_external_command(cmd)
end
def get_screenshot(input, output)
cmd = get_screenshot_command(input, output)
- run_external_command(cmd)
+ Platform.run_external_command(cmd)
end
private
- def run_external_command(cmd)
- logger.debug "Running #{cmd}"
-
- # FIXME: Dumb hack code!
- pid = nil
- unless (pid = fork)
- STDOUT.reopen '/dev/null'
- STDERR.reopen '/dev/null'
- logger.debug "Executing: #{cmd}"
- before_transcode() if self.respond_to? :before_transcode
- system(cmd)
- after_transcode() if self.respond_to? :before_transcode
- Kernel.exit!
- end
- e = Process.wait pid
- exitcode = ($?) ? ($?.exitstatus) : -1
- logger.info "Process returned #{exitcode}"
-
- # FIXME: Since we haven't got FFmpeg to actually return us not crap values,
- # just return true here
- true
-
- return exitcode == 0
-
-# IO.popen cmd do |i,o,e|
-# break
-# o.readlines.each do |line|
-# p line
-# end
-# end
-
-# if Platform.os == :windows
-# # TODO: Implement me
-# return
-# end
-#
-# # Platform is Posix so we have fork
-# Kernel.fork do
-# before_transcode() if self.respond_to? :before_transcode
-# Kernel.exec
-# after_transcode() if self.respond_to? :before_transcode
-# end
- end
end
View
@@ -27,17 +27,89 @@
require 'gettext'
require 'pathname'
require 'fileutils'
+require 'rbconfig'
include GetText
module Platform
class << self
+
+ def run_external_command_fork(cmd)
+ # FIXME: Dumb hack code!
+ pid = nil
+ unless (pid = fork)
+ STDOUT.reopen '/dev/null'
+ STDERR.reopen '/dev/null'
+ logger.debug "Executing: #{cmd}"
+ before_transcode() if self.respond_to? :before_transcode
+ system(cmd)
+ after_transcode() if self.respond_to? :before_transcode
+ Kernel.exit!
+ end
+ e = Process.wait pid
+ exitcode = ($?) ? ($?.exitstatus) : -1
+ logger.info "Process returned #{exitcode}"
+ end
+
+ def run_external_command(cmd)
+ logger.debug "Running #{cmd}"
+
+ if platform_has_fork?
+ run_external_command_fork(cmd)
+ return true
+ end
+
+ # Last chance - just use system
+ system(cmd)
+ return true
+
+# IO.popen cmd do |i,o,e|
+# break
+# o.readlines.each do |line|
+# p line
+# end
+# end
+
+# if Platform.os == :windows
+# # TODO: Implement me
+# return
+# end
+#
+# # Platform is Posix so we have fork
+# Kernel.fork do
+# before_transcode() if self.respond_to? :before_transcode
+# Kernel.exec
+# after_transcode() if self.respond_to? :before_transcode
+# end
+ end
+
+ def hostname
+ return "DONTKNOW" if os == :windows
+ return super_chomp(`hostname -s`)
+ end
+
+
+ ###
+ # Constant-returning routines (aka "boring")
+ ###
+
+ def ruby_runtime
+ # FIXME: Rubinius? IronRuby?
+ return :jruby if RUBY_PLATFORM =~ /java/
+ return :mri
+ end
+
def os
- return :linux if RUBY_PLATFORM =~ /linux/
- return :osx if RUBY_PLATFORM =~ /darwin/
- return :solaris if RUBY_PLATFORM =~ /solaris/
- return :bsd if RUBY_PLATFORM =~ /bsd/
- return :windows if RUBY_PLATFORM =~ /win/
+ host_os = Config::CONFIG['host_os']
+ return :linux if host_os =~ /linux/
+ return :osx if host_os =~ /darwin/
+ return :solaris if host_os =~ /solaris/
+ return :bsd if host_os =~ /bsd/
+ return :windows if host_os =~ /win/
+ end
+
+ def platform_has_fork?
+ os != :windows and [:mri, :rubinius].include? ruby_runtime
end
def home_dir
@@ -83,11 +155,6 @@ def screenshot_dir
return path
end
- def hostname
- return "DONTKNOW" if os == :windows
- return super_chomp(`hostname -s`)
- end
-
end # Class << self
end

0 comments on commit 6f24b51

Please sign in to comment.