fe_core_ext 0.29.0 → 0.29.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -7
- data/Rakefile +1 -1
- data/fe_core_ext.gemspec +19 -19
- data/lib/fe_core_ext/core_ext/array.rb +3 -4
- data/lib/fe_core_ext/core_ext/csv.rb +3 -4
- data/lib/fe_core_ext/core_ext/date.rb +3 -3
- data/lib/fe_core_ext/core_ext/hash.rb +2 -2
- data/lib/fe_core_ext/core_ext/numeric.rb +1 -1
- data/lib/fe_core_ext/core_ext/pathname.rb +6 -6
- data/lib/fe_core_ext/core_ext/string.rb +19 -19
- data/lib/fe_core_ext/core_ext/time.rb +2 -2
- data/lib/fe_core_ext/core_ext/uri.rb +10 -10
- data/lib/fe_core_ext/gem_ext/selenium_webdriver.rb +1 -1
- data/lib/fe_core_ext/gem_ext.rb +1 -1
- data/lib/fe_core_ext/version.rb +1 -1
- data/lib/fe_core_ext.rb +11 -11
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b9b658d86946ccac8f368b46e7bd11499a06a47c74b4c8edca54ef9b8ce4229
|
4
|
+
data.tar.gz: 2b2bf7e6016b90e168a17ca20e05a875f34c2ca9ea2553fbd23f63b6dad01b21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 360a5dba67f0b6c9d6a7efc9d1cc7ff6ac924b28b3d4bac62c7442181cecf10f9bb274815950f67d966257b9237eff4cd0c2152f8a9feeb5d9c95d65d69bd024
|
7
|
+
data.tar.gz: e8f828991168666de4055110e65f082983400b9daec27bce0e307d055dd93357e1e99ac1675941b568841cf7945c4ac76fa04616584d79e31805ae8fcce480f3
|
data/Gemfile
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in fe_core_ext.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
gem
|
7
|
-
gem
|
8
|
-
gem
|
9
|
-
gem
|
10
|
-
gem
|
11
|
-
|
6
|
+
gem "bigdecimal"
|
7
|
+
gem "timecop"
|
8
|
+
gem "test-unit"
|
9
|
+
gem "pry"
|
10
|
+
gem "awesome_print"
|
data/Rakefile
CHANGED
data/fe_core_ext.gemspec
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
lib = File.expand_path(
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
4
|
+
require "fe_core_ext/version"
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name
|
8
|
-
spec.version
|
9
|
-
spec.authors
|
10
|
-
spec.email
|
7
|
+
spec.name = "fe_core_ext"
|
8
|
+
spec.version = FeCoreExt::VERSION
|
9
|
+
spec.authors = ["Tetsu"]
|
10
|
+
spec.email = ["eisensand@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary
|
13
|
-
spec.description
|
14
|
-
spec.homepage
|
15
|
-
spec.license
|
12
|
+
spec.summary = %q{Core class extensions}
|
13
|
+
spec.description = %q{Core class extensions that doesn't supported by active_recored core_ext}
|
14
|
+
spec.homepage = "http://github.com/ironsand/fe_core_ext"
|
15
|
+
spec.license = "MIT"
|
16
16
|
|
17
|
-
spec.files
|
18
|
-
spec.bindir
|
19
|
-
spec.executables
|
20
|
-
spec.require_paths = [
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.add_runtime_dependency
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
22
|
+
spec.add_runtime_dependency "activesupport"
|
23
|
+
spec.add_development_dependency "bundler", "~> 2.1"
|
24
|
+
spec.add_development_dependency "rake", "~> 12.3"
|
25
|
+
spec.add_development_dependency "rspec", "~> 0"
|
26
|
+
spec.add_development_dependency "selenium-webdriver", "~> 0"
|
27
27
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "bigdecimal"
|
4
|
+
require "bigdecimal/util"
|
5
5
|
|
6
6
|
module FeCoreExt::CoreExt
|
7
7
|
end
|
@@ -41,10 +41,9 @@ module FeCoreExt::CoreExt::Array
|
|
41
41
|
# ブロックを持たない場合
|
42
42
|
return temp.delete_if unless block_given?
|
43
43
|
|
44
|
-
self.each{|val| temp.delete(val) if yield(val)}
|
44
|
+
self.each { |val| temp.delete(val) if yield(val) }
|
45
45
|
temp
|
46
46
|
end
|
47
|
-
|
48
47
|
end
|
49
48
|
|
50
49
|
class Array
|
@@ -1,14 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "bigdecimal"
|
4
|
+
require "bigdecimal/util"
|
5
|
+
require "csv"
|
6
6
|
|
7
7
|
module FeCoreExt::CoreExt
|
8
8
|
end
|
9
9
|
|
10
10
|
module FeCoreExt::CoreExt::CSV
|
11
|
-
|
12
11
|
end
|
13
12
|
|
14
13
|
class CSV
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "active_support"
|
4
|
+
require "active_support/time"
|
5
5
|
|
6
6
|
module FeCoreExt::CoreExt
|
7
7
|
end
|
@@ -48,7 +48,7 @@ module FeCoreExt::CoreExt::DateClassMethods
|
|
48
48
|
|
49
49
|
def parse_reiwa(string)
|
50
50
|
string.match('令和(\S+)年(\d+)月(\d+)日') do
|
51
|
-
year = 1 if ::Regexp.last_match(1) ==
|
51
|
+
year = 1 if ::Regexp.last_match(1) == "元"
|
52
52
|
year ||= ::Regexp.last_match(1).to_i
|
53
53
|
Date.new(year + 2018, ::Regexp.last_match(2).to_i, ::Regexp.last_match(3).to_i)
|
54
54
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "pathname"
|
4
|
+
require "yaml"
|
5
|
+
require "fileutils"
|
6
6
|
|
7
7
|
module FeCoreExt::CoreExt
|
8
8
|
end
|
@@ -21,11 +21,11 @@ module FeCoreExt::CoreExt::Pathname
|
|
21
21
|
self if exist?
|
22
22
|
end
|
23
23
|
|
24
|
-
def touch(options={})
|
24
|
+
def touch(options = {})
|
25
25
|
FileUtils.touch(@path, options)
|
26
26
|
end
|
27
27
|
|
28
|
-
def rm(options={})
|
28
|
+
def rm(options = {})
|
29
29
|
FileUtils.rm(self, options)
|
30
30
|
end
|
31
31
|
|
@@ -48,7 +48,7 @@ module FeCoreExt::CoreExt::PathnameClassMethods
|
|
48
48
|
new(File.join(*args))
|
49
49
|
end
|
50
50
|
|
51
|
-
def mktmpdir(prefix_suffix=nil, tmpdir=nil)
|
51
|
+
def mktmpdir(prefix_suffix = nil, tmpdir = nil)
|
52
52
|
if block_given?
|
53
53
|
Dir.mktmpdir prefix_suffix, tmpdir do |dir|
|
54
54
|
yield new(dir)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
3
|
+
require "bigdecimal"
|
4
|
+
require "bigdecimal/util"
|
5
|
+
require "pathname"
|
6
|
+
require "nkf"
|
7
7
|
|
8
8
|
module FeCoreExt::CoreExt
|
9
9
|
end
|
@@ -11,26 +11,26 @@ end
|
|
11
11
|
module FeCoreExt::CoreExt::String
|
12
12
|
def to_integer
|
13
13
|
return unless valid_number?
|
14
|
-
delete(
|
14
|
+
delete(",").to_i
|
15
15
|
end
|
16
16
|
|
17
17
|
def integer?
|
18
|
-
self.to_integer.to_s == self.delete(
|
18
|
+
self.to_integer.to_s == self.delete(",")
|
19
19
|
end
|
20
20
|
|
21
21
|
def to_decimal
|
22
22
|
return unless valid_number?
|
23
|
-
delete(
|
23
|
+
delete(",").to_d
|
24
24
|
end
|
25
25
|
|
26
26
|
def to_decimal_new
|
27
27
|
return unless valid_number?
|
28
|
-
delete(
|
28
|
+
delete(",").to_d
|
29
29
|
end
|
30
30
|
|
31
31
|
def to_float
|
32
32
|
return unless valid_number?
|
33
|
-
delete(
|
33
|
+
delete(",").to_f
|
34
34
|
end
|
35
35
|
|
36
36
|
def to_pathname
|
@@ -38,7 +38,7 @@ module FeCoreExt::CoreExt::String
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def not_number?
|
41
|
-
to_i == 0 && match(
|
41
|
+
to_i == 0 && match("0").nil?
|
42
42
|
end
|
43
43
|
|
44
44
|
def valid_number?
|
@@ -47,15 +47,15 @@ module FeCoreExt::CoreExt::String
|
|
47
47
|
|
48
48
|
## deprecated
|
49
49
|
def zen_to_han
|
50
|
-
tr(
|
50
|
+
tr("0-9A-Za-z &・-()", '0-9A-Za-z &・\-()')
|
51
51
|
end
|
52
52
|
|
53
53
|
def alphanumeric_zen_to_han
|
54
|
-
tr(
|
54
|
+
tr("0-9A-Za-z &・.-()", '0-9A-Za-z &・.\-()')
|
55
55
|
end
|
56
56
|
|
57
57
|
def to_katakana
|
58
|
-
tr(
|
58
|
+
tr("ぁ-ん", "ァ-ン")
|
59
59
|
end
|
60
60
|
|
61
61
|
def match?(str)
|
@@ -63,17 +63,17 @@ module FeCoreExt::CoreExt::String
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def kana_upcase
|
66
|
-
tr(
|
66
|
+
tr("ァィゥェォヵヶッャュョヮ", "アイウエオカケツヤユヨワ")
|
67
67
|
end
|
68
68
|
|
69
69
|
def to_han_kana
|
70
70
|
return if self.nil?
|
71
|
-
NKF.nkf(
|
71
|
+
NKF.nkf("-wxZ4", self)
|
72
72
|
end
|
73
73
|
|
74
74
|
def to_zen_kana
|
75
75
|
return if self.nil?
|
76
|
-
NKF.nkf(
|
76
|
+
NKF.nkf("-wX", self)
|
77
77
|
end
|
78
78
|
|
79
79
|
def to_date_in_ja
|
@@ -81,16 +81,16 @@ module FeCoreExt::CoreExt::String
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def to_date_in_ja_seireki
|
84
|
-
match(/(\d{4})年(\d{1,2})月(\d{1,2})日/) {Date.new($1.to_i, $2.to_i, $3.to_i)}
|
84
|
+
match(/(\d{4})年(\d{1,2})月(\d{1,2})日/) { Date.new($1.to_i, $2.to_i, $3.to_i) }
|
85
85
|
end
|
86
86
|
|
87
87
|
def to_date_in_ja_heisei
|
88
|
-
match(/平成(\d{2})年(\d{1,2})月(\d{1,2})日/) {Date.new($1.to_i + 1988, $2.to_i, $3.to_i)}
|
88
|
+
match(/平成(\d{2})年(\d{1,2})月(\d{1,2})日/) { Date.new($1.to_i + 1988, $2.to_i, $3.to_i) }
|
89
89
|
end
|
90
90
|
|
91
91
|
# remove also no break space and other space like characters.
|
92
92
|
def strong_strip
|
93
|
-
reverse.gsub(/^\p{Zs}+|^\p{Cf}+/,
|
93
|
+
reverse.gsub(/^\p{Zs}+|^\p{Cf}+/, "").reverse.gsub(/^\p{Zs}+|^\p{Cf}+/, "")
|
94
94
|
end
|
95
95
|
|
96
96
|
def sjis_encodable
|
@@ -1,29 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
3
|
+
require "uri"
|
4
|
+
require "fileutils"
|
5
|
+
require "open-uri"
|
6
|
+
require "net/http"
|
7
7
|
|
8
8
|
module FeCoreExt::CoreExt
|
9
9
|
end
|
10
10
|
|
11
11
|
module URI
|
12
12
|
def download(file)
|
13
|
-
warn
|
13
|
+
warn "URI#downloadの引数にはPathnameを使いましょう!" if file.is_a?(String)
|
14
14
|
binary = OpenURI.open_uri(self).read
|
15
|
-
file = file + self.basename if file.to_s[-1] ==
|
15
|
+
file = file + self.basename if file.to_s[-1] == "/"
|
16
16
|
dirname = ::File.dirname(file)
|
17
17
|
::FileUtils.mkdir_p(dirname) unless ::File.directory?(dirname)
|
18
|
-
::File.open(file,
|
18
|
+
::File.open(file, "wb") { |f| f.write(binary) }
|
19
19
|
end
|
20
20
|
|
21
21
|
def exists?
|
22
22
|
req = ::Net::HTTP.new(host, port)
|
23
|
-
req.use_ssl = true if scheme ==
|
23
|
+
req.use_ssl = true if scheme == "https"
|
24
24
|
res = req.request_head(path)
|
25
|
-
return URI(res[
|
26
|
-
res.code ==
|
25
|
+
return URI(res["location"]).exists? if %w(301 302).include?(res.code)
|
26
|
+
res.code == "200"
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
data/lib/fe_core_ext/gem_ext.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require "fe_core_ext/gem_ext/selenium_webdriver"
|
data/lib/fe_core_ext/version.rb
CHANGED
data/lib/fe_core_ext.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
require_relative
|
2
|
-
require_relative
|
3
|
-
require_relative
|
4
|
-
require_relative
|
5
|
-
require_relative
|
6
|
-
require_relative
|
7
|
-
require_relative
|
8
|
-
require_relative
|
9
|
-
require_relative
|
10
|
-
require_relative
|
11
|
-
require_relative
|
1
|
+
require_relative "fe_core_ext/version"
|
2
|
+
require_relative "fe_core_ext/core_ext/array"
|
3
|
+
require_relative "fe_core_ext/core_ext/csv"
|
4
|
+
require_relative "fe_core_ext/core_ext/date"
|
5
|
+
require_relative "fe_core_ext/core_ext/hash"
|
6
|
+
require_relative "fe_core_ext/core_ext/integer"
|
7
|
+
require_relative "fe_core_ext/core_ext/numeric"
|
8
|
+
require_relative "fe_core_ext/core_ext/pathname"
|
9
|
+
require_relative "fe_core_ext/core_ext/string"
|
10
|
+
require_relative "fe_core_ext/core_ext/time"
|
11
|
+
require_relative "fe_core_ext/core_ext/uri"
|
12
12
|
|
13
13
|
module FeCoreExt
|
14
14
|
end
|