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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b07dfd3cb4b79ad499a3d508eeb9eb3cd965278ee3e52ad78a9c3a463859a2bf
4
- data.tar.gz: c24f1cda6e78bb1e197782fd2672f487917f2e415b8cfd12fe9d26546239a383
3
+ metadata.gz: 599dbe972c098336ab72062ceb66f9801495d5a8de856df2248bdeb7e129cb75
4
+ data.tar.gz: 1bdadf6475a339ebe08fc7b645dff9f080659f595d27053fcd3813a1f1ef94e0
5
5
  SHA512:
6
- metadata.gz: 030ef4d1254507a56ba84ef95872137dbd7bc3fa744112acd0704460221455b9bc89a2b37ab57289b34f1375a3ee07941ca12503f9631aba569891532e5627a7
7
- data.tar.gz: 9729c276bf751075d723cdb5cefdf1960a83f145b48d8513ecfb42424e603b4ad873c18b247bceb4824467c20a51138706631e095505d0271ecea901a0e3f055
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)
@@ -1,3 +1,3 @@
1
1
  module FeCoreExt
2
- VERSION = '0.12.1'
2
+ VERSION = '0.14.1'
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.1
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-07-06 00:00:00.000000000 Z
11
+ date: 2021-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport