fe_core_ext 0.12.1 → 0.14.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fe_core_ext/core_ext/date.rb +15 -4
- data/lib/fe_core_ext/core_ext/uri.rb +6 -1
- data/lib/fe_core_ext/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 599dbe972c098336ab72062ceb66f9801495d5a8de856df2248bdeb7e129cb75
|
4
|
+
data.tar.gz: 1bdadf6475a339ebe08fc7b645dff9f080659f595d27053fcd3813a1f1ef94e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60113a88a3353eba78e9fcedbcd2d4ccf520e147e20a9fd4b059936a287e74998abc914037fc1ac081ad29ebb215f7a14629b9794fdd31a931c8a229817d2cbb
|
7
|
+
data.tar.gz: bb2a725187a335a65f5a3e60661626aae269a70b4b91187b144477f03e4778cd42f834d2e29a19175cdd506a1b0aac523b0b8822cbc91818fabb2b56dc29fbb4
|
@@ -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
|
12
|
+
dirname = ::File.dirname(file)
|
13
|
+
unless ::File.directory?(dirname)
|
14
|
+
::FileUtils.mkdir_p(dirname)
|
15
|
+
end
|
11
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)
|
data/lib/fe_core_ext/version.rb
CHANGED
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.
|
4
|
+
version: 0.14.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tetsu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|