flame_channel_parser 2.1.2 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +8 -0
- data/lib/flame_channel_parser.rb +2 -2
- data/lib/parser.rb +21 -3
- data/test/test_flame_channel_parser.rb +13 -0
- metadata +4 -4
data/History.txt
CHANGED
data/lib/flame_channel_parser.rb
CHANGED
data/lib/parser.rb
CHANGED
@@ -3,8 +3,14 @@ require "forwardable"
|
|
3
3
|
# Basic parser used for setups from versions up to 2011
|
4
4
|
module FlameChannelParser
|
5
5
|
class Parser
|
6
|
+
|
7
|
+
# Here you can assign a logger proc or a lambda that will be call'ed with progress reports
|
8
|
+
attr_accessor :logger_proc
|
9
|
+
|
6
10
|
# Parses the setup passed in the IO
|
7
11
|
def parse(io)
|
12
|
+
@do_logs = (@logger_proc.respond_to?(:call))
|
13
|
+
|
8
14
|
channels = []
|
9
15
|
node_name, node_type = nil, nil
|
10
16
|
|
@@ -15,13 +21,21 @@ module FlameChannelParser
|
|
15
21
|
elsif line =~ NODE_NAME_MATCHER
|
16
22
|
node_name = $1
|
17
23
|
elsif line =~ CHANNEL_MATCHER && channel_is_useful?($1)
|
18
|
-
|
24
|
+
log("Parsing channel #{$1.inspect}")
|
25
|
+
channel = parse_channel(io, $1, node_type, node_name)
|
26
|
+
channels << channel
|
19
27
|
end
|
20
28
|
end
|
21
29
|
|
22
30
|
channels
|
23
31
|
end
|
24
|
-
|
32
|
+
|
33
|
+
# This method will be called internally with information on items being processed.
|
34
|
+
# The implementation just calls the logger_proc instance variable
|
35
|
+
def log(message)
|
36
|
+
@logger_proc.call(message) if @do_logs
|
37
|
+
end
|
38
|
+
|
25
39
|
# Override this method to skip some channels, this will speedup
|
26
40
|
# your code alot
|
27
41
|
def channel_is_useful?(channel_name)
|
@@ -74,7 +88,11 @@ module FlameChannelParser
|
|
74
88
|
end
|
75
89
|
|
76
90
|
if line =~ KF_COUNT_MATCHER
|
77
|
-
$1.to_i
|
91
|
+
num_keyframes = $1.to_i
|
92
|
+
num_keyframes.times do | idx |
|
93
|
+
log("Extracting keyframe %d of %d" % [idx + 1, num_keyframes])
|
94
|
+
c.push(extract_key_from(io))
|
95
|
+
end
|
78
96
|
elsif line =~ BASE_VALUE_MATCHER# && empty?
|
79
97
|
c.base_value = $1.to_f
|
80
98
|
elsif line =~ EXTRAP_MATCHER
|
@@ -19,6 +19,19 @@ class TestFlameChannelParser < Test::Unit::TestCase
|
|
19
19
|
assert_equal 12, chans[0].length
|
20
20
|
end
|
21
21
|
|
22
|
+
def test_parsing_kronos_with_reports
|
23
|
+
logging_console = ""
|
24
|
+
data = File.open(File.dirname(__FILE__) + "/snaps/TW_TEST.F_Kronos")
|
25
|
+
parser = FlameChannelParser::Parser.new
|
26
|
+
parser.logger_proc = lambda do | log_message |
|
27
|
+
logging_console << log_message
|
28
|
+
end
|
29
|
+
|
30
|
+
parser.parse(data)
|
31
|
+
assert_match /Extracting keyframe 1 of 12/, logging_console
|
32
|
+
assert_no_match /Extracting keyframe 0 of 12/, logging_console, "Keyframe indices should not start at zero"
|
33
|
+
end
|
34
|
+
|
22
35
|
def test_parsing
|
23
36
|
data = File.open(File.dirname(__FILE__) + "/sample_channel.dat")
|
24
37
|
channels = FlameChannelParser.parse(data)
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: flame_channel_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 2.1
|
5
|
+
version: 2.2.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Julik Tarkhanov
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-07-31 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: update_hints
|
@@ -40,9 +40,9 @@ dependencies:
|
|
40
40
|
requirement: &id003 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 2.
|
45
|
+
version: "2.10"
|
46
46
|
type: :development
|
47
47
|
version_requirements: *id003
|
48
48
|
description: |-
|