transproc 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +3 -2
- data/lib/transproc/composite.rb +1 -1
- data/lib/transproc/function.rb +6 -2
- data/lib/transproc/version.rb +1 -1
- data/spec/unit/function_spec.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b2b9e293f1bc88414fb4b5f49380dfc59eb72e9
|
4
|
+
data.tar.gz: 551725a59dac3558f757aa2c3094fa6085999408
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3626b0f8b8198a308bfd19595a9246babe7778d94ccfe75c41ce23bfe595f5ebadbd9c0d0d186c81064b5b0e1137b83d60b28765a091ea29c9ecc69fefd10d09
|
7
|
+
data.tar.gz: 615eb4a86e3216cc450d5270447998fd80764d1668dc69ba70cb0d95ed364d3775b82a5f37701c36de093947fafd7734a91c40633f45c8ebc5e6f066e4245202
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## v0.3.2 2015-08-17
|
2
|
+
|
3
|
+
## Changed
|
4
|
+
|
5
|
+
* Functions now use `.call` rather than `.[]` as it's more common (solnic)
|
6
|
+
|
7
|
+
## Fixed
|
8
|
+
|
9
|
+
* `Function#to_proc` properly carries additional args required by the proc (solnic)
|
10
|
+
|
11
|
+
[Compare v0.3.1...v0.3.2](https://github.com/solnic/transproc/compare/v0.3.1...v0.3.2)
|
12
|
+
|
1
13
|
## v0.3.1 2015-08-06
|
2
14
|
|
3
15
|
### Added
|
data/README.md
CHANGED
@@ -66,8 +66,9 @@ transformation = t(:camel_case)
|
|
66
66
|
transformation.call 'i_am_a_camel'
|
67
67
|
# => "IAmACamel"
|
68
68
|
|
69
|
-
transformation = t(:map_array, t(:symbolize_keys)
|
70
|
-
|
69
|
+
transformation = t(:map_array, t(:symbolize_keys)
|
70
|
+
.>> t(:rename_keys, user_name: :user))
|
71
|
+
.>> t(:wrap, :address, [:city, :street, :zipcode])
|
71
72
|
|
72
73
|
transformation.call(
|
73
74
|
[
|
data/lib/transproc/composite.rb
CHANGED
data/lib/transproc/function.rb
CHANGED
@@ -44,7 +44,7 @@ module Transproc
|
|
44
44
|
#
|
45
45
|
# @api public
|
46
46
|
def call(*value)
|
47
|
-
fn
|
47
|
+
fn.(*value, *args)
|
48
48
|
rescue => e
|
49
49
|
raise MalformedInputError.new(@name, value, e)
|
50
50
|
end
|
@@ -95,7 +95,11 @@ module Transproc
|
|
95
95
|
# @return [Proc]
|
96
96
|
#
|
97
97
|
def to_proc
|
98
|
-
|
98
|
+
if args.size > 0
|
99
|
+
proc { |*value| fn.call(*value, *args) }
|
100
|
+
else
|
101
|
+
fn.to_proc
|
102
|
+
end
|
99
103
|
end
|
100
104
|
end
|
101
105
|
end
|
data/lib/transproc/version.rb
CHANGED
data/spec/unit/function_spec.rb
CHANGED
@@ -157,5 +157,17 @@ describe Transproc::Function do
|
|
157
157
|
expect([:foo, :bar].map(&source)).to eql(%w(foo bar))
|
158
158
|
end
|
159
159
|
end
|
160
|
+
|
161
|
+
context 'with curried args' do
|
162
|
+
let(:source) { -> i, j { [i, j].join(' ') } }
|
163
|
+
|
164
|
+
it 'works fine' do
|
165
|
+
fn = described_class.new(source, args: ['world'])
|
166
|
+
|
167
|
+
result = fn.to_proc.call('hello')
|
168
|
+
|
169
|
+
expect(result).to eql('hello world')
|
170
|
+
end
|
171
|
+
end
|
160
172
|
end
|
161
173
|
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.3.
|
4
|
+
version: 0.3.2
|
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-08-
|
11
|
+
date: 2015-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|