Class: I18nPoTools::Formats::BaseFormat
- Inherits:
-
Object
- Object
- I18nPoTools::Formats::BaseFormat
show all
- Defined in:
- lib/i18n_po_tools/formats/base_format.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
7
8
9
|
# File 'lib/i18n_po_tools/formats/base_format.rb', line 7
def options
@options
end
|
Instance Method Details
#banner_msg ⇒ Object
52
53
54
|
# File 'lib/i18n_po_tools/formats/base_format.rb', line 52
def banner_msg
"Generated by i18n-po #{I18nPoTools::VERSION} on #{Time.now.strftime("%Y-%m-%d %H:%M:%S")} by #{ENV['USER']} on #{`hostname`.gsub("\n",'')}"
end
|
#file_encoding ⇒ Object
56
57
58
|
# File 'lib/i18n_po_tools/formats/base_format.rb', line 56
def file_encoding
'UTF-8'
end
|
#read(filename) ⇒ Object
44
45
46
|
# File 'lib/i18n_po_tools/formats/base_format.rb', line 44
def read(filename)
raise "Not Implemented"
end
|
#read_file(input_filename) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/i18n_po_tools/formats/base_format.rb', line 9
def read_file(input_filename)
if input_filename.present?
if file_encoding.index('UTF-16')
mode = "rb:#{file_encoding}"
else
mode = "r:#{file_encoding}"
end
File.open(input_filename, mode, &:read)
else
$stdin.read
end
end
|
#read_with_options(filename, options, mode) ⇒ Object
39
40
41
42
|
# File 'lib/i18n_po_tools/formats/base_format.rb', line 39
def read_with_options(filename, options, mode)
@options = options
read(filename)
end
|
#write(filename, data) ⇒ Object
48
49
50
|
# File 'lib/i18n_po_tools/formats/base_format.rb', line 48
def write(filename, data)
raise "Not Implemented"
end
|
#write_file(output_filename, data) ⇒ Object
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/i18n_po_tools/formats/base_format.rb', line 23
def write_file(output_filename, data)
FileUtils.mkdir_p File.dirname(output_filename)
if output_filename.present?
File.open(output_filename, "w:"+file_encoding) do |f|
f << data
end
else
puts data
end
end
|
#write_with_options(data, base_data, options) ⇒ Object
34
35
36
37
|
# File 'lib/i18n_po_tools/formats/base_format.rb', line 34
def write_with_options(data, base_data, options)
@options = options
write(options[:output_filename], data)
end
|