lib/i18n/tasks/scanners/base_scanner.rb in i18n-tasks-0.6.3 vs lib/i18n/tasks/scanners/base_scanner.rb in i18n-tasks-0.7.0
- old
+ new
@@ -34,17 +34,17 @@
def key_filter=(value)
@key_filter = value
@key_filter_pattern = compile_key_pattern(value) if @key_filter
end
- # @return [Array<{key,data:{source_locations:[]}}]
+ # @return [Array<{key,data:{source_occurrences:[]}}]
def keys(opts = {})
keys = traverse_files { |path|
scan_file(path, opts)
}.reduce(:+) || []
keys.group_by(&:first).map { |key, key_loc|
- [key, data: {source_locations: key_loc.map { |(k, attr)| attr[:data] }}]
+ [key, data: {source_occurrences: key_loc.map { |(k, attr)| attr[:data] }}]
}
end
def read_file(path)
result = nil
@@ -113,11 +113,12 @@
key = key[1..-1] if ':' == key[0]
key = key[1..-2] if %w(' ").include?(key[0])
key
end
- VALID_KEY_RE = /^[-\w.\#{}]+$/
- VALID_KEY_RE_STRICT = /^[-\w.]+$/
+ VALID_KEY_CHARS = /[-\w.?!;:]/
+ VALID_KEY_RE_STRICT = /^#{VALID_KEY_CHARS}+$/
+ VALID_KEY_RE = /^(#{VALID_KEY_CHARS}|[\#{}])+$/
def valid_key?(key, strict = false)
return false if @key_filter && @key_filter_pattern !~ key
if strict
key =~ VALID_KEY_RE_STRICT && !key.end_with?('.')