Sha256: c0b076202fc1c1c00f49d15949b75a687c6ff78b8bb03c3f10c7fc486e4e04e9
Contents?: true
Size: 1.49 KB
Versions: 2
Compression:
Stored size: 1.49 KB
Contents
module HamlI18nLint # Configuration for the lint class Config # Returns a new lint configuration by given options # # @param options [Options] def initialize(options) @options = options if (@options.config_path) load_config(@options.config_content) end end # @param content [String] the text content found in haml template # @return [true, false] the content need i18n or not. def need_i18n?(content) /^[\s]+$/ !~ content && /\p{Alpha}/ =~ content end # Output the formatted result # # @param result [Linter::Result] the lint result def report(result) print '.' and return if result.success? puts file = File.readlines(result.filename) result.matched_nodes.each do |node| puts "#{result.filename}:#{node.line}" puts "#{node.line-1}: #{file[node.line - 2]}" if file[node.line - 2] && !(node.line - 2).negative? puts "#{node.line}: #{file[node.line - 1]}" puts "#{node.line+1}: #{file[node.line]}" if file[node.line] puts '-' * 16 end puts end # @return [Array<String>] the list of files to be linted. def files Dir[*@options.files].uniq end # @return [String] the list of methods, which takes string. The string is no translation required. def ignore_methods %w(t render) end private def load_config(config_content) singleton_class.class_eval { eval(config_content, binding) } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
haml_i18n_lint-0.5.0 | lib/haml_i18n_lint/config.rb |
haml_i18n_lint-0.4.0 | lib/haml_i18n_lint/config.rb |