X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fredact%2Fredact.rb;h=f1a93faa0cd3b8667c11a48c549cda9062296cec;hb=5509b434e26fd1a8c9c3990154a881583b81d2a6;hp=59740f70f2f1e23b1477de9c3f6aec0b2cf102dc;hpb=2c25c90e2aaf57a7508a7988f58b2784d5071a7e;p=redact.git diff --git a/lib/redact/redact.rb b/lib/redact/redact.rb index 59740f7..f1a93fa 100644 --- a/lib/redact/redact.rb +++ b/lib/redact/redact.rb @@ -1,6 +1,4 @@ #-- -# $Id: redact.rb 1 2005-03-26 01:32:38Z tilman $ -# # Copyright (c) 2005 Tilman Sauerbeck (tilman at code-monkey de) # # Permission is hereby granted, free of charge, to any person obtaining @@ -27,7 +25,7 @@ require "imlib2" require "redact/part" require "redact/program" -class Object +class Object # :nodoc: undef :id end @@ -57,7 +55,7 @@ class String end module Redact - VERSION = "0.0.1" + VERSION = "0.1.5" class RedactError < StandardError; end @@ -84,12 +82,13 @@ module Redact @data = DataHash.new end - def collection(name) + def collection(name) # :yields: collection c = @collections[name] block_given? ? (yield c) : c end + protected def to_eet_name "Edje_File" end @@ -105,7 +104,7 @@ module Redact end end - class DataHash < Hash + class DataHash < Hash # :nodoc: def [](key) super.value end @@ -115,7 +114,7 @@ module Redact end end - class HashEntry + class HashEntry # :nodoc: attr_reader :key, :value def initialize(key, value) @@ -123,12 +122,14 @@ module Redact @value = value.to_str.dup.freeze end + protected def to_eet_name "Edje_Data" end end - class FontDirectory < Array + class FontDirectory < Array # :nodoc: + protected def to_eet_name "Edje_Font_Directory" end @@ -138,29 +139,33 @@ module Redact end end - class FontDirectoryEntry - attr_reader :filename + class FontDirectoryEntry # :nodoc: + attr_reader :save_as, :filename, :alias - def initialize(filename) + def initialize(fn_alias, filename) + @save_as = fn_alias.to_str.dup.freeze @filename = filename.to_str.dup.freeze + @alias = "Edje." + fn_alias.sub(/.[^.]+$/, "").freeze end + protected def to_eet_name "Edje_Font_Directory_Entry" end def to_eet_properties - {"entry" => [@filename]} + {"entry" => [@alias]} end end - class ImageDirectory < Array + class ImageDirectory < Array # :nodoc: def <<(entry) super entry.id = size - 1 end + protected def to_eet_name "Edje_Image_Directory" end @@ -170,10 +175,11 @@ module Redact end end - class ImageDirectoryEntry + class ImageDirectoryEntry # :nodoc: attr_reader :filename, :image, :id - def initialize(filename) + def initialize(im_alias, filename) + @alias = im_alias.to_str.dup.freeze @filename = filename.to_str.dup.freeze @image = Imlib2::Image.load(@filename) @id = -1 @@ -191,19 +197,21 @@ module Redact end end + protected def to_eet_name "Edje_Image_Directory_Entry" end def to_eet_properties - {"entry" => [@filename], + {"entry" => [@alias], "source_type" => [@source_type], "source_param" => [@source_param], "id" => [@id]} end end - class CollectionDirectory < Array + class CollectionDirectory < Array # :nodoc: + protected def to_eet_name "Edje_Part_Collection_Directory" end @@ -213,12 +221,13 @@ module Redact end end - class CollectionDirectoryEntry + class CollectionDirectoryEntry # :nodoc: def initialize(col) @name = col.name.to_str.dup.freeze @id = col.id end + protected def to_eet_name "Edje_Part_Collection_Directory_Entry" end @@ -230,8 +239,8 @@ module Redact end class Collection - attr_reader :name, :id, :data, :min, :max, :parts, :programs - attr_accessor :script + attr_reader :name, :id, :data, :min, :max, :parts, :programs, + :script def initialize(name, id) @name = name.to_str.dup.freeze @@ -247,7 +256,12 @@ module Redact @script = nil end - def part(name, type = :invalid) + def script=(v) + v = v.to_str + @script = (File.exist?(v) ? File.read(v) : v).dup + end + + def part(name, type = :invalid) # :yields: part p = @parts[name] if p.nil? klass = case type @@ -261,7 +275,7 @@ module Redact ImagePart else raise(ArgumentError, - "invalid program type - #{type.to_s}") + "invalid part type - #{type.to_s}") end p = klass.new(self, @parts.size, name) @@ -271,7 +285,7 @@ module Redact block_given? ? (yield p) : p end - def program(name, type = :invalid) + def program(name, type = :invalid) # :yields: program p = @programs[name] if p.nil? klass = case type @@ -322,6 +336,7 @@ module Redact end end + protected def to_eet_name "Edje_Part_Collection" end