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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 504a9eb60037d436fe931f54f40ea31b90a321c7d1f8bcfc824699c1b42e6554
4
- data.tar.gz: e8aa654cb29fdc99586bec36dc581817ba0215e0b7ed09f6803e21ac9cf76634
3
+ metadata.gz: a6cd8529a06ea9662fb8b412f69a6e3c2c87dbeaa65ac166725b794e3ad40cc0
4
+ data.tar.gz: 5ffce5cbccd29318f6b9f4f23bbe6b2f76788be3a11ec235fc11a42be55e81a7
5
5
  SHA512:
6
- metadata.gz: aae6439a396cab2139730381e65e9071cf6af9828646191ec1ba6b9a9d193f2948a039ade8540088b0001175912c5c38b3ac3f12f4c3558bcee4112563886421
7
- data.tar.gz: ffa8ef6242d3a8bae401f772e0e1524ef56ca95c80c83edf2f7632613176aae5f77cb02b084a50bf42330f0317bf2c28afe933a42fef8f4b108cdd2a23cab99a
6
+ metadata.gz: dda9f382c0b4f612d8be932ccab98538e8c86c99d3a2c9b6d02cdff0e32b8a110f6fb211d69b0aaf7020da1bb0d9dc533aeff6aad00b893fc87e0b76fed95044
7
+ data.tar.gz: 10f13d4d064943f9244085414c7e4d344b8c9d98a6beec5c3a5bd9bbef76a1030f522d0e1a738fe6982cdd69e7e33023f2b5f2fc17c233919a6dd3d03070b67b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- babaloa (0.1.1)
4
+ babaloa (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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. In addition, in case of comparing with `2, 3, 100` note that the order will be `100, 2, 3` when comparing by character string.
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
@@ -1,3 +1,3 @@
1
1
  module Babaloa
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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.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-22 00:00:00.000000000 Z
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
- rubyforge_project:
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