transproc 0.2.0 → 0.2.1

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.
data/transproc.gemspec CHANGED
@@ -4,21 +4,21 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'transproc/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "transproc"
7
+ spec.name = 'transproc'
8
8
  spec.version = Transproc::VERSION.dup
9
- spec.authors = ["Piotr Solnica"]
10
- spec.email = ["piotr.solnica@gmail.com"]
11
- spec.summary = %q{Transform Ruby objects in functional style}
9
+ spec.authors = ['Piotr Solnica']
10
+ spec.email = ['piotr.solnica@gmail.com']
11
+ spec.summary = 'Transform Ruby objects in functional style'
12
12
  spec.description = spec.summary
13
- spec.homepage = "http://solnic.github.io/transproc/"
14
- spec.license = "MIT"
13
+ spec.homepage = 'http://solnic.github.io/transproc/'
14
+ spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.7"
22
- spec.add_development_dependency "rake", "~> 10.0"
23
- spec.add_development_dependency "rspec", "~> 3.1"
21
+ spec.add_development_dependency 'bundler', '~> 1.7'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_development_dependency 'rspec', '~> 3.1'
24
24
  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.2.0
4
+ version: 0.2.1
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-04-14 00:00:00.000000000 Z
11
+ date: 2015-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -61,6 +61,8 @@ extra_rdoc_files: []
61
61
  files:
62
62
  - ".gitignore"
63
63
  - ".rspec"
64
+ - ".rubocop.yml"
65
+ - ".rubocop_todo.yml"
64
66
  - ".travis.yml"
65
67
  - CHANGELOG.md
66
68
  - Gemfile
@@ -71,22 +73,29 @@ files:
71
73
  - lib/transproc.rb
72
74
  - lib/transproc/all.rb
73
75
  - lib/transproc/array.rb
76
+ - lib/transproc/class.rb
74
77
  - lib/transproc/coercions.rb
75
78
  - lib/transproc/composer.rb
79
+ - lib/transproc/composite.rb
76
80
  - lib/transproc/conditional.rb
81
+ - lib/transproc/error.rb
77
82
  - lib/transproc/function.rb
78
83
  - lib/transproc/hash.rb
84
+ - lib/transproc/object.rb
79
85
  - lib/transproc/recursion.rb
80
86
  - lib/transproc/version.rb
81
- - spec/integration/array_spec.rb
82
- - spec/integration/coercions_spec.rb
83
- - spec/integration/composer_spec.rb
84
- - spec/integration/conditional_spec.rb
85
- - spec/integration/function_spec.rb
86
- - spec/integration/hash_spec.rb
87
- - spec/integration/recursion_spec.rb
88
- - spec/integration/transproc_spec.rb
87
+ - rakelib/mutant.rake
88
+ - rakelib/rubocop.rake
89
89
  - spec/spec_helper.rb
90
+ - spec/unit/array_transformations_spec.rb
91
+ - spec/unit/class_transformations_spec.rb
92
+ - spec/unit/coercions_spec.rb
93
+ - spec/unit/composer_spec.rb
94
+ - spec/unit/conditional_spec.rb
95
+ - spec/unit/function_spec.rb
96
+ - spec/unit/hash_transformations_spec.rb
97
+ - spec/unit/recursion_spec.rb
98
+ - spec/unit/transproc_spec.rb
90
99
  - transproc.gemspec
91
100
  homepage: http://solnic.github.io/transproc/
92
101
  licenses:
@@ -113,13 +122,13 @@ signing_key:
113
122
  specification_version: 4
114
123
  summary: Transform Ruby objects in functional style
115
124
  test_files:
116
- - spec/integration/array_spec.rb
117
- - spec/integration/coercions_spec.rb
118
- - spec/integration/composer_spec.rb
119
- - spec/integration/conditional_spec.rb
120
- - spec/integration/function_spec.rb
121
- - spec/integration/hash_spec.rb
122
- - spec/integration/recursion_spec.rb
123
- - spec/integration/transproc_spec.rb
124
125
  - spec/spec_helper.rb
125
- has_rdoc:
126
+ - spec/unit/array_transformations_spec.rb
127
+ - spec/unit/class_transformations_spec.rb
128
+ - spec/unit/coercions_spec.rb
129
+ - spec/unit/composer_spec.rb
130
+ - spec/unit/conditional_spec.rb
131
+ - spec/unit/function_spec.rb
132
+ - spec/unit/hash_transformations_spec.rb
133
+ - spec/unit/recursion_spec.rb
134
+ - spec/unit/transproc_spec.rb
@@ -1,98 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Array transformations with Transproc' do
4
- describe 'map_array' do
5
- it 'applies funtions to all values' do
6
- map = t(:map_array, t(:symbolize_keys))
7
-
8
- original = [
9
- { 'name' => 'Jane', 'title' => 'One' },
10
- { 'name' => 'Jane', 'title' => 'Two' }
11
- ]
12
-
13
- input = original
14
-
15
- output = [
16
- { name: 'Jane', title: 'One' },
17
- { name: 'Jane', title: 'Two' }
18
- ]
19
-
20
- expect(map[input]).to eql(output)
21
- expect(input).to eql(original)
22
- end
23
- end
24
-
25
- describe 'map_array!' do
26
- it 'updates array with the result of the function applied to each value' do
27
- map = t(:map_array!, t(:symbolize_keys))
28
-
29
- input = [
30
- { 'name' => 'Jane', 'title' => 'One' },
31
- { 'name' => 'Jane', 'title' => 'Two' }
32
- ]
33
-
34
- output = [
35
- { name: 'Jane', title: 'One' },
36
- { name: 'Jane', title: 'Two' }
37
- ]
38
-
39
- map[input]
40
-
41
- expect(input).to eql(output)
42
- end
43
- end
44
-
45
- describe 'wrap' do
46
- it 'returns a new array with wrapped hashes' do
47
- wrap = t(:wrap, :task, [:title])
48
-
49
- input = [{ name: 'Jane', title: 'One' }]
50
- output = [{ name: 'Jane', task: { title: 'One' } }]
51
-
52
- expect(wrap[input]).to eql(output)
53
- end
54
-
55
- it 'returns a array new with deeply wrapped hashes' do
56
- wrap =
57
- t(
58
- :map_array,
59
- t(:nest, :user, [:name, :title]) +
60
- t(:map_value, :user, t(:nest, :task, [:title]))
61
- )
62
-
63
- input = [{ name: 'Jane', title: 'One' }]
64
- output = [{ user: { name: 'Jane', task: { title: 'One' } } }]
65
-
66
- expect(wrap[input]).to eql(output)
67
- end
68
- end
69
-
70
- describe 'group' do
71
- it 'returns a new array with grouped hashes' do
72
- group = t(:group, :tasks, [:title])
73
-
74
- input = [{ name: 'Jane', title: 'One' }, { name: 'Jane', title: 'Two' }]
75
- output = [{ name: 'Jane', tasks: [{ title: 'One' }, { title: 'Two' }] }]
76
-
77
- expect(group[input]).to eql(output)
78
- end
79
- end
80
-
81
- describe 'composition' do
82
- it 'allows composing transformations' do
83
- map = t(:map_array, t(:symbolize_keys))
84
- group = t(:group, :tasks, [:title])
85
-
86
- input = [
87
- { 'name' => 'Jane', 'title' => 'One' },
88
- { 'name' => 'Jane', 'title' => 'Two' }
89
- ]
90
-
91
- output = [{ name: 'Jane', tasks: [{ title: 'One' }, { title: 'Two' }] }]
92
-
93
- transformation = map >> group
94
-
95
- expect(transformation[input]).to eql(output)
96
- end
97
- end
98
- end
@@ -1,37 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Transproc do
4
- describe 'composition' do
5
- it 'allows composing two transformation functions' do
6
- input = '1'
7
- output = 1.0
8
-
9
- to_i = t(-> value { value.to_i })
10
- to_f = t(-> value { value.to_f })
11
-
12
- result = to_i >> to_f
13
-
14
- expect(result[input]).to eql(output)
15
- end
16
- end
17
-
18
- describe 'function registration' do
19
- it 'allows registering functions by name' do
20
- Transproc.register(:to_boolean, -> value { value == 'true' })
21
-
22
- result = t(-> value { value.to_s }) >> t(:to_boolean)
23
-
24
- expect(result[:true]).to be(true)
25
- expect(result[:false]).to be(false)
26
- end
27
-
28
- it 'allows registering function by passing a block' do
29
- Transproc.register(:to_boolean) { |value| value == 'true' }
30
-
31
- result = t(-> value { value.to_s }) >> t(:to_boolean)
32
-
33
- expect(result[:true]).to be(true)
34
- expect(result[:false]).to be(false)
35
- end
36
- end
37
- end