Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Freeze the "." character used in comparisons #181

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ rdoc
*.sqlite3
*.gem
.ruby-*
.idea/
5 changes: 4 additions & 1 deletion lib/stringex/localization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ module Localization
include DefaultConversions

class << self

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line detected at class body beginning.

DOT = ".".freeze

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected.

def backend
@backend ||= i18n_present? ? Backend::I18n : Backend::Internal
end
Expand All @@ -36,7 +39,7 @@ def store_translations(locale, scope, data)
end

def translate(scope, key, options = {})
return if key == "." # I18n doesn't support dots as translation keys so we don't either
return if key == DOT # I18n doesn't support dots as translation keys so we don't either
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [95/80]


locale = options[:locale] || self.locale

Expand Down
8 changes: 5 additions & 3 deletions lib/stringex/localization/default_conversions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ module DefaultConversions
}

class << self
%w{characters currencies html_entities transliterations vulgar_fractions}.each do |conversion_type|
define_method conversion_type do
const_get conversion_type.upcase
# %w{characters currencies html_entities transliterations vulgar_fractions}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [83/80]


[['characters'.freeze, 'CHARACTERS'.freeze], ['currencies'.freeze, 'CURRENCIES'.freeze], ['html_entities'.freeze, 'HTML_ENTITIES'.freeze], ['transliterations'.freeze, 'TRANSLITERATIONS'.freeze], ['vulgar_fractions'.freeze, 'VULGAR_FRACTIONS'.freeze]].each do |conversion_type|
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [284/80]
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

define_method conversion_type[0] do
const_get conversion_type[1]
end
end
end
Expand Down