Class: FlexUtils::Adl

Inherits:
AbstractTool
  • Object
show all
Defined in:
lib/flexutils/adl.rb

Direct Known Subclasses

TestRunner

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(swf) ⇒ Adl

Returns a new instance of Adl.



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/flexutils/adl.rb', line 17

def initialize( swf )
  @swf           = swf
  @title         = "Temporary AIR application"
  @visible       = true
  @transparent   = false
  @width         = 1024
  @height        = 768
  @x             = 100
  @y             = 100
  @system_chrome = "standard"
  @arguments     = []
end

Instance Attribute Details

#arguments=(value) ⇒ Object (writeonly)

Sets the attribute arguments

Parameters:

  • value

    the value to set the attribute arguments to.



5
6
7
# File 'lib/flexutils/adl.rb', line 5

def arguments=(value)
  @arguments = value
end

#descriptor=(value) ⇒ Object (writeonly)

Sets the attribute descriptor

Parameters:

  • value

    the value to set the attribute descriptor to.



5
6
7
# File 'lib/flexutils/adl.rb', line 5

def descriptor=(value)
  @descriptor = value
end

#height=(value) ⇒ Object (writeonly)

Sets the attribute height

Parameters:

  • value

    the value to set the attribute height to.



5
6
7
# File 'lib/flexutils/adl.rb', line 5

def height=(value)
  @height = value
end

#swf=(value) ⇒ Object (writeonly)

Sets the attribute swf

Parameters:

  • value

    the value to set the attribute swf to.



5
6
7
# File 'lib/flexutils/adl.rb', line 5

def swf=(value)
  @swf = value
end

#system_chrome=(value) ⇒ Object (writeonly)

Sets the attribute system_chrome

Parameters:

  • value

    the value to set the attribute system_chrome to.



5
6
7
# File 'lib/flexutils/adl.rb', line 5

def system_chrome=(value)
  @system_chrome = value
end

#title=(value) ⇒ Object (writeonly)

Sets the attribute title

Parameters:

  • value

    the value to set the attribute title to.



5
6
7
# File 'lib/flexutils/adl.rb', line 5

def title=(value)
  @title = value
end

#transparent=(value) ⇒ Object (writeonly)

Sets the attribute transparent

Parameters:

  • value

    the value to set the attribute transparent to.



5
6
7
# File 'lib/flexutils/adl.rb', line 5

def transparent=(value)
  @transparent = value
end

#visible=(value) ⇒ Object (writeonly)

Sets the attribute visible

Parameters:

  • value

    the value to set the attribute visible to.



5
6
7
# File 'lib/flexutils/adl.rb', line 5

def visible=(value)
  @visible = value
end

#width=(value) ⇒ Object (writeonly)

Sets the attribute width

Parameters:

  • value

    the value to set the attribute width to.



5
6
7
# File 'lib/flexutils/adl.rb', line 5

def width=(value)
  @width = value
end

#x=(value) ⇒ Object (writeonly)

Sets the attribute x

Parameters:

  • value

    the value to set the attribute x to.



5
6
7
# File 'lib/flexutils/adl.rb', line 5

def x=(value)
  @x = value
end

#y=(value) ⇒ Object (writeonly)

Sets the attribute y

Parameters:

  • value

    the value to set the attribute y to.



5
6
7
# File 'lib/flexutils/adl.rb', line 5

def y=(value)
  @y = value
end

Class Method Details

.run(*args) {|c| ... } ⇒ Object

Yields:

  • (c)


53
54
55
56
57
58
59
# File 'lib/flexutils/adl.rb', line 53

def self.run( *args )
  c = self.new(*args)
  
  yield c
  
  c.run!
end

Instance Method Details

#command_stringObject



61
62
63
64
65
66
67
# File 'lib/flexutils/adl.rb', line 61

def command_string
  @extra_args ||= [ ]
  
  args = (@arguments + @extra_args).join(" ")
  
  "#{command_path 'adl'} #{@descriptor} -- #{args}"
end

#generate_descriptorObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/flexutils/adl.rb', line 30

def generate_descriptor
  return <<-stop
<?xml version="1.0"?>

<application xmlns="http://ns.adobe.com/air/application/1.5">
	<id>net.iconara.tmp</id>
	<version>1.0</version>
	<filename>#{@title}</filename>
	<initialWindow>
		<title>#{@title}</title>
		<content>#{File.basename(@swf)}</content>
		<systemChrome>#{@system_chrome}</systemChrome>
 <transparent>#{@transparent}</transparent>
 <visible>#{@visible}</visible>
		<width>#{@width}</width> 
		<height>#{@height}</height>
<x>#{@x}</x>
<y>#{@y}</y>
	</initialWindow>
</application>
stop
end

#run!(extra_args = []) {|$?| ... } ⇒ Object

Yields:

  • ($?)


69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/flexutils/adl.rb', line 69

def run!( extra_args=[], &block )
  @extra_args = extra_args
  
  current_dir = Dir.pwd

  dir = File.dirname(@swf)

  Dir.chdir(dir)
  
  temporary_descriptor = @descriptor == nil

  if temporary_descriptor
    @descriptor = "temporary-application.xml"

    descriptor = File.new(@descriptor, "w")
    descriptor.puts(generate_descriptor)
    descriptor.close
  end
    
  execute_command
  
  yield($?) if block_given?

  File.delete(@descriptor) if temporary_descriptor

  Dir.chdir(current_dir)
end