transformator 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0474274566563edf8f9f8cff236f3fdeff325375
4
- data.tar.gz: 7d50aff06d3999b3e80cc8b50878d5f578093f5f
3
+ metadata.gz: 3b18762ea7ff4419e08195d18ff1ca6b839985d9
4
+ data.tar.gz: 029f31bedd8f0a5e8a8667f26ef556a1da31688a
5
5
  SHA512:
6
- metadata.gz: 0c875a1285ffe4b1f726b3955a6acda7d87e5221d9d4325b626e6196e5aef1882e970e83ba4f613ee565bdfd8ecda83652babf3d748f934af50ff4a461f87a8b
7
- data.tar.gz: fc94425c73d50d232e40053b2a0477193cd0077abe8c949748df62cf5f385a656bca2e29983ec4b5779415eb6062427e4b1427702c4e88c67d18282de35eba28
6
+ metadata.gz: 3c85e2ab36e07e2f1d4a03665457c89de42d4e8581b175db9d96da788d49d3ede4666d465655ef6ad2556efa466a4c75d1863829707b9a5ceb207a6ea0bf9958
7
+ data.tar.gz: b75ea62ffcaac500613564f1a95b29df6a161bbb801ad6489c2a60f456705d6f7bc91a3573f17222a6f0b88f60cf63713176c6ae0016f758c8ad7bb1f616950b
@@ -3,6 +3,11 @@ require "transformator/dsl"
3
3
 
4
4
  class Transformator::Transformation
5
5
  def initialize(options = {}, &block)
6
+ # make it possible to initialize a transformation with external data
7
+ options.each_pair do |key, value|
8
+ instance_variable_set "@#{key}".to_sym, value
9
+ end
10
+
6
11
  @rules = []
7
12
  self.instance_eval(&block) if block
8
13
  end
@@ -1,3 +1,3 @@
1
1
  module Transformator
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -16,6 +16,25 @@ describe Transformator::Transformation do
16
16
  end
17
17
 
18
18
  describe "#new" do
19
+ context "when called with an options hash" do
20
+ let(:transformed_xml) do
21
+ <<-xml.strip_heredoc
22
+ <?xml version="1.0" encoding="UTF-8"?>
23
+ <muff>value1</muff>
24
+ xml
25
+ end
26
+
27
+ it "provides each key as an instance variable inside the transformation" do
28
+ transformation = described_class.new(option1: "value1") do
29
+ process "foo/bar" do |element, target|
30
+ target << element("muff", text: @option1)
31
+ end
32
+ end
33
+
34
+ expect(transformation.apply(to: source_xml)).to eq(transformed_xml)
35
+ end
36
+ end
37
+
19
38
  it "can be called with a block, containing the mapping described by the dsl" do
20
39
  transformation = described_class.new do
21
40
  process "foo/bar" do |element, target|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transformator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Sievers