fastlane-plugin-wpmreleasetoolkit 9.0.0 → 9.0.1
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/fastlane/plugin/wpmreleasetoolkit/actions/android/an_update_metadata_source_action.rb +7 -5
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb +3 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/metadata_block.rb +20 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/release_note_metadata_block.rb +72 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/release_note_short_metadata_block.rb +23 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/standard_metadata_block.rb +47 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/unknown_metadata_block.rb +13 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/whats_new_metadata_block.rb +53 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/version.rb +1 -1
- metadata +8 -4
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/an_metadata_update_helper.rb +0 -152
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_update_helper.rb +0 -182
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 982e123d25f4bc8ee55dfc605e8e6873c0365d4d75f4eabce7884a4de01649e4
|
4
|
+
data.tar.gz: 462ba969f7790d6aabf6201e5bae1e4df4ac0512c8ef42955247a3319e891827
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10433f33f1af9890023113464a26c5ff5ed29df4388f11248d6afb5cd85bc83622d4511c4f8e4279cde75fbcaa0605f6487aee6267042fcdd897c3a0036404f6
|
7
|
+
data.tar.gz: ce0e3fc971589f2f5a750c23e2acf78ae4bba2637d133717d361ee3bc5778e6f37b5d3f1f2455c9a9024454e7f443d3ce27b5c034eea41de61aed72e422532ab
|
data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_update_metadata_source_action.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'fastlane/action'
|
2
|
-
require_relative '../../helper/
|
2
|
+
require_relative '../../helper/metadata/release_note_metadata_block'
|
3
|
+
require_relative '../../helper/metadata/release_note_short_metadata_block'
|
4
|
+
require_relative '../../helper/metadata/whats_new_metadata_block'
|
3
5
|
|
4
6
|
module Fastlane
|
5
7
|
module Actions
|
@@ -71,17 +73,17 @@ module Fastlane
|
|
71
73
|
@blocks = []
|
72
74
|
|
73
75
|
# Inits default handler
|
74
|
-
@blocks.push Fastlane::Helper::
|
76
|
+
@blocks.push Fastlane::Helper::UnknownMetadataBlock.new
|
75
77
|
|
76
78
|
# Init special handlers
|
77
79
|
block_files.each do |key, file_path|
|
78
80
|
case key
|
79
81
|
when :release_note
|
80
|
-
@blocks.push Fastlane::Helper::
|
82
|
+
@blocks.push Fastlane::Helper::ReleaseNoteMetadataBlock.new(key, file_path, release_version)
|
81
83
|
when :release_note_short
|
82
|
-
@blocks.push Fastlane::Helper::
|
84
|
+
@blocks.push Fastlane::Helper::ReleaseNoteShortMetadataBlock.new(key, file_path, release_version)
|
83
85
|
else
|
84
|
-
@blocks.push Fastlane::Helper::
|
86
|
+
@blocks.push Fastlane::Helper::StandardMetadataBlock.new(key, file_path)
|
85
87
|
end
|
86
88
|
end
|
87
89
|
|
@@ -1,4 +1,6 @@
|
|
1
|
-
require_relative '../../helper/
|
1
|
+
require_relative '../../helper/metadata/release_note_metadata_block'
|
2
|
+
require_relative '../../helper/metadata/release_note_short_metadata_block'
|
3
|
+
require_relative '../../helper/metadata/whats_new_metadata_block'
|
2
4
|
|
3
5
|
module Fastlane
|
4
6
|
module Actions
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Fastlane
|
2
|
+
module Helper
|
3
|
+
# Basic line handler
|
4
|
+
class MetadataBlock
|
5
|
+
attr_reader :block_key
|
6
|
+
|
7
|
+
def initialize(block_key)
|
8
|
+
@block_key = block_key
|
9
|
+
end
|
10
|
+
|
11
|
+
def handle_line(file, line)
|
12
|
+
file.puts(line) # Standard line handling: just copy
|
13
|
+
end
|
14
|
+
|
15
|
+
def is_handler_for(key)
|
16
|
+
true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require_relative 'metadata_block'
|
2
|
+
require_relative 'standard_metadata_block'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Helper
|
6
|
+
class ReleaseNoteMetadataBlock < StandardMetadataBlock
|
7
|
+
attr_reader :new_key, :keep_key, :rel_note_key, :release_version
|
8
|
+
|
9
|
+
def initialize(block_key, content_file_path, release_version)
|
10
|
+
super(block_key, content_file_path)
|
11
|
+
@rel_note_key = 'release_note'
|
12
|
+
@release_version = release_version
|
13
|
+
generate_keys(release_version)
|
14
|
+
end
|
15
|
+
|
16
|
+
def generate_keys(release_version)
|
17
|
+
values = release_version.split('.')
|
18
|
+
version_major = Integer(values[0])
|
19
|
+
version_minor = Integer(values[1])
|
20
|
+
@new_key = "#{@rel_note_key}_#{version_major.to_s.rjust(2, '0')}#{version_minor}"
|
21
|
+
|
22
|
+
version_major -= 1 if version_minor.zero?
|
23
|
+
version_minor = version_minor.zero? ? 9 : version_minor - 1
|
24
|
+
|
25
|
+
@keep_key = "#{@rel_note_key}_#{version_major.to_s.rjust(2, '0')}#{version_minor}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def is_handler_for(key)
|
29
|
+
values = key.split('_')
|
30
|
+
key.start_with?(@rel_note_key) && values.length == 3 && is_int?(values[2].sub(/^0*/, ''))
|
31
|
+
end
|
32
|
+
|
33
|
+
def handle_line(file, line)
|
34
|
+
# put content on block start or if copying the latest one
|
35
|
+
# and skip all the other content
|
36
|
+
if line.start_with?('msgctxt')
|
37
|
+
key = extract_key(line)
|
38
|
+
@is_copying = (key == @keep_key)
|
39
|
+
generate_block(file) if @is_copying
|
40
|
+
end
|
41
|
+
|
42
|
+
file.puts(line) if @is_copying
|
43
|
+
end
|
44
|
+
|
45
|
+
def generate_block(file)
|
46
|
+
# init
|
47
|
+
file.puts("msgctxt \"#{@new_key}\"")
|
48
|
+
file.puts('msgid ""')
|
49
|
+
file.puts("\"#{@release_version}:\\n\"")
|
50
|
+
|
51
|
+
# insert content
|
52
|
+
File.open(@content_file_path, 'r').each do |line|
|
53
|
+
file.puts("\"#{line.strip}\\n\"")
|
54
|
+
end
|
55
|
+
|
56
|
+
# close
|
57
|
+
file.puts('msgstr ""')
|
58
|
+
file.puts('')
|
59
|
+
end
|
60
|
+
|
61
|
+
def extract_key(line)
|
62
|
+
line.split[1].tr('\"', '')
|
63
|
+
end
|
64
|
+
|
65
|
+
def is_int?(value)
|
66
|
+
true if Integer(value)
|
67
|
+
rescue StandardError
|
68
|
+
false
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/release_note_short_metadata_block.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative 'release_note_metadata_block'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
module Helper
|
5
|
+
class ReleaseNoteShortMetadataBlock < ReleaseNoteMetadataBlock
|
6
|
+
def initialize(block_key, content_file_path, release_version)
|
7
|
+
super(block_key, content_file_path, release_version)
|
8
|
+
@rel_note_key = 'release_note_short'
|
9
|
+
@release_version = release_version
|
10
|
+
generate_keys(release_version)
|
11
|
+
end
|
12
|
+
|
13
|
+
def is_handler_for(key)
|
14
|
+
values = key.split('_')
|
15
|
+
key.start_with?(@rel_note_key) && values.length == 4 && is_int?(values[3].sub(/^0*/, ''))
|
16
|
+
end
|
17
|
+
|
18
|
+
def generate_block(file)
|
19
|
+
super(file) unless File.empty?(@content_file_path)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require_relative 'metadata_block'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
module Helper
|
5
|
+
class StandardMetadataBlock < MetadataBlock
|
6
|
+
attr_reader :content_file_path
|
7
|
+
|
8
|
+
def initialize(block_key, content_file_path)
|
9
|
+
super(block_key)
|
10
|
+
@content_file_path = content_file_path
|
11
|
+
end
|
12
|
+
|
13
|
+
def is_handler_for(key)
|
14
|
+
key == @block_key.to_s
|
15
|
+
end
|
16
|
+
|
17
|
+
def handle_line(file, line)
|
18
|
+
# put the new content on block start
|
19
|
+
# and skip all the other content
|
20
|
+
generate_block(file) if line.start_with?('msgctxt')
|
21
|
+
end
|
22
|
+
|
23
|
+
def generate_block(file)
|
24
|
+
# init
|
25
|
+
file.puts("msgctxt \"#{@block_key}\"")
|
26
|
+
line_count = File.foreach(@content_file_path).inject(0) { |c, _line| c + 1 }
|
27
|
+
|
28
|
+
if line_count <= 1
|
29
|
+
# Single line output
|
30
|
+
file.puts("msgid \"#{File.read(@content_file_path).rstrip}\"")
|
31
|
+
else
|
32
|
+
# Multiple line output
|
33
|
+
file.puts('msgid ""')
|
34
|
+
|
35
|
+
# insert content
|
36
|
+
File.open(@content_file_path, 'r').each do |line|
|
37
|
+
file.puts("\"#{line.strip}\\n\"")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# close
|
42
|
+
file.puts('msgstr ""')
|
43
|
+
file.puts('')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require_relative 'standard_metadata_block'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
module Helper
|
5
|
+
class WhatsNewMetadataBlock < StandardMetadataBlock
|
6
|
+
attr_reader :new_key, :old_key, :rel_note_key, :release_version
|
7
|
+
|
8
|
+
def initialize(block_key, content_file_path, release_version)
|
9
|
+
super(block_key, content_file_path)
|
10
|
+
@rel_note_key = 'whats_new'
|
11
|
+
@release_version = release_version
|
12
|
+
generate_keys(release_version)
|
13
|
+
end
|
14
|
+
|
15
|
+
def generate_keys(release_version)
|
16
|
+
values = release_version.split('.')
|
17
|
+
version_major = Integer(values[0])
|
18
|
+
version_minor = Integer(values[1])
|
19
|
+
@new_key = "v#{release_version}-whats-new"
|
20
|
+
|
21
|
+
version_major -= 1 if version_minor.zero?
|
22
|
+
version_minor = version_minor.zero? ? 9 : version_minor - 1
|
23
|
+
|
24
|
+
@old_key = "v#{version_major}.#{version_minor}-whats-new"
|
25
|
+
end
|
26
|
+
|
27
|
+
def is_handler_for(key)
|
28
|
+
key.start_with?('v') && key.end_with?('-whats-new')
|
29
|
+
end
|
30
|
+
|
31
|
+
def handle_line(file, line)
|
32
|
+
# put content on block start or if copying the latest one
|
33
|
+
# and skip all the other content
|
34
|
+
generate_block(file) if line.start_with?('msgctxt')
|
35
|
+
end
|
36
|
+
|
37
|
+
def generate_block(file)
|
38
|
+
# init
|
39
|
+
file.puts("msgctxt \"#{@new_key}\"")
|
40
|
+
file.puts('msgid ""')
|
41
|
+
|
42
|
+
# insert content
|
43
|
+
File.open(@content_file_path, 'r').each do |line|
|
44
|
+
file.puts("\"#{line.strip}\\n\"")
|
45
|
+
end
|
46
|
+
|
47
|
+
# close
|
48
|
+
file.puts('msgstr ""')
|
49
|
+
file.puts('')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-wpmreleasetoolkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.0.
|
4
|
+
version: 9.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Automattic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -476,7 +476,6 @@ files:
|
|
476
476
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_metadata_source.rb
|
477
477
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_release_notes.rb
|
478
478
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_validate_ci_build.rb
|
479
|
-
- lib/fastlane/plugin/wpmreleasetoolkit/helper/an_metadata_update_helper.rb
|
480
479
|
- lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_emulator_helper.rb
|
481
480
|
- lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_git_helper.rb
|
482
481
|
- lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_localize_helper.rb
|
@@ -497,8 +496,13 @@ files:
|
|
497
496
|
- lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_l10n_linter_helper.rb
|
498
497
|
- lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_strings_file_validation_helper.rb
|
499
498
|
- lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb
|
499
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/metadata_block.rb
|
500
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/release_note_metadata_block.rb
|
501
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/release_note_short_metadata_block.rb
|
502
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/standard_metadata_block.rb
|
503
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/unknown_metadata_block.rb
|
504
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/whats_new_metadata_block.rb
|
500
505
|
- lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_download_helper.rb
|
501
|
-
- lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_update_helper.rb
|
502
506
|
- lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb
|
503
507
|
- lib/fastlane/plugin/wpmreleasetoolkit/helper/release_notes_helper.rb
|
504
508
|
- lib/fastlane/plugin/wpmreleasetoolkit/helper/user_agent.rb
|
@@ -1,152 +0,0 @@
|
|
1
|
-
module Fastlane
|
2
|
-
module Helper
|
3
|
-
# Basic line handler
|
4
|
-
class AnMetadataBlock
|
5
|
-
attr_reader :block_key
|
6
|
-
|
7
|
-
def initialize(block_key)
|
8
|
-
@block_key = block_key
|
9
|
-
end
|
10
|
-
|
11
|
-
def handle_line(fw, line)
|
12
|
-
fw.puts(line) # Standard line handling: just copy
|
13
|
-
end
|
14
|
-
|
15
|
-
def is_handler_for(key)
|
16
|
-
true
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class AnUnknownMetadataBlock < AnMetadataBlock
|
21
|
-
attr_reader :content_file_path
|
22
|
-
|
23
|
-
def initialize
|
24
|
-
super(nil)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class AnStandardMetadataBlock < AnMetadataBlock
|
29
|
-
attr_reader :content_file_path
|
30
|
-
|
31
|
-
def initialize(block_key, content_file_path)
|
32
|
-
super(block_key)
|
33
|
-
@content_file_path = content_file_path
|
34
|
-
end
|
35
|
-
|
36
|
-
def is_handler_for(key)
|
37
|
-
key == @block_key.to_s
|
38
|
-
end
|
39
|
-
|
40
|
-
def handle_line(fw, line)
|
41
|
-
# put the new content on block start
|
42
|
-
# and skip all the other content
|
43
|
-
generate_block(fw) if line.start_with?('msgctxt')
|
44
|
-
end
|
45
|
-
|
46
|
-
def generate_block(fw)
|
47
|
-
# init
|
48
|
-
fw.puts("msgctxt \"#{@block_key}\"")
|
49
|
-
line_count = File.foreach(@content_file_path).inject(0) { |c, _line| c + 1 }
|
50
|
-
|
51
|
-
if line_count <= 1
|
52
|
-
# Single line output
|
53
|
-
fw.puts("msgid \"#{File.read(@content_file_path).rstrip}\"")
|
54
|
-
else
|
55
|
-
# Multiple line output
|
56
|
-
fw.puts('msgid ""')
|
57
|
-
|
58
|
-
# insert content
|
59
|
-
File.open(@content_file_path, 'r').each do |line|
|
60
|
-
fw.puts("\"#{line.strip}\\n\"")
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
# close
|
65
|
-
fw.puts('msgstr ""')
|
66
|
-
fw.puts('')
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
class AnReleaseNoteMetadataBlock < AnStandardMetadataBlock
|
71
|
-
attr_reader :new_key, :keep_key, :rel_note_key, :release_version
|
72
|
-
|
73
|
-
def initialize(block_key, content_file_path, release_version)
|
74
|
-
super(block_key, content_file_path)
|
75
|
-
@rel_note_key = 'release_note'
|
76
|
-
@release_version = release_version
|
77
|
-
generate_keys(release_version)
|
78
|
-
end
|
79
|
-
|
80
|
-
def generate_keys(release_version)
|
81
|
-
values = release_version.split('.')
|
82
|
-
version_major = Integer(values[0])
|
83
|
-
version_minor = Integer(values[1])
|
84
|
-
@new_key = "#{@rel_note_key}_#{version_major.to_s.rjust(2, '0')}#{version_minor}"
|
85
|
-
|
86
|
-
version_major -= 1 if version_minor == 0
|
87
|
-
version_minor = version_minor == 0 ? 9 : version_minor - 1
|
88
|
-
|
89
|
-
@keep_key = "#{@rel_note_key}_#{version_major.to_s.rjust(2, '0')}#{version_minor}"
|
90
|
-
end
|
91
|
-
|
92
|
-
def is_handler_for(key)
|
93
|
-
values = key.split('_')
|
94
|
-
key.start_with?(@rel_note_key) && values.length == 3 && is_int?(values[2].sub(/^0*/, ''))
|
95
|
-
end
|
96
|
-
|
97
|
-
def handle_line(fw, line)
|
98
|
-
# put content on block start or if copying the latest one
|
99
|
-
# and skip all the other content
|
100
|
-
if line.start_with?('msgctxt')
|
101
|
-
key = extract_key(line)
|
102
|
-
@is_copying = (key == @keep_key)
|
103
|
-
generate_block(fw) if @is_copying
|
104
|
-
end
|
105
|
-
|
106
|
-
fw.puts(line) if @is_copying
|
107
|
-
end
|
108
|
-
|
109
|
-
def generate_block(fw)
|
110
|
-
# init
|
111
|
-
fw.puts("msgctxt \"#{@new_key}\"")
|
112
|
-
fw.puts('msgid ""')
|
113
|
-
fw.puts("\"#{@release_version}:\\n\"")
|
114
|
-
|
115
|
-
# insert content
|
116
|
-
File.open(@content_file_path, 'r').each do |line|
|
117
|
-
fw.puts("\"#{line.strip}\\n\"")
|
118
|
-
end
|
119
|
-
|
120
|
-
# close
|
121
|
-
fw.puts('msgstr ""')
|
122
|
-
fw.puts('')
|
123
|
-
end
|
124
|
-
|
125
|
-
def extract_key(line)
|
126
|
-
line.split[1].tr('\"', '')
|
127
|
-
end
|
128
|
-
|
129
|
-
def is_int?(value)
|
130
|
-
true if Integer(value) rescue false
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
class AnReleaseNoteShortMetadataBlock < AnReleaseNoteMetadataBlock
|
135
|
-
def initialize(block_key, content_file_path, release_version)
|
136
|
-
super(block_key, content_file_path, release_version)
|
137
|
-
@rel_note_key = 'release_note_short'
|
138
|
-
@release_version = release_version
|
139
|
-
generate_keys(release_version)
|
140
|
-
end
|
141
|
-
|
142
|
-
def is_handler_for(key)
|
143
|
-
values = key.split('_')
|
144
|
-
key.start_with?(@rel_note_key) && values.length == 4 && is_int?(values[3].sub(/^0*/, ''))
|
145
|
-
end
|
146
|
-
|
147
|
-
def generate_block(fw)
|
148
|
-
super(fw) unless File.empty?(@content_file_path)
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
@@ -1,182 +0,0 @@
|
|
1
|
-
module Fastlane
|
2
|
-
module Helper
|
3
|
-
# Basic line handler
|
4
|
-
class MetadataBlock
|
5
|
-
attr_reader :block_key
|
6
|
-
|
7
|
-
def initialize(block_key)
|
8
|
-
@block_key = block_key
|
9
|
-
end
|
10
|
-
|
11
|
-
def handle_line(fw, line)
|
12
|
-
fw.puts(line) # Standard line handling: just copy
|
13
|
-
end
|
14
|
-
|
15
|
-
def is_handler_for(key)
|
16
|
-
true
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class UnknownMetadataBlock < MetadataBlock
|
21
|
-
attr_reader :content_file_path
|
22
|
-
|
23
|
-
def initialize
|
24
|
-
super(nil)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class StandardMetadataBlock < MetadataBlock
|
29
|
-
attr_reader :content_file_path
|
30
|
-
|
31
|
-
def initialize(block_key, content_file_path)
|
32
|
-
super(block_key)
|
33
|
-
@content_file_path = content_file_path
|
34
|
-
end
|
35
|
-
|
36
|
-
def is_handler_for(key)
|
37
|
-
key == @block_key.to_s
|
38
|
-
end
|
39
|
-
|
40
|
-
def handle_line(fw, line)
|
41
|
-
# put the new content on block start
|
42
|
-
# and skip all the other content
|
43
|
-
generate_block(fw) if line.start_with?('msgctxt')
|
44
|
-
end
|
45
|
-
|
46
|
-
def generate_block(fw)
|
47
|
-
# init
|
48
|
-
fw.puts("msgctxt \"#{@block_key}\"")
|
49
|
-
line_count = File.foreach(@content_file_path).inject(0) { |c, _line| c + 1 }
|
50
|
-
|
51
|
-
if line_count <= 1
|
52
|
-
# Single line output
|
53
|
-
fw.puts("msgid \"#{File.read(@content_file_path)}\"")
|
54
|
-
else
|
55
|
-
# Multiple line output
|
56
|
-
fw.puts('msgid ""')
|
57
|
-
|
58
|
-
# insert content
|
59
|
-
sf = File.open(@content_file_path, 'r').to_a
|
60
|
-
sf.each do |line|
|
61
|
-
l = "\"#{line.strip}"
|
62
|
-
l << '\\n' unless line == sf.last
|
63
|
-
l << '"'
|
64
|
-
fw.puts(l)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
# close
|
69
|
-
fw.puts('msgstr ""')
|
70
|
-
fw.puts('')
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
class ReleaseNoteMetadataBlock < StandardMetadataBlock
|
75
|
-
attr_reader :new_key, :keep_key, :rel_note_key, :release_version
|
76
|
-
|
77
|
-
def initialize(block_key, content_file_path, release_version)
|
78
|
-
super(block_key, content_file_path)
|
79
|
-
@rel_note_key = 'release_note'
|
80
|
-
@release_version = release_version
|
81
|
-
generate_keys(release_version)
|
82
|
-
end
|
83
|
-
|
84
|
-
def generate_keys(release_version)
|
85
|
-
values = release_version.split('.')
|
86
|
-
version_major = Integer(values[0])
|
87
|
-
version_minor = Integer(values[1])
|
88
|
-
@new_key = "#{@rel_note_key}_#{version_major}#{version_minor}"
|
89
|
-
|
90
|
-
version_major -= 1 if version_minor == 0
|
91
|
-
version_minor = version_minor == 0 ? 9 : version_minor - 1
|
92
|
-
|
93
|
-
@keep_key = "#{@rel_note_key}_#{version_major}#{version_minor}"
|
94
|
-
end
|
95
|
-
|
96
|
-
def is_handler_for(key)
|
97
|
-
values = key.split('_')
|
98
|
-
key.start_with?(@rel_note_key) && values.length == 3 && (!Integer(values[2]).nil? rescue false)
|
99
|
-
end
|
100
|
-
|
101
|
-
def handle_line(fw, line)
|
102
|
-
# put content on block start or if copying the latest one
|
103
|
-
# and skip all the other content
|
104
|
-
if line.start_with?('msgctxt')
|
105
|
-
key = extract_key(line)
|
106
|
-
@is_copying = (key == @keep_key)
|
107
|
-
generate_block(fw) if @is_copying
|
108
|
-
end
|
109
|
-
|
110
|
-
fw.puts(line) if @is_copying
|
111
|
-
end
|
112
|
-
|
113
|
-
def generate_block(fw)
|
114
|
-
# init
|
115
|
-
fw.puts("msgctxt \"#{@new_key}\"")
|
116
|
-
fw.puts('msgid ""')
|
117
|
-
fw.puts("\"#{@release_version}:\\n\"")
|
118
|
-
|
119
|
-
# insert content
|
120
|
-
File.open(@content_file_path, 'r').each do |line|
|
121
|
-
fw.puts("\"#{line.strip}\\n\"")
|
122
|
-
end
|
123
|
-
|
124
|
-
# close
|
125
|
-
fw.puts('msgstr ""')
|
126
|
-
fw.puts('')
|
127
|
-
end
|
128
|
-
|
129
|
-
def extract_key(line)
|
130
|
-
line.split[1].tr('\"', '')
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
class WhatsNewMetadataBlock < StandardMetadataBlock
|
135
|
-
attr_reader :new_key, :old_key, :rel_note_key, :release_version
|
136
|
-
|
137
|
-
def initialize(block_key, content_file_path, release_version)
|
138
|
-
super(block_key, content_file_path)
|
139
|
-
@rel_note_key = 'whats_new'
|
140
|
-
@release_version = release_version
|
141
|
-
generate_keys(release_version)
|
142
|
-
end
|
143
|
-
|
144
|
-
def generate_keys(release_version)
|
145
|
-
values = release_version.split('.')
|
146
|
-
version_major = Integer(values[0])
|
147
|
-
version_minor = Integer(values[1])
|
148
|
-
@new_key = "v#{release_version}-whats-new"
|
149
|
-
|
150
|
-
version_major -= 1 if version_minor == 0
|
151
|
-
version_minor = version_minor == 0 ? 9 : version_minor - 1
|
152
|
-
|
153
|
-
@old_key = "v#{version_major}.#{version_minor}-whats-new"
|
154
|
-
end
|
155
|
-
|
156
|
-
def is_handler_for(key)
|
157
|
-
key.start_with?('v') && key.end_with?('-whats-new')
|
158
|
-
end
|
159
|
-
|
160
|
-
def handle_line(fw, line)
|
161
|
-
# put content on block start or if copying the latest one
|
162
|
-
# and skip all the other content
|
163
|
-
generate_block(fw) if line.start_with?('msgctxt')
|
164
|
-
end
|
165
|
-
|
166
|
-
def generate_block(fw)
|
167
|
-
# init
|
168
|
-
fw.puts("msgctxt \"#{@new_key}\"")
|
169
|
-
fw.puts('msgid ""')
|
170
|
-
|
171
|
-
# insert content
|
172
|
-
File.open(@content_file_path, 'r').each do |line|
|
173
|
-
fw.puts("\"#{line.strip}\\n\"")
|
174
|
-
end
|
175
|
-
|
176
|
-
# close
|
177
|
-
fw.puts('msgstr ""')
|
178
|
-
fw.puts('')
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|