Sha256: c00eb3410a5e770901268a5d77ba98252d2cf8a91d13eea50fa357729ec2c007

Contents?: true

Size: 1.05 KB

Versions: 18

Compression:

Stored size: 1.05 KB

Contents

class AwesomeTranslations::Handlers::ErbHandler < AwesomeTranslations::Handlers::BaseHandler
  METHOD_NAMES = ["_", "t"]
  VALID_BEGINNING = '(^|\s+|\(|\{|<%=\s*)'

  def groups
    ArrayEnumerator.new do |yielder|
      erb_inspector.files.each do |file|
        yielder << AwesomeTranslations::Group.new(
          id: Base64.urlsafe_encode64(file.full_path),
          handler: self,
          data: {
            name: file.file_path,
            root_path: file.root_path,
            full_path: file.full_path,
            file_path: file.file_path
          }
        )
      end
    end
  end

  def translations_for_group(group)
    ArrayEnumerator.new do |yielder|
      # Parse views for translations.
      file = erb_inspector.file(group.data[:root_path], group.data[:file_path])
      file.translations.each do |translation|
        next if translation.global?
        yielder << translation.model
      end
    end
  end

private

  def erb_inspector
    @erb_inspector ||= AwesomeTranslations::ErbInspector.new(
      exts: [".erb", ".haml"]
    )
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
awesome_translations-0.0.24 lib/awesome_translations/handlers/erb_handler.rb
awesome_translations-0.0.23 lib/awesome_translations/handlers/erb_handler.rb
awesome_translations-0.0.22 lib/awesome_translations/handlers/erb_handler.rb
awesome_translations-0.0.21 lib/awesome_translations/handlers/erb_handler.rb
awesome_translations-0.0.20 lib/awesome_translations/handlers/erb_handler.rb
awesome_translations-0.0.19 lib/awesome_translations/handlers/erb_handler.rb
awesome_translations-0.0.18 lib/awesome_translations/handlers/erb_handler.rb
awesome_translations-0.0.17 lib/awesome_translations/handlers/erb_handler.rb
awesome_translations-0.0.16 lib/awesome_translations/handlers/erb_handler.rb
awesome_translations-0.0.15 lib/awesome_translations/handlers/erb_handler.rb
awesome_translations-0.0.14 lib/awesome_translations/handlers/erb_handler.rb
awesome_translations-0.0.13 lib/awesome_translations/handlers/erb_handler.rb
awesome_translations-0.0.12 lib/awesome_translations/handlers/erb_handler.rb
awesome_translations-0.0.10 lib/awesome_translations/handlers/erb_handler.rb
awesome_translations-0.0.9 lib/awesome_translations/handlers/erb_handler.rb
awesome_translations-0.0.8 lib/awesome_translations/handlers/erb_handler.rb
awesome_translations-0.0.7 lib/awesome_translations/handlers/erb_handler.rb
awesome_translations-0.0.6 lib/awesome_translations/handlers/erb_handler.rb