Class: GettextI18nRails::BaseParser
- Inherits:
-
Object
- Object
- GettextI18nRails::BaseParser
- Defined in:
- lib/gettext_i18n_rails/base_parser.rb
Direct Known Subclasses
Class Method Summary collapse
- .libraries ⇒ Object
- .load_library ⇒ Object
- .parse(file, options = {}, _msgids = []) ⇒ Object
- .target?(file) ⇒ Boolean
Class Method Details
.libraries ⇒ Object
15 16 17 |
# File 'lib/gettext_i18n_rails/base_parser.rb', line 15 def self.libraries [extension] end |
.load_library ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# 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 = []) ⇒ Object
9 10 11 12 13 |
# File 'lib/gettext_i18n_rails/base_parser.rb', line 9 def self.parse(file, = {}, _msgids = []) return _msgids unless load_library code = convert_to_code(File.read(file)) GetText::RubyParser.new(file, ).parse_source(code) end |
.target?(file) ⇒ Boolean
5 6 7 |
# File 'lib/gettext_i18n_rails/base_parser.rb', line 5 def self.target?(file) File.extname(file) == ".#{extension}" end |