Module: GettextSetup::MetadataPot

Defined in:
lib/gettext-setup/metadata_pot.rb

Class Method Summary collapse

Class Method Details

.generate_metadata_pot(pot_metadata = metadata, path = metadata_path) ⇒ Object



33
34
35
36
37
# File 'lib/gettext-setup/metadata_pot.rb', line 33

def self.( = , path = )
  File.open(path, 'w') do |f|
    f << pot_string()
  end
end

.metadata(metadata_file = 'metadata.json') ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/gettext-setup/metadata_pot.rb', line 17

def self.( = 'metadata.json')
  if File.exist?()
    file = File.open()
    json = file.read
    JSON.parse(json)
  else
    {}
  end
end

.metadata_pathObject



9
10
11
# File 'lib/gettext-setup/metadata_pot.rb', line 9

def self.
  File.join(GettextSetup.locales_path, GettextSetup.config['project_name'] + '_metadata.pot')
end

.pot_string(metadata) ⇒ Object



27
28
29
30
31
# File 'lib/gettext-setup/metadata_pot.rb', line 27

def self.pot_string()
  b = binding.freeze
  # Uses `metadata`
  ERB.new(File.read(template_path)).result(b)
end

.template_pathObject



13
14
15
# File 'lib/gettext-setup/metadata_pot.rb', line 13

def self.template_path
  File.join(File.dirname(__FILE__), '../templates/metadata.pot.erb')
end