swf_file 1.0.0 → 1.1.0.rc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +38 -25
- data/lib/swf_file/assertions.rb +15 -9
- data/lib/swf_file/compression.rb +30 -24
- data/lib/swf_file/conversions.rb +36 -30
- data/lib/swf_file/flash_file.rb +30 -0
- data/lib/swf_file/packed_bit_object.rb +46 -42
- data/lib/swf_file/parser.rb +54 -48
- data/lib/swf_file/swf_header.rb +43 -39
- data/lib/swf_file.rb +13 -33
- metadata +37 -30
- data/.gitignore +0 -3
- data/Rakefile +0 -28
- data/VERSION +0 -1
- data/fixtures/clicktag-decompressed.swf +0 -0
- data/fixtures/clicktag.swf +0 -0
- data/fixtures/smallgoat.jpg +0 -0
- data/swf_file.gemspec +0 -59
- data/test/test_helper.rb +0 -11
- data/test/unit/swf_file_test.rb +0 -108
data/README.rdoc
CHANGED
@@ -1,43 +1,56 @@
|
|
1
1
|
=swf_file
|
2
|
-
|
2
|
+
A Ruby Gem based on swfutil lib, by Dennis Zhuang.
|
3
|
+
SWF File is lightweight gem to read swf file headers from within a Ruby application.
|
3
4
|
|
4
5
|
==Ruby compatibility
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
Target version: 1.9.2dev
|
7
|
+
Also compatible with: 1.9.1 and 1.8.7
|
8
|
+
|
9
|
+
Not tested with versions under 1.8.7. Should you use this lib with other ruby versions, please provide feedback.
|
9
10
|
|
10
11
|
==Install
|
11
12
|
gem install swf_file
|
12
13
|
|
13
14
|
==LICENSE
|
14
|
-
|
15
|
+
Please refer to the LICENSE file.
|
15
16
|
|
16
17
|
==Example
|
17
|
-
|
18
|
+
header = SwfFile::FlashFile.header 'clicktag.swf' # load the file
|
18
19
|
|
19
20
|
# Access the various header options. Please check the unit tests for more usage examples.
|
20
|
-
puts
|
21
|
-
puts
|
22
|
-
puts
|
23
|
-
puts
|
24
|
-
puts
|
25
|
-
puts
|
26
|
-
puts
|
27
|
-
puts
|
28
|
-
puts
|
29
|
-
puts
|
30
|
-
puts
|
31
|
-
puts
|
32
|
-
puts
|
21
|
+
puts header.size
|
22
|
+
puts header.compressed?
|
23
|
+
puts header.version
|
24
|
+
puts header.bit_count
|
25
|
+
puts header.xmax
|
26
|
+
puts header.ymax
|
27
|
+
puts header.width # In pixels
|
28
|
+
puts header.height # In pixels
|
29
|
+
puts header.frame_rate
|
30
|
+
puts header.frame_count
|
31
|
+
puts header.duration # In milliseconds
|
32
|
+
puts header.avm_version
|
33
|
+
puts header.signature
|
34
|
+
|
35
|
+
# You can also pass a block to SwfFile::FlashFile.header
|
36
|
+
puts SwfFile::FlashFile.header 'clicktag.swf' { |h| puts h.duration }
|
37
|
+
|
38
|
+
# It's also possible to create instances of SwfFile::FlashFile
|
39
|
+
swf = SwfFile::FlashFile.new 'clicktag.swf'
|
40
|
+
swf.header # => SwfHeader class instance equivalent to the return of SwfFile::FlashFile.header(<file>)
|
41
|
+
swf.header.duration
|
42
|
+
|
43
|
+
# Instances of SwfFile::FlashFile also receive blocks
|
44
|
+
swf.header { |h| h.duration }
|
45
|
+
|
46
|
+
# SwfFile::FlashFile instance helper method
|
47
|
+
swf.compressed? # => Helper method. Effectively it's an alias to same as SwfHeader#compressed?
|
33
48
|
|
34
49
|
|
35
50
|
==Issues, improvements, feedback an suggestions
|
36
|
-
|
51
|
+
To report issues, please use GitHub's issue manager (http://github.com/DBA/swf_file/issues). Meanwhile, feel free to fork the project and submit your modifications.
|
37
52
|
|
38
|
-
|
53
|
+
Should you wish to contact me directly, please use GitHub's message box or the email available at the Rakefile.
|
39
54
|
|
40
55
|
==Pending
|
41
|
-
|
42
|
-
* Docs
|
43
|
-
* Modularize SwfHeader a bit more
|
56
|
+
* Docs
|
data/lib/swf_file/assertions.rb
CHANGED
@@ -1,10 +1,16 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
def swf?
|
8
|
-
@buffer[0,3] == 'FWS' || @buffer[0,3] == 'CWS'
|
1
|
+
module SwfFile
|
2
|
+
|
3
|
+
module Assertions
|
4
|
+
|
5
|
+
def compressed?(memoize_result = true)
|
6
|
+
buffer_compressed?(memoize_result)
|
9
7
|
end
|
10
|
-
|
8
|
+
|
9
|
+
private
|
10
|
+
def swf?
|
11
|
+
@buffer[0,3] == 'FWS' || @buffer[0,3] == 'CWS'
|
12
|
+
end
|
13
|
+
|
14
|
+
end # Assertions
|
15
|
+
|
16
|
+
end # SwfFile
|
data/lib/swf_file/compression.rb
CHANGED
@@ -1,25 +1,31 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
module SwfFile
|
2
|
+
|
3
|
+
module Compression
|
4
|
+
|
5
|
+
private
|
6
|
+
def buffer_compressed?(memoize_result = true)
|
7
|
+
if memoize_result
|
8
|
+
@compressed ||= @buffer[0].ord == ?C.ord
|
9
|
+
else
|
10
|
+
@compressed = @buffer[0].ord == ?C.ord
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def decompress_buffer!
|
15
|
+
return @buffer unless buffer_compressed?(false)
|
16
|
+
|
17
|
+
_buffer = @buffer # local buffer copy
|
18
|
+
_buffer = Zlib::Inflate.new.inflate strip_buffer_header(_buffer)
|
19
|
+
_buffer = _buffer[0,8] + _buffer
|
20
|
+
_buffer[0] = ?F
|
21
|
+
|
22
|
+
@buffer = _buffer
|
23
|
+
end
|
24
|
+
|
25
|
+
def strip_buffer_header(buffer)
|
26
|
+
buffer[8, buffer.size - 8]
|
8
27
|
end
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
_buffer = @buffer # local buffer copy
|
15
|
-
_buffer = Zlib::Inflate.new.inflate strip_buffer_header(_buffer)
|
16
|
-
_buffer = _buffer[0,8] + _buffer
|
17
|
-
_buffer[0] = ?F
|
18
|
-
|
19
|
-
@buffer = _buffer
|
20
|
-
end
|
21
|
-
|
22
|
-
def strip_buffer_header(buffer)
|
23
|
-
buffer[8, buffer.size - 8]
|
24
|
-
end
|
25
|
-
end
|
28
|
+
|
29
|
+
end # Compression
|
30
|
+
|
31
|
+
end # SwfFile
|
data/lib/swf_file/conversions.rb
CHANGED
@@ -1,32 +1,38 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
{ :file => @file,
|
8
|
-
:signature => @signature,
|
9
|
-
:version => @version,
|
10
|
-
:avm_version => @avm_version,
|
11
|
-
:size => @size,
|
12
|
-
:bit_count => @bit_count,
|
13
|
-
:xmax => @xmax,
|
14
|
-
:ymax => @ymax,
|
15
|
-
:width => @width,
|
16
|
-
:height => @height,
|
17
|
-
:frame_rate => @frame_rate,
|
18
|
-
:frame_count => @frame_count }
|
19
|
-
end
|
20
|
-
|
21
|
-
module Twips
|
22
|
-
def self.from_pixels(pixels)
|
23
|
-
pixels * 20
|
1
|
+
module SwfFile
|
2
|
+
|
3
|
+
module Conversions
|
4
|
+
|
5
|
+
def to_s
|
6
|
+
"#{@file} #{@width}x#{@height} #{@frame_rate}fps"
|
24
7
|
end
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
8
|
+
|
9
|
+
def to_hash
|
10
|
+
{ :file => @file,
|
11
|
+
:signature => @signature,
|
12
|
+
:version => @version,
|
13
|
+
:avm_version => @avm_version,
|
14
|
+
:size => @size,
|
15
|
+
:bit_count => @bit_count,
|
16
|
+
:xmax => @xmax,
|
17
|
+
:ymax => @ymax,
|
18
|
+
:width => @width,
|
19
|
+
:height => @height,
|
20
|
+
:frame_rate => @frame_rate,
|
21
|
+
:frame_count => @frame_count }
|
30
22
|
end
|
31
|
-
|
32
|
-
|
23
|
+
|
24
|
+
module Twips
|
25
|
+
def self.from_pixels(pixels)
|
26
|
+
pixels * 20
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
module Pixels
|
31
|
+
def self.from_twips(twips)
|
32
|
+
twips / 20
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end # Conversions
|
37
|
+
|
38
|
+
end # SwfFile
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module SwfFile
|
2
|
+
|
3
|
+
class FlashFile
|
4
|
+
# Class methods
|
5
|
+
def self.header(swf_path)
|
6
|
+
raise RuntimeError, "SWF file not found.", caller unless File.exists?(swf_path)
|
7
|
+
|
8
|
+
header = SwfHeader.new(swf_path)
|
9
|
+
yield(header) if block_given?
|
10
|
+
header
|
11
|
+
end
|
12
|
+
|
13
|
+
# Instance methods
|
14
|
+
def initialize(swf_path)
|
15
|
+
raise RuntimeError, "SWF file not found.", caller unless File.exists?(swf_path)
|
16
|
+
|
17
|
+
@header = SwfHeader.new(swf_path)
|
18
|
+
end
|
19
|
+
|
20
|
+
def header
|
21
|
+
yield(@header) if block_given?
|
22
|
+
@header
|
23
|
+
end
|
24
|
+
|
25
|
+
def compressed?
|
26
|
+
@header.compressed?
|
27
|
+
end
|
28
|
+
end # FlashFile
|
29
|
+
|
30
|
+
end # SwfFile
|
@@ -1,47 +1,51 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
def self.from_packed_bits(bytes, byte_marker, bit_marker, length)
|
21
|
-
counter = total = 0
|
22
|
-
shift = 7 - bit_marker
|
23
|
-
bit_index = bit_marker
|
24
|
-
byte_index = byte_marker
|
25
|
-
|
26
|
-
while counter < length
|
27
|
-
(bit_marker...8).each do |i|
|
28
|
-
bit = ((bytes[byte_marker].ord & 0xff ) >> shift) & 1
|
29
|
-
total = (total << 1) + bit
|
30
|
-
bit_index = i
|
31
|
-
shift -= 1
|
32
|
-
counter += 1
|
33
|
-
|
34
|
-
break if counter == length
|
1
|
+
module SwfFile
|
2
|
+
|
3
|
+
class PackedBitObject
|
4
|
+
attr_accessor :bitIndex, :byteIndex, :value, :nextBitIndex, :nextByteIndex, :nextByteBoundary
|
5
|
+
|
6
|
+
def initialize(bitMarker, byteMarker, decimalValue)
|
7
|
+
@nextBitIndex = @bitIndex = bitMarker
|
8
|
+
@byteIndex = byteMarker
|
9
|
+
@value = decimalValue
|
10
|
+
|
11
|
+
if bitMarker <= 7
|
12
|
+
@nextBitIndex += 1
|
13
|
+
@nextByteIndex = byteMarker
|
14
|
+
@nextByteBoundary = byteMarker += 1
|
15
|
+
else
|
16
|
+
@nextBitIndex = 0
|
17
|
+
@nextByteIndex +=1
|
18
|
+
@nextByteBoundary = @nextByteIndex;
|
35
19
|
end
|
20
|
+
end
|
36
21
|
|
22
|
+
def self.from_packed_bits(bytes, byte_marker, bit_marker, length)
|
23
|
+
counter = total = 0
|
24
|
+
shift = 7 - bit_marker
|
25
|
+
bit_index = bit_marker
|
37
26
|
byte_index = byte_marker
|
38
|
-
|
39
|
-
|
40
|
-
|
27
|
+
|
28
|
+
while counter < length
|
29
|
+
(bit_marker...8).each do |i|
|
30
|
+
bit = ((bytes[byte_marker].ord & 0xff ) >> shift) & 1
|
31
|
+
total = (total << 1) + bit
|
32
|
+
bit_index = i
|
33
|
+
shift -= 1
|
34
|
+
counter += 1
|
35
|
+
|
36
|
+
break if counter == length
|
37
|
+
end
|
38
|
+
|
39
|
+
byte_index = byte_marker
|
40
|
+
byte_marker +=1
|
41
|
+
bit_marker = 0
|
42
|
+
shift = 7
|
43
|
+
end
|
44
|
+
|
45
|
+
pbo = PackedBitObject.new(bit_index, byte_index, total)
|
46
|
+
yield pbo if block_given?
|
47
|
+
pbo
|
41
48
|
end
|
49
|
+
end # PackedBitObject
|
42
50
|
|
43
|
-
|
44
|
-
yield pbo if block_given?
|
45
|
-
pbo
|
46
|
-
end
|
47
|
-
end
|
51
|
+
end # SwfFile
|
data/lib/swf_file/parser.rb
CHANGED
@@ -1,48 +1,54 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
PackedBitObject.from_packed_bits(@buffer,
|
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
|
-
|
47
|
-
|
48
|
-
end
|
1
|
+
module SwfFile
|
2
|
+
|
3
|
+
module Parser
|
4
|
+
|
5
|
+
private
|
6
|
+
def parse_header
|
7
|
+
@buffer, @size = get_swf_buffer_and_size
|
8
|
+
raise RuntimeError, "The provided file does not appear to be an SWF", caller unless swf?
|
9
|
+
|
10
|
+
@signature = @buffer[0,3]
|
11
|
+
@version = @buffer[3].ord
|
12
|
+
|
13
|
+
decompress_buffer! if compressed?
|
14
|
+
|
15
|
+
@bit_count = ((@buffer[8].ord & 0xff) >> 3)
|
16
|
+
end # parse_header
|
17
|
+
|
18
|
+
def parse_packed_bits
|
19
|
+
PackedBitObject.from_packed_bits(@buffer, 8, 5, @bit_count) do |pbo|
|
20
|
+
|
21
|
+
PackedBitObject.from_packed_bits(@buffer, pbo.nextByteIndex, pbo.nextBitIndex, @bit_count) do |pbo2|
|
22
|
+
@xmax = pbo2.value
|
23
|
+
|
24
|
+
PackedBitObject.from_packed_bits(@buffer, pbo2.nextByteIndex, pbo2.nextBitIndex, @bit_count) do |pbo3|
|
25
|
+
|
26
|
+
PackedBitObject.from_packed_bits(@buffer, pbo3.nextByteIndex, pbo3.nextBitIndex, @bit_count) do |pbo4|
|
27
|
+
@ymax = pbo4.value
|
28
|
+
@width = Conversions::Pixels.from_twips @xmax
|
29
|
+
@height = Conversions::Pixels.from_twips @ymax
|
30
|
+
|
31
|
+
byte_pointer = pbo4.nextByteIndex + 2
|
32
|
+
|
33
|
+
@frame_rate = @buffer[byte_pointer].ord
|
34
|
+
byte_pointer += 1
|
35
|
+
|
36
|
+
fc1 = @buffer[byte_pointer].ord & 0xFF
|
37
|
+
byte_pointer += 1
|
38
|
+
|
39
|
+
fc2 = @buffer[byte_pointer].ord & 0xFF
|
40
|
+
byte_pointer += 1
|
41
|
+
|
42
|
+
@frame_count = (fc2 << 8) + fc1
|
43
|
+
byte_pointer+=2
|
44
|
+
|
45
|
+
@avm_version = ((@buffer[byte_pointer].ord & 0x08) == 0) ? "AVM1" : "AVM2"
|
46
|
+
end #pbo4
|
47
|
+
end #pbo3
|
48
|
+
end #pbo2
|
49
|
+
end #pbo
|
50
|
+
end # parse_packed_bits
|
51
|
+
|
52
|
+
end # Parser
|
53
|
+
|
54
|
+
end # SwfFile
|
data/lib/swf_file/swf_header.rb
CHANGED
@@ -1,40 +1,44 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
# Returns the duration in milliseconds
|
18
|
-
# The formula used in this method used to be +((@frame_count / @frame_rate.to_f).round(5) * 1000).round+.
|
19
|
-
# This however, was not compatible with ruby 1.8, thus reverted to its current form.
|
20
|
-
def duration
|
21
|
-
((@frame_count / @frame_rate.to_f * 10**5).round.to_f / 10**5 * 1000).round
|
22
|
-
end
|
23
|
-
|
24
|
-
alias :inspect :to_hash
|
25
|
-
|
26
|
-
private
|
27
|
-
def get_swf_buffer_and_size
|
28
|
-
size = 0
|
29
|
-
|
30
|
-
buffer = File.open(@file,"rb") do |file|
|
31
|
-
file.seek(4, IO::SEEK_CUR)
|
32
|
-
size = file.read(4).unpack("L")[0]
|
33
|
-
|
34
|
-
file.rewind
|
35
|
-
file.read
|
36
|
-
end
|
37
|
-
|
38
|
-
[buffer, size]
|
1
|
+
module SwfFile
|
2
|
+
|
3
|
+
class SwfHeader
|
4
|
+
include Parser
|
5
|
+
include Compression
|
6
|
+
include Conversions
|
7
|
+
include Assertions
|
8
|
+
|
9
|
+
attr_reader :file, :signature, :version, :avm_version, :size, :bit_count,
|
10
|
+
:xmax, :ymax, :width, :height,
|
11
|
+
:frame_rate, :frame_count
|
12
|
+
|
13
|
+
def initialize(swf_file)
|
14
|
+
@file = swf_file
|
15
|
+
parse_header
|
16
|
+
parse_packed_bits
|
39
17
|
end
|
40
|
-
|
18
|
+
|
19
|
+
# Returns the duration in milliseconds
|
20
|
+
# The formula used in this method used to be +((@frame_count / @frame_rate.to_f).round(5) * 1000).round+.
|
21
|
+
# This however, was not compatible with ruby 1.8, thus reverted to its current form.
|
22
|
+
def duration
|
23
|
+
((@frame_count / @frame_rate.to_f * 10**5).round.to_f / 10**5 * 1000).round
|
24
|
+
end
|
25
|
+
|
26
|
+
alias :inspect :to_hash
|
27
|
+
|
28
|
+
private
|
29
|
+
def get_swf_buffer_and_size
|
30
|
+
size = 0
|
31
|
+
|
32
|
+
buffer = File.open(@file,"rb") do |file|
|
33
|
+
file.seek(4, IO::SEEK_CUR)
|
34
|
+
size = file.read(4).unpack("L")[0]
|
35
|
+
|
36
|
+
file.rewind
|
37
|
+
file.read
|
38
|
+
end
|
39
|
+
|
40
|
+
[buffer, size]
|
41
|
+
end
|
42
|
+
end # SwfHeader
|
43
|
+
|
44
|
+
end # SwfFile
|
data/lib/swf_file.rb
CHANGED
@@ -1,36 +1,16 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), 'swf_file') unless $:.include? File.join(File.dirname(__FILE__),
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), 'swf_file') unless $:.include? File.join(File.dirname(__FILE__),
|
2
|
+
'swf_file')
|
2
3
|
|
3
4
|
require 'zlib'
|
4
|
-
require 'parser'
|
5
|
-
require 'compression'
|
6
|
-
require 'conversions'
|
7
|
-
require 'assertions'
|
8
|
-
require 'packed_bit_object'
|
9
|
-
require 'swf_header'
|
10
5
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
def initialize(swf_path)
|
23
|
-
raise RuntimeError, "SWF file not found.", caller unless File.exists?(swf_path)
|
24
|
-
|
25
|
-
@header = SwfHeader.new(swf_path)
|
26
|
-
end
|
27
|
-
|
28
|
-
def header
|
29
|
-
yield(@header) if block_given?
|
30
|
-
@header
|
31
|
-
end
|
32
|
-
|
33
|
-
def compressed?
|
34
|
-
@header.compressed?
|
35
|
-
end
|
36
|
-
end
|
6
|
+
module SwfFile
|
7
|
+
|
8
|
+
autoload :FlashFile, 'lib/swf_file/flash_file'
|
9
|
+
autoload :Parser, 'lib/swf_file/parser'
|
10
|
+
autoload :Compression, 'lib/swf_file/compression'
|
11
|
+
autoload :Conversions, 'lib/swf_file/conversions'
|
12
|
+
autoload :Assertions, 'lib/swf_file/assertions'
|
13
|
+
autoload :PackedBitObject, 'lib/swf_file/packed_bit_object'
|
14
|
+
autoload :SwfHeader, 'lib/swf_file/swf_header'
|
15
|
+
|
16
|
+
end # SwfFile
|
metadata
CHANGED
@@ -1,25 +1,39 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swf_file
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
4
|
+
prerelease: true
|
5
5
|
segments:
|
6
6
|
- 1
|
7
|
+
- 1
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
version: 1.0.
|
9
|
+
- rc
|
10
|
+
version: 1.1.0.rc
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
|
-
-
|
13
|
+
- Diogo Almeida
|
13
14
|
autorequire:
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-08-27 00:00:00 +01:00
|
18
19
|
default_executable:
|
19
|
-
dependencies:
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: shoulda
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
type: :development
|
33
|
+
version_requirements: *id001
|
34
|
+
description: Based on the swfutil lib, by Dennis Zhuang, the SWF File is lightweight gem to read swf file headers from within a Ruby application. This gem is fully written in Ruby and is compatible with Ruby v1.8.7 through v1.9.2.
|
35
|
+
email:
|
36
|
+
- dba@gnomeslab.com
|
23
37
|
executables: []
|
24
38
|
|
25
39
|
extensions: []
|
@@ -28,31 +42,23 @@ extra_rdoc_files:
|
|
28
42
|
- LICENSE
|
29
43
|
- README.rdoc
|
30
44
|
files:
|
31
|
-
- .gitignore
|
32
|
-
- LICENSE
|
33
|
-
- README.rdoc
|
34
|
-
- Rakefile
|
35
|
-
- VERSION
|
36
|
-
- fixtures/clicktag-decompressed.swf
|
37
|
-
- fixtures/clicktag.swf
|
38
|
-
- fixtures/smallgoat.jpg
|
39
|
-
- lib/swf_file.rb
|
40
45
|
- lib/swf_file/assertions.rb
|
41
46
|
- lib/swf_file/compression.rb
|
42
47
|
- lib/swf_file/conversions.rb
|
48
|
+
- lib/swf_file/flash_file.rb
|
43
49
|
- lib/swf_file/packed_bit_object.rb
|
44
50
|
- lib/swf_file/parser.rb
|
45
51
|
- lib/swf_file/swf_header.rb
|
46
|
-
- swf_file.
|
47
|
-
-
|
48
|
-
-
|
52
|
+
- lib/swf_file.rb
|
53
|
+
- LICENSE
|
54
|
+
- README.rdoc
|
49
55
|
has_rdoc: true
|
50
|
-
homepage: http://github.com/DBA/swf_file
|
56
|
+
homepage: http://github.com/DBA/swf_file/
|
51
57
|
licenses: []
|
52
58
|
|
53
59
|
post_install_message:
|
54
|
-
rdoc_options:
|
55
|
-
|
60
|
+
rdoc_options: []
|
61
|
+
|
56
62
|
require_paths:
|
57
63
|
- lib
|
58
64
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -69,15 +75,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
75
|
- - ">="
|
70
76
|
- !ruby/object:Gem::Version
|
71
77
|
segments:
|
72
|
-
-
|
73
|
-
|
78
|
+
- 1
|
79
|
+
- 3
|
80
|
+
- 7
|
81
|
+
version: 1.3.7
|
74
82
|
requirements: []
|
75
83
|
|
76
84
|
rubyforge_project:
|
77
85
|
rubygems_version: 1.3.7
|
78
86
|
signing_key:
|
79
87
|
specification_version: 3
|
80
|
-
summary: SWF File is lightweight gem to read swf file headers from within a Ruby application
|
81
|
-
test_files:
|
82
|
-
|
83
|
-
- test/unit/swf_file_test.rb
|
88
|
+
summary: SWF File is lightweight gem to read swf file headers from within a Ruby application.
|
89
|
+
test_files: []
|
90
|
+
|
data/.gitignore
DELETED
data/Rakefile
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'jeweler'
|
5
|
-
Jeweler::Tasks.new do |gemspec|
|
6
|
-
gemspec.name = "swf_file"
|
7
|
-
gemspec.summary = "SWF File is lightweight gem to read swf file headers from within a Ruby application"
|
8
|
-
gemspec.description = "Based on the swfutil lib, by Dennis Zhuang, the SWF File is lightweight gem to read swf file headers from within a Ruby application. This gem is fully written in Ruby and is compatible with Ruby v1.9.x"
|
9
|
-
gemspec.email = "dba@gnomeslab.com"
|
10
|
-
gemspec.homepage = "http://github.com/DBA/swf_file"
|
11
|
-
gemspec.authors = ["DBA"]
|
12
|
-
|
13
|
-
# dependencies defined in Gemfile
|
14
|
-
end
|
15
|
-
rescue LoadError
|
16
|
-
puts "Jeweler not available. Install it with: gem install jeweler"
|
17
|
-
end
|
18
|
-
|
19
|
-
require 'rake/testtask'
|
20
|
-
#test_files_pattern = 'test/{unit,functional,other,matchers}/**/*_test.rb'
|
21
|
-
test_files_pattern = 'test/unit/swf_file_test.rb'
|
22
|
-
Rake::TestTask.new do |t|
|
23
|
-
t.libs << 'lib'
|
24
|
-
t.pattern = test_files_pattern
|
25
|
-
t.verbose = true
|
26
|
-
end
|
27
|
-
|
28
|
-
task :default => :test
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.0.0
|
Binary file
|
data/fixtures/clicktag.swf
DELETED
Binary file
|
data/fixtures/smallgoat.jpg
DELETED
Binary file
|
data/swf_file.gemspec
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{swf_file}
|
8
|
-
s.version = "1.0.0"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["DBA"]
|
12
|
-
s.date = %q{2010-05-08}
|
13
|
-
s.description = %q{Based on the swfutil lib, by Dennis Zhuang, the SWF File is lightweight gem to read swf file headers from within a Ruby application. This gem is fully written in Ruby and is compatible with Ruby v1.9.x}
|
14
|
-
s.email = %q{dba@gnomeslab.com}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.rdoc"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".gitignore",
|
21
|
-
"LICENSE",
|
22
|
-
"README.rdoc",
|
23
|
-
"Rakefile",
|
24
|
-
"VERSION",
|
25
|
-
"fixtures/clicktag-decompressed.swf",
|
26
|
-
"fixtures/clicktag.swf",
|
27
|
-
"fixtures/smallgoat.jpg",
|
28
|
-
"lib/swf_file.rb",
|
29
|
-
"lib/swf_file/assertions.rb",
|
30
|
-
"lib/swf_file/compression.rb",
|
31
|
-
"lib/swf_file/conversions.rb",
|
32
|
-
"lib/swf_file/packed_bit_object.rb",
|
33
|
-
"lib/swf_file/parser.rb",
|
34
|
-
"lib/swf_file/swf_header.rb",
|
35
|
-
"swf_file.gemspec",
|
36
|
-
"test/test_helper.rb",
|
37
|
-
"test/unit/swf_file_test.rb"
|
38
|
-
]
|
39
|
-
s.homepage = %q{http://github.com/DBA/swf_file}
|
40
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
41
|
-
s.require_paths = ["lib"]
|
42
|
-
s.rubygems_version = %q{1.3.7}
|
43
|
-
s.summary = %q{SWF File is lightweight gem to read swf file headers from within a Ruby application}
|
44
|
-
s.test_files = [
|
45
|
-
"test/test_helper.rb",
|
46
|
-
"test/unit/swf_file_test.rb"
|
47
|
-
]
|
48
|
-
|
49
|
-
if s.respond_to? :specification_version then
|
50
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
51
|
-
s.specification_version = 3
|
52
|
-
|
53
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
54
|
-
else
|
55
|
-
end
|
56
|
-
else
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
data/test/test_helper.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
-
|
3
|
-
require 'rubygems' if RUBY_VERSION =~ /1\.8.+/
|
4
|
-
require 'test/unit'
|
5
|
-
require 'shoulda'
|
6
|
-
require 'ruby-debug'
|
7
|
-
require 'swf_file'
|
8
|
-
|
9
|
-
def fixture_path(filename)
|
10
|
-
File.join(File.dirname(__FILE__), '..', 'fixtures', filename)
|
11
|
-
end
|
data/test/unit/swf_file_test.rb
DELETED
@@ -1,108 +0,0 @@
|
|
1
|
-
$:.unshift(File.join(File.dirname(__FILE__), '../', '../', 'test'))
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class SwfFileTest < Test::Unit::TestCase
|
6
|
-
|
7
|
-
context "SwfFile" do
|
8
|
-
context "instance methods" do
|
9
|
-
should "not be initializable without an SWF file path" do
|
10
|
-
assert_raise(ArgumentError) { SwfFile.new }
|
11
|
-
end
|
12
|
-
|
13
|
-
should "raise an error if an invalid path is provided" do
|
14
|
-
assert_raise(RuntimeError) { SwfFile.new "/path_to_imaginary_file" }
|
15
|
-
end
|
16
|
-
|
17
|
-
should "return a header with the regular properties" do
|
18
|
-
swf = SwfFile.new fixture_path('clicktag.swf')
|
19
|
-
assert_equal SwfHeader, swf.header.class
|
20
|
-
assert_equal 4156, swf.header.size
|
21
|
-
assert_equal swf.compressed?, swf.header.compressed?
|
22
|
-
end
|
23
|
-
end # instance methods
|
24
|
-
|
25
|
-
context "class method header" do
|
26
|
-
should "raise an error when not provided with an SWF" do
|
27
|
-
assert_raise(RuntimeError) { SwfFile.header fixture_path('smallgoat.jpg') }
|
28
|
-
end
|
29
|
-
|
30
|
-
setup do
|
31
|
-
@header = SwfFile.header fixture_path('clicktag.swf')
|
32
|
-
end
|
33
|
-
|
34
|
-
should "return an instance of SwfHeader" do
|
35
|
-
assert_equal SwfHeader, @header.class
|
36
|
-
end
|
37
|
-
|
38
|
-
should "indicate the file's size" do
|
39
|
-
assert_equal 4156, @header.size
|
40
|
-
end
|
41
|
-
|
42
|
-
should "state if the swf was originally compressed" do
|
43
|
-
assert @header.compressed?
|
44
|
-
assert !SwfFile.header(fixture_path('clicktag-decompressed.swf')).compressed?
|
45
|
-
end
|
46
|
-
|
47
|
-
should "not make available private compression module methods" do
|
48
|
-
%w{ :buffer_compressed? :strip_buffer_header :decompress_buffer! }.each do |method|
|
49
|
-
assert !@header.respond_to?(method)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
should "state if its buffer is currently compressed" do
|
54
|
-
assert @header.compressed?
|
55
|
-
assert !@header.compressed?(false)
|
56
|
-
end
|
57
|
-
|
58
|
-
should "have the version" do
|
59
|
-
assert_equal 8, @header.version
|
60
|
-
end
|
61
|
-
|
62
|
-
should "have the bit count" do
|
63
|
-
assert_equal 15, @header.bit_count
|
64
|
-
end
|
65
|
-
|
66
|
-
should "have the xmax and ymax values" do
|
67
|
-
assert_equal 9360, @header.xmax
|
68
|
-
assert_equal 1200, @header.ymax
|
69
|
-
end
|
70
|
-
|
71
|
-
should "have the width and height values" do
|
72
|
-
assert_equal 468, @header.width
|
73
|
-
assert_equal 60, @header.height
|
74
|
-
end
|
75
|
-
|
76
|
-
should "have the frame rate and frame count" do
|
77
|
-
assert_equal 24, @header.frame_rate
|
78
|
-
assert_equal 1, @header.frame_count
|
79
|
-
end
|
80
|
-
|
81
|
-
should "include the duration of the swf file" do
|
82
|
-
assert_equal 42, @header.duration
|
83
|
-
end
|
84
|
-
|
85
|
-
should "contain the avm version" do
|
86
|
-
assert_equal 'AVM1', @header.avm_version
|
87
|
-
end
|
88
|
-
|
89
|
-
should "include the swf signature" do
|
90
|
-
assert_equal 'CWS', @header.signature
|
91
|
-
end
|
92
|
-
|
93
|
-
should "output basing information when to_s is invoked" do
|
94
|
-
assert @header.to_s =~ /.+clicktag.swf\s\d+x\d+\s\d\dfps/
|
95
|
-
end
|
96
|
-
|
97
|
-
should "be have a hash converter" do
|
98
|
-
assert_equal Hash, @header.to_hash.class
|
99
|
-
end
|
100
|
-
|
101
|
-
should "have the same output for the instance methods inspect and to_hash" do
|
102
|
-
assert_equal @header.to_hash, @header.inspect
|
103
|
-
end
|
104
|
-
|
105
|
-
end # SWF operations context
|
106
|
-
|
107
|
-
end # SwfFile context
|
108
|
-
end # SwfFileTest
|