tickly 2.1.4 → 2.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 178bbaee09a8714a619462a767a15dc86284e039
4
- data.tar.gz: 8d5d22b037fb58ad14593b246579a74d3b725d63
3
+ metadata.gz: dab8e9284b9ac1080b3870bc306b07eff3a27822
4
+ data.tar.gz: f908bafd3590bdcc34a0fa3a53f7830295cee2cb
5
5
  SHA512:
6
- metadata.gz: 4c81568f20334cbdfd0265130f15d0420d46d6633fef1baf1c5cdd869bcb492666ce6058da2919e3a5e75600b378c4003002d6c24f070d79914412e36d25b374
7
- data.tar.gz: cc2bc355e7c6bac3cb25d93616ccc8c5d9e84643213f1c4368c52c77b3a089799988a0d532cc5451bfa545d6a0d8254a238a4d7060800976e3ac920a41ea387f
6
+ metadata.gz: f47268cfe9c25315ee58f64c9ebad472db545786df1c63ba6929ad123b6d2a71de90073adc639267598f960ba595c40601cf4891e62f94a71d4da0f57567b553
7
+ data.tar.gz: 699f16255741459e8e2e574c3230a2c432c6dc682a91fe4dcf759967e81268ac20254945004d57e77b4b80acbd4f4d019deeeed09d17e6c73362bf38c4bf7c50
data/Gemfile CHANGED
@@ -8,5 +8,6 @@ group :development do
8
8
  gem "rake"
9
9
  gem "rdoc", "~> 3.12"
10
10
  gem "jeweler", "~> 1.8.7"
11
- gem "ruby-prof"
11
+ # Use the older ruby-prof that still supports 1.8.7
12
+ gem "ruby-prof", '0.13.0'
12
13
  end
@@ -1,5 +1,3 @@
1
- = tickly
2
-
3
1
  A highly simplistic TCL parser and evaluator (primarily designed for parsing Nuke scripts).
4
2
  It transforms the passed Nuke scripts into a TCL AST.
5
3
  It also supports some cheap tricks to discard the nodes you are not interested in, since Nuke
@@ -7,7 +5,7 @@ scripts easily grow into tens of megabytes.
7
5
 
8
6
  The AST format is extremely simple (nested arrays).
9
7
 
10
- == Plain parsing
8
+ ## Plain parsing
11
9
 
12
10
  Create a Parser object and pass TCL expressions/scripts to it. You can pass IO obejcts or strings. Note that parse()
13
11
  will always return an Array of expressions, even if you only fed it one expression line. For example:
@@ -30,8 +28,9 @@ will always return an Array of expressions, even if you only fed it one expressi
30
28
  p.parse '{exec cmd [fileName]}' #=> [[:c, "exec", "cmd", [:b, "fileName"]]]
31
29
 
32
30
  The AST is represented by simple arrays. Each TCL expression becomes an array. An array starting
33
- with the :c symbol ("c" for "curlies") is a literal expression in curly braces ({}). An array with the
34
- :b symbol at the beginning is an expression with string interpolations (square brackets).
31
+ with the `:c` symbol ("c" for "curlies") is a literal expression in curly braces (`{}`).
32
+ An array with the `:b` symbol at the beginning is an expression with string interpolations
33
+ (square brackets).
35
34
  All the other array elements are guaranteed to be strings or innner expressions (arrays).
36
35
 
37
36
  String literals are expanded to string array elements.
@@ -40,10 +39,10 @@ String literals are expanded to string array elements.
40
39
 
41
40
  Multiple expressions separated by semicolons or newlines will be accumulated as multiple arrays.
42
41
 
43
- Lots and lots of TCL features are probably not supported - remember that most Nuke scripts are machine-generated and they do not
44
- use most of the esoteric language features.
42
+ Lots and lots of TCL features are probably not supported - remember that most Nuke scripts are
43
+ machine-generated and they do not use most of the esoteric language features.
45
44
 
46
- == Evaulating nodes in Nuke scripts
45
+ ## Evaulating nodes in Nuke scripts
47
46
 
48
47
  What you are likely to use Tickly for is parsing Nuke scripts. They got multiple node definitions, which
49
48
  are actially arguments for a node constructor written out in TCL. Consider this ubiquitous fragment for a
@@ -58,7 +57,7 @@ hypothetic SomeNode in your script:
58
57
  y_pos -10
59
58
  }
60
59
 
61
- and so on. You can use a +NodeProcessor+ to capture these node constructors right as they are being parsed.
60
+ and so on. You can use a `NodeProcessor` to capture these node constructors right as they are being parsed.
62
61
  The advantage of this workflow is that the processor will discard all the nodes you don't need, saving time
63
62
  and memory.
64
63
 
@@ -100,12 +99,12 @@ nodes containing tracking data:
100
99
  parser.add_node_handler_class(PlanarTracker1_0)
101
100
  parser.add_node_handler_class(Tracker4)
102
101
 
103
- == Animation curves
102
+ ## Animation curves
104
103
 
105
104
  You can parse Nuke's animation curves using Tickly::Curve. This will give you a way to iterate over every defined keyframe.
106
105
  This currently does not happen automatically for things passing through the parser.
107
106
 
108
- == Contributing to tickly
107
+ ## Contributing to tickly
109
108
 
110
109
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
111
110
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
@@ -115,7 +114,7 @@ This currently does not happen automatically for things passing through the pars
115
114
  * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
116
115
  * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
117
116
 
118
- == Copyright
117
+ ## Copyright
119
118
 
120
119
  Copyright (c) 2013 Julik Tarkhanov. See LICENSE.txt for
121
120
  further details.
@@ -4,5 +4,5 @@ require File.dirname(__FILE__) + "/tickly/curve"
4
4
  require File.dirname(__FILE__) + "/tickly/node_processor"
5
5
 
6
6
  module Tickly
7
- VERSION = '2.1.4'
7
+ VERSION = '2.1.5'
8
8
  end
@@ -22,10 +22,18 @@ module Tickly
22
22
  # Nuke7 sometimes produces curves where the command is a string literal
23
23
  # within quotes, and it contains a trailing space
24
24
  cmd = curve_expression[1].to_s.strip
25
- raise InvalidCurveError, "Curve expression should start with a 'curve' command" unless cmd == 'curve'
25
+ raise InvalidCurveError, "Curve expression should start with a 'curve' command" unless cmd =~ /^curve/
26
26
 
27
+ # Compute the curve increment or decrement. It looks like a modifier:
28
+ # "curve+5" means we have to add 5 to every value on the curve
29
+ xformer = lambda { |v| v} # Identity
30
+ if cmd =~ /^(curve)([+-])([\d\.]+)$/
31
+ operator = $2[0..1] # Ensure only one character gets through
32
+ modifier = $3.to_f
33
+ xformer = lambda{|v| v.send(operator, modifier) }
34
+ end
27
35
 
28
- expand_curve(curve_expression)
36
+ expand_curve(curve_expression, &xformer)
29
37
  end
30
38
 
31
39
  # Returns each defined keyframe as a pair of a frame number and a value
@@ -35,15 +43,17 @@ module Tickly
35
43
 
36
44
  private
37
45
 
38
- def expand_curve(curve_expression)
46
+ def expand_curve(curve_expression, &post_lambda)
39
47
  # Replace the closing curly brace with a curly brace with space so that it gets caught by split
40
48
  atoms = curve_expression[2..-1] # remove the :c curly designator and the "curve" keyword
41
49
 
42
50
  @tuples = []
43
- # Nuke saves curves very efficiently. x(keyframe_number) means that an uninterrupted sequence of values will start,
44
- # after which values follow. When the curve is interrupted in some way a new x(keyframe_number) will signifu that we
45
- # skip to that specified keyframe and the curve continues from there, in gap size defined by the last fragment.
46
- # That is, x1 1 x3 2 3 4 will place 2, 3 and 4 at 2-frame increments.
51
+ # Nuke saves curves very efficiently. x(keyframe_number) means that an
52
+ # uninterrupted sequence of values will start, after which values follow.
53
+ # When the curve is interrupted in some way a new x(keyframe_number) will
54
+ # signify that we skip to that specified keyframe and the curve continues
55
+ # from there, in gap size defined by the last fragment. That is,
56
+ # x1 1 x3 2 3 4 will place 2, 3 and 4 at 2-frame increments.
47
57
  # Thanks to Michael Lester for explaining this.
48
58
  last_processed_keyframe = 1
49
59
  intraframe_gap_size = 1
@@ -55,7 +65,7 @@ module Tickly
55
65
  intraframe_gap_size = last_processed_keyframe - last_captured_frame
56
66
  end
57
67
  elsif atom =~ KEYFRAME
58
- @tuples << [last_processed_keyframe, $1.to_f]
68
+ @tuples << [last_processed_keyframe, yield($1.to_f)]
59
69
  last_processed_keyframe += intraframe_gap_size
60
70
  end
61
71
  end
@@ -45,7 +45,7 @@ module Tickly
45
45
  ESC = 92.chr # Backslash (\)
46
46
  QUOTES = %w( " ' )
47
47
 
48
- # TODO: this has to go into Bychar. We should not use exprs for flow control.
48
+ # TODO: this has to go into Bychar. We should not use exceptions for flow control.
49
49
  class R #:nodoc: :all
50
50
  def initialize(bychar)
51
51
  @bychar = bychar
@@ -157,7 +157,7 @@ module Tickly
157
157
  c = io.read_one_char
158
158
  if c.nil?
159
159
  raise Error, "The IO ran out before the end of a literal string"
160
- elsif buf.length > 0 && last_char(buf) == ESC # If this char was escaped
160
+ elsif buf.length > 0 && buf[-1..-1] == ESC # If this char was escaped
161
161
  # Trim the escape character at the end of the buffer
162
162
  buf = buf[0..-2]
163
163
  buf << c
@@ -168,9 +168,5 @@ module Tickly
168
168
  end
169
169
  end
170
170
  end
171
-
172
- def last_char(str)
173
- RUBY_VERSION < '1.9' ? str[-1].chr : str[-1]
174
- end
175
171
  end
176
172
  end
@@ -15,6 +15,15 @@ x754 912.0731812 x755 913.7190552 916.0959473 918.1025391 920.0751953 922.189880
15
15
  assert_equal 754, result[7][0]
16
16
  end
17
17
 
18
+ def test_curve_plus
19
+ curve = [:c] + %w( curve+5 x1 987 x32 989.5999756 )
20
+
21
+ p = Tickly::Curve.new(curve)
22
+ result = p.to_a
23
+ assert_kind_of Array, result
24
+ assert_equal [[1, 992.0], [32, 994.5999756]], result
25
+ end
26
+
18
27
  def test_invalid_curves
19
28
  assert_raise Tickly::Curve::InvalidCurveError do
20
29
  Tickly::Curve.new([])
@@ -5,23 +5,23 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "tickly"
8
- s.version = "2.1.4"
8
+ s.version = "2.1.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Julik Tarkhanov"]
12
- s.date = "2013-12-06"
12
+ s.date = "2014-03-04"
13
13
  s.description = "Parses the subset of the TCL grammar needed for Nuke scripts"
14
14
  s.email = "me@julik.nl"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
- "README.rdoc"
17
+ "README.md"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
21
  ".travis.yml",
22
22
  "Gemfile",
23
23
  "LICENSE.txt",
24
- "README.rdoc",
24
+ "README.md",
25
25
  "Rakefile",
26
26
  "lib/tickly.rb",
27
27
  "lib/tickly/curve.rb",
@@ -63,20 +63,20 @@ Gem::Specification.new do |s|
63
63
  s.add_development_dependency(%q<rake>, [">= 0"])
64
64
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
65
65
  s.add_development_dependency(%q<jeweler>, ["~> 1.8.7"])
66
- s.add_development_dependency(%q<ruby-prof>, [">= 0"])
66
+ s.add_development_dependency(%q<ruby-prof>, ["= 0.13.0"])
67
67
  else
68
68
  s.add_dependency(%q<bychar>, ["~> 2"])
69
69
  s.add_dependency(%q<rake>, [">= 0"])
70
70
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
71
71
  s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
72
- s.add_dependency(%q<ruby-prof>, [">= 0"])
72
+ s.add_dependency(%q<ruby-prof>, ["= 0.13.0"])
73
73
  end
74
74
  else
75
75
  s.add_dependency(%q<bychar>, ["~> 2"])
76
76
  s.add_dependency(%q<rake>, [">= 0"])
77
77
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
78
78
  s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
79
- s.add_dependency(%q<ruby-prof>, [">= 0"])
79
+ s.add_dependency(%q<ruby-prof>, ["= 0.13.0"])
80
80
  end
81
81
  end
82
82
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tickly
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.4
4
+ version: 2.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julik Tarkhanov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-06 00:00:00.000000000 Z
11
+ date: 2014-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bychar
@@ -70,29 +70,29 @@ dependencies:
70
70
  name: ruby-prof
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: 0.13.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: 0.13.0
83
83
  description: Parses the subset of the TCL grammar needed for Nuke scripts
84
84
  email: me@julik.nl
85
85
  executables: []
86
86
  extensions: []
87
87
  extra_rdoc_files:
88
88
  - LICENSE.txt
89
- - README.rdoc
89
+ - README.md
90
90
  files:
91
91
  - .document
92
92
  - .travis.yml
93
93
  - Gemfile
94
94
  - LICENSE.txt
95
- - README.rdoc
95
+ - README.md
96
96
  - Rakefile
97
97
  - lib/tickly.rb
98
98
  - lib/tickly/curve.rb