Sha256: 4c96718980fdee5bd0f0f31e7dd742c728c70a5959b4bbb731f951b08c858287

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

class AwesomeTranslations::Handlers::LibraryHandler < AwesomeTranslations::Handlers::BaseHandler
  def groups
    ArrayEnumerator.new do |yielder|
      erb_inspector.files.each do |file|
        id = file.file_path.gsub(/[^A-z0-9]/, "_")

        group = AwesomeTranslations::Group.new(
          id: id,
          handler: self,
          data: {
            name: file.file_path,
            root_path: file.root_path,
            full_path: file.full_path,
            file_path: file.file_path
          }
        )

        yielder << group if translations_for_group(group).any?
      end
    end
  end

  def translations_for_group(group)
    ArrayEnumerator.new do |yielder|
      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: ['.rb', '.rake']
    )
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
awesome_translations-0.0.25 lib/awesome_translations/handlers/library_handler.rb