Class: Fastlane::Helper::ReleaseNoteMetadataBlock
Instance Attribute Summary collapse
#content_file_path
#block_key
Instance Method Summary
collapse
Constructor Details
#initialize(block_key, content_file_path, release_version) ⇒ ReleaseNoteMetadataBlock
Returns a new instance of ReleaseNoteMetadataBlock.
9
10
11
12
13
14
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/release_note_metadata_block.rb', line 9
def initialize(block_key, content_file_path, release_version)
super(block_key, content_file_path)
@rel_note_key = 'release_note'
@release_version = release_version
generate_keys(release_version)
end
|
Instance Attribute Details
#keep_key ⇒ Object
Returns the value of attribute keep_key.
7
8
9
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/release_note_metadata_block.rb', line 7
def keep_key
@keep_key
end
|
#new_key ⇒ Object
Returns the value of attribute new_key.
7
8
9
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/release_note_metadata_block.rb', line 7
def new_key
@new_key
end
|
#rel_note_key ⇒ Object
Returns the value of attribute rel_note_key.
7
8
9
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/release_note_metadata_block.rb', line 7
def rel_note_key
@rel_note_key
end
|
#release_version ⇒ Object
Returns the value of attribute release_version.
7
8
9
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/release_note_metadata_block.rb', line 7
def release_version
@release_version
end
|
Instance Method Details
61
62
63
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/release_note_metadata_block.rb', line 61
def (line)
line.split[1].tr('\"', '')
end
|
#generate_block(file) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/release_note_metadata_block.rb', line 45
def generate_block(file)
file.puts("msgctxt \"#{@new_key}\"")
file.puts('msgid ""')
file.puts("\"#{@release_version}:\\n\"")
File.open(@content_file_path, 'r').each do |line|
file.puts("\"#{line.strip}\\n\"")
end
file.puts('msgstr ""')
file.puts('')
end
|
#generate_keys(release_version) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/release_note_metadata_block.rb', line 16
def generate_keys(release_version)
values = release_version.split('.')
version_major = Integer(values[0])
version_minor = Integer(values[1])
@new_key = "#{@rel_note_key}_#{version_major.to_s.rjust(2, '0')}#{version_minor}"
version_major -= 1 if version_minor.zero?
version_minor = version_minor.zero? ? 9 : version_minor - 1
@keep_key = "#{@rel_note_key}_#{version_major.to_s.rjust(2, '0')}#{version_minor}"
end
|
#handle_line(file, line) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/release_note_metadata_block.rb', line 33
def handle_line(file, line)
if line.start_with?('msgctxt')
key = (line)
@is_copying = (key == @keep_key)
generate_block(file) if @is_copying
end
file.puts(line) if @is_copying
end
|
#is_handler_for(key) ⇒ Object
28
29
30
31
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/release_note_metadata_block.rb', line 28
def is_handler_for(key)
values = key.split('_')
key.start_with?(@rel_note_key) && values.length == 3 && is_int?(values[2].sub(/^0*/, ''))
end
|
#is_int?(value) ⇒ Boolean
65
66
67
68
69
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/release_note_metadata_block.rb', line 65
def is_int?(value)
true if Integer(value)
rescue StandardError
false
end
|