Sha256: 34f18790cfdd380ce44e388fe93c686f0f197afe41e38935d8e7c82da26f796e
Contents?: true
Size: 1.46 KB
Versions: 19
Compression:
Stored size: 1.46 KB
Contents
# Used to find translations in the Rails app by inspecting .erb- and .haml-files. class AwesomeTranslations::ErbInspector autoload :FileInspector, "#{File.dirname(__FILE__)}/erb_inspector/file_inspector" autoload :TranslationInspector, "#{File.dirname(__FILE__)}/erb_inspector/translation_inspector" def initialize(args = {}) @args = args @args[:exts] ||= [".erb", ".haml", ".rb"] if @args[:dirs] @dirs = @args[:dirs] else @dirs = AwesomeTranslations.config.paths_to_translate end end # Yields all relevant .erb- and .haml-files. def files Enumerator.new do |yielder| @dirs.each do |dir| scan_dir("", dir, yielder) end end end def file(root_path, file_path) return AwesomeTranslations::ErbInspector::FileInspector.new( file_path: file_path, root_path: root_path ) end private def scan_dir(path, root_path, yielder) Dir.foreach("#{root_path}/#{path}") do |file| next if file == "." || file == ".." file_path = "#{path}" file_path << "/" unless file_path.empty? file_path << file full_path = "#{root_path}/#{file_path}" ext = File.extname(file_path) if File.directory?(full_path) scan_dir(file_path, root_path, yielder) elsif @args[:exts].include?(ext) yielder << AwesomeTranslations::ErbInspector::FileInspector.new( file_path: file_path, root_path: root_path ) end end end end
Version data entries
19 entries across 19 versions & 1 rubygems