babaloa 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/babaloa.rb +4 -2
- data/lib/babaloa/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6cd8529a06ea9662fb8b412f69a6e3c2c87dbeaa65ac166725b794e3ad40cc0
|
4
|
+
data.tar.gz: 5ffce5cbccd29318f6b9f4f23bbe6b2f76788be3a11ec235fc11a42be55e81a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dda9f382c0b4f612d8be932ccab98538e8c86c99d3a2c9b6d02cdff0e32b8a110f6fb211d69b0aaf7020da1bb0d9dc533aeff6aad00b893fc87e0b76fed95044
|
7
|
+
data.tar.gz: 10f13d4d064943f9244085414c7e4d344b8c9d98a6beec5c3a5bd9bbef76a1030f522d0e1a738fe6982cdd69e7e33023f2b5f2fc17c233919a6dd3d03070b67b
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -42,7 +42,7 @@ Introduces the available options.
|
|
42
42
|
### Sort options
|
43
43
|
You can sort content for using sort options.
|
44
44
|
You can use option value with Hash(only use desc) or String, Symbol.
|
45
|
-
**Be sure to use the same hash key type as the header name** to be specified. It does not move if the type is different.
|
45
|
+
**Be sure to use the same hash key type as the header name** to be specified. It does not move if the type is different.
|
46
46
|
|
47
47
|
```ruby
|
48
48
|
arr = [{ "col1" => "row2-1", "col2" => "row2-2", "col3" => "row2-3"},{"col1" => "row1-1", "col2" => "row1-2", "col3" => "row1-3"}]
|
data/lib/babaloa.rb
CHANGED
@@ -40,14 +40,16 @@ module Babaloa
|
|
40
40
|
sort = options[:sort] || configuration.define(options[:name], :sort) || configuration.default[:sort]
|
41
41
|
return data unless sort
|
42
42
|
|
43
|
+
conv = proc {|v| v.is_a?(String) && v =~ /^\d+$/ ? v.to_i : v }
|
44
|
+
|
43
45
|
if sort.is_a?(Hash)
|
44
46
|
k, v = sort.first
|
45
47
|
k = header.index(k.to_sym) if data.first.is_a?(Array)
|
46
|
-
data.sort_by! {|col| col[k] }
|
48
|
+
data.sort_by! {|col| conv.(col[k]) }
|
47
49
|
data.reverse! if v == :desc
|
48
50
|
elsif sort.is_a?(Symbol) || sort.is_a?(String)
|
49
51
|
sort = header.index(sort.to_sym) if data.first.is_a?(Array)
|
50
|
-
data.sort_by! {|col| col[sort] }
|
52
|
+
data.sort_by! {|col| conv.(col[sort]) }
|
51
53
|
else
|
52
54
|
raise BabaloaError, "sort option must be Hash, Symbol, String."
|
53
55
|
end
|
data/lib/babaloa/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: babaloa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- belion-freee
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -95,8 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
|
-
|
99
|
-
rubygems_version: 2.7.3
|
98
|
+
rubygems_version: 3.0.3
|
100
99
|
signing_key:
|
101
100
|
specification_version: 4
|
102
101
|
summary: CSV generator gem for ActiveRecord
|