Module: ProperProperties

Defined in:
lib/proper_properties.rb,
lib/proper_properties/version.rb,
lib/proper_properties/encoding.rb,
lib/proper_properties/properties.rb,
lib/proper_properties/parsing/parser.rb,
lib/proper_properties/encoding/unicode.rb,
lib/proper_properties/parsing/normalizer.rb,
lib/proper_properties/encoding/separators.rb,
lib/proper_properties/generating/generator.rb,
lib/proper_properties/encoding/special_chars.rb

Overview

A module to read and write Proper properties files

Defined Under Namespace

Modules: Encoding, Generating, Parsing Classes: Properties

Constant Summary collapse

VERSION =
"0.0.2"

Class Method Summary collapse

Class Method Details

.generate(hash, options = {}) ⇒ String

Generates the content of a Proper properties file

Parameters:

  • hash (Hash)
  • options (Hash) (defaults to: {})

    options for the generator

Returns:

  • (String)

See Also:



23
24
25
# File 'lib/proper_properties.rb', line 23

def self.generate(hash, options = {})
  Generating::Generator.generate(hash, options)
end

.load(path, encoding = 'UTF-8', allow_invalid_byte_sequence = true) ⇒ Properties

Loads and parses a Proper properties file

Parameters:

  • path (String)
  • encoding (String) (defaults to: 'UTF-8')
  • allow_invalid_byte_sequence (Boolean) (defaults to: true)

Returns:

See Also:



33
34
35
# File 'lib/proper_properties.rb', line 33

def self.load(path, encoding = 'UTF-8', allow_invalid_byte_sequence = true)
    parse(File.read(path).encode(encoding, 'binary', allow_invalid_byte_sequence ? {invalid: :replace, undef: :replace} : {} ))
end

.parse(text) ⇒ Properties

Parses the content of a Proper properties file

Parameters:

  • text (String)

Returns:

See Also:



14
15
16
# File 'lib/proper_properties.rb', line 14

def self.parse(text)
  Parsing::Parser.parse(text)
end

.write(hash, path, options = {}) ⇒ Object

Generates a Proper properties file

Parameters:

  • hash (Hash)
  • path (String)
  • options (Hash) (defaults to: {})

    options for the generator

See Also:



42
43
44
# File 'lib/proper_properties.rb', line 42

def self.write(hash, path, options = {})
  File.write(path, generate(hash, options))
end