Class: Fastlane::Helper::StandardMetadataBlock
- Inherits:
-
MetadataBlock
show all
- Defined in:
- lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/standard_metadata_block.rb
Instance Attribute Summary collapse
#block_key
Instance Method Summary
collapse
Constructor Details
#initialize(block_key, content_file_path) ⇒ StandardMetadataBlock
Returns a new instance of StandardMetadataBlock.
8
9
10
11
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/standard_metadata_block.rb', line 8
def initialize(block_key, content_file_path)
super(block_key)
@content_file_path = content_file_path
end
|
Instance Attribute Details
#content_file_path ⇒ Object
Returns the value of attribute content_file_path.
6
7
8
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/standard_metadata_block.rb', line 6
def content_file_path
@content_file_path
end
|
Instance Method Details
#generate_block(file) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/standard_metadata_block.rb', line 23
def generate_block(file)
file.puts("msgctxt \"#{@block_key}\"")
line_count = File.foreach(@content_file_path).inject(0) { |c, _line| c + 1 }
if line_count <= 1
file.puts("msgid \"#{File.read(@content_file_path).rstrip}\"")
else
file.puts('msgid ""')
File.open(@content_file_path, 'r').each do |line|
file.puts("\"#{line.strip}\\n\"")
end
end
file.puts('msgstr ""')
file.puts('')
end
|
#handle_line(file, line) ⇒ Object
17
18
19
20
21
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/standard_metadata_block.rb', line 17
def handle_line(file, line)
generate_block(file) if line.start_with?('msgctxt')
end
|
#is_handler_for(key) ⇒ Object
13
14
15
|
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/standard_metadata_block.rb', line 13
def is_handler_for(key)
key == @block_key.to_s
end
|