cwyckoff-babel_icious 0.0.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.
- data/MIT-LICENSE +22 -0
- data/README.rdoc +58 -0
- metadata +68 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2008-2009 David Brady github@shinybit.com
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
= Babel-icious
|
2
|
+
|
3
|
+
A flexible and scalable mapping tool that currently only supports mapping hashes and xml.
|
4
|
+
|
5
|
+
|
6
|
+
== Author
|
7
|
+
|
8
|
+
* Chris Wyckoff -- cwyckoff@leadmediapartners.com
|
9
|
+
|
10
|
+
|
11
|
+
== To Do
|
12
|
+
|
13
|
+
Add a mapper for JSON.
|
14
|
+
|
15
|
+
|
16
|
+
== Examples
|
17
|
+
|
18
|
+
Mappings are set up by calling passing mapping 'coordinates' to a 'config' block on the Mapper class:
|
19
|
+
|
20
|
+
Mapper.config(:foo) do |m|
|
21
|
+
|
22
|
+
m.direction = {:from => :xml, :to => :hash}
|
23
|
+
|
24
|
+
m.map :from => "foo/bar", :to => "bar/foo"
|
25
|
+
m.map :from => "foo/baz", :to => "bar/boo"
|
26
|
+
m.map :from => "foo/cuk/coo", :to => "foo/bar/coo"
|
27
|
+
m.map :from => "foo/cuk/doo", :to => "doo"
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
The 'config' method takes a symbol as its first argument which serves as an identification tag for that mapping. The second argument is a block where you indiate the details of your mapping. This should include a direction indicator and individual mapping 'coordinates'.
|
32
|
+
|
33
|
+
m.direction = {:from => :xml, :to => :hash}
|
34
|
+
|
35
|
+
tells the mapper that the source of the mapping will be xml and the target will be a hash. And the mapping coordinates
|
36
|
+
|
37
|
+
m.map :from => "foo/bar", :to => "bar/foo"
|
38
|
+
|
39
|
+
tell the mapper to place the value of element located at "foo/bar" in position "bar/foo". Here, the slashes indicate nestings for both hashes and xml. So, given the hash:
|
40
|
+
|
41
|
+
{"foo" => {"bar" => "baz"}}
|
42
|
+
|
43
|
+
the slash indicates that "bar" is a nested hash within "foo". The target xml then should be mapped as
|
44
|
+
|
45
|
+
<bar><foo>baz</foo></bar>
|
46
|
+
|
47
|
+
with the value of "bar" from the hash above placed in the nested <foo> tags in the xml.
|
48
|
+
|
49
|
+
|
50
|
+
When you want to translate the mappings, simply call:
|
51
|
+
|
52
|
+
Mapper.translate(:foo, source)
|
53
|
+
|
54
|
+
passing the tag for the mapping and the actual source you want to translate from.
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cwyckoff-babel_icious
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Wyckoff
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-04-13 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: libxml-ruby
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
description: Babel_icious dynamic and scalable mapping tool
|
26
|
+
email: github@cwyckoff.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README.rdoc
|
33
|
+
- MIT-LICENSE
|
34
|
+
files: []
|
35
|
+
|
36
|
+
has_rdoc: true
|
37
|
+
homepage: http://github.com/cwyckoff/babel_icious
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options:
|
40
|
+
- --line-numbers
|
41
|
+
- --inline-source
|
42
|
+
- --main
|
43
|
+
- README.rdoc
|
44
|
+
- --title
|
45
|
+
- Babel_icious - A Mapping Tool for the Ages
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: "0"
|
53
|
+
version:
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: "0"
|
59
|
+
version:
|
60
|
+
requirements: []
|
61
|
+
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 1.2.0
|
64
|
+
signing_key:
|
65
|
+
specification_version: 2
|
66
|
+
summary: Babel_icious dynamic and scalable mapping tool
|
67
|
+
test_files: []
|
68
|
+
|