cwyckoff-babel_icious 0.0.4.9 → 0.0.5.0

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.
@@ -6,6 +6,10 @@ module Babelicious
6
6
 
7
7
  class << self
8
8
  attr_reader :direction, :current_target_map_key
9
+
10
+ def [](key)
11
+ mappings[key.to_sym]
12
+ end
9
13
 
10
14
  def config(key)
11
15
  raise MapperError, "A mapping for the key #{key} currently exists. Are you sure you want to merge the mapping you are about to do with the existing mapping?" if mapping_already_exists?(key)
@@ -26,6 +30,11 @@ module Babelicious
26
30
  current_target_mapper.register_from(from_str)
27
31
  self
28
32
  end
33
+
34
+ def include(key, opts={})
35
+ current_target_mapper.register_include(key, opts)
36
+ self
37
+ end
29
38
 
30
39
  def map(opts={})
31
40
  current_target_mapper.register_mapping(opts)
@@ -63,7 +72,7 @@ module Babelicious
63
72
  private
64
73
 
65
74
  def current_target_mapper
66
- mappings[@current_target_map_key] ||= (mappings[@current_target_map_key] = TargetMapper.new)
75
+ mappings[@current_target_map_key] ||= TargetMapper.new
67
76
  end
68
77
 
69
78
  def mapping_already_exists?(key)
@@ -1,6 +1,8 @@
1
1
  module Babelicious
2
2
 
3
3
  class HashMap < BaseMap
4
+ attr_accessor :path_translator
5
+
4
6
  class << self
5
7
 
6
8
  def initial_target
@@ -3,6 +3,7 @@ require 'xml'
3
3
  module Babelicious
4
4
 
5
5
  class XmlMap < BaseMap
6
+ attr_accessor :path_translator
6
7
 
7
8
  class << self
8
9
 
@@ -37,6 +37,11 @@ module Babelicious
37
37
  untranslated_path.gsub(/^\//, "").split("/")
38
38
  end
39
39
 
40
+ def unshift(element)
41
+ @parsed_path.unshift(element)
42
+ @full_path = "#{element}/" << @full_path
43
+ end
44
+
40
45
  end
41
46
 
42
47
  end
@@ -50,6 +50,16 @@ module Babelicious
50
50
  @mappings.last << target
51
51
  end
52
52
 
53
+ def register_include(map_definition=nil, opts={})
54
+ raise TargetMapperError, "A mapping definition key is required (e.g., m.include(:another_map))" if map_definition.nil?
55
+ raise TargetMapperError, "Mapping definition for #{map_definition} does not exist" unless (other_mapper = Mapper[map_definition.to_sym])
56
+
57
+ other_mapper.mappings.each do |m|
58
+ m[1].path_translator.unshift(opts[:inside_of]) if opts[:inside_of]
59
+ @mappings << m
60
+ end
61
+ end
62
+
53
63
  def register_mapping(opts={})
54
64
  raise TargetMapperError, "Both :from and :to keys must be set (e.g., {:from => \"foo/bar\", :to => \"bar/foo\")" unless (opts[:from] && opts[:to])
55
65
  target = MapFactory.target(@direction, opts)
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.9
4
+ version: 0.0.5.0
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-06-09 00:00:00 -07:00
12
+ date: 2009-06-17 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency