transformator 0.1.1 → 0.1.2
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: 5da1c0998ecdd4c7a4f6b862011ef029244cfd06
|
4
|
+
data.tar.gz: 6e993b4c18f491a851b4e6238aa8d085045e07b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ff77077de278799b5088e0b6df6db3746e34806ab8b449405419cac1d08d2350beb3d9ab979cbb87903b6282cf6dc1cd65037478cb0ac5157eaee590a6dcfd2
|
7
|
+
data.tar.gz: 87b3444767fd835166b06885a036f20153f7e09d47ebf3793057f603d6f76e58c8b04b7b9ae53eec1629a25fff606b0658028b54a56f52320238043842e890eb
|
@@ -52,7 +52,7 @@ class Transformator::Transformation
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
case options[:output_format] || Transformator.determine_format(options[:source])
|
55
|
+
case options[:output_format] || @output_format || Transformator.determine_format(options[:source])
|
56
56
|
when :hash then Transformator.hash_from_document(target)
|
57
57
|
when :ox_document then target
|
58
58
|
when :xml then Ox.dump(target, with_xml: true)
|
@@ -64,7 +64,11 @@ class Transformator::Transformation
|
|
64
64
|
private
|
65
65
|
#
|
66
66
|
include Transformator::Dsl
|
67
|
-
|
67
|
+
|
68
|
+
def output_format(format)
|
69
|
+
@output_format = format.to_sym
|
70
|
+
end
|
71
|
+
|
68
72
|
def process(path, options = {}, &block)
|
69
73
|
@rules.push({ callable: block, path: path, type: :process}.merge(options))
|
70
74
|
self
|
@@ -15,7 +15,7 @@ describe Transformator::Transformation do
|
|
15
15
|
xml
|
16
16
|
end
|
17
17
|
|
18
|
-
describe "
|
18
|
+
describe ".new" do
|
19
19
|
context "when called with an options hash" do
|
20
20
|
let(:transformed_xml) do
|
21
21
|
<<-xml.strip_heredoc
|
@@ -46,7 +46,19 @@ describe Transformator::Transformation do
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
describe "
|
49
|
+
describe "#output_format" do
|
50
|
+
let(:transformation) do
|
51
|
+
described_class.new do
|
52
|
+
output_format :xml
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it "sets the default output format for the transformation" do
|
57
|
+
expect(transformation.apply(to: {})).to start_with("<?xml")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "#process" do
|
50
62
|
context "when called with the special path :document" do
|
51
63
|
it "provides the whole input document to the block" do
|
52
64
|
transformation = described_class.new 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.2
|
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-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|