fe_core_ext 0.25.0 → 0.26.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: 8d998bdd8ef167a99dd070c92a4ecd4274060e78678aa6f8c4960127d8733993
4
- data.tar.gz: 7e328ffc2d16c7e33518f18cd892f8995e9f5f97b0fcfe2dda2908ab351c3081
3
+ metadata.gz: 90cc42e64a3355c2a471e3232cc907a8abbdb7e7a9fe74b62368e264ae680b55
4
+ data.tar.gz: dbf52bd2f8489954b26a523de1664a5143a84622d1eba120773e9f718845da6e
5
5
  SHA512:
6
- metadata.gz: f9b696b70388b2784625a019132d7408d850f9a0427c36cb1fde8d6c7cb318cd3604a41fd1e5bd3fefd98b127233be1fa7a284d80d1e715a972729e65dce3e29
7
- data.tar.gz: 3f0d3de9784893f88f97863cb4f6b0d55ce64c94024d20553b442db119a7ef7552d165d1e45bb44aef8805ac2b51fd0738039caeda8f1ec81bb7452b0a02e860
6
+ metadata.gz: a33053eca4efeef215fa437ec6e938c24d09f62c0761423b6fee751380cb542644781c5fc0ec9e4c13b05a4c7d0a708486088fb25bab115dae7e2da74a25f908
7
+ data.tar.gz: f1de27fdbeb76b3ae768dc19681595ac152088cf40d34443bbd2b4815964492152d278a67a86d010cb8969f8658be80ed4b629dcf227b25c960a559dab3c58ce
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bigdecimal'
2
4
  require 'bigdecimal/util'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bigdecimal'
2
4
  require 'bigdecimal/util'
3
5
  require 'csv'
@@ -19,4 +21,4 @@ class CSV
19
21
  field
20
22
  end
21
23
  end
22
- end
24
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support'
2
4
  require 'active_support/time'
3
5
 
@@ -18,9 +20,9 @@ module FeCoreExt::CoreExt::Date
18
20
  end
19
21
 
20
22
  def nth_weekday(nth, weekday)
21
- first_day = Date.new(self.year, self.month, 1)
22
- weekdays_hash = {sun: 0, mon: 1, tue: 2, wed: 3, thu: 4, fri: 5, sat: 6}
23
- weekday_dates = (first_day..first_day.end_of_month).select{|d| d.wday == weekdays_hash[weekday]}
23
+ first_day = Date.new(year, month, 1)
24
+ weekdays_hash = { sun: 0, mon: 1, tue: 2, wed: 3, thu: 4, fri: 5, sat: 6 }
25
+ weekday_dates = (first_day..first_day.end_of_month).select { |d| d.wday == weekdays_hash[weekday] }
24
26
  weekday_dates[nth - 1]
25
27
  end
26
28
  end
@@ -29,6 +31,7 @@ module FeCoreExt::CoreExt::DateClassMethods
29
31
  def parsable?(string)
30
32
  parsed_hash = _parse(string)
31
33
  return true if parsed_hash.has_key?(:year) && parsed_hash.has_key?(:mon)
34
+
32
35
  false
33
36
  end
34
37
 
@@ -39,15 +42,15 @@ module FeCoreExt::CoreExt::DateClassMethods
39
42
 
40
43
  def parse_heisei(string)
41
44
  string.match('平成(\d+)年(\d+)月(\d+)日') do
42
- Date.new($1.to_i + 1988, $2.to_i, $3.to_i)
45
+ Date.new(::Regexp.last_match(1).to_i + 1988, ::Regexp.last_match(2).to_i, ::Regexp.last_match(3).to_i)
43
46
  end
44
47
  end
45
48
 
46
49
  def parse_reiwa(string)
47
50
  string.match('令和(\S+)年(\d+)月(\d+)日') do
48
- year = 1 if $1 == '元'
49
- year ||= $1.to_i
50
- Date.new(year + 2018, $2.to_i, $3.to_i)
51
+ year = 1 if ::Regexp.last_match(1) == '元'
52
+ year ||= ::Regexp.last_match(1).to_i
53
+ Date.new(year + 2018, ::Regexp.last_match(2).to_i, ::Regexp.last_match(3).to_i)
51
54
  end
52
55
  end
53
56
 
@@ -57,14 +60,13 @@ module FeCoreExt::CoreExt::DateClassMethods
57
60
 
58
61
  def parse_nengappi(string)
59
62
  string.match(/(\d{4})年(\d+)月(\d+)日/) do
60
- Date.new($1.to_i, $2.to_i, $3.to_i)
63
+ Date.new(::Regexp.last_match(1).to_i, ::Regexp.last_match(2).to_i, ::Regexp.last_match(3).to_i)
61
64
  end
62
65
  end
63
66
 
64
67
  def parse_ja(string)
65
68
  parse_nengappi(string) || parse_gengo(string)
66
69
  end
67
-
68
70
  end
69
71
 
70
72
  class Date
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support'
2
4
  require 'active_support/core_ext/hash'
3
5
 
@@ -5,6 +7,9 @@ module FeCoreExt::CoreExt
5
7
  end
6
8
 
7
9
  module FeCoreExt::CoreExt::Hash
10
+ def symbolize_keys
11
+ transform_keys { |key| key.to_s.underscore.to_sym }
12
+ end
8
13
  end
9
14
 
10
15
  class Hash
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FeCoreExt::CoreExt
2
4
  end
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FeCoreExt::CoreExt
2
4
  end
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pathname'
2
4
  require 'yaml'
3
5
  require 'fileutils'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bigdecimal'
2
4
  require 'bigdecimal/util'
3
5
  require 'pathname'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support'
2
4
  require 'active_support/time'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'uri'
2
4
  require 'fileutils'
3
5
  require 'open-uri'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FeCoreExt
2
- VERSION = '0.25.0'
4
+ VERSION = '0.26.1'
3
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fe_core_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.0
4
+ version: 0.26.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tetsu
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-27 00:00:00.000000000 Z
11
+ date: 2023-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  requirements: []
133
- rubygems_version: 3.1.6
133
+ rubygems_version: 3.2.33
134
134
  signing_key:
135
135
  specification_version: 4
136
136
  summary: Core class extensions