transformator 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de79125e94963cf8f64a509a0ad23c1f33b6404e
|
4
|
+
data.tar.gz: bd978c37ba87a8a64c31240d48096f0a477d5b4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05aa679773f11e290dab9b3de31499dfd452940b6670c0e8894689e1605f9eb04b5e2a264440a1679d6935c05006b9d782d379b23ecfb212e41db643f0385dba
|
7
|
+
data.tar.gz: c352e245758bbc162a87ac6c8d7b9fded4bb9f060972b7379303c23eb0696303810eb64f05488706af58253b26f37b583a8b3f13731d15c54e262152bd0bd6d4
|
@@ -76,6 +76,10 @@ class Transformator::Transformation
|
|
76
76
|
#
|
77
77
|
include Transformator::Dsl
|
78
78
|
|
79
|
+
def before_apply(options = {}, &block)
|
80
|
+
@rules.unshift({ callable: block, path: :none, type: :process}.merge(options))
|
81
|
+
end
|
82
|
+
|
79
83
|
def output_format(format)
|
80
84
|
@output_format = format.to_sym
|
81
85
|
end
|
@@ -45,6 +45,26 @@ describe Transformator::Transformation do
|
|
45
45
|
expect(transformation.apply(to: source_xml)).to eq(transformed_xml)
|
46
46
|
end
|
47
47
|
end
|
48
|
+
|
49
|
+
describe "#before_apply" do
|
50
|
+
let(:transformation) do
|
51
|
+
described_class.new(data: "some_data") do
|
52
|
+
process :target do |target|
|
53
|
+
target << element("data", text: @foo)
|
54
|
+
end
|
55
|
+
|
56
|
+
# usually rules are executed in order as the are defined, but this one comes first
|
57
|
+
before_apply do
|
58
|
+
@foo = @data
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
it "executes the given block before applying the transformation" do
|
64
|
+
transformed_document = transformation.apply(to: nil, output_format: :ox_document)
|
65
|
+
expect(transformed_document.locate("data").first.text).to eq("some_data")
|
66
|
+
end
|
67
|
+
end
|
48
68
|
|
49
69
|
describe "#output_format" do
|
50
70
|
let(:transformation) do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: transformator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Sievers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|