transformers 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +92 -77
- data/README.md +3 -8
- data/lib/transformers.rb +6 -3
- data/lib/transformers/version.rb +1 -1
- data/spec/rails_spec_helper.rb +1 -3
- data/spec/transformers/extensions/action_controller_spec.rb +1 -0
- data/spec/transformers/extensions/hash_spec.rb +3 -3
- data/spec/transformers_spec.rb +1 -1
- data/transformers.gemspec +5 -5
- metadata +63 -100
data/Gemfile.lock
CHANGED
@@ -1,97 +1,112 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
transformers (0.0.
|
5
|
-
activesupport (~> 3.0
|
4
|
+
transformers (0.0.2)
|
5
|
+
activesupport (~> 3.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
rack (~> 1.2
|
21
|
-
rack-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
arel (
|
38
|
-
builder (
|
39
|
-
diff-lcs (1.1.
|
40
|
-
erubis (2.
|
41
|
-
|
42
|
-
i18n (0.
|
43
|
-
|
44
|
-
|
10
|
+
actionmailer (3.2.8)
|
11
|
+
actionpack (= 3.2.8)
|
12
|
+
mail (~> 2.4.4)
|
13
|
+
actionpack (3.2.8)
|
14
|
+
activemodel (= 3.2.8)
|
15
|
+
activesupport (= 3.2.8)
|
16
|
+
builder (~> 3.0.0)
|
17
|
+
erubis (~> 2.7.0)
|
18
|
+
journey (~> 1.0.4)
|
19
|
+
rack (~> 1.4.0)
|
20
|
+
rack-cache (~> 1.2)
|
21
|
+
rack-test (~> 0.6.1)
|
22
|
+
sprockets (~> 2.1.3)
|
23
|
+
activemodel (3.2.8)
|
24
|
+
activesupport (= 3.2.8)
|
25
|
+
builder (~> 3.0.0)
|
26
|
+
activerecord (3.2.8)
|
27
|
+
activemodel (= 3.2.8)
|
28
|
+
activesupport (= 3.2.8)
|
29
|
+
arel (~> 3.0.2)
|
30
|
+
tzinfo (~> 0.3.29)
|
31
|
+
activeresource (3.2.8)
|
32
|
+
activemodel (= 3.2.8)
|
33
|
+
activesupport (= 3.2.8)
|
34
|
+
activesupport (3.2.8)
|
35
|
+
i18n (~> 0.6)
|
36
|
+
multi_json (~> 1.0)
|
37
|
+
arel (3.0.2)
|
38
|
+
builder (3.0.4)
|
39
|
+
diff-lcs (1.1.3)
|
40
|
+
erubis (2.7.0)
|
41
|
+
hike (1.2.1)
|
42
|
+
i18n (0.6.1)
|
43
|
+
journey (1.0.4)
|
44
|
+
json (1.7.5)
|
45
|
+
mail (2.4.4)
|
45
46
|
i18n (>= 0.4.0)
|
46
47
|
mime-types (~> 1.16)
|
47
48
|
treetop (~> 1.4.8)
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
rack
|
49
|
+
metaclass (0.0.1)
|
50
|
+
mime-types (1.19)
|
51
|
+
mocha (0.12.7)
|
52
|
+
metaclass (~> 0.0.1)
|
53
|
+
multi_json (1.3.6)
|
54
|
+
polyglot (0.3.3)
|
55
|
+
rack (1.4.1)
|
56
|
+
rack-cache (1.2)
|
57
|
+
rack (>= 0.4)
|
58
|
+
rack-ssl (1.3.2)
|
59
|
+
rack
|
60
|
+
rack-test (0.6.2)
|
55
61
|
rack (>= 1.0)
|
56
|
-
rails (3.
|
57
|
-
actionmailer (= 3.
|
58
|
-
actionpack (= 3.
|
59
|
-
activerecord (= 3.
|
60
|
-
activeresource (= 3.
|
61
|
-
activesupport (= 3.
|
62
|
+
rails (3.2.8)
|
63
|
+
actionmailer (= 3.2.8)
|
64
|
+
actionpack (= 3.2.8)
|
65
|
+
activerecord (= 3.2.8)
|
66
|
+
activeresource (= 3.2.8)
|
67
|
+
activesupport (= 3.2.8)
|
62
68
|
bundler (~> 1.0)
|
63
|
-
railties (= 3.
|
64
|
-
railties (3.
|
65
|
-
actionpack (= 3.
|
66
|
-
activesupport (= 3.
|
69
|
+
railties (= 3.2.8)
|
70
|
+
railties (3.2.8)
|
71
|
+
actionpack (= 3.2.8)
|
72
|
+
activesupport (= 3.2.8)
|
73
|
+
rack-ssl (~> 1.3.2)
|
67
74
|
rake (>= 0.8.7)
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
rspec-
|
78
|
-
rspec-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
75
|
+
rdoc (~> 3.4)
|
76
|
+
thor (>= 0.14.6, < 2.0)
|
77
|
+
rake (0.9.2.2)
|
78
|
+
rdoc (3.12)
|
79
|
+
json (~> 1.4)
|
80
|
+
rspec (2.11.0)
|
81
|
+
rspec-core (~> 2.11.0)
|
82
|
+
rspec-expectations (~> 2.11.0)
|
83
|
+
rspec-mocks (~> 2.11.0)
|
84
|
+
rspec-core (2.11.1)
|
85
|
+
rspec-expectations (2.11.3)
|
86
|
+
diff-lcs (~> 1.1.3)
|
87
|
+
rspec-mocks (2.11.3)
|
88
|
+
rspec-rails (2.11.4)
|
89
|
+
actionpack (>= 3.0)
|
90
|
+
activesupport (>= 3.0)
|
91
|
+
railties (>= 3.0)
|
92
|
+
rspec (~> 2.11.0)
|
93
|
+
sprockets (2.1.3)
|
94
|
+
hike (~> 1.2)
|
95
|
+
rack (~> 1.0)
|
96
|
+
tilt (~> 1.1, != 1.3.0)
|
97
|
+
thor (0.16.0)
|
98
|
+
tilt (1.3.3)
|
99
|
+
treetop (1.4.11)
|
100
|
+
polyglot
|
85
101
|
polyglot (>= 0.3.1)
|
86
|
-
tzinfo (0.3.
|
102
|
+
tzinfo (0.3.33)
|
87
103
|
|
88
104
|
PLATFORMS
|
89
105
|
ruby
|
90
106
|
|
91
107
|
DEPENDENCIES
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
rspec (~> 2.5
|
96
|
-
rspec-rails (~> 2.5.0)
|
108
|
+
mocha (~> 0.9)
|
109
|
+
rails (~> 3.0)
|
110
|
+
rspec (~> 2.5)
|
111
|
+
rspec-rails (~> 2.5)
|
97
112
|
transformers!
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Transformers [![Build Status](
|
1
|
+
Transformers [![Build Status](https://travis-ci.org/endeepak/transformers.png)](https://travis-ci.org/endeepak/transformers)
|
2
2
|
============
|
3
3
|
|
4
4
|
Transformers is an extension to hash to allow various transformations using simple DSL. It also has optional rails extension to dry up frequently applied transformations on controller params.
|
@@ -6,16 +6,11 @@ Transformers is an extension to hash to allow various transformations using simp
|
|
6
6
|
Install
|
7
7
|
=======
|
8
8
|
|
9
|
-
[not yet released]
|
10
|
-
|
11
|
-
Usage
|
12
|
-
=====
|
13
|
-
|
14
9
|
gem install transformers
|
15
10
|
|
16
|
-
OR Add dependency in
|
11
|
+
OR Add dependency in _Gemfile_ for projects using bundler
|
17
12
|
|
18
|
-
gem transformers
|
13
|
+
gem 'transformers'
|
19
14
|
|
20
15
|
Available Transformations
|
21
16
|
=========================
|
data/lib/transformers.rb
CHANGED
@@ -19,9 +19,12 @@ module Transformers
|
|
19
19
|
|
20
20
|
def self.get(transformer)
|
21
21
|
case transformer
|
22
|
-
when Module, Proc
|
23
|
-
|
24
|
-
|
22
|
+
when Module, Proc
|
23
|
+
transformer
|
24
|
+
when Symbol
|
25
|
+
all.has_key?(transformer) ? all[transformer] : MethodCall.new(transformer)
|
26
|
+
else
|
27
|
+
raise UnknownTransformer.new(transformer)
|
25
28
|
end
|
26
29
|
end
|
27
30
|
|
data/lib/transformers/version.rb
CHANGED
data/spec/rails_spec_helper.rb
CHANGED
@@ -2,6 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
#TODO: Find why adding transform_params in individual spec definition fails and fix it.
|
4
4
|
class TestActionController < ActionController::Base
|
5
|
+
include Rails.application.routes.url_helpers
|
5
6
|
transform_params { convert :foo, :to => :upcase }
|
6
7
|
|
7
8
|
transform_params :bar do
|
@@ -41,7 +41,7 @@ describe Hash do
|
|
41
41
|
hash.transform(:key) do
|
42
42
|
convert :foo, :as => :bar
|
43
43
|
end
|
44
|
-
}.
|
44
|
+
}.to raise_error(/Can't apply transformations on "value". Expected a Hash/)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -168,7 +168,7 @@ describe Hash do
|
|
168
168
|
it "should raise error if :to option is missing" do
|
169
169
|
hash = {:stan => 'marsh'}
|
170
170
|
|
171
|
-
expect { hash.rename :stan }.
|
171
|
+
expect { hash.rename :stan }.to raise_error(/Missing options : :to/)
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
@@ -186,7 +186,7 @@ describe Hash do
|
|
186
186
|
it "should raise error if :to option is missing" do
|
187
187
|
hash = {:stan => 'marsh'}
|
188
188
|
|
189
|
-
expect { hash.copy :stan }.
|
189
|
+
expect { hash.copy :stan }.to raise_error(/Missing options : :to/)
|
190
190
|
end
|
191
191
|
end
|
192
192
|
end
|
data/spec/transformers_spec.rb
CHANGED
@@ -41,7 +41,7 @@ describe Transformers do
|
|
41
41
|
|
42
42
|
context "when key is anything else" do
|
43
43
|
it "should raise error" do
|
44
|
-
expect { Transformers.get("UNKNOWN") }.
|
44
|
+
expect { Transformers.get("UNKNOWN") }.to raise_error('The "UNKNOWN" transformer is not supported')
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
data/transformers.gemspec
CHANGED
@@ -16,9 +16,9 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
18
|
s.require_paths = ["lib"]
|
19
|
-
s.add_runtime_dependency("activesupport", "~> 3.0
|
20
|
-
s.add_development_dependency("rails", "~> 3.0
|
21
|
-
s.add_development_dependency("rspec", "~> 2.5
|
22
|
-
s.add_development_dependency("rspec-rails", "~> 2.5
|
23
|
-
s.add_development_dependency("mocha", "~> 0.9
|
19
|
+
s.add_runtime_dependency("activesupport", "~> 3.0")
|
20
|
+
s.add_development_dependency("rails", "~> 3.0")
|
21
|
+
s.add_development_dependency("rspec", "~> 2.5")
|
22
|
+
s.add_development_dependency("rspec-rails", "~> 2.5")
|
23
|
+
s.add_development_dependency("mocha", "~> 0.9")
|
24
24
|
end
|
metadata
CHANGED
@@ -1,113 +1,80 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: transformers
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
version: 0.0.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Deepak N
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-10-18 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: activesupport
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &2160120700 !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
18
|
+
requirements:
|
27
19
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 3
|
32
|
-
- 0
|
33
|
-
- 0
|
34
|
-
version: 3.0.0
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.0'
|
35
22
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: rails
|
39
23
|
prerelease: false
|
40
|
-
|
24
|
+
version_requirements: *2160120700
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rails
|
27
|
+
requirement: &2160117280 !ruby/object:Gem::Requirement
|
41
28
|
none: false
|
42
|
-
requirements:
|
29
|
+
requirements:
|
43
30
|
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
segments:
|
47
|
-
- 3
|
48
|
-
- 0
|
49
|
-
- 0
|
50
|
-
version: 3.0.0
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3.0'
|
51
33
|
type: :development
|
52
|
-
version_requirements: *id002
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: rspec
|
55
34
|
prerelease: false
|
56
|
-
|
35
|
+
version_requirements: *2160117280
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
requirement: &2160116600 !ruby/object:Gem::Requirement
|
57
39
|
none: false
|
58
|
-
requirements:
|
40
|
+
requirements:
|
59
41
|
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
|
62
|
-
segments:
|
63
|
-
- 2
|
64
|
-
- 5
|
65
|
-
- 0
|
66
|
-
version: 2.5.0
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '2.5'
|
67
44
|
type: :development
|
68
|
-
version_requirements: *id003
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rspec-rails
|
71
45
|
prerelease: false
|
72
|
-
|
46
|
+
version_requirements: *2160116600
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec-rails
|
49
|
+
requirement: &2160116020 !ruby/object:Gem::Requirement
|
73
50
|
none: false
|
74
|
-
requirements:
|
51
|
+
requirements:
|
75
52
|
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
segments:
|
79
|
-
- 2
|
80
|
-
- 5
|
81
|
-
- 0
|
82
|
-
version: 2.5.0
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.5'
|
83
55
|
type: :development
|
84
|
-
version_requirements: *id004
|
85
|
-
- !ruby/object:Gem::Dependency
|
86
|
-
name: mocha
|
87
56
|
prerelease: false
|
88
|
-
|
57
|
+
version_requirements: *2160116020
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: mocha
|
60
|
+
requirement: &2160115520 !ruby/object:Gem::Requirement
|
89
61
|
none: false
|
90
|
-
requirements:
|
62
|
+
requirements:
|
91
63
|
- - ~>
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
|
94
|
-
segments:
|
95
|
-
- 0
|
96
|
-
- 9
|
97
|
-
- 10
|
98
|
-
version: 0.9.10
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0.9'
|
99
66
|
type: :development
|
100
|
-
|
101
|
-
|
102
|
-
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *2160115520
|
69
|
+
description: An extension to hash to allow various transformations using simple DSL.
|
70
|
+
Also has optional rails extension to dry up frequently applied transformations on
|
71
|
+
controller params.
|
72
|
+
email:
|
103
73
|
- endeep123@gmail.com
|
104
74
|
executables: []
|
105
|
-
|
106
75
|
extensions: []
|
107
|
-
|
108
76
|
extra_rdoc_files: []
|
109
|
-
|
110
|
-
files:
|
77
|
+
files:
|
111
78
|
- .gitignore
|
112
79
|
- Gemfile
|
113
80
|
- Gemfile.lock
|
@@ -134,41 +101,37 @@ files:
|
|
134
101
|
- spec/transformers/method_call_spec.rb
|
135
102
|
- spec/transformers_spec.rb
|
136
103
|
- transformers.gemspec
|
137
|
-
has_rdoc: true
|
138
104
|
homepage: https://github.com/endeepak/transformers
|
139
105
|
licenses: []
|
140
|
-
|
141
106
|
post_install_message:
|
142
107
|
rdoc_options: []
|
143
|
-
|
144
|
-
require_paths:
|
108
|
+
require_paths:
|
145
109
|
- lib
|
146
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
147
111
|
none: false
|
148
|
-
requirements:
|
149
|
-
- -
|
150
|
-
- !ruby/object:Gem::Version
|
151
|
-
|
152
|
-
segments:
|
112
|
+
requirements:
|
113
|
+
- - ! '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
segments:
|
153
117
|
- 0
|
154
|
-
|
155
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
hash: -3475705913555311726
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
120
|
none: false
|
157
|
-
requirements:
|
158
|
-
- -
|
159
|
-
- !ruby/object:Gem::Version
|
160
|
-
|
161
|
-
segments:
|
121
|
+
requirements:
|
122
|
+
- - ! '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
segments:
|
162
126
|
- 0
|
163
|
-
|
127
|
+
hash: -3475705913555311726
|
164
128
|
requirements: []
|
165
|
-
|
166
129
|
rubyforge_project:
|
167
|
-
rubygems_version: 1.
|
130
|
+
rubygems_version: 1.8.15
|
168
131
|
signing_key:
|
169
132
|
specification_version: 3
|
170
133
|
summary: DSL to transform a hash
|
171
|
-
test_files:
|
134
|
+
test_files:
|
172
135
|
- spec/rails_spec_helper.rb
|
173
136
|
- spec/spec_helper.rb
|
174
137
|
- spec/transformers/boolean_spec.rb
|