transformator 0.1.1 → 0.1.2

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: 3b18762ea7ff4419e08195d18ff1ca6b839985d9
4
- data.tar.gz: 029f31bedd8f0a5e8a8667f26ef556a1da31688a
3
+ metadata.gz: 5da1c0998ecdd4c7a4f6b862011ef029244cfd06
4
+ data.tar.gz: 6e993b4c18f491a851b4e6238aa8d085045e07b7
5
5
  SHA512:
6
- metadata.gz: 3c85e2ab36e07e2f1d4a03665457c89de42d4e8581b175db9d96da788d49d3ede4666d465655ef6ad2556efa466a4c75d1863829707b9a5ceb207a6ea0bf9958
7
- data.tar.gz: b75ea62ffcaac500613564f1a95b29df6a161bbb801ad6489c2a60f456705d6f7bc91a3573f17222a6f0b88f60cf63713176c6ae0016f758c8ad7bb1f616950b
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
@@ -1,3 +1,3 @@
1
1
  module Transformator
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -15,7 +15,7 @@ describe Transformator::Transformation do
15
15
  xml
16
16
  end
17
17
 
18
- describe "#new" do
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 ".process" do
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.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-17 00:00:00.000000000 Z
11
+ date: 2014-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport