transproc 0.1.2 → 0.1.3

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: 8e48e0386ec7eb3b18878b0a49f7aa292eceaf95
4
- data.tar.gz: 8add522072d758b21a1bdcdacd038e074e276656
3
+ metadata.gz: b43b407d9915f16f63dbf1a12f10c9a87228213c
4
+ data.tar.gz: a46a7614a839a50da267593eeef25acbc8db167b
5
5
  SHA512:
6
- metadata.gz: ec69053a3c644da6e9681ff45e7f61c19a843ca2d7d3bca3678ee6afbca25685c9c503852e634bdcefadffb3fc67b61311785fe95ca2e3b0b10e6a335616779d
7
- data.tar.gz: 1d379f5fa10fc373a2f3d56d5ffc2392189c93fc184f09c9fcb992b912418655e3cc11f2da223b5463b328dfea878981b439409d32a1ffe9498630668044006e
6
+ metadata.gz: 5ce15554b0639b3c79a0a4da686e588f01dd0de7798b89a7129c39b0a51f0f0c31b094533775b3b21f5b6b893917020f2d99aa1b84648c445617c75f3f8e5688
7
+ data.tar.gz: 104618d775a9ce9781583b2c6f4e0e61ca28107f1f4494124b41456c8442b4663a7d4ad5b353dd6641b0e885f56d5b33ee0d0a32e23ff5a6ad4c9fcf2f029e96
data/.gitignore CHANGED
@@ -1,6 +1,7 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
3
  /Gemfile.lock
4
+ /vendor/
4
5
  /_yardoc/
5
6
  /coverage/
6
7
  /doc/
@@ -1,4 +1,6 @@
1
1
  language: ruby
2
+ sudo: false
3
+ cache: bundler
2
4
  env:
3
5
  - CODECLIMATE_REPO_TOKEN=aead71de2239048f830499462c54b57dfc646f1d56ad5dcbbc3469a6ebaf97ca
4
6
  script: "bundle exec rake spec"
@@ -1,3 +1,16 @@
1
+ ## v0.1.3 to-be-released
2
+
3
+ ### Added
4
+
5
+ * Added `hash_recursion` and `array_recursion` functions (AMHOL)
6
+ * Added `unwrap` and `unwrap!` functions (aflatter)
7
+
8
+ ### Changed
9
+
10
+ * Speedup transproc `group` (splattael)
11
+
12
+ [Compare v0.1.2...v0.1.3](https://github.com/solnic/transproc/compare/v0.1.2...v0.1.3)
13
+
1
14
  ## v0.1.2 2015-03-14
2
15
 
3
16
  ### Changed
data/README.md CHANGED
@@ -39,7 +39,7 @@ Or install it yourself as:
39
39
  require 'transproc/all'
40
40
 
41
41
  # compose transformation functions
42
- transformation = Transproc(:symbolize_keys) + Transproc(:map_hash, user_name: :name))
42
+ transformation = Transproc(:symbolize_keys) >> Transproc(:map_hash, user_name: :name))
43
43
 
44
44
  # call the function
45
45
  transformation['user_name' => 'Jane']
@@ -3,3 +3,4 @@ require 'transproc'
3
3
  require 'transproc/coercions'
4
4
  require 'transproc/array'
5
5
  require 'transproc/hash'
6
+ require 'transproc/recursion'
@@ -13,17 +13,15 @@ module Transproc
13
13
  end
14
14
 
15
15
  register(:group) do |array, key, keys|
16
- names = nil
17
-
18
- array
19
- .group_by { |hash|
20
- names ||= hash.keys - keys
21
- Hash[names.zip(hash.values_at(*names))]
22
- }
23
- .map { |root, children|
24
- children.map! { |child| Hash[keys.zip(child.values_at(*keys))] }
25
- children.select! { |child| child.values.any? }
26
- root.merge(key => children)
27
- }
16
+ grouped = Hash.new { |hash, key| hash[key] = [] }
17
+ array.each do |hash|
18
+ hash = hash.dup
19
+ child = {}
20
+ keys.each { |k| child[k] = hash.delete(k) }
21
+ grouped[hash] << child
22
+ end
23
+ grouped.map do |root, children|
24
+ root.merge(key => children)
25
+ end
28
26
  end
29
27
  end
@@ -1,5 +1,12 @@
1
1
  module Transproc
2
+ module Helper
3
+ def t(*args, &block)
4
+ Transproc(*args, &block)
5
+ end
6
+ end
7
+
2
8
  module Composer
9
+ include Helper
3
10
 
4
11
  class Factory
5
12
  attr_reader :fns, :default
@@ -19,15 +26,10 @@ module Transproc
19
26
  end
20
27
  end
21
28
 
22
- def t(*args)
23
- Transproc(*args)
24
- end
25
-
26
29
  def compose(default = nil)
27
30
  factory = Factory.new(default)
28
31
  yield(factory)
29
32
  factory.to_fn
30
33
  end
31
-
32
34
  end
33
35
  end
@@ -13,8 +13,9 @@ module Transproc
13
13
  alias_method :[], :call
14
14
 
15
15
  def compose(other)
16
- self.class.new(-> *result { other[fn[*result]] }, args)
16
+ self.class.new(-> *input { other[fn[*input]] }, args)
17
17
  end
18
18
  alias_method :+, :compose
19
+ alias_method :>>, :compose
19
20
  end
20
21
  end
@@ -39,4 +39,19 @@ module Transproc
39
39
  hash.update(root => {})
40
40
  end
41
41
  end
42
+
43
+ register(:unwrap) do |hash, root, keys|
44
+ copy = Hash[hash].merge(root => Hash[hash[root]])
45
+ Transproc(:unwrap!, root, keys)[copy]
46
+ end
47
+
48
+ register(:unwrap!) do |hash, root, keys|
49
+ if nested_hash = hash[root]
50
+ keys ||= nested_hash.keys
51
+ hash.update(Hash[keys.zip(keys.map { |key| nested_hash.delete(key) })])
52
+ hash.delete(root) if nested_hash.empty?
53
+ end
54
+
55
+ hash
56
+ end
42
57
  end
@@ -0,0 +1,29 @@
1
+ module Transproc
2
+ register(:array_recursion) do |value, fn|
3
+ result = fn[value]
4
+
5
+ result.map! do |item|
6
+ if item.is_a?(::Array)
7
+ Transproc(:array_recursion, fn)[item]
8
+ else
9
+ item
10
+ end
11
+ end
12
+ end
13
+
14
+ register(:hash_recursion) do |value, fn|
15
+ result = fn[value]
16
+
17
+ result.keys.each do |key|
18
+ item = result.delete(key)
19
+
20
+ if item.is_a?(::Hash)
21
+ result[key] = Transproc(:hash_recursion, fn)[item]
22
+ else
23
+ result[key] = item
24
+ end
25
+ end
26
+
27
+ result
28
+ end
29
+ end
@@ -1,3 +1,3 @@
1
1
  module Transproc
2
- VERSION = '0.1.2'.freeze
2
+ VERSION = '0.1.3'.freeze
3
3
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe 'Array transformations with Transproc' do
4
4
  describe 'map_array' do
5
5
  it 'applies funtions to all values' do
6
- map = Transproc(:map_array, Transproc(:symbolize_keys))
6
+ map = t(:map_array, t(:symbolize_keys))
7
7
 
8
8
  original = [
9
9
  { 'name' => 'Jane', 'title' => 'One' },
@@ -24,7 +24,7 @@ describe 'Array transformations with Transproc' do
24
24
 
25
25
  describe 'map_array!' do
26
26
  it 'updates array with the result of the function applied to each value' do
27
- map = Transproc(:map_array!, Transproc(:symbolize_keys))
27
+ map = t(:map_array!, t(:symbolize_keys))
28
28
 
29
29
  input = [
30
30
  { 'name' => 'Jane', 'title' => 'One' },
@@ -44,7 +44,7 @@ describe 'Array transformations with Transproc' do
44
44
 
45
45
  describe 'wrap' do
46
46
  it 'returns a new array with wrapped hashes' do
47
- wrap = Transproc(:wrap, :task, [:title])
47
+ wrap = t(:wrap, :task, [:title])
48
48
 
49
49
  input = [{ name: 'Jane', title: 'One' }]
50
50
  output = [{ name: 'Jane', task: { title: 'One' } }]
@@ -54,10 +54,10 @@ describe 'Array transformations with Transproc' do
54
54
 
55
55
  it 'returns a array new with deeply wrapped hashes' do
56
56
  wrap =
57
- Transproc(
57
+ t(
58
58
  :map_array,
59
- Transproc(:nest, :user, [:name, :title]),
60
- Transproc(:map_key, :user, Transproc(:nest, :task, [:title]))
59
+ t(:nest, :user, [:name, :title]),
60
+ t(:map_key, :user, t(:nest, :task, [:title]))
61
61
  )
62
62
 
63
63
  input = [{ name: 'Jane', title: 'One' }]
@@ -69,7 +69,7 @@ describe 'Array transformations with Transproc' do
69
69
 
70
70
  describe 'group' do
71
71
  it 'returns a new array with grouped hashes' do
72
- group = Transproc(:group, :tasks, [:title])
72
+ group = t(:group, :tasks, [:title])
73
73
 
74
74
  input = [{ name: 'Jane', title: 'One' }, { name: 'Jane', title: 'Two' }]
75
75
  output = [{ name: 'Jane', tasks: [{ title: 'One' }, { title: 'Two' }] }]
@@ -80,8 +80,8 @@ describe 'Array transformations with Transproc' do
80
80
 
81
81
  describe 'composition' do
82
82
  it 'allows composing transformations' do
83
- map = Transproc(:map_array, Transproc(:symbolize_keys))
84
- group = Transproc(:group, :tasks, [:title])
83
+ map = t(:map_array, t(:symbolize_keys))
84
+ group = t(:group, :tasks, [:title])
85
85
 
86
86
  input = [
87
87
  { 'name' => 'Jane', 'title' => 'One' },
@@ -90,7 +90,7 @@ describe 'Array transformations with Transproc' do
90
90
 
91
91
  output = [{ name: 'Jane', tasks: [{ title: 'One' }, { title: 'Two' }] }]
92
92
 
93
- transformation = map + group
93
+ transformation = map >> group
94
94
 
95
95
  expect(transformation[input]).to eql(output)
96
96
  end
@@ -3,63 +3,63 @@ require 'spec_helper'
3
3
  describe 'Transproc / Coercions' do
4
4
  describe 'to_string' do
5
5
  it 'turns integer into a string' do
6
- expect(Transproc(:to_string)[1]).to eql('1')
6
+ expect(t(:to_string)[1]).to eql('1')
7
7
  end
8
8
  end
9
9
 
10
10
  describe 'to_integer' do
11
11
  it 'turns string into an integer' do
12
- expect(Transproc(:to_integer)['1']).to eql(1)
12
+ expect(t(:to_integer)['1']).to eql(1)
13
13
  end
14
14
  end
15
15
 
16
16
  describe 'to_float' do
17
17
  it 'turns string into a float' do
18
- expect(Transproc(:to_float)['1']).to eql(1.0)
18
+ expect(t(:to_float)['1']).to eql(1.0)
19
19
  end
20
20
 
21
21
  it 'turns integer into a float' do
22
- expect(Transproc(:to_float)[1]).to eql(1.0)
22
+ expect(t(:to_float)[1]).to eql(1.0)
23
23
  end
24
24
  end
25
25
 
26
26
  describe 'to_decimal' do
27
27
  it 'turns string into a decimal' do
28
- expect(Transproc(:to_decimal)['1.251']).to eql(BigDecimal('1.251'))
28
+ expect(t(:to_decimal)['1.251']).to eql(BigDecimal('1.251'))
29
29
  end
30
30
 
31
31
  it 'turns float into a decimal' do
32
- expect(Transproc(:to_decimal)[1.251]).to eql(BigDecimal('1.251'))
32
+ expect(t(:to_decimal)[1.251]).to eql(BigDecimal('1.251'))
33
33
  end
34
34
 
35
35
  it 'turns integer into a decimal' do
36
- expect(Transproc(:to_decimal)[1]).to eql(BigDecimal('1.0'))
36
+ expect(t(:to_decimal)[1]).to eql(BigDecimal('1.0'))
37
37
  end
38
38
  end
39
39
 
40
40
  describe 'to_date' do
41
41
  it 'turns string into a date' do
42
42
  date = Date.new(1983, 11, 18)
43
- expect(Transproc(:to_date)['18th, November 1983']).to eql(date)
43
+ expect(t(:to_date)['18th, November 1983']).to eql(date)
44
44
  end
45
45
  end
46
46
 
47
47
  describe 'to_time' do
48
48
  it 'turns string into a time object' do
49
49
  time = Time.new(2012, 1, 23, 11, 7, 7)
50
- expect(Transproc(:to_time)['2012-01-23 11:07:07']).to eql(time)
50
+ expect(t(:to_time)['2012-01-23 11:07:07']).to eql(time)
51
51
  end
52
52
  end
53
53
 
54
54
  describe 'to_datetime' do
55
55
  it 'turns string into a date' do
56
56
  datetime = DateTime.new(2012, 1, 23, 11, 7, 7)
57
- expect(Transproc(:to_datetime)['2012-01-23 11:07:07']).to eql(datetime)
57
+ expect(t(:to_datetime)['2012-01-23 11:07:07']).to eql(datetime)
58
58
  end
59
59
  end
60
60
 
61
61
  describe 'to_boolean' do
62
- subject(:coercer) { Transproc(:to_boolean) }
62
+ subject(:coercer) { t(:to_boolean) }
63
63
 
64
64
  Transproc::TRUE_VALUES.each do |value|
65
65
  it "turns #{value.inspect} to true" do
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe 'Hash mapping with Transproc' do
4
4
  describe 'symbolize_keys' do
5
5
  it 'returns a new hash with symbolized keys' do
6
- symbolize_keys = Transproc(:symbolize_keys)
6
+ symbolize_keys = t(:symbolize_keys)
7
7
 
8
8
  input = { 'foo' => 'bar' }
9
9
  output = { foo: 'bar' }
@@ -15,7 +15,7 @@ describe 'Hash mapping with Transproc' do
15
15
 
16
16
  describe 'symbolize_keys!' do
17
17
  it 'returns updated hash with symbolized keys' do
18
- symbolize_keys = Transproc(:symbolize_keys!)
18
+ symbolize_keys = t(:symbolize_keys!)
19
19
 
20
20
  input = { 'foo' => 'bar' }
21
21
  output = { foo: 'bar' }
@@ -28,7 +28,7 @@ describe 'Hash mapping with Transproc' do
28
28
 
29
29
  describe 'nest' do
30
30
  it 'returns new hash with keys nested under a new key' do
31
- nest = Transproc(:nest, :baz, ['foo'])
31
+ nest = t(:nest, :baz, ['foo'])
32
32
 
33
33
  input = { 'foo' => 'bar' }
34
34
  output = { baz: { 'foo' => 'bar' } }
@@ -40,7 +40,7 @@ describe 'Hash mapping with Transproc' do
40
40
 
41
41
  describe 'nest!' do
42
42
  it 'returns new hash with keys nested under a new key' do
43
- nest = Transproc(:nest!, :baz, ['one', 'two', 'not-here'])
43
+ nest = t(:nest!, :baz, ['one', 'two', 'not-here'])
44
44
 
45
45
  input = { 'foo' => 'bar', 'one' => nil, 'two' => false }
46
46
  output = { 'foo' => 'bar', baz: { 'one' => nil, 'two' => false } }
@@ -51,7 +51,7 @@ describe 'Hash mapping with Transproc' do
51
51
  end
52
52
 
53
53
  it 'returns new hash with an empty hash under a new key when nest-keys are missing' do
54
- nest = Transproc(:nest!, :baz, ['foo'])
54
+ nest = t(:nest!, :baz, ['foo'])
55
55
 
56
56
  input = { 'bar' => 'foo' }
57
57
  output = { 'bar' => 'foo', baz: {} }
@@ -62,9 +62,48 @@ describe 'Hash mapping with Transproc' do
62
62
  end
63
63
  end
64
64
 
65
+ describe 'unwrap!' do
66
+ it 'returns updated hash with nested keys lifted to the root' do
67
+ unwrap = t(:unwrap!, 'wrapped', ['one', 'two'])
68
+
69
+ input = { 'foo' => 'bar', 'wrapped' => { 'one' => nil, 'two' => false } }
70
+ output = { 'foo' => 'bar', 'one' => nil, 'two' => false }
71
+
72
+ unwrap[input]
73
+
74
+ expect(input).to eql(output)
75
+ end
76
+
77
+ it 'lifts all keys if none are passed' do
78
+ unwrap = t(:unwrap!, 'wrapped')
79
+
80
+ input = { 'wrapped' => { 'one' => nil, 'two' => false } }
81
+ output = { 'one' => nil, 'two' => false }
82
+
83
+ unwrap[input]
84
+
85
+ expect(input).to eql(output)
86
+ end
87
+ end
88
+
89
+ describe 'unwrap' do
90
+ it 'returns new hash with nested keys lifted to the root' do
91
+ unwrap = t(:unwrap, 'wrapped', ['one', 'two'])
92
+
93
+ input = {
94
+ 'foo' => 'bar',
95
+ 'wrapped' => { 'one' => nil, 'two' => false }
96
+ }.freeze
97
+
98
+ expect(unwrap[input]).to eql({'foo' => 'bar',
99
+ 'one' => nil,
100
+ 'two' => false})
101
+ end
102
+ end
103
+
65
104
  describe 'map_hash' do
66
105
  it 'returns a new hash with applied functions' do
67
- map = Transproc(:map_hash, 'foo' => :foo)
106
+ map = t(:map_hash, 'foo' => :foo)
68
107
 
69
108
  input = { 'foo' => 'bar', :bar => 'baz' }
70
109
  output = { foo: 'bar', bar: 'baz' }
@@ -76,7 +115,7 @@ describe 'Hash mapping with Transproc' do
76
115
 
77
116
  describe 'map_hash!' do
78
117
  it 'returns updated hash with applied functions' do
79
- map = Transproc(:map_hash!, 'foo' => :foo)
118
+ map = t(:map_hash!, 'foo' => :foo)
80
119
 
81
120
  input = { 'foo' => 'bar', :bar => 'baz' }
82
121
  output = { foo: 'bar', bar: 'baz' }
@@ -89,7 +128,7 @@ describe 'Hash mapping with Transproc' do
89
128
 
90
129
  describe 'map_key' do
91
130
  it 'applies function to value under specified key' do
92
- transformation = Transproc(:map_key, :user, Transproc(:symbolize_keys))
131
+ transformation = t(:map_key, :user, t(:symbolize_keys))
93
132
 
94
133
  input = { user: { 'name' => 'Jane' } }
95
134
  output = { user: { name: 'Jane' } }
@@ -101,7 +140,7 @@ describe 'Hash mapping with Transproc' do
101
140
 
102
141
  describe 'map_key!' do
103
142
  it 'applies function to value under specified key' do
104
- transformation = Transproc(:map_key!, :user, Transproc(:symbolize_keys))
143
+ transformation = t(:map_key!, :user, t(:symbolize_keys))
105
144
 
106
145
  input = { user: { 'name' => 'Jane' } }
107
146
  output = { user: { name: 'Jane' } }
@@ -114,10 +153,10 @@ describe 'Hash mapping with Transproc' do
114
153
 
115
154
  describe 'nested transform' do
116
155
  it 'applies functions to nested hashes' do
117
- symbolize_keys = Transproc(:symbolize_keys)
118
- map_user_key = Transproc(:map_key, :user, symbolize_keys)
156
+ symbolize_keys = t(:symbolize_keys)
157
+ map_user_key = t(:map_key, :user, symbolize_keys)
119
158
 
120
- transformation = symbolize_keys + map_user_key
159
+ transformation = symbolize_keys >> map_user_key
121
160
 
122
161
  input = { 'user' => { 'name' => 'Jane' } }
123
162
  output = { user: { name: 'Jane' } }
@@ -128,10 +167,10 @@ describe 'Hash mapping with Transproc' do
128
167
 
129
168
  describe 'combining transformations' do
130
169
  it 'applies functions to the hash' do
131
- symbolize_keys = Transproc(:symbolize_keys)
132
- map = Transproc(:map_hash, user_name: :name, user_email: :email)
170
+ symbolize_keys = t(:symbolize_keys)
171
+ map = t(:map_hash, user_name: :name, user_email: :email)
133
172
 
134
- transformation = symbolize_keys + map
173
+ transformation = symbolize_keys >> map
135
174
 
136
175
  input = { 'user_name' => 'Jade', 'user_email' => 'jade@doe.org' }
137
176
  output = { name: 'Jade', email: 'jade@doe.org' }
@@ -0,0 +1,106 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Recursive transformations with Transproc' do
4
+ describe 'array_recursion' do
5
+ let(:original) do
6
+ [
7
+ 'foo',
8
+ 'bar',
9
+ nil,
10
+ [
11
+ 'foo',
12
+ 'bar',
13
+ nil,
14
+ [
15
+ 'foo',
16
+ 'bar',
17
+ nil
18
+ ]
19
+ ]
20
+ ]
21
+ end
22
+
23
+ let(:input) { original.dup }
24
+
25
+ let(:output) do
26
+ [
27
+ 'foo',
28
+ 'bar',
29
+ [
30
+ 'foo',
31
+ 'bar',
32
+ [
33
+ 'foo',
34
+ 'bar'
35
+ ]
36
+ ]
37
+ ]
38
+ end
39
+
40
+ context 'when function is non-destructive' do
41
+ let(:map) { t(:array_recursion, proc { |arr| arr.compact }) }
42
+
43
+ it 'applies funtions to all items recursively' do
44
+ expect(map[input]).to eql(output)
45
+ expect(input).to eql(original)
46
+ end
47
+ end
48
+
49
+ context 'when function is destructive' do
50
+ let(:map) { t(:array_recursion, proc { |arr| arr.compact! }) }
51
+
52
+ it 'applies funtions to all items recursively and destructively' do
53
+ expect(map[input]).to eql(output)
54
+ expect(input).to eql(output)
55
+ end
56
+ end
57
+ end
58
+
59
+ describe 'hash_recursion' do
60
+ let(:original) do
61
+ {
62
+ 'foo' => 'bar',
63
+ 'bar' => {
64
+ 'foo' => 'bar',
65
+ 'bar' => {
66
+ 'foo' => 'bar'
67
+ }
68
+ },
69
+ 'baz' => 'bar'
70
+ }
71
+ end
72
+
73
+ let(:input) { original.dup }
74
+
75
+ let(:output) do
76
+ {
77
+ foo: 'bar',
78
+ bar: {
79
+ foo: 'bar',
80
+ bar: {
81
+ foo: 'bar'
82
+ }
83
+ },
84
+ baz: 'bar'
85
+ }
86
+ end
87
+
88
+ context 'when function is non-destructive' do
89
+ let(:map) { t(:hash_recursion, t(:symbolize_keys)) }
90
+
91
+ it 'applies funtions to all values recursively' do
92
+ expect(map[input]).to eql(output)
93
+ expect(input).to eql(original)
94
+ end
95
+ end
96
+
97
+ context 'when function is destructive' do
98
+ let(:map) { t(:hash_recursion, t(:symbolize_keys!)) }
99
+
100
+ it 'applies funtions to all values recursively and destructively' do
101
+ expect(map[input]).to eql(output)
102
+ expect(input).to eql(output)
103
+ end
104
+ end
105
+ end
106
+ end
@@ -6,10 +6,10 @@ describe Transproc do
6
6
  input = '1'
7
7
  output = 1.0
8
8
 
9
- to_i = Transproc(-> value { value.to_i })
10
- to_f = Transproc(-> value { value.to_f })
9
+ to_i = t(-> value { value.to_i })
10
+ to_f = t(-> value { value.to_f })
11
11
 
12
- result = to_i + to_f
12
+ result = to_i >> to_f
13
13
 
14
14
  expect(result[input]).to eql(output)
15
15
  end
@@ -19,7 +19,7 @@ describe Transproc do
19
19
  it 'allows registering functions by name' do
20
20
  Transproc.register(:to_boolean, -> value { value == 'true' })
21
21
 
22
- result = Transproc(-> value { value.to_s }) + Transproc(:to_boolean)
22
+ result = t(-> value { value.to_s }) >> t(:to_boolean)
23
23
 
24
24
  expect(result[:true]).to be(true)
25
25
  expect(result[:false]).to be(false)
@@ -28,7 +28,7 @@ describe Transproc do
28
28
  it 'allows registering function by passing a block' do
29
29
  Transproc.register(:to_boolean) { |value| value == 'true' }
30
30
 
31
- result = Transproc(-> value { value.to_s }) + Transproc(:to_boolean)
31
+ result = t(-> value { value.to_s }) >> t(:to_boolean)
32
32
 
33
33
  expect(result[:true]).to be(true)
34
34
  expect(result[:false]).to be(false)
@@ -9,3 +9,7 @@ begin
9
9
  require 'byebug'
10
10
  rescue LoadError
11
11
  end
12
+
13
+ RSpec.configure do |config|
14
+ config.include(Transproc::Helper)
15
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transproc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-14 00:00:00.000000000 Z
11
+ date: 2015-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -75,11 +75,13 @@ files:
75
75
  - lib/transproc/composer.rb
76
76
  - lib/transproc/function.rb
77
77
  - lib/transproc/hash.rb
78
+ - lib/transproc/recursion.rb
78
79
  - lib/transproc/version.rb
79
80
  - spec/integration/array_spec.rb
80
81
  - spec/integration/coercions_spec.rb
81
82
  - spec/integration/composer_spec.rb
82
83
  - spec/integration/hash_spec.rb
84
+ - spec/integration/recursion_spec.rb
83
85
  - spec/integration/transproc_spec.rb
84
86
  - spec/spec_helper.rb
85
87
  - transproc.gemspec
@@ -112,5 +114,7 @@ test_files:
112
114
  - spec/integration/coercions_spec.rb
113
115
  - spec/integration/composer_spec.rb
114
116
  - spec/integration/hash_spec.rb
117
+ - spec/integration/recursion_spec.rb
115
118
  - spec/integration/transproc_spec.rb
116
119
  - spec/spec_helper.rb
120
+ has_rdoc: