fastlane-plugin-wpmreleasetoolkit 9.0.0 → 9.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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/copy_branch_protection_action.rb +80 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb +3 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/{removebranchprotection_action.rb → remove_branch_protection_action.rb} +24 -17
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/set_branch_protection_action.rb +153 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb +49 -4
- 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/models/app_version.rb +36 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/models/build_code.rb +27 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/version.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/abstract_version_calculator.rb +85 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/date_build_code_calculator.rb +32 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/date_version_calculator.rb +37 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/marketing_version_calculator.rb +26 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/semantic_version_calculator.rb +21 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/simple_build_code_calculator.rb +22 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/files/android_version_file.rb +76 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/files/ios_version_file.rb +64 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/abstract_version_formatter.rb +27 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/derived_build_code_formatter.rb +33 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/four_part_build_code_formatter.rb +22 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/four_part_version_formatter.rb +35 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/rc_notation_version_formatter.rb +65 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/simple_build_code_formatter.rb +20 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit.rb +1 -1
- metadata +41 -6
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/setbranchprotection_action.rb +0 -63
- 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
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.
|
4
|
+
version: 9.1.0
|
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-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.3'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: java-properties
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.3.0
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.3.0
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: nokogiri
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -426,6 +440,7 @@ files:
|
|
426
440
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/circleci_trigger_job_action.rb
|
427
441
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/close_milestone_action.rb
|
428
442
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/comment_on_pr.rb
|
443
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/copy_branch_protection_action.rb
|
429
444
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_new_milestone_action.rb
|
430
445
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_action.rb
|
431
446
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb
|
@@ -436,8 +451,8 @@ files:
|
|
436
451
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb
|
437
452
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/promo_screenshots_action.rb
|
438
453
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/prototype_build_details_comment_action.rb
|
439
|
-
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/
|
440
|
-
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/
|
454
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/remove_branch_protection_action.rb
|
455
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/set_branch_protection_action.rb
|
441
456
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/setfrozentag_action.rb
|
442
457
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/upload_to_s3.rb
|
443
458
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_add_files_to_copy_action.rb
|
@@ -476,7 +491,6 @@ files:
|
|
476
491
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_metadata_source.rb
|
477
492
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_release_notes.rb
|
478
493
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_validate_ci_build.rb
|
479
|
-
- lib/fastlane/plugin/wpmreleasetoolkit/helper/an_metadata_update_helper.rb
|
480
494
|
- lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_emulator_helper.rb
|
481
495
|
- lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_git_helper.rb
|
482
496
|
- lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_localize_helper.rb
|
@@ -497,11 +511,18 @@ files:
|
|
497
511
|
- lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_l10n_linter_helper.rb
|
498
512
|
- lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_strings_file_validation_helper.rb
|
499
513
|
- lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb
|
514
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/metadata_block.rb
|
515
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/release_note_metadata_block.rb
|
516
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/release_note_short_metadata_block.rb
|
517
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/standard_metadata_block.rb
|
518
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/unknown_metadata_block.rb
|
519
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/whats_new_metadata_block.rb
|
500
520
|
- lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_download_helper.rb
|
501
|
-
- lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_update_helper.rb
|
502
521
|
- lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb
|
503
522
|
- lib/fastlane/plugin/wpmreleasetoolkit/helper/release_notes_helper.rb
|
504
523
|
- lib/fastlane/plugin/wpmreleasetoolkit/helper/user_agent.rb
|
524
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/models/app_version.rb
|
525
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/models/build_code.rb
|
505
526
|
- lib/fastlane/plugin/wpmreleasetoolkit/models/configuration.rb
|
506
527
|
- lib/fastlane/plugin/wpmreleasetoolkit/models/file_reference.rb
|
507
528
|
- lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_account.rb
|
@@ -509,6 +530,20 @@ files:
|
|
509
530
|
- lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_test_lab_result.rb
|
510
531
|
- lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_test_runner.rb
|
511
532
|
- lib/fastlane/plugin/wpmreleasetoolkit/version.rb
|
533
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/abstract_version_calculator.rb
|
534
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/date_build_code_calculator.rb
|
535
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/date_version_calculator.rb
|
536
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/marketing_version_calculator.rb
|
537
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/semantic_version_calculator.rb
|
538
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/simple_build_code_calculator.rb
|
539
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/versioning/files/android_version_file.rb
|
540
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/versioning/files/ios_version_file.rb
|
541
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/abstract_version_formatter.rb
|
542
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/derived_build_code_formatter.rb
|
543
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/four_part_build_code_formatter.rb
|
544
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/four_part_version_formatter.rb
|
545
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/rc_notation_version_formatter.rb
|
546
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/simple_build_code_formatter.rb
|
512
547
|
homepage: https://github.com/wordpress-mobile/release-toolkit
|
513
548
|
licenses:
|
514
549
|
- MIT
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'fastlane/action'
|
2
|
-
require_relative '../../helper/github_helper'
|
3
|
-
|
4
|
-
module Fastlane
|
5
|
-
module Actions
|
6
|
-
class SetbranchprotectionAction < Action
|
7
|
-
def self.run(params)
|
8
|
-
repository = params[:repository]
|
9
|
-
branch_name = params[:branch]
|
10
|
-
|
11
|
-
branch_url = "https://api.github.com/repos/#{repository}/branches/#{branch_name}"
|
12
|
-
restrictions = { url: "#{branch_url}/protection/restrictions", users_url: "#{branch_url}/protection/restrictions/users", teams_url: "#{branch_url}/protection/restrictions/teams", users: [], teams: [] }
|
13
|
-
required_pull_request_reviews = { url: "#{branch_url}/protection/required_pull_request_reviews", dismiss_stale_reviews: false, require_code_owner_reviews: false }
|
14
|
-
|
15
|
-
github_helper = Fastlane::Helper::GithubHelper.new(github_token: params[:github_token])
|
16
|
-
github_helper.set_branch_protection(
|
17
|
-
repository: repository,
|
18
|
-
branch: branch_name,
|
19
|
-
restrictions: restrictions,
|
20
|
-
enforce_admins: nil,
|
21
|
-
required_pull_request_reviews: required_pull_request_reviews
|
22
|
-
)
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.description
|
26
|
-
"Sets the 'release branch' protection state for the specified branch"
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.authors
|
30
|
-
['Automattic']
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.return_value
|
34
|
-
# If your method provides a return value, you can describe here what it does
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.details
|
38
|
-
# Optional:
|
39
|
-
"Sets the 'release branch' protection state for the specified branch"
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.available_options
|
43
|
-
[
|
44
|
-
FastlaneCore::ConfigItem.new(key: :repository,
|
45
|
-
env_name: 'GHHELPER_REPOSITORY',
|
46
|
-
description: 'The remote path of the GH repository on which we work',
|
47
|
-
optional: false,
|
48
|
-
type: String),
|
49
|
-
FastlaneCore::ConfigItem.new(key: :branch,
|
50
|
-
env_name: 'GHHELPER_BRANCH',
|
51
|
-
description: 'The branch to protect',
|
52
|
-
optional: false,
|
53
|
-
type: String),
|
54
|
-
Fastlane::Helper::GithubHelper.github_token_config_item,
|
55
|
-
]
|
56
|
-
end
|
57
|
-
|
58
|
-
def self.is_supported?(platform)
|
59
|
-
true
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -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
|