natural_sort_jp 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '06468e39e925af897dbcf27ee6c04ec4e8941d89d3d3ce0bd17021414568f2c6'
4
- data.tar.gz: 1c5845917fdabd93bbb3dfa51f875d04256999d903967ec1270ebac00316087c
3
+ metadata.gz: e0ebb8dc4b56eab8c1c5cdedab1261f956ab2f56aad1675db0848bb4939caf95
4
+ data.tar.gz: 6570669777808d13972061b9e06c86ed0738387ae65af3b4486be53b1331c030
5
5
  SHA512:
6
- metadata.gz: e1ad6d01f561694ebc8836424a9ebbb32205199da71d4a8436c385db100fb0dbc8d26bb794b0215b51ad08feb34cc6bd1f10f09384a493fbb96b908bf0fe271f
7
- data.tar.gz: f304379728764ea4a660b339a198f0a34b5bd3ee189fb79852f4b397b4c6a1cd9dc4d91c650b58bf1ded07efa5923ec0c42b0a8c4cf105ee66c21a1858c8a884
6
+ metadata.gz: 3e83f0eeeeabdb9c4b08dac4027b8c96eb4ebc12114c6b9610e1d38fccf638899f12fdb3760338c327225b3b9d97759da2fed62183f693316e254e9dc4f568f3
7
+ data.tar.gz: aac3d39976a60699c03ba62454504e469739cc9252016807f630ac2f5e5f71476ee9137b6e73f3bb23ddefe670a5b8ea1dd5a255548ea693d139635727562bb2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- natural_sort_jp (0.3.0)
4
+ natural_sort_jp (0.4.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -45,7 +45,9 @@ GEM
45
45
  unicode-display_width (2.4.2)
46
46
 
47
47
  PLATFORMS
48
+ ruby
48
49
  x86_64-darwin-21
50
+ x86_64-linux
49
51
 
50
52
  DEPENDENCIES
51
53
  bundler (~> 2.4.6)
data/License.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Yuto Takahashi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -36,8 +36,49 @@ NaturalSortJp.sort(
36
36
  )
37
37
  # => ["2022/1/1", "2022/01/02", "2022/01/03", "2022/1/10", "2023/1/1"]
38
38
 
39
+
40
+ # It can also be used in hashes, structures, and active record data structures.
41
+
42
+ NaturalSortJp.sort(
43
+ [
44
+ { id: 1, date: '2022/1/1'},
45
+ { id: 2, date: '2022/01/10'},
46
+ { id: 3, date: '2022/01/03'},
47
+ { id: 4, date: '2022/1/2'},
48
+ { id: 5, date: '2023/1/1'}
49
+ ], by: :date)
50
+ # => [
51
+ # {:id=>1, :date=>"2022/1/1"},
52
+ # {:id=>4, :date=>"2022/1/2"},
53
+ # {:id=>3, :date=>"2022/01/03"},
54
+ # {:id=>2, :date=>"2022/01/10"},
55
+ # {:id=>5, :date=>"2023/1/1"}
56
+ # ]
57
+
58
+ # and can use asc or desc option.
59
+
60
+ NaturalSortJp.sort(
61
+ [
62
+ { id: 1, date: '2022/1/1'},
63
+ { id: 2, date: '2022/01/10'},
64
+ { id: 3, date: '2022/01/03'},
65
+ { id: 4, date: '2022/1/2'},
66
+ { id: 5, date: '2023/1/1'}
67
+ ], by: :date, desc: true)
68
+ # => [
69
+ # {:id=>5, :date=>"2023/1/1"},
70
+ # {:id=>2, :date=>"2022/01/10"},
71
+ # {:id=>3, :date=>"2022/01/03"},
72
+ # {:id=>4, :date=>"2022/1/2"},
73
+ # {:id=>1, :date=>"2022/1/1"}
74
+ # ]
75
+
39
76
  ```
40
77
 
41
78
  ## Contributing
42
79
 
43
80
  Bug reports and pull requests are welcome on GitHub at https://github.com/thehighhigh/natural_sort_jp.
81
+
82
+ ## License
83
+
84
+ The gem is available as open source under the terms of the MIT License.
data/Rakefile CHANGED
@@ -1,4 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bundler/gem_tasks"
4
- task default: %i[]
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+ task default: :spec
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NaturalSortJp
4
- VERSION = '0.4.0'
4
+ VERSION = '0.4.2'
5
5
  end
@@ -15,8 +15,8 @@ module NaturalSortJp
15
15
  end
16
16
 
17
17
  def self.convert(title)
18
- elements = title.to_s.gsub(/[0-90-9]+/, ',\&,').split(',')
19
- elements.map { |t| Element.new(t) }
18
+ elements = title.to_s.scan(/([^0-90-9]*)([0-90-9]*)/).flatten
19
+ elements.map { |t| Element.new(t) if t != '' }
20
20
  end
21
21
 
22
22
  def self.referenced_by_attribute(obj, attribute)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: natural_sort_jp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - thehighhigh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-09 00:00:00.000000000 Z
11
+ date: 2023-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -76,6 +76,7 @@ files:
76
76
  - CHANGELOG.md
77
77
  - Gemfile
78
78
  - Gemfile.lock
79
+ - License.txt
79
80
  - README.md
80
81
  - Rakefile
81
82
  - lib/natural_sort_jp.rb