empezar 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module Empezar
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/empezar.rb CHANGED
@@ -10,4 +10,6 @@ require 'empezar/symbolmatrix'
10
10
  require 'empezar/configuration'
11
11
  require 'empezar/runner'
12
12
  require 'empezar/echoing_formatter'
13
- require 'empezar/log'
13
+ require 'empezar/log'
14
+
15
+ require 'writer/symbolmatrix'
@@ -0,0 +1,21 @@
1
+ module Writer
2
+ class SymbolMatrix
3
+ attr_accessor :source
4
+
5
+ def initialize source
6
+ @source = source
7
+ end
8
+
9
+ def serialization prefix = ""
10
+ text = ""
11
+ @source.each do |key, value|
12
+ if value.is_a? Hash
13
+ text += value.to.serialization(prefix + key.to_s + ".") +" "
14
+ else
15
+ text += "#{prefix}#{key}:#{value} "
16
+ end
17
+ end
18
+ text[0..-2]
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe Writer::SymbolMatrix do
4
+ describe '#initialize' do
5
+ it 'should set the argument as the source' do
6
+ source = stub 'source'
7
+ writer = Writer::SymbolMatrix.new source
8
+ writer.source.should == source
9
+ end
10
+ end
11
+
12
+ describe '#serialization' do
13
+ it 'should transform the multidimentional hash into a simple dot and colons serialization' do
14
+ multidimentional = SymbolMatrix.new hola: {
15
+ the: "start",
16
+ asdfdf: 8989,
17
+ of: {
18
+ some: "multidimentional"
19
+ }
20
+ },
21
+ stuff: "oops"
22
+
23
+ writer = Writer::SymbolMatrix.new multidimentional
24
+ writer.serialization.should == "hola.the:start hola.asdfdf:8989 hola.of.some:multidimentional stuff:oops"
25
+ end
26
+
27
+ context 'with argument' do
28
+ it 'should do the transformation appending the argument to each key-value pair' do
29
+ simple = SymbolMatrix.new mykey: "myvalue", otherkey: "othervalue"
30
+
31
+ writer = Writer::SymbolMatrix.new simple
32
+ writer.serialization("inside.").should == "inside.mykey:myvalue inside.otherkey:othervalue"
33
+ end
34
+ end
35
+ end
36
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: empezar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -97,6 +97,7 @@ files:
97
97
  - lib/empezar/runner.rb
98
98
  - lib/empezar/symbolmatrix.rb
99
99
  - lib/empezar/version.rb
100
+ - lib/writer/symbolmatrix.rb
100
101
  - sample/config/main.yaml
101
102
  - sample/script.rb
102
103
  - spec/configuration_spec.rb
@@ -108,6 +109,7 @@ files:
108
109
  - spec/runner_spec.rb
109
110
  - spec/spec_helper.rb
110
111
  - spec/symbolmatrix_spec.rb
112
+ - spec/writer/symbolmatrix_spec.rb
111
113
  homepage: http://github.com/Fetcher/empezar
112
114
  licenses: []
113
115
  post_install_message:
@@ -143,4 +145,5 @@ test_files:
143
145
  - spec/runner_spec.rb
144
146
  - spec/spec_helper.rb
145
147
  - spec/symbolmatrix_spec.rb
148
+ - spec/writer/symbolmatrix_spec.rb
146
149
  has_rdoc: