Ruby example code
authortak <taktaktaktaktaktaktaktaktaktak@gmail.com>
Wed, 23 Jan 2008 16:15:09 +0000 (16:15 +0000)
committertak <taktaktaktaktaktaktaktaktaktak@gmail.com>
Wed, 23 Jan 2008 16:15:09 +0000 (16:15 +0000)
ruby-lightmediascanner/examples/test.rb [new file with mode: 0755]

diff --git a/ruby-lightmediascanner/examples/test.rb b/ruby-lightmediascanner/examples/test.rb
new file mode 100755 (executable)
index 0000000..9aba072
--- /dev/null
@@ -0,0 +1,54 @@
+#!/usr/bin/env ruby
+# 
+# Copyright (C) 2007 by Levi Bard
+# 
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# 
+# @author Levi Bard <taktaktaktaktaktaktaktaktaktak@gmail.com>
+# 
+
+
+require 'lightmediascanner'
+
+include LightMediaScanner
+
+def printUsage
+       puts("Usage: #{$0} <commit-interval> <slave-timeout> <db-path> <parsers> <charsets> <scan-path>")
+end
+
+def main
+       lms = nil
+       scan_path = ''
+
+       begin
+               lms = Scanner.new(ARGV[2])
+               lms.commit_interval = ARGV[0].to_i()
+               lms.timeout = ARGV[1].to_i()
+               ARGV[4].split(',').each{ |charset| lms.add_charset(charset) }
+               parsers = ARGV[3].split(',').collect{ |parser_name| Parser.new(lms, parser_name) }
+               scan_path = ARGV[5]
+               puts(lms.to_s())
+       rescue
+               printUsage()
+               exit
+       end
+
+       lms.check(scan_path)
+       lms.process(scan_path)
+end
+
+if(__FILE__ == $0)
+       main()
+end