Moved Redact::App's @options to Redact::OPTIONS.
authorTilman Sauerbeck <tilman@code-monkey.de>
Wed, 8 Jun 2005 17:31:47 +0000 (17:31 +0000)
committerTilman Sauerbeck <tilman@code-monkey.de>
Wed, 8 Jun 2005 17:31:47 +0000 (17:31 +0000)
ChangeLog
lib/redact/app.rb

index 19ce77a61ea7796186d6f05d01cdb76d2c13512c..d29ca017d652984ab5d0a93315acbf1969b8e57d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,11 @@
 --
-$Id: ChangeLog 42 2005-06-08 17:16:09Z tilman $
+$Id: ChangeLog 43 2005-06-08 17:31:47Z tilman $
 ++
 
 2005-06-08 Tilman Sauerbeck (tilman at code-monkey de)
         * Rakefile: Code cleanup
+        * lib/redact/app.rb: Moved Redact::App's @options to
+          Redact::OPTIONS
 
 2005-05-29 Tilman Sauerbeck (tilman at code-monkey de)
         * Rakefile: Use FileUtils.mkdir_p to create the destination
index 2cc9dd7cf74b7022948a0d207380bb08127c32ab..c7266d8c09b4e33e5a810fa84e38b4e09e6325e2 100644 (file)
@@ -1,5 +1,5 @@
 #--
-# $Id: app.rb 40 2005-05-25 20:19:45Z tilman $
+# $Id: app.rb 43 2005-06-08 17:31:47Z tilman $
 #
 # Copyright (c) 2005 Tilman Sauerbeck (tilman at code-monkey de)
 #
@@ -32,20 +32,30 @@ require "optparse"
 
 SCRIPT_LINES__ = {}
 
+class OpenStruct
+       def clear
+               @table = {}
+       end
+end
+
 module Redact
+       OPTIONS = OpenStruct.new
+
        class App
+               attr_reader :options
+
                def initialize(args)
                        @filename = nil
-                       @options = OpenStruct.new
+                       OPTIONS.clear
                        @option_parser = parse_args(args)
 
-                       @options.input = args.first
-                       if @options.input.nil?
+                       OPTIONS.input = args.first
+                       if OPTIONS.input.nil?
                                puts @option_parser.help
                                exit
                        end
 
-                       @options.output ||= @options.input.sub(/.[^.]+$/, ".edj")
+                       OPTIONS.output ||= @options.input.sub(/.[^.]+$/, ".edj")
                end
 
                def run
@@ -53,12 +63,12 @@ module Redact
                        SCRIPT_LINES__.clear
 
                        begin
-                               load @options.input
+                               load OPTIONS.input
                        rescue LoadError
-                               raise("Cannot load '#{@options.input}'")
+                               raise("Cannot load '#{OPTIONS.input}'")
                        end
 
-                       @filename = Pathname.new(@options.input).cleanpath.to_s
+                       @filename = Pathname.new(OPTIONS.input).cleanpath.to_s
 
                        if EDJE.collections.empty?
                                raise("No collections found")
@@ -67,7 +77,7 @@ module Redact
                        amx = compile_embryo
 
                        begin
-                               Eet::File.open(@options.output, "w") do |ef|
+                               Eet::File.open(OPTIONS.output, "w") do |ef|
                                        dump_amx(amx, ef)
 
                                        dump_header(ef)
@@ -78,7 +88,7 @@ module Redact
                                        dump_fontmap(ef)
                                end
                        rescue Exception
-                               File.rm_f(@options.output)
+                               File.rm_f(OPTIONS.output)
                                raise
                        end
                end
@@ -93,17 +103,17 @@ module Redact
 
                                o.on("-o", "--output OUTPUT_FILE",
                                     "Write Edje to OUTPUT_FILE") do |file|
-                                       @options.output = file
+                                       OPTIONS.output = file
                                end
 
                                o.on("--image_dir IMAGE_DIR",
                                     "Add IMAGE_DIR to the image lookup path") do |dir|
-                                       @options.image_dir = dir
+                                       OPTIONS.image_dir = dir
                                end
 
                                o.on("--font_dir FONT_DIR",
                                     "Add FONT_DIR to the font lookup path") do |dir|
-                                       @options.font_dir = dir
+                                       OPTIONS.font_dir = dir
                                end
 
                                o.separator ""