class GettextI18nRails::BaseParser

Public Class Methods

libraries() click to toggle source
# File lib/gettext_i18n_rails/base_parser.rb, line 15
def self.libraries
  [extension]
end
load_library() click to toggle source
# File lib/gettext_i18n_rails/base_parser.rb, line 19
def self.load_library
  return true if @library_loaded

  loaded = libraries.detect do |library|
    if Gem::Specification.find_all_by_name(library).any?
      require library
      true
    else
      false
    end
  end

  unless loaded
    puts "No #{extension} library could be found: #{libraries.join(" or ")}"

    return false
  end

  require 'gettext/tools/parser/ruby'
  @library_loaded = loaded
end
parse(file, options = {}, _msgids = []) click to toggle source
# File lib/gettext_i18n_rails/base_parser.rb, line 9
def self.parse(file, options = {}, _msgids = [])
  return _msgids unless load_library
  code = convert_to_code(File.read(file))
  GetText::RubyParser.new(file, options).parse_source(code)
end
target?(file) click to toggle source
# File lib/gettext_i18n_rails/base_parser.rb, line 5
def self.target?(file)
  File.extname(file) == ".#{extension}"
end