honey_format 0.21.0 → 0.21.1

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
  SHA256:
3
- metadata.gz: 46fdc7932e9287a30e106b06d264e1816ca0b0270c175a279b52e5173eb79780
4
- data.tar.gz: 67e680e4771404bd64d8c07267982296f49fcf123d154d8739b8d3776fa05b53
3
+ metadata.gz: dd0d06f453986109809c196cef032b5f60233e165a8d5e029162b26b6cc801b2
4
+ data.tar.gz: 8f5a15f42e9f2587bc80b7e88d5c929d74a04ef69bd6be272513ba8fc544a22a
5
5
  SHA512:
6
- metadata.gz: a0fec7274008e64d2848d1f7f6c4b277651993d1355948bb948b68a91034f57689e05b8443874141bc8edb1183ade8dbfe2d387ef28bd9a0e67db2172df61a3d
7
- data.tar.gz: a64d69090268ae7c8d4abcef2ff3f33d1be3aba971719f63aa50183f0c1c953e798a192945af9f283669b661fe560d4cdb0fa205857b6165a1ad501b0a494402
6
+ metadata.gz: 563e6ba6a8ede49e13d15957c12c247b6e26c981afe25b150d6ae8c6c3dab58929c100341dcc0181790a03eabffca5ddd3ac127cf97fcdb4ac76ef04b01c9839
7
+ data.tar.gz: 93a08cb9b2683961e80f8f2bb79f763f05fb1401e112458a6188bf86530233e93f9d397b0ee415e4ce9c8b95ff644485e50dc6b52a2c8381aa4379b0bce0e65a
@@ -1,5 +1,9 @@
1
1
  # HEAD
2
2
 
3
+ ## v0.21.1
4
+
5
+ * Closes [issue #58](https://github.com/buren/honey_format/issues/58). [PR #62](https://github.com/buren/honey_format/pull/62)
6
+
3
7
  ## v0.21.0
4
8
 
5
9
  * Add `Rows#[]` method
data/README.md CHANGED
@@ -91,7 +91,7 @@ __Type converters__
91
91
 
92
92
  > Type converters are great if you want to convert column values, like numbers and dates.
93
93
 
94
- There are a few default type converters
94
+ There are a bunch of [default type converters](https://github.com/buren/honey_format/blob/master/lib/honey_format/converters/converters.rb)
95
95
  ```ruby
96
96
  csv_string = "Id,Username\n1,buren"
97
97
  type_map = { id: :integer }
@@ -139,7 +139,7 @@ Default converter names
139
139
  HoneyFormat.config.default_converters.keys
140
140
  ```
141
141
 
142
- See [`Configuration#default_converters`](https://github.com/buren/honey_format/blob/master/lib/honey_format/configuration.rb#L99) for a complete list of the default ones.
142
+ See [`Converters::DEFAULT`](https://github.com/buren/honey_format/blob/master/lib/honey_format/converters.rb) for a complete list of the default converter names.
143
143
 
144
144
  __Row builder__
145
145
 
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency 'benchmark-ips'
26
26
  spec.add_development_dependency 'bundler', '> 1.10', '< 3'
27
27
  spec.add_development_dependency 'byebug'
28
- spec.add_development_dependency 'rake', '~> 10.0'
28
+ spec.add_development_dependency 'rake', '~> 12.3'
29
29
  spec.add_development_dependency 'rspec'
30
30
  spec.add_development_dependency 'simplecov'
31
31
  end
@@ -97,34 +97,7 @@ module HoneyFormat
97
97
  # Default converter registry
98
98
  # @return [Hash] hash with default converters
99
99
  def default_converters
100
- @default_converters ||= {
101
- # strict variants
102
- decimal!: StrictConvertDecimal,
103
- integer!: StrictConvertInteger,
104
- date!: StrictConvertDate,
105
- datetime!: StrictConvertDatetime,
106
- symbol!: StrictConvertSymbol,
107
- downcase!: StrictConvertDowncase,
108
- upcase!: StrictConvertUpcase,
109
- boolean!: StrictConvertBoolean,
110
- # safe variants
111
- decimal: ConvertDecimal,
112
- decimal_or_zero: ConvertDecimalOrZero,
113
- integer: ConvertInteger,
114
- integer_or_zero: ConvertIntegerOrZero,
115
- date: ConvertDate,
116
- datetime: ConvertDatetime,
117
- symbol: ConvertSymbol,
118
- downcase: ConvertDowncase,
119
- upcase: ConvertUpcase,
120
- boolean: ConvertBoolean,
121
- md5: ConvertMD5,
122
- hex: ConvertHex,
123
- nil: ConvertNil,
124
- blank: ConvertBlank,
125
- header_column: ConvertHeaderColumn,
126
- method_name: ConvertHeaderColumn,
127
- }.freeze
100
+ @default_converters ||= Converters::DEFAULT
128
101
  end
129
102
  end
130
103
  end
@@ -4,9 +4,9 @@ require 'set'
4
4
 
5
5
  module HoneyFormat
6
6
  # String values considered truthy
7
- TRUTHY = Set.new(%w[t T 1 y Y true TRUE]).freeze
7
+ TRUTHY = Set.new(%w[t T 1 y Y true TRUE] + [true]).freeze
8
8
  # String values considered falsy
9
- FALSY = Set.new(%w[f F 0 n N false FALSE]).freeze
9
+ FALSY = Set.new(%w[f F 0 n N false FALSE] + [false]).freeze
10
10
 
11
11
  # Tries to convert value boolean to, returns nil if it can't convert
12
12
  ConvertBoolean = proc do |v|
@@ -23,8 +23,8 @@ module HoneyFormat
23
23
  end
24
24
 
25
25
  # Convert to date or raise error
26
- StrictConvertDate = proc { |v| Date.parse(v) }
26
+ StrictConvertDate = proc { |v| v.is_a?(Date) ? v : Date.parse(v) }
27
27
 
28
28
  # Convert to datetime or raise error
29
- StrictConvertDatetime = proc { |v| Time.parse(v) }
29
+ StrictConvertDatetime = proc { |v| v.is_a?(Time) ? v : Time.parse(v) }
30
30
  end
@@ -9,4 +9,35 @@ require 'honey_format/converters/convert_string'
9
9
  module HoneyFormat
10
10
  # Convert to nil
11
11
  ConvertNil = proc {}
12
+
13
+ module Converters
14
+ DEFAULT = {
15
+ # strict variants
16
+ decimal!: StrictConvertDecimal,
17
+ integer!: StrictConvertInteger,
18
+ date!: StrictConvertDate,
19
+ datetime!: StrictConvertDatetime,
20
+ symbol!: StrictConvertSymbol,
21
+ downcase!: StrictConvertDowncase,
22
+ upcase!: StrictConvertUpcase,
23
+ boolean!: StrictConvertBoolean,
24
+ # safe variants
25
+ decimal: ConvertDecimal,
26
+ decimal_or_zero: ConvertDecimalOrZero,
27
+ integer: ConvertInteger,
28
+ integer_or_zero: ConvertIntegerOrZero,
29
+ date: ConvertDate,
30
+ datetime: ConvertDatetime,
31
+ symbol: ConvertSymbol,
32
+ downcase: ConvertDowncase,
33
+ upcase: ConvertUpcase,
34
+ boolean: ConvertBoolean,
35
+ md5: ConvertMD5,
36
+ hex: ConvertHex,
37
+ nil: ConvertNil,
38
+ blank: ConvertBlank,
39
+ header_column: ConvertHeaderColumn,
40
+ method_name: ConvertHeaderColumn,
41
+ }.freeze
42
+ end
12
43
  end
@@ -5,6 +5,6 @@ module HoneyFormat
5
5
  VERSION = [
6
6
  MAJOR_VERSION = 0,
7
7
  MINOR_VERSION = 21,
8
- PATCH_VERSION = 0,
8
+ PATCH_VERSION = 1,
9
9
  ].join('.')
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honey_format
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.0
4
+ version: 0.21.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Burenstam
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-17 00:00:00.000000000 Z
11
+ date: 2020-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips
@@ -64,14 +64,14 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '10.0'
67
+ version: '12.3'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '10.0'
74
+ version: '12.3'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: rspec
77
77
  requirement: !ruby/object:Gem::Requirement