Sha256: f45333cf9c26243b2203d173941ccfe78910facf2272201399fcf68c76fc83c8
Contents?: true
Size: 1.39 KB
Versions: 1
Compression:
Stored size: 1.39 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 # @return [String] the translate method name def i18n_method 't' 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 && /[A-Za-z]/ =~ 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] 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] end private def load_config(config_content) singleton_class.class_eval { eval(config_content, binding) } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
haml_i18n_lint-0.1.0 | lib/haml_i18n_lint/config.rb |