rggen-core 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +2 -2
- data/lib/rggen/core.rb +0 -1
- data/lib/rggen/core/input_base/feature.rb +1 -1
- data/lib/rggen/core/input_base/input_matcher.rb +15 -16
- data/lib/rggen/core/input_base/yaml_loader.rb +21 -17
- data/lib/rggen/core/version.rb +1 -1
- metadata +5 -6
- data/lib/rggen/core/core_extensions/casecmp.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07b141658bda7d5c43afba30ecbff539ab05beb383844f5a5b8fc9d9b605ebb5
|
4
|
+
data.tar.gz: faac4148e8c6c2e1bfa2632e1e1a589139db03280e3d25af8d39a1172708950e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4838ab9d430ae360da7d223db91171e4460221ecec07e8ed475053eec91ed3a6af1ac10f62350731fb9593e34d7c332f135e68d4d459290cc440b9c7b882065e
|
7
|
+
data.tar.gz: 696f4186513d88b855434a295182dea303b54c52b6a04c251bb8a8dd2910bbeb42147abd9dfe292e28e42c91e4aba4971901490895b3685d375a18c988dd9d70
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
[](https://badge.fury.io/rb/rggen-core)
|
2
|
-
[](https://github.com/rggen/rggen-core/actions?query=workflow%3ACI)
|
3
3
|
[](https://codeclimate.com/github/rggen/rggen-core/maintainability)
|
4
4
|
[](https://codecov.io/gh/rggen/rggen-core)
|
5
5
|
[](https://sonarcloud.io/dashboard?id=rggen_rggen-core)
|
@@ -43,7 +43,7 @@ Feedbacks, bug reports, questions and etc. are wellcome! You can post them by us
|
|
43
43
|
|
44
44
|
## Copyright & License
|
45
45
|
|
46
|
-
Copyright © 2017-
|
46
|
+
Copyright © 2017-2020 Taichi Ishitani. RgGen::Core is licensed under the [MIT License](https://opensource.org/licenses/MIT), see [LICENSE](LICENSE) for futher details.
|
47
47
|
|
48
48
|
## Code of Conduct
|
49
49
|
|
data/lib/rggen/core.rb
CHANGED
@@ -44,7 +44,7 @@ module RgGen
|
|
44
44
|
|
45
45
|
def input_pattern(pattern_or_patterns, **options, &converter)
|
46
46
|
@input_matcher =
|
47
|
-
InputMatcher.new(pattern_or_patterns, options, &converter)
|
47
|
+
InputMatcher.new(pattern_or_patterns, **options, &converter)
|
48
48
|
end
|
49
49
|
|
50
50
|
attr_reader :input_matcher
|
@@ -4,7 +4,7 @@ module RgGen
|
|
4
4
|
module Core
|
5
5
|
module InputBase
|
6
6
|
class InputMatcher
|
7
|
-
def initialize(pattern_or_patterns, options, &converter)
|
7
|
+
def initialize(pattern_or_patterns, **options, &converter)
|
8
8
|
@options = options
|
9
9
|
@converter = converter
|
10
10
|
@patterns = format_patterns(pattern_or_patterns)
|
@@ -22,23 +22,22 @@ module RgGen
|
|
22
22
|
|
23
23
|
private
|
24
24
|
|
25
|
-
def format_patterns(
|
25
|
+
def format_patterns(pattern_or_patterns)
|
26
26
|
if @options.fetch(:match_wholly, true)
|
27
|
-
|
28
|
-
.
|
29
|
-
.to_h
|
27
|
+
expand_patterns(pattern_or_patterns)
|
28
|
+
.transform_values { |pattern| /\A#{pattern}\z/ }
|
30
29
|
else
|
31
|
-
|
30
|
+
expand_patterns(pattern_or_patterns)
|
32
31
|
end
|
33
32
|
end
|
34
33
|
|
35
|
-
def
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
.
|
41
|
-
|
34
|
+
def expand_patterns(pattern_or_patterns)
|
35
|
+
Array(pattern_or_patterns).each_with_object({}) do |pattern, patterns|
|
36
|
+
if pattern.is_a? Hash
|
37
|
+
patterns.update(pattern)
|
38
|
+
else
|
39
|
+
patterns[patterns.size] = pattern
|
40
|
+
end
|
42
41
|
end
|
43
42
|
end
|
44
43
|
|
@@ -62,11 +61,11 @@ module RgGen
|
|
62
61
|
end
|
63
62
|
|
64
63
|
def match_patterns(rhs)
|
65
|
-
|
64
|
+
index, match_data =
|
66
65
|
@patterns
|
67
|
-
.
|
66
|
+
.transform_values { |pattern| pattern.match(rhs) }
|
68
67
|
.compact
|
69
|
-
.
|
68
|
+
.max_by { |_, m| m[0].length }
|
70
69
|
match_data && [convert_match_data(match_data), index]
|
71
70
|
end
|
72
71
|
|
@@ -6,34 +6,38 @@ module RgGen
|
|
6
6
|
module YAMLLoader
|
7
7
|
private
|
8
8
|
|
9
|
-
|
10
|
-
result = yaml_safe_load(File.binread(file), file)
|
11
|
-
symbolize_key(result)
|
12
|
-
end
|
13
|
-
|
14
|
-
if Psych::VERSION >= '3.1.0'
|
9
|
+
if RUBY_VERSION >= '2.6.0'
|
15
10
|
def yaml_safe_load(yaml, file)
|
16
11
|
YAML.safe_load(
|
17
12
|
yaml,
|
18
|
-
permitted_classes: [Symbol], aliases: true, filename: file
|
13
|
+
permitted_classes: [Symbol], aliases: true, filename: file,
|
14
|
+
symbolize_names: true
|
19
15
|
)
|
20
16
|
end
|
17
|
+
elsif RUBY_VERSION >= '2.5.0'
|
18
|
+
def yaml_safe_load(yaml, file)
|
19
|
+
YAML.safe_load(yaml, [Symbol], [], true, file, symbolize_names: true)
|
20
|
+
end
|
21
21
|
else
|
22
22
|
def yaml_safe_load(yaml, file)
|
23
|
-
YAML.safe_load(yaml, [Symbol], [], true, file)
|
23
|
+
reuslt = YAML.safe_load(yaml, [Symbol], [], true, file)
|
24
|
+
symbolize_keys(reuslt)
|
24
25
|
end
|
25
|
-
end
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
def symbolize_keys(result)
|
28
|
+
if result.is_a? Hash
|
29
|
+
result.keys.each do |key|
|
30
|
+
result[key.to_sym] = symbolize_keys(result.delete(key))
|
31
|
+
end
|
32
|
+
elsif result.is_a? Array
|
33
|
+
result.map! { |value| symbolize_keys(value) }
|
32
34
|
end
|
33
|
-
|
34
|
-
result.map! { |value| symbolize_key(value) }
|
35
|
+
result
|
35
36
|
end
|
36
|
-
|
37
|
+
end
|
38
|
+
|
39
|
+
def load_yaml(file)
|
40
|
+
yaml_safe_load(File.binread(file), file)
|
37
41
|
end
|
38
42
|
end
|
39
43
|
end
|
data/lib/rggen/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rggen-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taichi Ishitani
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docile
|
@@ -111,7 +111,6 @@ files:
|
|
111
111
|
- lib/rggen/core/configuration/loader.rb
|
112
112
|
- lib/rggen/core/configuration/ruby_loader.rb
|
113
113
|
- lib/rggen/core/configuration/yaml_loader.rb
|
114
|
-
- lib/rggen/core/core_extensions/casecmp.rb
|
115
114
|
- lib/rggen/core/core_extensions/object.rb
|
116
115
|
- lib/rggen/core/dsl.rb
|
117
116
|
- lib/rggen/core/exceptions.rb
|
@@ -177,15 +176,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
177
176
|
requirements:
|
178
177
|
- - ">="
|
179
178
|
- !ruby/object:Gem::Version
|
180
|
-
version: '2.
|
179
|
+
version: '2.4'
|
181
180
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
181
|
requirements:
|
183
182
|
- - ">="
|
184
183
|
- !ruby/object:Gem::Version
|
185
184
|
version: '0'
|
186
185
|
requirements: []
|
187
|
-
rubygems_version: 3.
|
186
|
+
rubygems_version: 3.1.2
|
188
187
|
signing_key:
|
189
188
|
specification_version: 4
|
190
|
-
summary: rggen-core-0.
|
189
|
+
summary: rggen-core-0.19.0
|
191
190
|
test_files: []
|