From 380b2dd82c174657fc77416bc0044012d3426828 Mon Sep 17 00:00:00 2001 From: tak Date: Wed, 23 Jan 2008 16:15:09 +0000 Subject: [PATCH] Ruby example code --- ruby-lightmediascanner/examples/test.rb | 54 +++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100755 ruby-lightmediascanner/examples/test.rb diff --git a/ruby-lightmediascanner/examples/test.rb b/ruby-lightmediascanner/examples/test.rb new file mode 100755 index 0000000..9aba072 --- /dev/null +++ b/ruby-lightmediascanner/examples/test.rb @@ -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 +# + + +require 'lightmediascanner' + +include LightMediaScanner + +def printUsage + puts("Usage: #{$0} ") +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 -- 1.7.9.5