fe_core_ext 0.12.0 → 0.14.0

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: d1eb5166f19707b3c70423e41f4d684d42efb95fc2e1a05783f89932c1e6d749
4
- data.tar.gz: 924a817b2c1dd13aa3930ed80bd59be04240496febe81a2bbfe6bca1153e6a2c
3
+ metadata.gz: 5ffc87e87a8dcc8965078c089a5b998a6d187414768289828efad5242ef22cb9
4
+ data.tar.gz: 5bb29b2d75f56cd4273efe71865baa9f7afbe42dce03ac5f093a44468081e790
5
5
  SHA512:
6
- metadata.gz: 211a97a14d2d271f876408ccc7bb9b1d4e5a895192413ac005126aebffd72655c6195bd92475e792630b03e7e6df74bc83c35b155eb60c173eeee1786cf373b8
7
- data.tar.gz: 2304b86ca90dbd5a97d8c7baaacee728fdeefa29540e650ea196f6d5b3d520bf412077b5a7a904960d596dff94fea8ecfec14ad6391401b9ac1585a0a66a6817
6
+ metadata.gz: d312f23a7b35e8a50514a5b03307d1cd20827f25a1b6b69d078ebefb5b0bf40c9ebb38d5b3ac0eee7fd6db4e398391bb30b5b033c788179512e867e3b6b28f2b
7
+ data.tar.gz: fb9c6be1641b7c7e8ecf58d23b40fb6e4722193de794ae84e501058fbdefbf5de88bcdc5c0a41e7223d6dd47bfe4a3266b9f5cc6b1ba5b28d49b3765937dce4e
@@ -34,22 +34,33 @@ module FeCoreExt::CoreExt::DateClassMethods
34
34
  end
35
35
 
36
36
  def parse_heisei(string)
37
- string.match('平成(\d+)年(\d+)月(\d+)日') {
37
+ string.match('平成(\d+)年(\d+)月(\d+)日') do
38
38
  Date.new($1.to_i + 1988, $2.to_i, $3.to_i)
39
- }
39
+ end
40
40
  end
41
41
 
42
42
  def parse_reiwa(string)
43
- string.match('令和(\S+)年(\d+)月(\d+)日') {
43
+ string.match('令和(\S+)年(\d+)月(\d+)日') do
44
44
  year = 1 if $1 == '元'
45
45
  year ||= $1.to_i
46
46
  Date.new(year + 2018, $2.to_i, $3.to_i)
47
- }
47
+ end
48
48
  end
49
49
 
50
50
  def parse_gengo(string)
51
51
  parse_heisei(string) || parse_reiwa(string)
52
52
  end
53
+
54
+ def parse_nengappi(string)
55
+ string.match(/(\d{4})年(\d+)月(\d+)日/) do
56
+ Date.new($1.to_i, $2.to_i, $3.to_i)
57
+ end
58
+ end
59
+
60
+ def parse_ja(string)
61
+ parse_nengappi(string) || parse_gengo(string)
62
+ end
63
+
53
64
  end
54
65
 
55
66
  class Date
@@ -1,4 +1,5 @@
1
1
  require 'uri'
2
+ require 'fileutils'
2
3
  require 'open-uri'
3
4
  require 'net/http'
4
5
 
@@ -8,11 +9,15 @@ end
8
9
  module URI
9
10
  def download(file)
10
11
  binary = OpenURI.open_uri(self).read
11
- File.open(file, 'wb') {|f| f.write(binary)}
12
+ dirname = ::File.dirname(file)
13
+ unless ::File.directory?(dirname)
14
+ ::FileUtils.mkdir_p(dirname)
15
+ end
16
+ ::File.open(file, 'wb') {|f| f.write(binary)}
12
17
  end
13
18
 
14
19
  def exists?
15
- req = Net::HTTP.new(host, port)
20
+ req = ::Net::HTTP.new(host, port)
16
21
  req.use_ssl = true if scheme == 'https'
17
22
  res = req.request_head(path)
18
23
  return URI(res['location']).exists? if %w(301 302).include?(res.code)
@@ -1,3 +1,3 @@
1
1
  module FeCoreExt
2
- VERSION = '0.12.0'
2
+ VERSION = '0.14.0'
3
3
  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.12.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tetsu
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-29 00:00:00.000000000 Z
11
+ date: 2021-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -130,8 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  requirements: []
133
- rubyforge_project:
134
- rubygems_version: 2.7.6.2
133
+ rubygems_version: 3.1.6
135
134
  signing_key:
136
135
  specification_version: 4
137
136
  summary: Core class extensions