cwyckoff-babel_icious 0.0.2 → 0.0.3
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/lib/babel_icious/hash_map.rb +12 -0
- data/lib/babel_icious/mapper.rb +1 -1
- data/lib/babel_icious/target_mapper.rb +6 -17
- data/lib/babel_icious/xml_map.rb +12 -0
- metadata +2 -2
data/lib/babel_icious/mapper.rb
CHANGED
@@ -16,10 +16,13 @@ module Babelicious
|
|
16
16
|
@direction = dir
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
20
|
-
target =
|
19
|
+
def translate(source)
|
20
|
+
target = nil
|
21
21
|
@mappings.each do |source_element, target_element|
|
22
|
-
|
22
|
+
target = target_element.class.initial_target if target.nil?
|
23
|
+
filtered_source = source_element.class.filter_source(source) if filtered_source.nil?
|
24
|
+
|
25
|
+
source_value = source_element.value_from(filtered_source)
|
23
26
|
target_element.map_from(target, source_value)
|
24
27
|
end
|
25
28
|
target
|
@@ -34,20 +37,6 @@ module Babelicious
|
|
34
37
|
def reset
|
35
38
|
@mappings, @direction = [], nil
|
36
39
|
end
|
37
|
-
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
def initial_target
|
42
|
-
raise TargetMapperError, "please set @direction (e.g., target_mapper.direction = {:from => :xml, :to => :hash}" unless @direction
|
43
|
-
|
44
|
-
case @direction[:to]
|
45
|
-
when :xml
|
46
|
-
XML::Document.new()
|
47
|
-
when :hash
|
48
|
-
{}
|
49
|
-
end
|
50
|
-
end
|
51
40
|
|
52
41
|
end
|
53
42
|
end
|
data/lib/babel_icious/xml_map.rb
CHANGED
@@ -4,6 +4,18 @@ module Babelicious
|
|
4
4
|
|
5
5
|
class XmlMap
|
6
6
|
|
7
|
+
class << self
|
8
|
+
|
9
|
+
def initial_target
|
10
|
+
XML::Document.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def filter_source(source)
|
14
|
+
XML::Document.string(source)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
7
19
|
def initialize(path_translator)
|
8
20
|
@path_translator = path_translator
|
9
21
|
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
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Wyckoff
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-04-
|
12
|
+
date: 2009-04-14 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|