fe_core_ext 0.30.0 → 0.32.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fe_core_ext.gemspec +3 -2
- data/lib/fe_core_ext/core_ext/array.rb +41 -40
- data/lib/fe_core_ext/core_ext/csv.rb +0 -7
- data/lib/fe_core_ext/core_ext/date.rb +55 -50
- data/lib/fe_core_ext/core_ext/hash.rb +8 -7
- data/lib/fe_core_ext/core_ext/integer.rb +7 -6
- data/lib/fe_core_ext/core_ext/numeric.rb +7 -6
- data/lib/fe_core_ext/core_ext/pathname.rb +44 -39
- data/lib/fe_core_ext/core_ext/string.rb +102 -101
- data/lib/fe_core_ext/core_ext/time.rb +12 -11
- data/lib/fe_core_ext/core_ext/uri.rb +5 -6
- data/lib/fe_core_ext/gem_ext/ferrum.rb +35 -0
- data/lib/fe_core_ext/gem_ext/selenium_webdriver.rb +41 -37
- data/lib/fe_core_ext/version.rb +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2a87561be521ad11c7d5b9c45c292b44dd806c14e2d4e836df71102bda24b92
|
4
|
+
data.tar.gz: 8f7cb9da94fe4add3c0460a135b2a53ff3ef2b5b4273c2c6531fdff221af7a5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a99aa40c9559997728260c51822d934d324b534f8ed5498cb5b230d23d7ee5aec2163e88634e1307b782d5ce3ad4f8ceeda37ed93f25d513e594fdaaf0f05ee7
|
7
|
+
data.tar.gz: 00277dc37128f4bd68e0abaec8f5eb5fdd67e858bf831072a876c34d9331d344de5d96b0311e7bba238ac6ca3a1c3a9a6a73c52eb69fba40fd6d1a1fb4462b62
|
data/fe_core_ext.gemspec
CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_runtime_dependency "activesupport"
|
23
23
|
spec.add_development_dependency "bundler", "~> 2.1"
|
24
24
|
spec.add_development_dependency "rake", "~> 12.3"
|
25
|
-
|
26
|
-
spec.add_development_dependency "
|
25
|
+
|
26
|
+
spec.add_development_dependency "ferrum"
|
27
|
+
spec.add_development_dependency "selenium-webdriver"
|
27
28
|
end
|
@@ -3,46 +3,47 @@
|
|
3
3
|
require "bigdecimal"
|
4
4
|
require "bigdecimal/util"
|
5
5
|
|
6
|
-
module FeCoreExt
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
6
|
+
module FeCoreExt
|
7
|
+
module CoreExt
|
8
|
+
module Array
|
9
|
+
def median
|
10
|
+
return if empty?
|
11
|
+
sorted = sort
|
12
|
+
len = sorted.length
|
13
|
+
(sorted[(len - 1) / 2] + sorted[len / 2]) / 2.0
|
14
|
+
end
|
15
|
+
|
16
|
+
def mean
|
17
|
+
return if empty?
|
18
|
+
sum.to_d / size
|
19
|
+
end
|
20
|
+
|
21
|
+
# remove, remove_at, remove_if はこちらのものを使わせてもらっています。
|
22
|
+
# https://gist.github.com/nekoTheShadow/2de8a324f445bdde8a67
|
23
|
+
def remove(val)
|
24
|
+
# ブロックが渡されており、かつvalと等しい要素が見つからなかった場合
|
25
|
+
return yield if block_given? && !include?(val)
|
26
|
+
|
27
|
+
temp = dup
|
28
|
+
temp.delete(val)
|
29
|
+
temp
|
30
|
+
end
|
31
|
+
|
32
|
+
def remove_at(pos)
|
33
|
+
temp = dup
|
34
|
+
temp.delete_at(pos)
|
35
|
+
temp
|
36
|
+
end
|
37
|
+
|
38
|
+
def remove_if
|
39
|
+
temp = dup
|
40
|
+
# ブロックを持たない場合
|
41
|
+
return temp.delete_if unless block_given?
|
42
|
+
|
43
|
+
each { |val| temp.delete(val) if yield(val) }
|
44
|
+
temp
|
45
|
+
end
|
46
|
+
end
|
46
47
|
end
|
47
48
|
end
|
48
49
|
|
@@ -4,14 +4,7 @@ require "bigdecimal"
|
|
4
4
|
require "bigdecimal/util"
|
5
5
|
require "csv"
|
6
6
|
|
7
|
-
module FeCoreExt::CoreExt
|
8
|
-
end
|
9
|
-
|
10
|
-
module FeCoreExt::CoreExt::CSV
|
11
|
-
end
|
12
|
-
|
13
7
|
class CSV
|
14
|
-
#include FeCoreExt::CoreExt::CSV
|
15
8
|
Converters[:decimal] = lambda do |field|
|
16
9
|
begin
|
17
10
|
Float(field)
|
@@ -3,69 +3,74 @@
|
|
3
3
|
require "active_support"
|
4
4
|
require "active_support/time"
|
5
5
|
|
6
|
-
module FeCoreExt
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
6
|
+
module FeCoreExt
|
7
|
+
module CoreExt
|
8
|
+
module Date
|
9
|
+
def end_of_month?
|
10
|
+
self == end_of_month
|
11
|
+
end
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
def range(duration)
|
14
|
+
Range.new(*[self + duration, self].minmax)
|
15
|
+
end
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
def to_time_range
|
18
|
+
Range.new(beginning_of_day, end_of_day)
|
19
|
+
end
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
def nth_weekday(nth, weekday)
|
22
|
+
first_day = Date.new(year, month, 1)
|
23
|
+
weekdays_hash = { sun: 0, mon: 1, tue: 2, wed: 3, thu: 4, fri: 5, sat: 6 }
|
24
|
+
weekday_dates = (first_day..first_day.end_of_month).select { |d| d.wday == weekdays_hash[weekday] }
|
25
|
+
weekday_dates[nth - 1]
|
26
|
+
end
|
27
|
+
end
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
30
|
-
module FeCoreExt
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
module FeCoreExt
|
32
|
+
module CoreExt
|
33
|
+
module DateClassMethods
|
34
|
+
def parsable?(string)
|
35
|
+
parsed_hash = _parse(string)
|
36
|
+
return true if parsed_hash.has_key?(:year) && parsed_hash.has_key?(:mon)
|
34
37
|
|
35
|
-
|
36
|
-
|
38
|
+
false
|
39
|
+
end
|
37
40
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
41
|
+
def parse_as_future(string)
|
42
|
+
date = parse(string)
|
43
|
+
date > current ? date : date + 1.year
|
44
|
+
end
|
42
45
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
def parse_heisei(string)
|
47
|
+
string.match('平成(\d+)年(\d+)月(\d+)日') do
|
48
|
+
Date.new(::Regexp.last_match(1).to_i + 1988, ::Regexp.last_match(2).to_i, ::Regexp.last_match(3).to_i)
|
49
|
+
end
|
50
|
+
end
|
48
51
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
52
|
+
def parse_reiwa(string)
|
53
|
+
string.match('令和(\S+)年(\d+)月(\d+)日') do
|
54
|
+
year = 1 if ::Regexp.last_match(1) == "元"
|
55
|
+
year ||= ::Regexp.last_match(1).to_i
|
56
|
+
Date.new(year + 2018, ::Regexp.last_match(2).to_i, ::Regexp.last_match(3).to_i)
|
57
|
+
end
|
58
|
+
end
|
56
59
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
+
def parse_gengo(string)
|
61
|
+
parse_heisei(string) || parse_reiwa(string)
|
62
|
+
end
|
60
63
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
64
|
+
def parse_nengappi(string)
|
65
|
+
string.match(/(\d{4})年(\d+)月(\d+)日/) do
|
66
|
+
Date.new(::Regexp.last_match(1).to_i, ::Regexp.last_match(2).to_i, ::Regexp.last_match(3).to_i)
|
67
|
+
end
|
68
|
+
end
|
66
69
|
|
67
|
-
|
68
|
-
|
70
|
+
def parse_ja(string)
|
71
|
+
parse_nengappi(string) || parse_gengo(string)
|
72
|
+
end
|
73
|
+
end
|
69
74
|
end
|
70
75
|
end
|
71
76
|
|
@@ -3,13 +3,14 @@
|
|
3
3
|
require "active_support"
|
4
4
|
require "active_support/core_ext/hash"
|
5
5
|
|
6
|
-
module FeCoreExt
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
module FeCoreExt
|
7
|
+
module CoreExt
|
8
|
+
module Hash
|
9
|
+
def rename_key(original_key, new_key)
|
10
|
+
self[new_key] = delete(original_key) if key?(original_key)
|
11
|
+
self
|
12
|
+
end
|
13
|
+
end
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
@@ -4,57 +4,62 @@ require "pathname"
|
|
4
4
|
require "yaml"
|
5
5
|
require "fileutils"
|
6
6
|
|
7
|
-
module FeCoreExt
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
7
|
+
module FeCoreExt
|
8
|
+
module CoreExt
|
9
|
+
module Pathname
|
10
|
+
def load_yaml
|
11
|
+
return unless exist?
|
12
|
+
YAML.load_file(self)
|
13
|
+
end
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
def glob(pattern, &block)
|
16
|
+
Pathname.glob(join(pattern), &block)
|
17
|
+
end
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
def existence
|
20
|
+
self if exist?
|
21
|
+
end
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
def touch(options = {})
|
24
|
+
FileUtils.touch(@path, options)
|
25
|
+
end
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
def rm(options = {})
|
28
|
+
FileUtils.rm(self, options)
|
29
|
+
end
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
def mkdir_p
|
32
|
+
mkpath
|
33
|
+
self
|
34
|
+
end
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
def copy(dest)
|
37
|
+
FileUtils.cp(self, dest)
|
38
|
+
end
|
40
39
|
|
41
|
-
|
42
|
-
|
40
|
+
def require_relative
|
41
|
+
Kernel.require_relative(self)
|
42
|
+
end
|
43
|
+
end
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
46
|
-
module FeCoreExt
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
module FeCoreExt
|
48
|
+
module CoreExt
|
49
|
+
module PathnameClassMethods
|
50
|
+
def join(*args)
|
51
|
+
new(File.join(*args))
|
52
|
+
end
|
50
53
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
54
|
+
def mktmpdir(prefix_suffix = nil, tmpdir = nil)
|
55
|
+
if block_given?
|
56
|
+
Dir.mktmpdir prefix_suffix, tmpdir do |dir|
|
57
|
+
yield new(dir)
|
58
|
+
end
|
59
|
+
else
|
60
|
+
new(Dir.mktmpdir(prefix_suffix, tmpdir))
|
61
|
+
end
|
55
62
|
end
|
56
|
-
else
|
57
|
-
new(Dir.mktmpdir(prefix_suffix, tmpdir))
|
58
63
|
end
|
59
64
|
end
|
60
65
|
end
|
@@ -5,107 +5,108 @@ require "bigdecimal/util"
|
|
5
5
|
require "pathname"
|
6
6
|
require "nkf"
|
7
7
|
|
8
|
-
module FeCoreExt
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
8
|
+
module FeCoreExt
|
9
|
+
module CoreExt
|
10
|
+
module String
|
11
|
+
def to_integer
|
12
|
+
return unless valid_number?
|
13
|
+
delete(",").to_i
|
14
|
+
end
|
15
|
+
|
16
|
+
def integer?
|
17
|
+
self.to_integer.to_s == self.delete(",")
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_decimal
|
21
|
+
return unless valid_number?
|
22
|
+
delete(",").to_d
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_decimal_new
|
26
|
+
return unless valid_number?
|
27
|
+
delete(",").to_d
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_float
|
31
|
+
return unless valid_number?
|
32
|
+
delete(",").to_f
|
33
|
+
end
|
34
|
+
|
35
|
+
def valid_sec_code?
|
36
|
+
valid_chars = "[0-9ACDFGHJKLMNPRSTUWXY]"
|
37
|
+
match?(/^\d#{valid_chars}\d#{valid_chars}$/)
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_pathname
|
41
|
+
Pathname(self)
|
42
|
+
end
|
43
|
+
|
44
|
+
def not_number?
|
45
|
+
to_i == 0 && match("0").nil?
|
46
|
+
end
|
47
|
+
|
48
|
+
def valid_number?
|
49
|
+
match?(/^-?([0-9][\d,.]*)$/)
|
50
|
+
end
|
51
|
+
|
52
|
+
## deprecated
|
53
|
+
def zen_to_han
|
54
|
+
tr("0-9A-Za-z &・-()", '0-9A-Za-z &・\-()')
|
55
|
+
end
|
56
|
+
|
57
|
+
def alphanumeric_zen_to_han
|
58
|
+
tr("0-9A-Za-z &・.-()", '0-9A-Za-z &・.\-()')
|
59
|
+
end
|
60
|
+
|
61
|
+
def to_katakana
|
62
|
+
tr("ぁ-ん", "ァ-ン")
|
63
|
+
end
|
64
|
+
|
65
|
+
def match?(str)
|
66
|
+
/#{str}/ === self
|
67
|
+
end
|
68
|
+
|
69
|
+
def kana_upcase
|
70
|
+
tr("ァィゥェォヵヶッャュョヮ", "アイウエオカケツヤユヨワ")
|
71
|
+
end
|
72
|
+
|
73
|
+
def to_han_kana
|
74
|
+
return if self.nil?
|
75
|
+
NKF.nkf("-wxZ4", self)
|
76
|
+
end
|
77
|
+
|
78
|
+
def to_zen_kana
|
79
|
+
return if self.nil?
|
80
|
+
NKF.nkf("-wX", self)
|
81
|
+
end
|
82
|
+
|
83
|
+
def to_date_in_ja
|
84
|
+
to_date_in_ja_seireki || to_date_in_ja_heisei
|
85
|
+
end
|
86
|
+
|
87
|
+
def to_date_in_ja_seireki
|
88
|
+
match(/(\d{4})年(\d{1,2})月(\d{1,2})日/) { Date.new($1.to_i, $2.to_i, $3.to_i) }
|
89
|
+
end
|
90
|
+
|
91
|
+
def to_date_in_ja_heisei
|
92
|
+
match(/平成(\d{2})年(\d{1,2})月(\d{1,2})日/) { Date.new($1.to_i + 1988, $2.to_i, $3.to_i) }
|
93
|
+
end
|
94
|
+
|
95
|
+
# remove also no break space and other space like characters.
|
96
|
+
def strong_strip
|
97
|
+
reverse.gsub(/^\p{Zs}+|^\p{Cf}+/, "").reverse.gsub(/^\p{Zs}+|^\p{Cf}+/, "")
|
98
|
+
end
|
99
|
+
|
100
|
+
def sjis_encodable
|
101
|
+
tr("\u301C\u2212\u00A2\u00A3\u00AC\u2014\u2016",
|
102
|
+
"\uFF5E\uFF0D\uFFE0\uFFE1\uFFE2\u2015\u2225")
|
103
|
+
end
|
104
|
+
|
105
|
+
def eucjp_encodable
|
106
|
+
tr("\uFF5E\uFF0D\uFFE0\uFFE1\uFFE2\u2015\u2225",
|
107
|
+
"\u301C\u2212\u00A2\u00A3\u00AC\u2014\u2016")
|
108
|
+
end
|
109
|
+
end
|
109
110
|
end
|
110
111
|
end
|
111
112
|
|
@@ -3,16 +3,17 @@
|
|
3
3
|
require "active_support"
|
4
4
|
require "active_support/time"
|
5
5
|
|
6
|
-
module FeCoreExt
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
6
|
+
module FeCoreExt
|
7
|
+
module CoreExt
|
8
|
+
module Time
|
9
|
+
def floor(unit = :sec)
|
10
|
+
case unit
|
11
|
+
when :sec
|
12
|
+
Time.zone.local(year, month, day, hour, min, sec)
|
13
|
+
else
|
14
|
+
self
|
15
|
+
end
|
16
|
+
end
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
@@ -23,4 +24,4 @@ end
|
|
23
24
|
class Time
|
24
25
|
include FeCoreExt::CoreExt::Time
|
25
26
|
extend FeCoreExt::CoreExt::TimeClassMethods
|
26
|
-
end
|
27
|
+
end
|
@@ -5,9 +5,6 @@ require "fileutils"
|
|
5
5
|
require "open-uri"
|
6
6
|
require "net/http"
|
7
7
|
|
8
|
-
module FeCoreExt::CoreExt
|
9
|
-
end
|
10
|
-
|
11
8
|
module URI
|
12
9
|
def download(file)
|
13
10
|
warn "URI#downloadの引数にはPathnameを使いましょう!" if file.is_a?(String)
|
@@ -27,8 +24,10 @@ module URI
|
|
27
24
|
end
|
28
25
|
end
|
29
26
|
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
module URI
|
28
|
+
class Generic
|
29
|
+
def basename
|
30
|
+
::File.basename(path)
|
31
|
+
end
|
33
32
|
end
|
34
33
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ferrum
|
4
|
+
class Browser
|
5
|
+
delegate :wait_for_css, :wait_for_xpath, to: :page
|
6
|
+
end
|
7
|
+
|
8
|
+
class Page
|
9
|
+
delegate :wait_for_css, :wait_for_xpath, to: :main_frame
|
10
|
+
end
|
11
|
+
|
12
|
+
class Frame
|
13
|
+
module DOM
|
14
|
+
def wait_for_css(selector, timeout: 3)
|
15
|
+
wait_for_selector(selector, :at_css, timeout)
|
16
|
+
end
|
17
|
+
|
18
|
+
def wait_for_xpath(selector, timeout: 3)
|
19
|
+
wait_for_selector(selector, :at_xpath, timeout)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def wait_for_selector(selector, selector_method, timeout)
|
25
|
+
interval = 0.1
|
26
|
+
(timeout / interval).to_i.times do
|
27
|
+
node = send(selector_method, selector)
|
28
|
+
return node if node
|
29
|
+
sleep(interval)
|
30
|
+
end
|
31
|
+
nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -1,46 +1,50 @@
|
|
1
|
-
module Selenium
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
module Selenium
|
2
|
+
module WebDriver
|
3
|
+
module Find
|
4
|
+
def find_element_without_no_element_error(*args)
|
5
|
+
find_element(*args)
|
6
|
+
rescue Selenium::WebDriver::Error::NoSuchElementError
|
7
|
+
nil
|
8
|
+
end
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
def find_elements_without_no_element_error(*args)
|
11
|
+
find_elements(*args)
|
12
|
+
rescue Selenium::WebDriver::Error::NoSuchElementError
|
13
|
+
nil
|
14
|
+
end
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
def at_xpath(path, wait: nil)
|
17
|
+
if wait.present?
|
18
|
+
driver_wait = Selenium::WebDriver::Wait.new(timeout: wait)
|
19
|
+
driver_wait.until { find_element_without_no_element_error(:xpath, path) }
|
20
|
+
end
|
21
|
+
find_element_without_no_element_error(:xpath, path)
|
22
|
+
end
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
def xpath(path, wait: nil)
|
25
|
+
if wait.present?
|
26
|
+
driver_wait = Selenium::WebDriver::Wait.new(timeout: wait)
|
27
|
+
driver_wait.until { find_elements_without_no_element_error(:xpath, path) }
|
28
|
+
end
|
29
|
+
find_elements_without_no_element_error(:xpath, path)
|
30
|
+
end
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
def at_css(path, wait: nil)
|
33
|
+
if wait.present?
|
34
|
+
driver_wait = Selenium::WebDriver::Wait.new(timeout: wait)
|
35
|
+
driver_wait.until { find_element_without_no_element_error(:css, path) }
|
36
|
+
end
|
37
|
+
find_element_without_no_element_error(:css, path)
|
38
|
+
end
|
37
39
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
40
|
+
def css(path, wait: nil)
|
41
|
+
if wait.present?
|
42
|
+
driver_wait = Selenium::WebDriver::Wait.new(timeout: wait)
|
43
|
+
driver_wait.until { find_elements_without_no_element_error(:css, path) }
|
44
|
+
end
|
45
|
+
find_elements_without_no_element_error(:css, path)
|
46
|
+
end
|
42
47
|
end
|
43
|
-
find_elements_without_no_element_error(:css, path)
|
44
48
|
end
|
45
49
|
end
|
46
50
|
|
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.32.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tetsu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -53,31 +53,31 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '12.3'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: ferrum
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: selenium-webdriver
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: Core class extensions that doesn't supported by active_recored core_ext
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- lib/fe_core_ext/core_ext/time.rb
|
110
110
|
- lib/fe_core_ext/core_ext/uri.rb
|
111
111
|
- lib/fe_core_ext/gem_ext.rb
|
112
|
+
- lib/fe_core_ext/gem_ext/ferrum.rb
|
112
113
|
- lib/fe_core_ext/gem_ext/selenium_webdriver.rb
|
113
114
|
- lib/fe_core_ext/version.rb
|
114
115
|
homepage: http://github.com/ironsand/fe_core_ext
|