Module: Jekyll::L10n::FileOperations
- Defined in:
- lib/jekyll-l10n/utils/file_operations.rb
Overview
File I/O operations with UTF-8 encoding.
FileOperations provides centralized file reading/writing and directory creation with automatic UTF-8 encoding. All PO files, HTML files, and configuration files are handled with UTF-8 encoding for internationalization.
Key responsibilities:
-
Read files with UTF-8 encoding
-
Write files with UTF-8 encoding
-
Create directory structures as needed
Constant Summary collapse
- ENCODING =
'UTF-8'
Class Method Summary collapse
-
.ensure_directory(file_path) ⇒ void
Ensure directory exists for a file path.
-
.read_utf8(path) ⇒ String
Read a file with UTF-8 encoding.
-
.write_utf8(path, content) ⇒ Integer
Write content to a file with UTF-8 encoding.
Class Method Details
.ensure_directory(file_path) ⇒ void
This method returns an undefined value.
Ensure directory exists for a file path.
Creates all parent directories as needed for the given file path. Does nothing if directory already exists.
49 50 51 52 |
# File 'lib/jekyll-l10n/utils/file_operations.rb', line 49 def self.ensure_directory(file_path) dir = ::File.dirname(file_path) ::FileUtils.mkdir_p(dir) end |
.read_utf8(path) ⇒ String
Read a file with UTF-8 encoding.
29 30 31 |
# File 'lib/jekyll-l10n/utils/file_operations.rb', line 29 def self.read_utf8(path) ::File.read(path, encoding: ENCODING) end |
.write_utf8(path, content) ⇒ Integer
Write content to a file with UTF-8 encoding.
38 39 40 |
# File 'lib/jekyll-l10n/utils/file_operations.rb', line 38 def self.write_utf8(path, content) ::File.write(path, content, encoding: ENCODING) end |