Skip to content

Commit

Permalink
Adds ':' to VALID_KEY_CHARS for ruby_key_literals. (#208)
Browse files Browse the repository at this point in the history
Fixes #207
  • Loading branch information
Jon authored and glebm committed Nov 1, 2016
1 parent 2ecc2dc commit 608c627
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/i18n/tasks/scanners/ruby_key_literals.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def strip_literal(literal)
literal
end

VALID_KEY_CHARS = /(?:[[:word:]]|[-.?!;À-ž])/
VALID_KEY_CHARS = /(?:[[:word:]]|[-.?!:;À-ž])/
VALID_KEY_RE = /^#{VALID_KEY_CHARS}+$/

def valid_key?(key)
Expand Down
2 changes: 2 additions & 0 deletions spec/fixtures/app/views/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ p = Spree.t 'not_a_key'
= t 'reference-ok-plain'
= t 'reference-ok-nested.a'
= t 'reference-missing-target.a'

p = t 'missing_key_ending_in_colon.key:'
1 change: 1 addition & 0 deletions spec/i18n_tasks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
missing_symbol.key_two
missing_symbol.key_three
missing-key-with-a-dash.key
missing_key_ending_in_colon.key:
missing-key-question?.key
fn_comment
events.show.success
Expand Down
18 changes: 17 additions & 1 deletion spec/support/capture_std.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
# frozen_string_literal: true
require 'active_support/core_ext/kernel/reporting'

# This is necessary because Rails 5 removed the Kernel extension of
# that added `#silence_stream` and moved it to their testing set of
# libraries. Therefore, I'm including this here. Technically any
# testing will conceivably install version 5 meaning the include is
# necessary. However, this allows us to clearly be compliant with
# both rails 4 and 5 which the gemspec supports.
require 'active_support/gem_version'

if ActiveSupport::VERSION::MAJOR == 4
require 'active_support/core_ext/kernel/reporting'
else
require 'active_support/testing/stream'
end

module CaptureStd
include ActiveSupport::Testing::Stream if defined?(ActiveSupport::Testing::Stream)

def capture_stderr
err, $stderr = $stderr, StringIO.new
yield
Expand Down
2 changes: 1 addition & 1 deletion spec/support/i18n_tasks_output_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def extract_keys(actual)
key_col = 1
actual.map { |row|
key = [row[locale_col], row[key_col]].map(&:presence).compact.join('.')
key = key[0..-2] if key.end_with?(':')
key = key[0..-2] if key.end_with?('.:')
key = key.sub(/\((?:ref|resolved ref|ref key)\) /, '')
key
}.compact
Expand Down

0 comments on commit 608c627

Please sign in to comment.