Module: LP::Exporter::App
- Defined in:
- lib/lp/exporter/app.rb
Overview
Application module
Class Method Summary collapse
-
.getOptions ⇒ Hash
Parse passed options.
-
.start ⇒ Object
Start Application.
Class Method Details
.getOptions ⇒ Hash
Parse passed options
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/lp/exporter/app.rb', line 12 def self.getOptions = { :Parser => nil, :LP => nil, :Path => './tmp/', :Files => [], :Lang => false } [:Parser] = OptionParser.new do |opts| opts. = 'Usage: lp_exporter.rb [options] lp.cab|langpacks' opts.on('-p', '--path dir', 'Path to output directory') do |path| [:Path] = path end opts.on('-f','--files names', Array, 'Names for files to match') do |files| files.each do |file| [:Files] << file end end opts.on('-l','--[no-]lang', 'Use language name not LangID from PE') do |lang| [:Lang] = lang end opts.on_tail('-h', '--help', 'Show this message') do puts opts return false end end begin [:LP] = [:Parser].parse!.first rescue OptionParser::ParseError => e $stderr.puts e. return false end end |
.start ⇒ Object
Start Application
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/lp/exporter/app.rb', line 49 def self.start = getOptions if not or [:LP].nil? puts [:Parser].help return false end Dir.mktmpdir do |tmpdir| cabs = [] if File.directory?([:LP]) cabs += Dir[File.join([:LP],'**','*.cab')] else cabs << [:LP] end cabs.each do |cab| LP::Exporter.process(cab, [:Files], tmpdir, [:Path], [:Lang]) puts 'Done for ' + cab end end true end |