tainbox 1.0.1 → 1.1.0

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: 363e986bb37cd4e76b357888de64c29575894704
4
- data.tar.gz: cc053609b310491829cecd2e3582c24c2024e05d
3
+ metadata.gz: 1e918789c23fdf76d107321cefc24c818644c5a1
4
+ data.tar.gz: f38d5d363ecd93f1215a92f9628f4e8c76845a48
5
5
  SHA512:
6
- metadata.gz: 37611bee35ad713e04a7db1cbed5268db0a89c10e65c3dc5384298331912905035709fbe25f8e113bf82a510e4bac3e1edf0e335ccf6c728b9a75cf0c6485dd9
7
- data.tar.gz: 42028d9a5a83ca2d220299e832b673d5ea8af6a7c32ebdfe57134d4791cfa5a9db087b45ae3b7e7f76d72cc6faaf946ab2887b61468707fd51b78eb7b3c64b0a
6
+ metadata.gz: 55697c48d4e0f1eed0de539a8a1d7561855747bd0ed0fbafc0d86a9a22491120cf4e72f5abd5f77b8a875fc7684ee716ccd3534f20748a330551b422c644a01c
7
+ data.tar.gz: 1b15674854681954ad2501be306b7e0af03d5e75d661a6dd8dbaed9295fa7fdb29f842d704457016aa90ed430e89e6fb6bcfd424bf3fdc336e6d5cf5155a7f5e
data/CHANGELOG.md CHANGED
@@ -33,3 +33,7 @@
33
33
 
34
34
  * `as_json` implementation does not use `to_hash` to
35
35
  avoid automatic casting from double star parameters
36
+
37
+ ## 1.1.0
38
+
39
+ * String converter supports `downcase` option to downcase values
data/README.md CHANGED
@@ -95,6 +95,17 @@ All converters return nil if conversion could not be made.
95
95
  - Time
96
96
  - Boolean
97
97
 
98
+ ### String type converter options
99
+
100
+ String converter supports additional options: `strip` and `downcase` which strip and downcase
101
+ input attribute values respectively
102
+
103
+ Example:
104
+
105
+ ``` ruby
106
+ attribute :name, String, strip: true, downcase: true
107
+ ```
108
+
98
109
  ### Custom type converters
99
110
 
100
111
  You can define a custom type converter like so:
@@ -41,7 +41,17 @@ end
41
41
 
42
42
  Tainbox.define_converter(String) do
43
43
  strip = options.fetch(:strip, false)
44
- value.to_s.tap { |result| result.strip! if strip }
44
+ downcase = options.fetch(:downcase, false)
45
+ result = value.to_s
46
+
47
+ result = result.strip if strip
48
+
49
+ if downcase
50
+ result = result.mb_chars if result.respond_to?(:mb_chars)
51
+ result = result.downcase
52
+ end
53
+
54
+ result
45
55
  end
46
56
 
47
57
  Tainbox.define_converter(Symbol) do
@@ -1,3 +1,3 @@
1
1
  module Tainbox
2
- VERSION = '1.0.1'
2
+ VERSION = '1.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tainbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Gubitskiy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-29 00:00:00.000000000 Z
11
+ date: 2016-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  version: '0'
124
124
  requirements: []
125
125
  rubyforge_project:
126
- rubygems_version: 2.5.2
126
+ rubygems_version: 2.4.6
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: Tainbox is a utility gem that can be used to inject attributes into ruby