transproc 0.3.1 → 0.3.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: 03da4ea0974d24e43c94ab16d920532aa9703e9d
4
- data.tar.gz: 5d0065ee097e3574e069062388f810ed0b81b108
3
+ metadata.gz: 0b2b9e293f1bc88414fb4b5f49380dfc59eb72e9
4
+ data.tar.gz: 551725a59dac3558f757aa2c3094fa6085999408
5
5
  SHA512:
6
- metadata.gz: dd79715c818c4161a4dbb574f8c2e359326a75739395f6ee1207dac1ffb40a138062090e2a1e94e6784ebc59dd46b8c1e036a149847ba5665ebf2635d7a53181
7
- data.tar.gz: 915a231c2730edd26900c1ec7db8cacd5b0d7a1abc557f2e096334cf5e2092951b41b1c21239b173f257403ee42c03ffba2083dc59a31eaf5c2f9c3bddf0ee92
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) >> t(:rename_keys, user_name: :user))
70
- transformation >>= t(:wrap, :address, [:city, :street, :zipcode])
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
  [
@@ -27,7 +27,7 @@ module Transproc
27
27
  #
28
28
  # @api public
29
29
  def call(value)
30
- right[left[value]]
30
+ right.(left.(value))
31
31
  end
32
32
  alias_method :[], :call
33
33
 
@@ -44,7 +44,7 @@ module Transproc
44
44
  #
45
45
  # @api public
46
46
  def call(*value)
47
- fn[*value, *args]
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
- fn.to_proc
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
@@ -1,3 +1,3 @@
1
1
  module Transproc
2
- VERSION = '0.3.1'.freeze
2
+ VERSION = '0.3.2'.freeze
3
3
  end
@@ -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.1
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-06 00:00:00.000000000 Z
11
+ date: 2015-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler