pokotarou 1.2.1 → 1.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb37e93ab913cfc45d6bb0c06cbfec3149ac957e0592ef12d62f1ad6d3b0146e
4
- data.tar.gz: c67cccf940b65008a991684a9603a99395aca02a9137613331680dc23612b841
3
+ metadata.gz: 12597f8db907a8280e94b6007de1bdd0b77e63501a3123f202e6fec7786c7bcd
4
+ data.tar.gz: 15072090ef575f4e34eba0e403c04552f22046a3ca1cc3effbe4d5cf4d8625e1
5
5
  SHA512:
6
- metadata.gz: 870208b9d5b2449ccd6bc1884bf0a78596da211d261deccba8353919fec4a617925cbcdeaf2330949d34c07370e89b24ad8649eef3c28aa8fe0f41b5602bab3c
7
- data.tar.gz: 406ad8070133722c71dcebf8b2df12f2471563b0e0ad15f4647d41a62025c20e85a32ba2334fee1951966e6b77fb8815e23f668e4f5320c92cfb57d26f6f3e87
6
+ metadata.gz: ff32c23a477fc3c4a618c6dce3eff767e413b63c37ec8a21dc83c6bc65d41b62c4c37109ab4faa0e96086b00eb48b673ca79184d1f764fe94b6c39bf1c9b6102
7
+ data.tar.gz: 84d896e8fc5418a08ce555aaf40fe327ee245d9e081a76ebb632789eb10c5dee6669d876bd7eeea7fbdfac2b734c4d4fcb47738cd06f46ea90ac9f5a26c8d30a
@@ -16,6 +16,11 @@ module Pokotarou
16
16
  return false if all_content.blank?
17
17
  return all_content.has_key?(:"template_path'")
18
18
  end
19
+
20
+ def has_dush_preset_path_syntax? all_content
21
+ return false if all_content.blank?
22
+ return all_content.has_key?(:"preset_path'")
23
+ end
19
24
 
20
25
  def has_grouping_syntax? model_content
21
26
  return false if model_content.blank?
@@ -4,7 +4,8 @@ require "pokotarou/registration_config_maker/import_option_setter.rb"
4
4
  require "pokotarou/registration_config_maker/template_option_setter.rb"
5
5
  require "pokotarou/registration_config_maker/grouping_option_setter.rb"
6
6
  require "pokotarou/registration_config_maker/model_option_setter.rb"
7
-
7
+ require "pokotarou/registration_config_maker/preset_option_setter.rb"
8
+
8
9
  module Pokotarou
9
10
  module RegistrationConfigMaker
10
11
  class Main
@@ -29,6 +30,7 @@ module Pokotarou
29
30
 
30
31
  def set_header_config all_content
31
32
  set_template_option(all_content)
33
+ set_preset_option(all_content)
32
34
  set_import_option(all_content)
33
35
  end
34
36
 
@@ -36,6 +38,11 @@ module Pokotarou
36
38
  return unless ConfigDomain.has_dush_import_syntax?(all_content)
37
39
  ImportOptionSetter.set(all_content)
38
40
  end
41
+
42
+ def set_preset_option all_content
43
+ return all_content unless ConfigDomain.has_dush_preset_path_syntax?(all_content)
44
+ PresetOptionSetter.set(all_content)
45
+ end
39
46
 
40
47
  def set_template_option all_content
41
48
  return if !ConfigDomain.has_dush_template_syntax?(all_content) && !ConfigDomain.has_dush_template_path_syntax?(all_content)
@@ -0,0 +1,45 @@
1
+ require "pokotarou/registration_config_maker/config_domain.rb"
2
+ module Pokotarou
3
+ module RegistrationConfigMaker
4
+ class PresetOptionSetter
5
+ class << self
6
+ def set all_content
7
+ preset_content = {}
8
+
9
+ all_content[:"preset_path'"].each do |path|
10
+ YAML.load_file(path).deep_symbolize_keys!.each do |preset|
11
+ preset_content[preset.first] = preset.second
12
+ end
13
+ end
14
+
15
+ # 使用済みのKeyなので削除
16
+ all_content.delete(:"preset_path'")
17
+
18
+ # hashの順番を更新するために一度全てのKeyを消す
19
+ tmp = {}
20
+ all_content.each do |config|
21
+ key = config.first
22
+ value = config.second
23
+ tmp[key] = value
24
+
25
+ all_content.delete(key)
26
+ end
27
+
28
+ # presetを先に展開する必要があるので、再代入して順番を変更する
29
+ merge(all_content, preset_content)
30
+ merge(all_content, tmp)
31
+ end
32
+
33
+ private
34
+ def merge all_content, merge_hash
35
+ merge_hash.each do |config|
36
+ key = config.first
37
+ value = config.second
38
+ all_content[key] = value
39
+ end
40
+ end
41
+ end
42
+
43
+ end
44
+ end
45
+ end
@@ -1,3 +1,3 @@
1
1
  module Pokotarou
2
- VERSION = '1.2.1'
2
+ VERSION = '1.2.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pokotarou
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kashiwara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-22 00:00:00.000000000 Z
11
+ date: 2021-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -65,6 +65,7 @@ files:
65
65
  - lib/pokotarou/registration_config_maker/import_option_setter.rb
66
66
  - lib/pokotarou/registration_config_maker/main.rb
67
67
  - lib/pokotarou/registration_config_maker/model_option_setter.rb
68
+ - lib/pokotarou/registration_config_maker/preset_option_setter.rb
68
69
  - lib/pokotarou/registration_config_maker/template_option_setter.rb
69
70
  - lib/pokotarou/registration_config_updater/array_utils.rb
70
71
  - lib/pokotarou/registration_config_updater/convert_config.rb