Class: Fastlane::Helper::ReleaseNoteMetadataBlock
- Inherits:
-
StandardMetadataBlock
show all
- Defined in:
- lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_update_helper.rb,
lib/fastlane/plugin/wpmreleasetoolkit/helper/an_metadata_update_helper.rb
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.
77
78
79
80
81
82
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_update_helper.rb', line 77
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.
75
76
77
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_update_helper.rb', line 75
def keep_key
@keep_key
end
|
#new_key ⇒ Object
Returns the value of attribute new_key.
75
76
77
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_update_helper.rb', line 75
def new_key
@new_key
end
|
#rel_note_key ⇒ Object
Returns the value of attribute rel_note_key.
75
76
77
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_update_helper.rb', line 75
def rel_note_key
@rel_note_key
end
|
#release_version ⇒ Object
Returns the value of attribute release_version.
75
76
77
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_update_helper.rb', line 75
def release_version
@release_version
end
|
Instance Method Details
129
130
131
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_update_helper.rb', line 129
def (line)
line.split[1].tr('\"', '')
end
|
#generate_block(fw) ⇒ Object
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_update_helper.rb', line 113
def generate_block(fw)
fw.puts("msgctxt \"#{@new_key}\"")
fw.puts('msgid ""')
fw.puts("\"#{@release_version}:\\n\"")
File.open(@content_file_path, 'r').each do |line|
fw.puts("\"#{line.strip}\\n\"")
end
fw.puts('msgstr ""')
fw.puts('')
end
|
#generate_keys(release_version) ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_update_helper.rb', line 84
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}#{version_minor}"
version_major = version_major - 1 if version_minor == 0
version_minor = version_minor == 0 ? 9 : version_minor - 1
@keep_key = "#{@rel_note_key}_#{version_major}#{version_minor}"
end
|
#handle_line(fw, line) ⇒ Object
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_update_helper.rb', line 101
def handle_line(fw, line)
if line.start_with?('msgctxt')
key = (line)
@is_copying = (key == @keep_key)
generate_block(fw) if @is_copying
end
fw.puts(line) if @is_copying
end
|
#is_handler_for(key) ⇒ Object
96
97
98
99
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_update_helper.rb', line 96
def is_handler_for(key)
values = key.split('_')
key.start_with?(@rel_note_key) && values.length == 3 && (!Integer(values[2]).nil? rescue false)
end
|
#is_int?(value) ⇒ Boolean
129
130
131
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/an_metadata_update_helper.rb', line 129
def is_int?(value)
true if Integer(value) rescue false
end
|