cwyckoff-babel_icious 0.0.4 → 0.0.4.1

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.
@@ -3,11 +3,10 @@ class TargetMapperError < Exception; end
3
3
  module Babelicious
4
4
 
5
5
  class TargetMapper
6
- attr_reader :mappings, :direction, :target
6
+ attr_reader :mappings, :direction
7
7
 
8
8
  def initialize
9
9
  @mappings = []
10
- @target = nil
11
10
  end
12
11
 
13
12
  def direction=(dir)
@@ -18,26 +17,27 @@ module Babelicious
18
17
  end
19
18
 
20
19
  def translate(source)
20
+ target = nil
21
21
  @mappings.each do |source_element, target_element|
22
+ target = target_element.class.initial_target if target.nil?
22
23
  filtered_source = source_element.class.filter_source(source) if filtered_source.nil?
23
24
 
24
25
  source_value = source_element.value_from(filtered_source)
25
- target_element.map_from(@target, source_value)
26
+ target_element.map_from(target, source_value)
26
27
  end
27
- @target
28
+ target
28
29
  end
29
30
 
30
31
  def register_mapping(opts={})
31
32
  raise TargetMapperError, "Both :from and :to keys must be set (e.g., {:from => \"foo/bar\", :to => \"bar/foo\")" unless (opts[:from] && opts[:to])
32
33
  target = MapFactory.target(@direction, opts)
33
34
  source = MapFactory.source(@direction, opts)
34
- @target = target.class.initial_target if @target.nil?
35
35
 
36
36
  @mappings << [source, target]
37
37
  end
38
38
 
39
39
  def reset
40
- @mappings, @direction, @target = [], nil, nil
40
+ @mappings, @direction = [], nil
41
41
  end
42
42
 
43
43
  end
@@ -85,7 +85,7 @@ module Babelicious
85
85
  if(node.children.size > 1)
86
86
  content = {}
87
87
  return map_with_strategies_for_children(node, content)
88
- else
88
+ else
89
89
  return node.content
90
90
  end
91
91
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cwyckoff-babel_icious
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Wyckoff