ehbrs_ruby_utils 0.32.0 → 0.33.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/lib/ehbrs_ruby_utils/cooking_book/build/base_page.rb +42 -0
- data/lib/ehbrs_ruby_utils/cooking_book/build/index_page.rb +26 -0
- data/lib/ehbrs_ruby_utils/cooking_book/build/recipe_page.rb +26 -0
- data/lib/ehbrs_ruby_utils/cooking_book/build.rb +45 -0
- data/lib/ehbrs_ruby_utils/cooking_book/project.rb +31 -0
- data/lib/ehbrs_ruby_utils/cooking_book/recipe/ingredient.rb +21 -0
- data/lib/ehbrs_ruby_utils/cooking_book/recipe/measure.rb +60 -0
- data/lib/ehbrs_ruby_utils/cooking_book/recipe/part.rb +32 -0
- data/lib/ehbrs_ruby_utils/cooking_book/recipe.rb +37 -0
- data/lib/ehbrs_ruby_utils/cooking_book.rb +9 -0
- data/lib/ehbrs_ruby_utils/version.rb +1 -1
- data/lib/ehbrs_ruby_utils/vg/wii/file_move.rb +89 -0
- data/lib/ehbrs_ruby_utils/vg/wii/game_file.rb +87 -0
- data/lib/ehbrs_ruby_utils/vg/wii/wit/image_format.rb +47 -0
- data/lib/ehbrs_ruby_utils/vg/wii/wit/parsers/dump.rb +67 -0
- data/lib/ehbrs_ruby_utils/vg/wii/wit/parsers/info.rb +39 -0
- data/lib/ehbrs_ruby_utils/vg/wii/wit/path.rb +55 -0
- data/lib/ehbrs_ruby_utils/vg/wii/wit.rb +13 -0
- data/lib/ehbrs_ruby_utils/vg/wii.rb +11 -0
- data/lib/ehbrs_ruby_utils/vg.rb +9 -0
- data/spec/lib/ehbrs_ruby_utils/cooking_book/recipe/measure_spec.rb +21 -0
- data/spec/lib/ehbrs_ruby_utils/vg/wii/game_file_spec.rb +21 -0
- data/spec/lib/ehbrs_ruby_utils/vg/wii/wit/parsers/dump_spec.rb +11 -0
- data/spec/lib/ehbrs_ruby_utils/vg/wii/wit/parsers/dump_spec_files/pikmin2_R92P01_wia.source.witdump +27 -0
- data/spec/lib/ehbrs_ruby_utils/vg/wii/wit/parsers/dump_spec_files/pikmin2_R92P01_wia.target.yaml +22 -0
- data/spec/lib/ehbrs_ruby_utils/vg/wii/wit/parsers/dump_spec_files/pikmin2_pal_iso.source.witdump +28 -0
- data/spec/lib/ehbrs_ruby_utils/vg/wii/wit/parsers/dump_spec_files/pikmin2_pal_iso.target.yaml +21 -0
- data/spec/lib/ehbrs_ruby_utils/vg/wii/wit/parsers/dump_spec_files/resident_evil_code_veronica_disc2_iso.source.witdump +16 -0
- data/spec/lib/ehbrs_ruby_utils/vg/wii/wit/parsers/dump_spec_files/resident_evil_code_veronica_disc2_iso.target.yaml +19 -0
- data/spec/lib/ehbrs_ruby_utils/vg/wii/wit/parsers/dump_spec_files/super_mario_galaxy_wbfs.source.witdump +28 -0
- data/spec/lib/ehbrs_ruby_utils/vg/wii/wit/parsers/dump_spec_files/super_mario_galaxy_wbfs.target.yaml +23 -0
- data/spec/lib/ehbrs_ruby_utils/vg/wii/wit/path_spec.rb +33 -0
- metadata +100 -57
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05a500e93163dbff946466f1e0500eb191734c6dab6f7ee221df9c6f7b1d652a
|
4
|
+
data.tar.gz: 551a4cd6c774196401f2c87a7b176c7e8b3ca3c94ae9b030ab16dc73a14f3555
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 652775ab4e50bdfc1066d11cab55e66fa9a5f98c670ec12cf0e7f2652b9668d5ce2c98a8a2e58faf20d433a8342a824296da1e05a34e99a516f787227ae2431b
|
7
|
+
data.tar.gz: 4be18d9b6f3641869a415e957a7ead726bec9d846c36d1ec893047b1be04a24217603388fda5c900910eb3aeba7ff86e6cd40ecae4547a01ad3ce481e286208d
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EhbrsRubyUtils
|
6
|
+
module CookingBook
|
7
|
+
class Build
|
8
|
+
class BasePage < SimpleDelegator
|
9
|
+
attr_reader :parent
|
10
|
+
|
11
|
+
def initialize(parent, source_object)
|
12
|
+
super(source_object)
|
13
|
+
@parent = parent
|
14
|
+
end
|
15
|
+
|
16
|
+
def build
|
17
|
+
target_path.write(target_content)
|
18
|
+
end
|
19
|
+
|
20
|
+
def href
|
21
|
+
"#{target_basename}.html"
|
22
|
+
end
|
23
|
+
|
24
|
+
def target_path
|
25
|
+
parent.target_dir.join(href)
|
26
|
+
end
|
27
|
+
|
28
|
+
def target_content
|
29
|
+
erb_result('layout', ::EhbrsRubyUtils::CookingBook::Build::BasePage)
|
30
|
+
end
|
31
|
+
|
32
|
+
def inner_content
|
33
|
+
erb_result('inner', self.class)
|
34
|
+
end
|
35
|
+
|
36
|
+
def erb_result(template_basename, template_source = self)
|
37
|
+
template_source.erb_template("#{template_basename}.html.erb", self)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'ehbrs_ruby_utils/cooking_book/build/base_page'
|
5
|
+
|
6
|
+
module EhbrsRubyUtils
|
7
|
+
module CookingBook
|
8
|
+
class Build
|
9
|
+
class IndexPage < ::EhbrsRubyUtils::CookingBook::Build::BasePage
|
10
|
+
TITLE = 'Início'
|
11
|
+
|
12
|
+
def initialize(parent)
|
13
|
+
super(parent, nil)
|
14
|
+
end
|
15
|
+
|
16
|
+
def target_basename
|
17
|
+
'index'
|
18
|
+
end
|
19
|
+
|
20
|
+
def title
|
21
|
+
TITLE
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'ehbrs_ruby_utils/cooking_book/build/base_page'
|
5
|
+
|
6
|
+
module EhbrsRubyUtils
|
7
|
+
module CookingBook
|
8
|
+
class Build
|
9
|
+
class RecipePage < ::EhbrsRubyUtils::CookingBook::Build::BasePage
|
10
|
+
def target_basename
|
11
|
+
title.variableize
|
12
|
+
end
|
13
|
+
|
14
|
+
def parts
|
15
|
+
@parts ||= super.map { |e| Part.new(e) }
|
16
|
+
end
|
17
|
+
|
18
|
+
class Part < SimpleDelegator
|
19
|
+
def content
|
20
|
+
::EhbrsRubyUtils::CookingBook::Build::RecipePage.erb_template('part.html.erb', self)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/fs/clearable_directory'
|
5
|
+
|
6
|
+
module EhbrsRubyUtils
|
7
|
+
module CookingBook
|
8
|
+
class Build
|
9
|
+
require_sub __FILE__
|
10
|
+
enable_simple_cache
|
11
|
+
enable_listable
|
12
|
+
lists.add_symbol :option, :target_dir
|
13
|
+
|
14
|
+
common_constructor :project, :options, default: [{}] do
|
15
|
+
self.options = self.class.lists.option.hash_keys_validate!(options.symbolize_keys)
|
16
|
+
end
|
17
|
+
|
18
|
+
def run
|
19
|
+
target_dir.clear
|
20
|
+
index_page.build
|
21
|
+
recipes_pages.each(&:build)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def index_page_uncached
|
27
|
+
::EhbrsRubyUtils::CookingBook::Build::IndexPage.new(self)
|
28
|
+
end
|
29
|
+
|
30
|
+
def recipes_pages_uncached
|
31
|
+
project.recipes.map do |recipe|
|
32
|
+
::EhbrsRubyUtils::CookingBook::Build::RecipePage.new(self, recipe)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def target_dir_uncached
|
37
|
+
::EacRubyUtils::Fs::ClearableDirectory.new(options[OPTION_TARGET_DIR] || default_target_dir)
|
38
|
+
end
|
39
|
+
|
40
|
+
def default_target_dir
|
41
|
+
project.root.join('dist')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'ehbrs_ruby_utils/cooking_book/recipe'
|
5
|
+
|
6
|
+
module EhbrsRubyUtils
|
7
|
+
module CookingBook
|
8
|
+
class Project
|
9
|
+
RECIPES_ROOT_SUBPATH = 'recipes'
|
10
|
+
|
11
|
+
enable_simple_cache
|
12
|
+
common_constructor :root do
|
13
|
+
self.root = root.to_pathname
|
14
|
+
end
|
15
|
+
|
16
|
+
delegate :to_s, to: :root
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def recipes_root_uncached
|
21
|
+
root.join(RECIPES_ROOT_SUBPATH)
|
22
|
+
end
|
23
|
+
|
24
|
+
def recipes_uncached
|
25
|
+
::Dir.glob(File.join('**', '*.{yml,yaml}'), base: recipes_root.to_path).map do |subpath|
|
26
|
+
::EhbrsRubyUtils::CookingBook::Recipe.from_file(recipes_root.join(subpath))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'ehbrs_ruby_utils/cooking_book/recipe/measure'
|
5
|
+
|
6
|
+
module EhbrsRubyUtils
|
7
|
+
module CookingBook
|
8
|
+
class Recipe
|
9
|
+
class Ingredient
|
10
|
+
class << self
|
11
|
+
def build(label, value)
|
12
|
+
new(label, ::EhbrsRubyUtils::CookingBook::Recipe::Measure.build(value))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
enable_simple_cache
|
17
|
+
common_constructor :name, :measure
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/yaml'
|
5
|
+
require 'ehbrs_ruby_utils/cooking_book/recipe/ingredient'
|
6
|
+
|
7
|
+
module EhbrsRubyUtils
|
8
|
+
module CookingBook
|
9
|
+
class Recipe
|
10
|
+
class Measure
|
11
|
+
FLOAT_PATTERN = /\d+(?:\.\d+)?/.freeze
|
12
|
+
FRACTION_PATTERN = %r{(#{FLOAT_PATTERN})(?:\s*/\s*(#{FLOAT_PATTERN}))?}.freeze
|
13
|
+
QUANTITY_UNIT_PATTERN = /\A#{FRACTION_PATTERN}(?:\s*(\S+))?\z/.freeze
|
14
|
+
VARIABLE_PATTERN = /\A\~\z/.freeze
|
15
|
+
VARIABLE_TEXT = 'a gosto'
|
16
|
+
|
17
|
+
class << self
|
18
|
+
def build(value)
|
19
|
+
value = value.to_s.strip
|
20
|
+
build_from_variable(value) || build_from_pattern(value) || build_unknown(value)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def build_from_variable(value)
|
26
|
+
VARIABLE_PATTERN.if_match(value, false) do
|
27
|
+
new(nil, nil, nil)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def build_from_pattern(value)
|
32
|
+
QUANTITY_UNIT_PATTERN.if_match(value, false) do |m|
|
33
|
+
new(m[1].if_present(&:to_f), m[2].if_present(&:to_f), m[3])
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def build_unknown(value)
|
38
|
+
new(nil, nil, "unknown format: |#{value}|")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
common_constructor :numerator, :denominator, :unit
|
43
|
+
|
44
|
+
def to_s
|
45
|
+
return VARIABLE_TEXT if variable?
|
46
|
+
|
47
|
+
"#{quantity_to_s} #{unit}"
|
48
|
+
end
|
49
|
+
|
50
|
+
def quantity_to_s
|
51
|
+
numerator.to_s + (denominator.if_present('') { |v| "/ #{v}" })
|
52
|
+
end
|
53
|
+
|
54
|
+
def variable?
|
55
|
+
numerator.blank?
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/yaml'
|
5
|
+
require 'ehbrs_ruby_utils/cooking_book/recipe/ingredient'
|
6
|
+
|
7
|
+
module EhbrsRubyUtils
|
8
|
+
module CookingBook
|
9
|
+
class Recipe
|
10
|
+
class Part
|
11
|
+
enable_simple_cache
|
12
|
+
common_constructor :title, :source_data
|
13
|
+
|
14
|
+
def notes
|
15
|
+
source_data[:notes]
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def ingredients_uncached
|
21
|
+
source_data.fetch(:ingredients).map do |label, value|
|
22
|
+
::EhbrsRubyUtils::CookingBook::Recipe::Ingredient.build(label, value)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def steps_uncached
|
27
|
+
source_data.fetch(:steps)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/yaml'
|
5
|
+
|
6
|
+
module EhbrsRubyUtils
|
7
|
+
module CookingBook
|
8
|
+
class Recipe
|
9
|
+
enable_simple_cache
|
10
|
+
require_sub __FILE__
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def from_file(path)
|
14
|
+
new(::EacRubyUtils::Yaml.load_file(path))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
common_constructor :source_data do
|
19
|
+
self.source_data = source_data.deep_symbolize_keys
|
20
|
+
end
|
21
|
+
|
22
|
+
def title
|
23
|
+
source_data.fetch(:title)
|
24
|
+
end
|
25
|
+
|
26
|
+
def notes
|
27
|
+
source_data[:notes]
|
28
|
+
end
|
29
|
+
|
30
|
+
def parts
|
31
|
+
@parts ||= source_data.fetch(:parts).map do |k, v|
|
32
|
+
::EhbrsRubyUtils::CookingBook::Recipe::Part.new(k, v)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'ehbrs/executables'
|
5
|
+
require 'ehbrs_ruby_utils/vg/wii/wit/image_format'
|
6
|
+
require 'ehbrs_ruby_utils/vg/wii/wit/path'
|
7
|
+
require 'fileutils'
|
8
|
+
|
9
|
+
module EhbrsRubyUtils
|
10
|
+
module Vg
|
11
|
+
module Wii
|
12
|
+
class FileMove
|
13
|
+
common_constructor :game, :target do
|
14
|
+
self.target = ::EhbrsRubyUtils::Vg::Wii::Wit::Path.assert(target)
|
15
|
+
end
|
16
|
+
|
17
|
+
['', 'path_', 'type_'].each do |prefix|
|
18
|
+
method_name = "#{prefix}change?"
|
19
|
+
define_method(method_name) do
|
20
|
+
source.send(method_name, target)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def run
|
25
|
+
[%w[path type], %w[path], %w[type]].each do |parts|
|
26
|
+
next unless parts.all? { |part| send("#{part}_change?") }
|
27
|
+
|
28
|
+
assert_target_dir
|
29
|
+
send("change_#{parts.join('_and_')}")
|
30
|
+
check_target
|
31
|
+
break
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def source
|
36
|
+
game.wit_path
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def assert_target_dir
|
42
|
+
target.path.parent.mkpath
|
43
|
+
end
|
44
|
+
|
45
|
+
def change_path
|
46
|
+
::FileUtils.mv(source.path, target.path)
|
47
|
+
end
|
48
|
+
|
49
|
+
def change_path_and_type
|
50
|
+
::Ehbrs::Executables.wit.command
|
51
|
+
.append(change_path_and_type_args)
|
52
|
+
.system!
|
53
|
+
check_target
|
54
|
+
source.path.unlink
|
55
|
+
end
|
56
|
+
|
57
|
+
def change_path_and_type_args
|
58
|
+
r = %w[copy]
|
59
|
+
target_image_format.if_present { |v| r << v.option }
|
60
|
+
r + [source.path, target.path]
|
61
|
+
end
|
62
|
+
|
63
|
+
def change_type
|
64
|
+
::Ehbrs::Executables.wit.command
|
65
|
+
.append(change_type_args)
|
66
|
+
.system!
|
67
|
+
end
|
68
|
+
|
69
|
+
def change_type_args
|
70
|
+
r = %w[convert]
|
71
|
+
target_image_format.if_present { |v| r << v.option }
|
72
|
+
r + [target.path]
|
73
|
+
end
|
74
|
+
|
75
|
+
def check_target
|
76
|
+
return if ::EhbrsRubyUtils::Vg::Wii::GameFile.new(target.path).valid?
|
77
|
+
|
78
|
+
raise "Target \"#{target}\" is not a valid Wii game"
|
79
|
+
end
|
80
|
+
|
81
|
+
def target_image_format
|
82
|
+
return nil if target.type.blank?
|
83
|
+
|
84
|
+
::EhbrsRubyUtils::Vg::Wii::Wit::ImageFormat.by_name(target.type)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/custom_format'
|
5
|
+
require 'ehbrs_ruby_utils/vg/wii/wit/parsers/dump'
|
6
|
+
require 'ehbrs_ruby_utils/vg/wii/wit/path'
|
7
|
+
require 'pathname'
|
8
|
+
|
9
|
+
module EhbrsRubyUtils
|
10
|
+
module Vg
|
11
|
+
module Wii
|
12
|
+
class GameFile < ::Pathname
|
13
|
+
enable_simple_cache
|
14
|
+
|
15
|
+
DISC_NUMBER_PATTERN = /disc.?(\d)/i.freeze
|
16
|
+
|
17
|
+
FORMAT = ::EacRubyUtils::CustomFormat.new(
|
18
|
+
b: :basename,
|
19
|
+
d: :dirname,
|
20
|
+
D: :disc_number,
|
21
|
+
e: :extname,
|
22
|
+
i: :id6,
|
23
|
+
m: :normalized_disc_name,
|
24
|
+
n: :disc_name,
|
25
|
+
N: :nintendont_basename,
|
26
|
+
s: :sanitized_disc_name,
|
27
|
+
t: :database_title,
|
28
|
+
T: :disc_type
|
29
|
+
)
|
30
|
+
|
31
|
+
def database_title
|
32
|
+
properties.fetch('DB title')
|
33
|
+
end
|
34
|
+
|
35
|
+
def disc_name
|
36
|
+
properties.fetch('Disc name')
|
37
|
+
end
|
38
|
+
|
39
|
+
def disc_number
|
40
|
+
DISC_NUMBER_PATTERN.if_match(basename.to_s, false) { |m| m[1].to_i }.if_present(1)
|
41
|
+
end
|
42
|
+
|
43
|
+
def disc_type
|
44
|
+
properties.fetch('File & disc type/type')
|
45
|
+
end
|
46
|
+
|
47
|
+
def format(string)
|
48
|
+
FORMAT.format(string).with(self)
|
49
|
+
end
|
50
|
+
|
51
|
+
def normalized_disc_name
|
52
|
+
sanitized_disc_name.downcase
|
53
|
+
end
|
54
|
+
|
55
|
+
def nintendont_basename
|
56
|
+
n = disc_number
|
57
|
+
n == 1 ? 'game' : "disc#{n}"
|
58
|
+
end
|
59
|
+
|
60
|
+
def id6
|
61
|
+
properties.fetch('Disc & part IDs/disc')
|
62
|
+
end
|
63
|
+
|
64
|
+
def sanitized_disc_name
|
65
|
+
::ActiveSupport::Inflector.transliterate(disc_name).gsub(/[^0-9a-z ]/i, '')
|
66
|
+
end
|
67
|
+
|
68
|
+
def valid?
|
69
|
+
properties.present?
|
70
|
+
end
|
71
|
+
|
72
|
+
def wit_path
|
73
|
+
::EhbrsRubyUtils::Vg::Wii::Wit::Path.new(disc_type, self)
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def properties_uncached
|
79
|
+
r = ::Ehbrs::Executables.wit.command.append(['dump', to_s]).execute
|
80
|
+
return nil unless r.fetch(:exit_code).zero?
|
81
|
+
|
82
|
+
::EhbrsRubyUtils::Vg::Wii::Wit::Parsers::Dump.new(r.fetch(:stdout)).properties
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'ehbrs/executables'
|
5
|
+
require 'ehbrs_ruby_utils/vg/wii/wit/parsers/info'
|
6
|
+
|
7
|
+
module EhbrsRubyUtils
|
8
|
+
module Vg
|
9
|
+
module Wii
|
10
|
+
module Wit
|
11
|
+
class ImageFormat
|
12
|
+
class << self
|
13
|
+
SECTION_NAME_PATTERN = /\A#{::Regexp.quote('IMAGE-FORMAT:')}(.+)\z/.freeze
|
14
|
+
|
15
|
+
enable_simple_cache
|
16
|
+
|
17
|
+
def by_name(name)
|
18
|
+
all.find { |i| i.name.downcase == name.to_s.downcase } ||
|
19
|
+
raise(::ArgumentError, "Image not found with name \"#{name.to_s.downcase}\"" \
|
20
|
+
" (Available: #{all.map(&:name).join(', ')})")
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def all_uncached
|
26
|
+
::EhbrsRubyUtils::Vg::Wii::Wit::Parsers::Info.new(info_output).images
|
27
|
+
.map do |_label, data|
|
28
|
+
new(
|
29
|
+
*%w[name info option].map { |k| data.fetch(k) },
|
30
|
+
*%w[extensions attributes].map { |k| data.fetch(k).to_s.split(/\s+/) }
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def info_output
|
36
|
+
::Ehbrs::Executables.wit.command
|
37
|
+
.append(%w[info image-format --sections])
|
38
|
+
.execute!
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
common_constructor :name, :description, :option, :extensions, :attributes
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EhbrsRubyUtils
|
6
|
+
module Vg
|
7
|
+
module Wii
|
8
|
+
module Wit
|
9
|
+
module Parsers
|
10
|
+
class Dump
|
11
|
+
enable_simple_cache
|
12
|
+
common_constructor :output
|
13
|
+
|
14
|
+
# WIA/WII (v1.00,LZMA2.7@100) & Wii
|
15
|
+
# ISO/WII & Wii
|
16
|
+
# WBFS/WII & Wii
|
17
|
+
# ISO/GC & GameCube
|
18
|
+
FILE_DISC_TYPE_PATTERN = %r{\A(\S+)/(\S+)\s+(?:\(([^\)]+)\)\s+)?&\s+(\S+)\z}.freeze
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def properties_uncached
|
23
|
+
r = {}
|
24
|
+
output.each_line do |line|
|
25
|
+
dump_output_line_to_hash(line).if_present { |v| r.merge!(v) }
|
26
|
+
end
|
27
|
+
r
|
28
|
+
end
|
29
|
+
|
30
|
+
def dump_output_line_to_hash(line)
|
31
|
+
m = /\A\s*([^:]+):\s+(.+)\z/.match(line.strip)
|
32
|
+
return nil unless m
|
33
|
+
|
34
|
+
parse_attribute(m[1].strip, m[2].strip)
|
35
|
+
end
|
36
|
+
|
37
|
+
def line_method_parser(label)
|
38
|
+
"parse_#{label}".parameterize.underscore
|
39
|
+
end
|
40
|
+
|
41
|
+
def parse_attribute(label, value)
|
42
|
+
method = line_method_parser(label)
|
43
|
+
return { label => value } unless respond_to?(method, true)
|
44
|
+
|
45
|
+
send(method, value).transform_keys { |k| "#{label}/#{k}" }
|
46
|
+
end
|
47
|
+
|
48
|
+
def parse_file_disc_type(value)
|
49
|
+
r = FILE_DISC_TYPE_PATTERN.match(value).if_present do |m|
|
50
|
+
{ type: m[1], platform_acronym: m[2], type_extra: m[3],
|
51
|
+
platform_name: m[4] }
|
52
|
+
end
|
53
|
+
r.if_blank { raise "\"#{FILE_DISC_TYPE_PATTERN}\" does not match \"#{value}\"" }
|
54
|
+
end
|
55
|
+
|
56
|
+
def parse_disc_part_ids(value)
|
57
|
+
value.split(',').map(&:strip).map do |v|
|
58
|
+
r = v.split('=')
|
59
|
+
[r[0].strip, r[1].strip]
|
60
|
+
end.to_h
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'ehbrs/executables'
|
5
|
+
require 'fileutils'
|
6
|
+
require 'inifile'
|
7
|
+
|
8
|
+
module EhbrsRubyUtils
|
9
|
+
module Vg
|
10
|
+
module Wii
|
11
|
+
module Wit
|
12
|
+
module Parsers
|
13
|
+
class Info
|
14
|
+
SECTION_NAME_PATTERN = /\A#{::Regexp.quote('IMAGE-FORMAT:')}(.+)\z/.freeze
|
15
|
+
|
16
|
+
enable_simple_cache
|
17
|
+
common_constructor :output
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def images_uncached
|
22
|
+
ini = ::IniFile.new(content: output)
|
23
|
+
r = {}
|
24
|
+
ini.sections.each do |section_name|
|
25
|
+
image_section_name = parse_image_section_name(section_name)
|
26
|
+
r[image_section_name] = ini[section_name] if image_section_name.present?
|
27
|
+
end
|
28
|
+
r
|
29
|
+
end
|
30
|
+
|
31
|
+
def parse_image_section_name(section_name)
|
32
|
+
SECTION_NAME_PATTERN.match(section_name).if_present { |m| m[1] }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|