Fix code style for Rubocop 1.16.0 (#36)
This commit is contained in:
parent
b35997936e
commit
23ce6c5f1d
|
@ -80,6 +80,11 @@ Metrics/MethodLength:
|
|||
Metrics/ClassLength:
|
||||
Enabled: false
|
||||
|
||||
Metrics/ModuleLength:
|
||||
Enabled: true
|
||||
Exclude:
|
||||
- "spec/**/*.rb"
|
||||
|
||||
Metrics/BlockLength:
|
||||
Enabled: false
|
||||
|
||||
|
|
1
Rakefile
1
Rakefile
|
@ -3,7 +3,6 @@
|
|||
require "rake"
|
||||
require "bundler/gem_tasks"
|
||||
|
||||
require "rspec/core/rake_task"
|
||||
require "rspec/core/rake_task"
|
||||
|
||||
task default: :spec
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'bundler/setup'
|
||||
require 'dry/inflector'
|
||||
require "bundler/setup"
|
||||
require "dry/inflector"
|
||||
|
||||
# You can add fixtures and/or initialization code here to make experimenting
|
||||
# with your gem easier. You can also use a different console, if you like.
|
||||
|
@ -11,7 +11,7 @@ require 'dry/inflector'
|
|||
# require "pry"
|
||||
# Pry.start
|
||||
|
||||
require 'irb'
|
||||
require "irb"
|
||||
Dry::Inflector.new.instance_exec do
|
||||
binding.irb
|
||||
binding.irb # rubocop:disable Lint/Debugger
|
||||
end
|
||||
|
|
|
@ -67,7 +67,7 @@ module Dry
|
|||
internal_camelize(input, true)
|
||||
end
|
||||
|
||||
alias :camelize :camelize_upper
|
||||
alias_method :camelize, :camelize_upper
|
||||
|
||||
# Find a constant with the name specified in the argument string
|
||||
#
|
||||
|
@ -158,7 +158,7 @@ module Dry
|
|||
match = /(?<separator>\W)/.match(result)
|
||||
separator = match ? match[:separator] : DEFAULT_SEPARATOR
|
||||
result.split(separator).map.with_index { |word, index|
|
||||
inflections.acronyms.apply_to(word, index.zero?)
|
||||
inflections.acronyms.apply_to(word, capitalize: index.zero?)
|
||||
}.join(separator)
|
||||
end
|
||||
|
||||
|
@ -192,7 +192,7 @@ module Dry
|
|||
# inflector.ordinalize(3) # => "3rd"
|
||||
# inflector.ordinalize(10) # => "10th"
|
||||
# inflector.ordinalize(23) # => "23rd"
|
||||
def ordinalize(number) # rubocop:disable Metrics/MethodLength
|
||||
def ordinalize(number)
|
||||
abs_value = number.abs
|
||||
|
||||
if ORDINALIZE_TH.key?(abs_value % 100)
|
||||
|
@ -281,7 +281,7 @@ module Dry
|
|||
input.gsub!(inflections.acronyms.regex) do
|
||||
m1 = Regexp.last_match(1)
|
||||
m2 = Regexp.last_match(2)
|
||||
"#{m1 ? '_' : ''}#{m2.downcase}"
|
||||
"#{m1 ? "_" : ""}#{m2.downcase}"
|
||||
end
|
||||
input.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
|
||||
input.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
|
||||
|
@ -308,7 +308,7 @@ module Dry
|
|||
def to_s
|
||||
"#<Dry::Inflector>"
|
||||
end
|
||||
alias inspect to_s
|
||||
alias_method :inspect, :to_s
|
||||
|
||||
private
|
||||
|
||||
|
@ -326,7 +326,7 @@ module Dry
|
|||
# @api private
|
||||
def internal_camelize(input, upper)
|
||||
input = input.to_s.dup
|
||||
input.sub!(/^[a-z\d]*/) { |match| inflections.acronyms.apply_to(match, upper) }
|
||||
input.sub!(/^[a-z\d]*/) { |match| inflections.acronyms.apply_to(match, capitalize: upper) }
|
||||
input.gsub!(%r{(?:_|(/))([a-z\d]*)}i) do
|
||||
m1 = Regexp.last_match(1)
|
||||
m2 = Regexp.last_match(2)
|
||||
|
|
|
@ -18,7 +18,7 @@ module Dry
|
|||
|
||||
# @since 0.1.2
|
||||
# @api private
|
||||
def apply_to(word, capitalize = true)
|
||||
def apply_to(word, capitalize: true)
|
||||
@rules[word.downcase] || (capitalize ? word.capitalize : word)
|
||||
end
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'set'
|
||||
require 'dry/inflector/rules'
|
||||
require 'dry/inflector/acronyms'
|
||||
require "set"
|
||||
require "dry/inflector/rules"
|
||||
require "dry/inflector/acronyms"
|
||||
|
||||
module Dry
|
||||
class Inflector
|
||||
|
@ -10,7 +10,7 @@ module Dry
|
|||
#
|
||||
# @since 0.1.0
|
||||
class Inflections
|
||||
require 'dry/inflector/inflections/defaults'
|
||||
require "dry/inflector/inflections/defaults"
|
||||
|
||||
# Instantiate a set of inflection rules.
|
||||
# It adds the default rules and the optional customizations, passed as a block.
|
||||
|
@ -87,7 +87,9 @@ module Dry
|
|||
#
|
||||
# Specifies a new pluralization rule and its replacement.
|
||||
# The rule can either be a string or a regular expression.
|
||||
# The replacement should always be a string that may include references to the matched data from the rule.
|
||||
#
|
||||
# The replacement should always be a string that may include
|
||||
# references to the matched data from the rule.
|
||||
#
|
||||
# @param rule [String, Regexp] the rule
|
||||
# @param replacement [String] the replacement
|
||||
|
@ -108,7 +110,9 @@ module Dry
|
|||
#
|
||||
# Specifies a new singularization rule and its replacement.
|
||||
# The rule can either be a string or a regular expression.
|
||||
# The replacement should always be a string that may include references to the matched data from the rule.
|
||||
#
|
||||
# The replacement should always be a string that may include
|
||||
# references to the matched data from the rule.
|
||||
#
|
||||
# @param rule [String, Regexp] the rule
|
||||
# @param replacement [String] the replacement
|
||||
|
@ -127,7 +131,9 @@ module Dry
|
|||
|
||||
# Add a custom pluralization rule
|
||||
#
|
||||
# Specifies a new irregular that applies to both pluralization and singularization at the same time.
|
||||
# Specifies a new irregular that applies to both pluralization
|
||||
# and singularization at the same time.
|
||||
#
|
||||
# This can only be used for strings, not regular expressions.
|
||||
# You simply pass the irregular in singular and plural form.
|
||||
#
|
||||
|
@ -194,9 +200,14 @@ module Dry
|
|||
|
||||
# Add a custom humanize rule
|
||||
#
|
||||
# Specifies a humanized form of a string by a regular expression rule or by a string mapping.
|
||||
# When using a regular expression based replacement, the normal humanize formatting is called after the replacement.
|
||||
# When a string is used, the human form should be specified as desired (example: `"The name"`, not `"the_name"`)
|
||||
# Specifies a humanized form of a string by a regular expression rule or
|
||||
# by a string mapping.
|
||||
#
|
||||
# When using a regular expression based replacement, the normal humanize
|
||||
# formatting is called after the replacement.
|
||||
#
|
||||
# When a string is used, the human form should be specified as desired
|
||||
# (example: `"The name"`, not `"the_name"`)
|
||||
#
|
||||
# @param rule [String, Regexp] the rule
|
||||
# @param replacement [String] the replacement
|
||||
|
@ -227,7 +238,7 @@ module Dry
|
|||
# @api private
|
||||
def add_irregular(rule, replacement, target)
|
||||
head, *tail = rule.chars.to_a
|
||||
rule(/(#{head})#{tail.join}\z/i, '\1' + replacement[1..-1], target)
|
||||
rule(/(#{head})#{tail.join}\z/i, "\\1#{replacement[1..]}", target)
|
||||
end
|
||||
|
||||
# Add a new rule
|
||||
|
|
|
@ -9,7 +9,6 @@ module Dry
|
|||
# @api private
|
||||
#
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
module Defaults
|
||||
# @since 0.1.0
|
||||
# @api private
|
||||
|
@ -24,8 +23,8 @@ module Dry
|
|||
# @since 0.1.0
|
||||
# @api private
|
||||
def self.plural(inflect)
|
||||
inflect.plural(/\z/, 's')
|
||||
inflect.plural(/s\z/i, 's')
|
||||
inflect.plural(/\z/, "s")
|
||||
inflect.plural(/s\z/i, "s")
|
||||
inflect.plural(/(ax|test)is\z/i, '\1es')
|
||||
inflect.plural(/(.*)us\z/i, '\1uses')
|
||||
inflect.plural(/(octop|vir|cact)us\z/i, '\1i')
|
||||
|
@ -34,8 +33,8 @@ module Dry
|
|||
inflect.plural(/(buffal|domin|ech|embarg|her|mosquit|potat|tomat)o\z/i, '\1oes')
|
||||
inflect.plural(/(?<!b)um\z/i, '\1a')
|
||||
inflect.plural(/([ti])a\z/i, '\1a')
|
||||
inflect.plural(/sis\z/i, 'ses')
|
||||
inflect.plural(/(.*)(?:([^f]))f[e]*\z/i, '\1\2ves')
|
||||
inflect.plural(/sis\z/i, "ses")
|
||||
inflect.plural(/(.*)(?:([^f]))fe*\z/i, '\1\2ves')
|
||||
inflect.plural(/(hive|proof)\z/i, '\1s') # TODO: proof can be moved in the above regexp
|
||||
inflect.plural(/([^aeiouy]|qu)y\z/i, '\1ies')
|
||||
inflect.plural(/(x|ch|ss|sh)\z/i, '\1es')
|
||||
|
@ -54,10 +53,11 @@ module Dry
|
|||
# @since 0.1.0
|
||||
# @api private
|
||||
def self.singular(inflect)
|
||||
inflect.singular(/s\z/i, '')
|
||||
inflect.singular(/s\z/i, "")
|
||||
inflect.singular(/(n)ews\z/i, '\1ews')
|
||||
inflect.singular(/([ti])a\z/i, '\1um')
|
||||
inflect.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)\z/i, '\1\2sis')
|
||||
inflect.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)\z/i,
|
||||
'\1\2sis')
|
||||
inflect.singular(/(^analy)(sis|ses)\z/i, '\1sis')
|
||||
inflect.singular(/([^f])ves\z/i, '\1fe')
|
||||
inflect.singular(/(hive)s\z/i, '\1')
|
||||
|
@ -85,21 +85,26 @@ module Dry
|
|||
# @since 0.1.0
|
||||
# @api private
|
||||
def self.irregular(inflect)
|
||||
inflect.irregular('person', 'people')
|
||||
inflect.irregular('man', 'men')
|
||||
inflect.irregular('human', 'humans') # NOTE: this is here only to override the previous rule
|
||||
inflect.irregular('child', 'children')
|
||||
inflect.irregular('sex', 'sexes')
|
||||
inflect.irregular('foot', 'feet')
|
||||
inflect.irregular('tooth', 'teeth')
|
||||
inflect.irregular('goose', 'geese')
|
||||
inflect.irregular('forum', 'forums') # FIXME: this is here because I need to fix the "um" regexp
|
||||
inflect.irregular("person", "people")
|
||||
inflect.irregular("man", "men")
|
||||
|
||||
# NOTE: this is here only to override the previous rule
|
||||
inflect.irregular("human", "humans")
|
||||
inflect.irregular("child", "children")
|
||||
inflect.irregular("sex", "sexes")
|
||||
inflect.irregular("foot", "feet")
|
||||
inflect.irregular("tooth", "teeth")
|
||||
inflect.irregular("goose", "geese")
|
||||
|
||||
# FIXME: this is here because I need to fix the "um" regexp
|
||||
inflect.irregular("forum", "forums")
|
||||
end
|
||||
|
||||
# @since 0.1.0
|
||||
# @api private
|
||||
def self.uncountable(inflect)
|
||||
inflect.uncountable(%w[hovercraft moose deer milk rain Swiss grass equipment information rice money species series fish sheep jeans])
|
||||
inflect.uncountable(%w[hovercraft moose deer milk rain Swiss grass equipment information
|
||||
rice money species series fish sheep jeans])
|
||||
end
|
||||
|
||||
# @since 0.1.2
|
||||
|
@ -110,7 +115,6 @@ module Dry
|
|||
|
||||
private_class_method :plural, :singular, :irregular, :uncountable, :acronyms
|
||||
end
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
module Dry
|
||||
class Inflector
|
||||
# @since 0.1.0
|
||||
VERSION = '0.2.0'
|
||||
VERSION = "0.2.0"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -33,7 +33,6 @@ end
|
|||
|
||||
require "dry/inflector"
|
||||
|
||||
require "pathname"
|
||||
Dir.glob(Pathname.new(__dir__).join("support", "**", "*.rb")).each do |file|
|
||||
require_relative file
|
||||
end
|
||||
|
|
|
@ -11,12 +11,12 @@ module Fixtures
|
|||
end
|
||||
|
||||
CASES = {
|
||||
'merb' => 'merb',
|
||||
'data_mapper' => 'dataMapper',
|
||||
'dry/inflector' => 'dry::Inflector',
|
||||
'dry/inflector/inflections' => 'dry::Inflector::Inflections',
|
||||
'blog_post/author' => 'blogPost::Author',
|
||||
'blog_post/tag_cloud' => 'blogPost::TagCloud'
|
||||
"merb" => "merb",
|
||||
"data_mapper" => "dataMapper",
|
||||
"dry/inflector" => "dry::Inflector",
|
||||
"dry/inflector/inflections" => "dry::Inflector::Inflections",
|
||||
"blog_post/author" => "blogPost::Author",
|
||||
"blog_post/tag_cloud" => "blogPost::TagCloud"
|
||||
}.freeze
|
||||
|
||||
# Missing rules
|
||||
|
|
|
@ -11,12 +11,12 @@ module Fixtures
|
|||
end
|
||||
|
||||
CASES = {
|
||||
'merb' => 'Merb',
|
||||
'data_mapper' => 'DataMapper',
|
||||
'dry/inflector' => 'Dry::Inflector',
|
||||
'dry/inflector/inflections' => 'Dry::Inflector::Inflections',
|
||||
'blog_post/author' => 'BlogPost::Author',
|
||||
'blog_post/tag_cloud' => 'BlogPost::TagCloud'
|
||||
"merb" => "Merb",
|
||||
"data_mapper" => "DataMapper",
|
||||
"dry/inflector" => "Dry::Inflector",
|
||||
"dry/inflector/inflections" => "Dry::Inflector::Inflections",
|
||||
"blog_post/author" => "BlogPost::Author",
|
||||
"blog_post/tag_cloud" => "BlogPost::TagCloud"
|
||||
}.freeze
|
||||
|
||||
# Missing rules
|
||||
|
|
|
@ -7,107 +7,107 @@ module Fixtures
|
|||
end
|
||||
|
||||
CASES = {
|
||||
0 => '0th',
|
||||
1 => '1st',
|
||||
2 => '2nd',
|
||||
3 => '3rd',
|
||||
4 => '4th',
|
||||
5 => '5th',
|
||||
6 => '6th',
|
||||
7 => '7th',
|
||||
8 => '8th',
|
||||
9 => '9th',
|
||||
10 => '10th',
|
||||
11 => '11th',
|
||||
12 => '12th',
|
||||
13 => '13th',
|
||||
14 => '14th',
|
||||
15 => '15th',
|
||||
16 => '16th',
|
||||
17 => '17th',
|
||||
18 => '18th',
|
||||
19 => '19th',
|
||||
20 => '20th',
|
||||
21 => '21st',
|
||||
22 => '22nd',
|
||||
23 => '23rd',
|
||||
24 => '24th',
|
||||
25 => '25th',
|
||||
26 => '26th',
|
||||
27 => '27th',
|
||||
28 => '28th',
|
||||
29 => '29th',
|
||||
30 => '30th',
|
||||
31 => '31st',
|
||||
32 => '32nd',
|
||||
33 => '33rd',
|
||||
34 => '34th',
|
||||
35 => '35th',
|
||||
36 => '36th',
|
||||
37 => '37th',
|
||||
38 => '38th',
|
||||
39 => '39th',
|
||||
40 => '40th',
|
||||
41 => '41st',
|
||||
42 => '42nd',
|
||||
43 => '43rd',
|
||||
44 => '44th',
|
||||
45 => '45th',
|
||||
46 => '46th',
|
||||
47 => '47th',
|
||||
48 => '48th',
|
||||
49 => '49th',
|
||||
50 => '50th',
|
||||
51 => '51st',
|
||||
52 => '52nd',
|
||||
53 => '53rd',
|
||||
54 => '54th',
|
||||
55 => '55th',
|
||||
56 => '56th',
|
||||
57 => '57th',
|
||||
58 => '58th',
|
||||
59 => '59th',
|
||||
60 => '60th',
|
||||
61 => '61st',
|
||||
62 => '62nd',
|
||||
63 => '63rd',
|
||||
64 => '64th',
|
||||
65 => '65th',
|
||||
66 => '66th',
|
||||
67 => '67th',
|
||||
68 => '68th',
|
||||
69 => '69th',
|
||||
70 => '70th',
|
||||
71 => '71st',
|
||||
72 => '72nd',
|
||||
73 => '73rd',
|
||||
74 => '74th',
|
||||
75 => '75th',
|
||||
76 => '76th',
|
||||
77 => '77th',
|
||||
78 => '78th',
|
||||
79 => '79th',
|
||||
80 => '80th',
|
||||
81 => '81st',
|
||||
82 => '82nd',
|
||||
83 => '83rd',
|
||||
84 => '84th',
|
||||
85 => '85th',
|
||||
86 => '86th',
|
||||
87 => '87th',
|
||||
88 => '88th',
|
||||
89 => '89th',
|
||||
90 => '90th',
|
||||
91 => '91st',
|
||||
92 => '92nd',
|
||||
93 => '93rd',
|
||||
94 => '94th',
|
||||
95 => '95th',
|
||||
96 => '96th',
|
||||
97 => '97th',
|
||||
98 => '98th',
|
||||
99 => '99th',
|
||||
100 => '100th'
|
||||
0 => "0th",
|
||||
1 => "1st",
|
||||
2 => "2nd",
|
||||
3 => "3rd",
|
||||
4 => "4th",
|
||||
5 => "5th",
|
||||
6 => "6th",
|
||||
7 => "7th",
|
||||
8 => "8th",
|
||||
9 => "9th",
|
||||
10 => "10th",
|
||||
11 => "11th",
|
||||
12 => "12th",
|
||||
13 => "13th",
|
||||
14 => "14th",
|
||||
15 => "15th",
|
||||
16 => "16th",
|
||||
17 => "17th",
|
||||
18 => "18th",
|
||||
19 => "19th",
|
||||
20 => "20th",
|
||||
21 => "21st",
|
||||
22 => "22nd",
|
||||
23 => "23rd",
|
||||
24 => "24th",
|
||||
25 => "25th",
|
||||
26 => "26th",
|
||||
27 => "27th",
|
||||
28 => "28th",
|
||||
29 => "29th",
|
||||
30 => "30th",
|
||||
31 => "31st",
|
||||
32 => "32nd",
|
||||
33 => "33rd",
|
||||
34 => "34th",
|
||||
35 => "35th",
|
||||
36 => "36th",
|
||||
37 => "37th",
|
||||
38 => "38th",
|
||||
39 => "39th",
|
||||
40 => "40th",
|
||||
41 => "41st",
|
||||
42 => "42nd",
|
||||
43 => "43rd",
|
||||
44 => "44th",
|
||||
45 => "45th",
|
||||
46 => "46th",
|
||||
47 => "47th",
|
||||
48 => "48th",
|
||||
49 => "49th",
|
||||
50 => "50th",
|
||||
51 => "51st",
|
||||
52 => "52nd",
|
||||
53 => "53rd",
|
||||
54 => "54th",
|
||||
55 => "55th",
|
||||
56 => "56th",
|
||||
57 => "57th",
|
||||
58 => "58th",
|
||||
59 => "59th",
|
||||
60 => "60th",
|
||||
61 => "61st",
|
||||
62 => "62nd",
|
||||
63 => "63rd",
|
||||
64 => "64th",
|
||||
65 => "65th",
|
||||
66 => "66th",
|
||||
67 => "67th",
|
||||
68 => "68th",
|
||||
69 => "69th",
|
||||
70 => "70th",
|
||||
71 => "71st",
|
||||
72 => "72nd",
|
||||
73 => "73rd",
|
||||
74 => "74th",
|
||||
75 => "75th",
|
||||
76 => "76th",
|
||||
77 => "77th",
|
||||
78 => "78th",
|
||||
79 => "79th",
|
||||
80 => "80th",
|
||||
81 => "81st",
|
||||
82 => "82nd",
|
||||
83 => "83rd",
|
||||
84 => "84th",
|
||||
85 => "85th",
|
||||
86 => "86th",
|
||||
87 => "87th",
|
||||
88 => "88th",
|
||||
89 => "89th",
|
||||
90 => "90th",
|
||||
91 => "91st",
|
||||
92 => "92nd",
|
||||
93 => "93rd",
|
||||
94 => "94th",
|
||||
95 => "95th",
|
||||
96 => "96th",
|
||||
97 => "97th",
|
||||
98 => "98th",
|
||||
99 => "99th",
|
||||
100 => "100th"
|
||||
}.freeze
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,394 +15,394 @@ module Fixtures
|
|||
end
|
||||
|
||||
IRREGULAR = {
|
||||
'person' => 'people',
|
||||
'man' => 'men',
|
||||
'child' => 'children',
|
||||
'sex' => 'sexes',
|
||||
'foot' => 'feet',
|
||||
'tooth' => 'teeth',
|
||||
'goose' => 'geese'
|
||||
"person" => "people",
|
||||
"man" => "men",
|
||||
"child" => "children",
|
||||
"sex" => "sexes",
|
||||
"foot" => "feet",
|
||||
"tooth" => "teeth",
|
||||
"goose" => "geese"
|
||||
}.freeze
|
||||
|
||||
CASES = {
|
||||
#
|
||||
# Test cases from Inflecto
|
||||
#
|
||||
'equipment' => 'equipment',
|
||||
'information' => 'information',
|
||||
'money' => 'money',
|
||||
'species' => 'species',
|
||||
'series' => 'series',
|
||||
'fish' => 'fish',
|
||||
'sheep' => 'sheep',
|
||||
'news' => 'news',
|
||||
'matrix' => 'matrices',
|
||||
'life' => 'lives',
|
||||
'wife' => 'wives',
|
||||
'alias' => 'aliases',
|
||||
'status' => 'statuses',
|
||||
'axis' => 'axes',
|
||||
'crisis' => 'crises',
|
||||
'testis' => 'testes',
|
||||
'tomato' => 'tomatoes',
|
||||
'buffalo' => 'buffaloes',
|
||||
'quiz' => 'quizzes',
|
||||
'vertex' => 'vertices',
|
||||
'index' => 'indices',
|
||||
'ox' => 'oxen',
|
||||
'mouse' => 'mice',
|
||||
'louse' => 'lice',
|
||||
'thesis' => 'theses',
|
||||
'analysis' => 'analyses',
|
||||
'octopus' => 'octopi',
|
||||
'grass' => 'grass',
|
||||
'drive' => 'drives',
|
||||
"equipment" => "equipment",
|
||||
"information" => "information",
|
||||
"money" => "money",
|
||||
"species" => "species",
|
||||
"series" => "series",
|
||||
"fish" => "fish",
|
||||
"sheep" => "sheep",
|
||||
"news" => "news",
|
||||
"matrix" => "matrices",
|
||||
"life" => "lives",
|
||||
"wife" => "wives",
|
||||
"alias" => "aliases",
|
||||
"status" => "statuses",
|
||||
"axis" => "axes",
|
||||
"crisis" => "crises",
|
||||
"testis" => "testes",
|
||||
"tomato" => "tomatoes",
|
||||
"buffalo" => "buffaloes",
|
||||
"quiz" => "quizzes",
|
||||
"vertex" => "vertices",
|
||||
"index" => "indices",
|
||||
"ox" => "oxen",
|
||||
"mouse" => "mice",
|
||||
"louse" => "lice",
|
||||
"thesis" => "theses",
|
||||
"analysis" => "analyses",
|
||||
"octopus" => "octopi",
|
||||
"grass" => "grass",
|
||||
"drive" => "drives",
|
||||
# ==== bugs, typos and reported issues
|
||||
|
||||
# ==== rules and most common cases
|
||||
|
||||
'forum' => 'forums',
|
||||
'hive' => 'hives',
|
||||
'athlete' => 'athletes',
|
||||
'dwarf' => 'dwarves',
|
||||
'woman' => 'women',
|
||||
'sportsman' => 'sportsmen',
|
||||
'branch' => 'branches',
|
||||
'crunch' => 'crunches',
|
||||
'trash' => 'trashes',
|
||||
'mash' => 'mashes',
|
||||
'cross' => 'crosses',
|
||||
'erratum' => 'errata',
|
||||
"forum" => "forums",
|
||||
"hive" => "hives",
|
||||
"athlete" => "athletes",
|
||||
"dwarf" => "dwarves",
|
||||
"woman" => "women",
|
||||
"sportsman" => "sportsmen",
|
||||
"branch" => "branches",
|
||||
"crunch" => "crunches",
|
||||
"trash" => "trashes",
|
||||
"mash" => "mashes",
|
||||
"cross" => "crosses",
|
||||
"erratum" => "errata",
|
||||
# FIXME: add -ia => -ium cases
|
||||
# FIXME: add -ra => -rum cases
|
||||
'ray' => 'rays',
|
||||
'spray' => 'sprays',
|
||||
"ray" => "rays",
|
||||
"spray" => "sprays",
|
||||
# Merriam-Webster dictionary says
|
||||
# preys is correct, too.
|
||||
'prey' => 'preys',
|
||||
'toy' => 'toys',
|
||||
'joy' => 'joys',
|
||||
'buy' => 'buys',
|
||||
'guy' => 'guys',
|
||||
'cry' => 'cries',
|
||||
'fly' => 'flies',
|
||||
'fox' => 'foxes',
|
||||
'elf' => 'elves',
|
||||
'shelf' => 'shelves',
|
||||
'cat' => 'cats',
|
||||
'rat' => 'rats',
|
||||
'rose' => 'roses',
|
||||
'project' => 'projects',
|
||||
'post' => 'posts',
|
||||
'article' => 'articles',
|
||||
'location' => 'locations',
|
||||
'friend' => 'friends',
|
||||
'link' => 'links',
|
||||
'url' => 'urls',
|
||||
'account' => 'accounts',
|
||||
'server' => 'servers',
|
||||
'fruit' => 'fruits',
|
||||
'map' => 'maps',
|
||||
'income' => 'incomes',
|
||||
'ping' => 'pings',
|
||||
'event' => 'events',
|
||||
'proof' => 'proofs',
|
||||
'typo' => 'typos',
|
||||
'attachment' => 'attachments',
|
||||
'download' => 'downloads',
|
||||
'asset' => 'assets',
|
||||
'job' => 'jobs',
|
||||
'city' => 'cities',
|
||||
'package' => 'packages',
|
||||
'commit' => 'commits',
|
||||
'version' => 'versions',
|
||||
'document' => 'documents',
|
||||
'edition' => 'editions',
|
||||
'movie' => 'movies',
|
||||
'song' => 'songs',
|
||||
'invoice' => 'invoices',
|
||||
'product' => 'products',
|
||||
'book' => 'books',
|
||||
'ticket' => 'tickets',
|
||||
'game' => 'games',
|
||||
'tournament' => 'tournaments',
|
||||
'prize' => 'prizes',
|
||||
'price' => 'prices',
|
||||
'installation' => 'installations',
|
||||
'date' => 'dates',
|
||||
'schedule' => 'schedules',
|
||||
'arena' => 'arenas',
|
||||
'spam' => 'spams',
|
||||
'bus' => 'buses',
|
||||
'rice' => 'rice',
|
||||
"prey" => "preys",
|
||||
"toy" => "toys",
|
||||
"joy" => "joys",
|
||||
"buy" => "buys",
|
||||
"guy" => "guys",
|
||||
"cry" => "cries",
|
||||
"fly" => "flies",
|
||||
"fox" => "foxes",
|
||||
"elf" => "elves",
|
||||
"shelf" => "shelves",
|
||||
"cat" => "cats",
|
||||
"rat" => "rats",
|
||||
"rose" => "roses",
|
||||
"project" => "projects",
|
||||
"post" => "posts",
|
||||
"article" => "articles",
|
||||
"location" => "locations",
|
||||
"friend" => "friends",
|
||||
"link" => "links",
|
||||
"url" => "urls",
|
||||
"account" => "accounts",
|
||||
"server" => "servers",
|
||||
"fruit" => "fruits",
|
||||
"map" => "maps",
|
||||
"income" => "incomes",
|
||||
"ping" => "pings",
|
||||
"event" => "events",
|
||||
"proof" => "proofs",
|
||||
"typo" => "typos",
|
||||
"attachment" => "attachments",
|
||||
"download" => "downloads",
|
||||
"asset" => "assets",
|
||||
"job" => "jobs",
|
||||
"city" => "cities",
|
||||
"package" => "packages",
|
||||
"commit" => "commits",
|
||||
"version" => "versions",
|
||||
"document" => "documents",
|
||||
"edition" => "editions",
|
||||
"movie" => "movies",
|
||||
"song" => "songs",
|
||||
"invoice" => "invoices",
|
||||
"product" => "products",
|
||||
"book" => "books",
|
||||
"ticket" => "tickets",
|
||||
"game" => "games",
|
||||
"tournament" => "tournaments",
|
||||
"prize" => "prizes",
|
||||
"price" => "prices",
|
||||
"installation" => "installations",
|
||||
"date" => "dates",
|
||||
"schedule" => "schedules",
|
||||
"arena" => "arenas",
|
||||
"spam" => "spams",
|
||||
"bus" => "buses",
|
||||
"rice" => "rice",
|
||||
|
||||
# Some specs from Rails (still taken from Inflecto code base)
|
||||
'search' => 'searches',
|
||||
'switch' => 'switches',
|
||||
'fix' => 'fixes',
|
||||
'box' => 'boxes',
|
||||
'process' => 'processes',
|
||||
'case' => 'cases',
|
||||
'stack' => 'stacks',
|
||||
'wish' => 'wishes',
|
||||
'category' => 'categories',
|
||||
'query' => 'queries',
|
||||
'ability' => 'abilities',
|
||||
'agency' => 'agencies',
|
||||
'archive' => 'archives',
|
||||
'safe' => 'saves',
|
||||
'half' => 'halves',
|
||||
'move' => 'moves',
|
||||
'salesperson' => 'salespeople',
|
||||
'spokesman' => 'spokesmen',
|
||||
'basis' => 'bases',
|
||||
'diagnosis' => 'diagnoses',
|
||||
'diagnosis_a' => 'diagnosis_as',
|
||||
'datum' => 'data',
|
||||
'medium' => 'media',
|
||||
'node_child' => 'node_children',
|
||||
'experience' => 'experiences',
|
||||
'day' => 'days',
|
||||
'comment' => 'comments',
|
||||
'foobar' => 'foobars',
|
||||
'newsletter' => 'newsletters',
|
||||
'old_news' => 'old_news',
|
||||
'perspective' => 'perspectives',
|
||||
'photo' => 'photos',
|
||||
'status_code' => 'status_codes',
|
||||
'house' => 'houses',
|
||||
'portfolio' => 'portfolios',
|
||||
'matrix_fu' => 'matrix_fus',
|
||||
'shoe' => 'shoes',
|
||||
'horse' => 'horses',
|
||||
'edge' => 'edges',
|
||||
'cow' => 'cows',
|
||||
"search" => "searches",
|
||||
"switch" => "switches",
|
||||
"fix" => "fixes",
|
||||
"box" => "boxes",
|
||||
"process" => "processes",
|
||||
"case" => "cases",
|
||||
"stack" => "stacks",
|
||||
"wish" => "wishes",
|
||||
"category" => "categories",
|
||||
"query" => "queries",
|
||||
"ability" => "abilities",
|
||||
"agency" => "agencies",
|
||||
"archive" => "archives",
|
||||
"safe" => "saves",
|
||||
"half" => "halves",
|
||||
"move" => "moves",
|
||||
"salesperson" => "salespeople",
|
||||
"spokesman" => "spokesmen",
|
||||
"basis" => "bases",
|
||||
"diagnosis" => "diagnoses",
|
||||
"diagnosis_a" => "diagnosis_as",
|
||||
"datum" => "data",
|
||||
"medium" => "media",
|
||||
"node_child" => "node_children",
|
||||
"experience" => "experiences",
|
||||
"day" => "days",
|
||||
"comment" => "comments",
|
||||
"foobar" => "foobars",
|
||||
"newsletter" => "newsletters",
|
||||
"old_news" => "old_news",
|
||||
"perspective" => "perspectives",
|
||||
"photo" => "photos",
|
||||
"status_code" => "status_codes",
|
||||
"house" => "houses",
|
||||
"portfolio" => "portfolios",
|
||||
"matrix_fu" => "matrix_fus",
|
||||
"shoe" => "shoes",
|
||||
"horse" => "horses",
|
||||
"edge" => "edges",
|
||||
"cow" => "cows",
|
||||
|
||||
#
|
||||
# Test cases from Hanami::Utils
|
||||
#
|
||||
|
||||
# um => a
|
||||
'bacterium' => 'bacteria',
|
||||
'agendum' => 'agenda',
|
||||
'desideratum' => 'desiderata',
|
||||
'stratum' => 'strata',
|
||||
'ovum' => 'ova',
|
||||
'extremum' => 'extrema',
|
||||
'candelabrum' => 'candelabra',
|
||||
'curriculum' => 'curricula',
|
||||
'millennium' => 'millennia',
|
||||
'referendum' => 'referenda',
|
||||
'stadium' => 'stadia',
|
||||
'memorandum' => 'memoranda',
|
||||
'criterium' => 'criteria',
|
||||
'perihelium' => 'perihelia',
|
||||
'aphelium' => 'aphelia',
|
||||
"bacterium" => "bacteria",
|
||||
"agendum" => "agenda",
|
||||
"desideratum" => "desiderata",
|
||||
"stratum" => "strata",
|
||||
"ovum" => "ova",
|
||||
"extremum" => "extrema",
|
||||
"candelabrum" => "candelabra",
|
||||
"curriculum" => "curricula",
|
||||
"millennium" => "millennia",
|
||||
"referendum" => "referenda",
|
||||
"stadium" => "stadia",
|
||||
"memorandum" => "memoranda",
|
||||
"criterium" => "criteria",
|
||||
"perihelium" => "perihelia",
|
||||
"aphelium" => "aphelia",
|
||||
# on => a
|
||||
'phenomenon' => 'phenomena',
|
||||
'prolegomenon' => 'prolegomena',
|
||||
'noumenon' => 'noumena',
|
||||
'organon' => 'organa',
|
||||
"phenomenon" => "phenomena",
|
||||
"prolegomenon" => "prolegomena",
|
||||
"noumenon" => "noumena",
|
||||
"organon" => "organa",
|
||||
# o => os
|
||||
'albino' => 'albinos',
|
||||
'archipelago' => 'archipelagos',
|
||||
'armadillo' => 'armadillos',
|
||||
'commando' => 'commandos',
|
||||
'crescendo' => 'crescendos',
|
||||
'fiasco' => 'fiascos',
|
||||
'ditto' => 'dittos',
|
||||
'dynamo' => 'dynamos',
|
||||
'embryo' => 'embryos',
|
||||
'ghetto' => 'ghettos',
|
||||
'guano' => 'guanos',
|
||||
'inferno' => 'infernos',
|
||||
'jumbo' => 'jumbos',
|
||||
'lumbago' => 'lumbagos',
|
||||
'magneto' => 'magnetos',
|
||||
'manifesto' => 'manifestos',
|
||||
'medico' => 'medicos',
|
||||
'octavo' => 'octavos',
|
||||
'pro' => 'pros',
|
||||
'quarto' => 'quartos',
|
||||
'canto' => 'cantos',
|
||||
'lingo' => 'lingos',
|
||||
'generalissimo' => 'generalissimos',
|
||||
'stylo' => 'stylos',
|
||||
'rhino' => 'rhinos',
|
||||
'casino' => 'casinos',
|
||||
'auto' => 'autos',
|
||||
'macro' => 'macros',
|
||||
'zero' => 'zeros',
|
||||
'todo' => 'todos',
|
||||
'studio' => 'studios',
|
||||
'avocado' => 'avocados',
|
||||
'zoo' => 'zoos',
|
||||
'banjo' => 'banjos',
|
||||
'cargo' => 'cargos',
|
||||
'flamingo' => 'flamingos',
|
||||
'fresco' => 'frescos',
|
||||
'halo' => 'halos',
|
||||
'mango' => 'mangos',
|
||||
'memento' => 'mementos',
|
||||
'motto' => 'mottos',
|
||||
'tornado' => 'tornados',
|
||||
'tuxedo' => 'tuxedos',
|
||||
'volcano' => 'volcanos',
|
||||
"albino" => "albinos",
|
||||
"archipelago" => "archipelagos",
|
||||
"armadillo" => "armadillos",
|
||||
"commando" => "commandos",
|
||||
"crescendo" => "crescendos",
|
||||
"fiasco" => "fiascos",
|
||||
"ditto" => "dittos",
|
||||
"dynamo" => "dynamos",
|
||||
"embryo" => "embryos",
|
||||
"ghetto" => "ghettos",
|
||||
"guano" => "guanos",
|
||||
"inferno" => "infernos",
|
||||
"jumbo" => "jumbos",
|
||||
"lumbago" => "lumbagos",
|
||||
"magneto" => "magnetos",
|
||||
"manifesto" => "manifestos",
|
||||
"medico" => "medicos",
|
||||
"octavo" => "octavos",
|
||||
"pro" => "pros",
|
||||
"quarto" => "quartos",
|
||||
"canto" => "cantos",
|
||||
"lingo" => "lingos",
|
||||
"generalissimo" => "generalissimos",
|
||||
"stylo" => "stylos",
|
||||
"rhino" => "rhinos",
|
||||
"casino" => "casinos",
|
||||
"auto" => "autos",
|
||||
"macro" => "macros",
|
||||
"zero" => "zeros",
|
||||
"todo" => "todos",
|
||||
"studio" => "studios",
|
||||
"avocado" => "avocados",
|
||||
"zoo" => "zoos",
|
||||
"banjo" => "banjos",
|
||||
"cargo" => "cargos",
|
||||
"flamingo" => "flamingos",
|
||||
"fresco" => "frescos",
|
||||
"halo" => "halos",
|
||||
"mango" => "mangos",
|
||||
"memento" => "mementos",
|
||||
"motto" => "mottos",
|
||||
"tornado" => "tornados",
|
||||
"tuxedo" => "tuxedos",
|
||||
"volcano" => "volcanos",
|
||||
# The correct form from italian is: o => i. (Eg. contralto => contralti)
|
||||
# English dictionaries are reporting o => s as a valid rule
|
||||
#
|
||||
# We're sticking to the latter rule, in order to not introduce exceptions
|
||||
# for words that end with "o". See the previous category.
|
||||
'solo' => 'solos',
|
||||
'soprano' => 'sopranos',
|
||||
'basso' => 'bassos',
|
||||
'alto' => 'altos',
|
||||
'contralto' => 'contraltos',
|
||||
'tempo' => 'tempos',
|
||||
'piano' => 'pianos',
|
||||
'virtuoso' => 'virtuosos',
|
||||
"solo" => "solos",
|
||||
"soprano" => "sopranos",
|
||||
"basso" => "bassos",
|
||||
"alto" => "altos",
|
||||
"contralto" => "contraltos",
|
||||
"tempo" => "tempos",
|
||||
"piano" => "pianos",
|
||||
"virtuoso" => "virtuosos",
|
||||
# o => oes
|
||||
'domino' => 'dominoes',
|
||||
'echo' => 'echoes',
|
||||
'embargo' => 'embargoes',
|
||||
'hero' => 'heroes',
|
||||
'mosquito' => 'mosquitoes',
|
||||
'potato' => 'potatoes',
|
||||
'torpedo' => 'torpedos',
|
||||
'veto' => 'vetos',
|
||||
"domino" => "dominoes",
|
||||
"echo" => "echoes",
|
||||
"embargo" => "embargoes",
|
||||
"hero" => "heroes",
|
||||
"mosquito" => "mosquitoes",
|
||||
"potato" => "potatoes",
|
||||
"torpedo" => "torpedos",
|
||||
"veto" => "vetos",
|
||||
# a => ata
|
||||
'anathema' => 'anathemata',
|
||||
'enema' => 'enemata',
|
||||
'oedema' => 'oedemata',
|
||||
'bema' => 'bemata',
|
||||
'enigma' => 'enigmata',
|
||||
'sarcoma' => 'sarcomata',
|
||||
'carcinoma' => 'carcinomata',
|
||||
'gumma' => 'gummata',
|
||||
'schema' => 'schemata',
|
||||
'charisma' => 'charismata',
|
||||
'lemma' => 'lemmata',
|
||||
'soma' => 'somata',
|
||||
'diploma' => 'diplomata',
|
||||
'lymphoma' => 'lymphomata',
|
||||
'stigma' => 'stigmata',
|
||||
'dogma' => 'dogmata',
|
||||
'magma' => 'magmata',
|
||||
'stoma' => 'stomata',
|
||||
'drama' => 'dramata',
|
||||
'melisma' => 'melismata',
|
||||
'trauma' => 'traumata',
|
||||
'edema' => 'edemata',
|
||||
'miasma' => 'miasmata',
|
||||
"anathema" => "anathemata",
|
||||
"enema" => "enemata",
|
||||
"oedema" => "oedemata",
|
||||
"bema" => "bemata",
|
||||
"enigma" => "enigmata",
|
||||
"sarcoma" => "sarcomata",
|
||||
"carcinoma" => "carcinomata",
|
||||
"gumma" => "gummata",
|
||||
"schema" => "schemata",
|
||||
"charisma" => "charismata",
|
||||
"lemma" => "lemmata",
|
||||
"soma" => "somata",
|
||||
"diploma" => "diplomata",
|
||||
"lymphoma" => "lymphomata",
|
||||
"stigma" => "stigmata",
|
||||
"dogma" => "dogmata",
|
||||
"magma" => "magmata",
|
||||
"stoma" => "stomata",
|
||||
"drama" => "dramata",
|
||||
"melisma" => "melismata",
|
||||
"trauma" => "traumata",
|
||||
"edema" => "edemata",
|
||||
"miasma" => "miasmata",
|
||||
# us => uses
|
||||
'apparatus' => 'apparatuses',
|
||||
'impetus' => 'impetuses',
|
||||
'prospectus' => 'prospectuses',
|
||||
'cantus' => 'cantuses',
|
||||
'nexus' => 'nexuses',
|
||||
'sinus' => 'sinuses',
|
||||
'coitus' => 'coituses',
|
||||
'plexus' => 'plexuses',
|
||||
'hiatus' => 'hiatuses',
|
||||
"apparatus" => "apparatuses",
|
||||
"impetus" => "impetuses",
|
||||
"prospectus" => "prospectuses",
|
||||
"cantus" => "cantuses",
|
||||
"nexus" => "nexuses",
|
||||
"sinus" => "sinuses",
|
||||
"coitus" => "coituses",
|
||||
"plexus" => "plexuses",
|
||||
"hiatus" => "hiatuses",
|
||||
# man => mans
|
||||
'human' => 'humans',
|
||||
"human" => "humans",
|
||||
# ch => es
|
||||
'witch' => 'witches',
|
||||
'church' => 'churches',
|
||||
"witch" => "witches",
|
||||
"church" => "churches",
|
||||
# ch => chs
|
||||
'stomach' => 'stomachs',
|
||||
'epoch' => 'epochs',
|
||||
"stomach" => "stomachs",
|
||||
"epoch" => "epochs",
|
||||
# e => es,
|
||||
'mustache' => 'mustaches',
|
||||
'verse' => 'verses',
|
||||
'universe' => 'universes',
|
||||
'inverse' => 'inverses',
|
||||
'advice' => 'advices',
|
||||
'device' => 'devices',
|
||||
"mustache" => "mustaches",
|
||||
"verse" => "verses",
|
||||
"universe" => "universes",
|
||||
"inverse" => "inverses",
|
||||
"advice" => "advices",
|
||||
"device" => "devices",
|
||||
# vowel + y => s
|
||||
'boy' => 'boys',
|
||||
'way' => 'ways',
|
||||
"boy" => "boys",
|
||||
"way" => "ways",
|
||||
# consonant + y => ies
|
||||
'baby' => 'babies',
|
||||
'lorry' => 'lorries',
|
||||
'entity' => 'entities',
|
||||
'repository' => 'repositories',
|
||||
"baby" => "babies",
|
||||
"lorry" => "lorries",
|
||||
"entity" => "entities",
|
||||
"repository" => "repositories",
|
||||
# f => ves
|
||||
'leaf' => 'leaves',
|
||||
'hoof' => 'hooves',
|
||||
'self' => 'selves',
|
||||
'scarf' => 'scarves',
|
||||
'thief' => 'thieves',
|
||||
"leaf" => "leaves",
|
||||
"hoof" => "hooves",
|
||||
"self" => "selves",
|
||||
"scarf" => "scarves",
|
||||
"thief" => "thieves",
|
||||
# vocal + fe => ves
|
||||
'knife' => 'knives',
|
||||
"knife" => "knives",
|
||||
# eau => eaux
|
||||
'beau' => 'beaux',
|
||||
'bureau' => 'bureaux',
|
||||
'tableau' => 'tableaux',
|
||||
"beau" => "beaux",
|
||||
"bureau" => "bureaux",
|
||||
"tableau" => "tableaux",
|
||||
# irregular
|
||||
'cactus' => 'cacti',
|
||||
"cactus" => "cacti",
|
||||
# uncountable
|
||||
'deer' => 'deer',
|
||||
'means' => 'means',
|
||||
'milk' => 'milk',
|
||||
'hovercraft' => 'hovercraft',
|
||||
'rain' => 'rain',
|
||||
'moose' => 'moose',
|
||||
"deer" => "deer",
|
||||
"means" => "means",
|
||||
"milk" => "milk",
|
||||
"hovercraft" => "hovercraft",
|
||||
"rain" => "rain",
|
||||
"moose" => "moose",
|
||||
# fallback (add s)
|
||||
'giraffe' => 'giraffes',
|
||||
'test' => 'tests',
|
||||
'feature' => 'features',
|
||||
'fixture' => 'fixtures',
|
||||
'controller' => 'controllers',
|
||||
'action' => 'actions',
|
||||
'router' => 'routers',
|
||||
'route' => 'routes',
|
||||
'endpoint' => 'endpoints',
|
||||
'string' => 'strings',
|
||||
'view' => 'views',
|
||||
'template' => 'templates',
|
||||
'layout' => 'layouts',
|
||||
'application' => 'applications',
|
||||
'api' => 'apis',
|
||||
'model' => 'models',
|
||||
'mapper' => 'mappers',
|
||||
'mapping' => 'mappings',
|
||||
'table' => 'tables',
|
||||
'attribute' => 'attributes',
|
||||
'column' => 'columns',
|
||||
'migration' => 'migrations',
|
||||
'presenter' => 'presenters',
|
||||
'wizard' => 'wizards',
|
||||
'architecture' => 'architectures',
|
||||
'car' => 'cars',
|
||||
'area' => 'areas',
|
||||
"giraffe" => "giraffes",
|
||||
"test" => "tests",
|
||||
"feature" => "features",
|
||||
"fixture" => "fixtures",
|
||||
"controller" => "controllers",
|
||||
"action" => "actions",
|
||||
"router" => "routers",
|
||||
"route" => "routes",
|
||||
"endpoint" => "endpoints",
|
||||
"string" => "strings",
|
||||
"view" => "views",
|
||||
"template" => "templates",
|
||||
"layout" => "layouts",
|
||||
"application" => "applications",
|
||||
"api" => "apis",
|
||||
"model" => "models",
|
||||
"mapper" => "mappers",
|
||||
"mapping" => "mappings",
|
||||
"table" => "tables",
|
||||
"attribute" => "attributes",
|
||||
"column" => "columns",
|
||||
"migration" => "migrations",
|
||||
"presenter" => "presenters",
|
||||
"wizard" => "wizards",
|
||||
"architecture" => "architectures",
|
||||
"car" => "cars",
|
||||
"area" => "areas",
|
||||
# https://github.com/hanami/utils/issues/106
|
||||
'album' => 'albums',
|
||||
"album" => "albums",
|
||||
# https://github.com/hanami/utils/issues/173
|
||||
'kitten' => 'kittens',
|
||||
"kitten" => "kittens",
|
||||
|
||||
# Ending with 'ss'
|
||||
'address' => 'addresses',
|
||||
'boss' => 'bosses',
|
||||
'class' => 'classes',
|
||||
'glass' => 'glasses',
|
||||
'kiss' => 'kisses',
|
||||
"address" => "addresses",
|
||||
"boss" => "bosses",
|
||||
"class" => "classes",
|
||||
"glass" => "glasses",
|
||||
"kiss" => "kisses",
|
||||
|
||||
# Ending with 'sses'
|
||||
'addresses' => 'addresses',
|
||||
'bosses' => 'bosses',
|
||||
'classes' => 'classes',
|
||||
'glasses' => 'glasses',
|
||||
'kisses' => 'kisses'
|
||||
"addresses" => "addresses",
|
||||
"bosses" => "bosses",
|
||||
"classes" => "classes",
|
||||
"glasses" => "glasses",
|
||||
"kisses" => "kisses"
|
||||
}.merge(IRREGULAR).freeze
|
||||
|
||||
# Missing rule or exception?
|
||||
PENDING = {
|
||||
'criterion' => 'criteria',
|
||||
'thesaurus' => 'thesauri',
|
||||
'plus' => 'plusses',
|
||||
'virus' => 'viruses',
|
||||
'Swiss' => 'Swiss'
|
||||
"criterion" => "criteria",
|
||||
"thesaurus" => "thesauri",
|
||||
"plus" => "plusses",
|
||||
"virus" => "viruses",
|
||||
"Swiss" => "Swiss"
|
||||
}.freeze
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,167 +13,167 @@ module Fixtures
|
|||
# ==== exceptional cases
|
||||
|
||||
CASES = {
|
||||
'equipment' => 'equipment',
|
||||
'mysql' => 'mysql',
|
||||
'information' => 'information',
|
||||
'money' => 'money',
|
||||
'species' => 'species',
|
||||
'series' => 'series',
|
||||
'fish' => 'fish',
|
||||
'sheep' => 'sheep',
|
||||
'news' => 'news',
|
||||
'rain' => 'rain',
|
||||
'milk' => 'milk',
|
||||
'moose' => 'moose',
|
||||
'geese' => 'goose',
|
||||
'hovercraft' => 'hovercraft',
|
||||
'matrices' => 'matrix',
|
||||
'lives' => 'life',
|
||||
'wives' => 'wife',
|
||||
'aliases' => 'alias',
|
||||
'statuses' => 'status',
|
||||
'axes' => 'axis',
|
||||
'crises' => 'crisis',
|
||||
'testes' => 'testis',
|
||||
'children' => 'child',
|
||||
'people' => 'person',
|
||||
'potatoes' => 'potato',
|
||||
'tomatoes' => 'tomato',
|
||||
'buffaloes' => 'buffalo',
|
||||
'torpedoes' => 'torpedo',
|
||||
'quizzes' => 'quiz',
|
||||
'vertices' => 'vertex',
|
||||
'indices' => 'index',
|
||||
'indexes' => 'index',
|
||||
'oxen' => 'ox',
|
||||
'mice' => 'mouse',
|
||||
'lice' => 'louse',
|
||||
'theses' => 'thesis',
|
||||
'analyses' => 'analysis',
|
||||
'octopi' => 'octopus',
|
||||
'grass' => 'grass',
|
||||
"equipment" => "equipment",
|
||||
"mysql" => "mysql",
|
||||
"information" => "information",
|
||||
"money" => "money",
|
||||
"species" => "species",
|
||||
"series" => "series",
|
||||
"fish" => "fish",
|
||||
"sheep" => "sheep",
|
||||
"news" => "news",
|
||||
"rain" => "rain",
|
||||
"milk" => "milk",
|
||||
"moose" => "moose",
|
||||
"geese" => "goose",
|
||||
"hovercraft" => "hovercraft",
|
||||
"matrices" => "matrix",
|
||||
"lives" => "life",
|
||||
"wives" => "wife",
|
||||
"aliases" => "alias",
|
||||
"statuses" => "status",
|
||||
"axes" => "axis",
|
||||
"crises" => "crisis",
|
||||
"testes" => "testis",
|
||||
"children" => "child",
|
||||
"people" => "person",
|
||||
"potatoes" => "potato",
|
||||
"tomatoes" => "tomato",
|
||||
"buffaloes" => "buffalo",
|
||||
"torpedoes" => "torpedo",
|
||||
"quizzes" => "quiz",
|
||||
"vertices" => "vertex",
|
||||
"indices" => "index",
|
||||
"indexes" => "index",
|
||||
"oxen" => "ox",
|
||||
"mice" => "mouse",
|
||||
"lice" => "louse",
|
||||
"theses" => "thesis",
|
||||
"analyses" => "analysis",
|
||||
"octopi" => "octopus",
|
||||
"grass" => "grass",
|
||||
# ==== bugs, typos and reported issues
|
||||
|
||||
'alias' => 'alias',
|
||||
'status' => 'status',
|
||||
'bus' => 'bus',
|
||||
'axis' => 'axis',
|
||||
'crisis' => 'crisis',
|
||||
'testis' => 'testis',
|
||||
'thesis' => 'thesis',
|
||||
'analysis' => 'analysis',
|
||||
'octopus' => 'octopus',
|
||||
"alias" => "alias",
|
||||
"status" => "status",
|
||||
"bus" => "bus",
|
||||
"axis" => "axis",
|
||||
"crisis" => "crisis",
|
||||
"testis" => "testis",
|
||||
"thesis" => "thesis",
|
||||
"analysis" => "analysis",
|
||||
"octopus" => "octopus",
|
||||
|
||||
# ==== rules
|
||||
|
||||
'forums' => 'forum',
|
||||
'hives' => 'hive',
|
||||
'athletes' => 'athlete',
|
||||
'dwarves' => 'dwarf',
|
||||
'heroes' => 'hero',
|
||||
'zeroes' => 'zero',
|
||||
'men' => 'man',
|
||||
'women' => 'woman',
|
||||
'sportsmen' => 'sportsman',
|
||||
'branches' => 'branch',
|
||||
'crunches' => 'crunch',
|
||||
'trashes' => 'trash',
|
||||
'mashes' => 'mash',
|
||||
'crosses' => 'cross',
|
||||
'errata' => 'erratum',
|
||||
"forums" => "forum",
|
||||
"hives" => "hive",
|
||||
"athletes" => "athlete",
|
||||
"dwarves" => "dwarf",
|
||||
"heroes" => "hero",
|
||||
"zeroes" => "zero",
|
||||
"men" => "man",
|
||||
"women" => "woman",
|
||||
"sportsmen" => "sportsman",
|
||||
"branches" => "branch",
|
||||
"crunches" => "crunch",
|
||||
"trashes" => "trash",
|
||||
"mashes" => "mash",
|
||||
"crosses" => "cross",
|
||||
"errata" => "erratum",
|
||||
# FIXME: add -ia => -ium cases
|
||||
|
||||
# FIXME: add -ra => -rum cases
|
||||
|
||||
'rays' => 'ray',
|
||||
'sprays' => 'spray',
|
||||
"rays" => "ray",
|
||||
"sprays" => "spray",
|
||||
# Merriam-Webster dictionary says
|
||||
# preys is correct, too.
|
||||
'preys' => 'prey',
|
||||
'toys' => 'toy',
|
||||
'joys' => 'joy',
|
||||
'buys' => 'buy',
|
||||
'guys' => 'guy',
|
||||
'cries' => 'cry',
|
||||
'flies' => 'fly',
|
||||
'foxes' => 'fox',
|
||||
'elves' => 'elf',
|
||||
'shelves' => 'shelf',
|
||||
'cats' => 'cat',
|
||||
'rats' => 'rat',
|
||||
'roses' => 'rose',
|
||||
'projects' => 'project',
|
||||
'posts' => 'post',
|
||||
'articles' => 'article',
|
||||
'locations' => 'location',
|
||||
'friends' => 'friend',
|
||||
'links' => 'link',
|
||||
'urls' => 'url',
|
||||
'accounts' => 'account',
|
||||
'servers' => 'server',
|
||||
'fruits' => 'fruit',
|
||||
'maps' => 'map',
|
||||
'incomes' => 'income',
|
||||
'pings' => 'ping',
|
||||
'events' => 'event',
|
||||
'proofs' => 'proof',
|
||||
'typos' => 'typo',
|
||||
'attachments' => 'attachment',
|
||||
'downloads' => 'download',
|
||||
'assets' => 'asset',
|
||||
'jobs' => 'job',
|
||||
'cities' => 'city',
|
||||
'packages' => 'package',
|
||||
'commits' => 'commit',
|
||||
'versions' => 'version',
|
||||
'documents' => 'document',
|
||||
'editions' => 'edition',
|
||||
'movies' => 'movie',
|
||||
'songs' => 'song',
|
||||
'invoices' => 'invoice',
|
||||
'products' => 'product',
|
||||
'books' => 'book',
|
||||
'tickets' => 'ticket',
|
||||
'games' => 'game',
|
||||
'tournaments' => 'tournament',
|
||||
'prizes' => 'prize',
|
||||
'prices' => 'price',
|
||||
'installations' => 'installation',
|
||||
'dates' => 'date',
|
||||
'schedules' => 'schedule',
|
||||
'arenas' => 'arena',
|
||||
'spams' => 'spam',
|
||||
'rice' => 'rice',
|
||||
"preys" => "prey",
|
||||
"toys" => "toy",
|
||||
"joys" => "joy",
|
||||
"buys" => "buy",
|
||||
"guys" => "guy",
|
||||
"cries" => "cry",
|
||||
"flies" => "fly",
|
||||
"foxes" => "fox",
|
||||
"elves" => "elf",
|
||||
"shelves" => "shelf",
|
||||
"cats" => "cat",
|
||||
"rats" => "rat",
|
||||
"roses" => "rose",
|
||||
"projects" => "project",
|
||||
"posts" => "post",
|
||||
"articles" => "article",
|
||||
"locations" => "location",
|
||||
"friends" => "friend",
|
||||
"links" => "link",
|
||||
"urls" => "url",
|
||||
"accounts" => "account",
|
||||
"servers" => "server",
|
||||
"fruits" => "fruit",
|
||||
"maps" => "map",
|
||||
"incomes" => "income",
|
||||
"pings" => "ping",
|
||||
"events" => "event",
|
||||
"proofs" => "proof",
|
||||
"typos" => "typo",
|
||||
"attachments" => "attachment",
|
||||
"downloads" => "download",
|
||||
"assets" => "asset",
|
||||
"jobs" => "job",
|
||||
"cities" => "city",
|
||||
"packages" => "package",
|
||||
"commits" => "commit",
|
||||
"versions" => "version",
|
||||
"documents" => "document",
|
||||
"editions" => "edition",
|
||||
"movies" => "movie",
|
||||
"songs" => "song",
|
||||
"invoices" => "invoice",
|
||||
"products" => "product",
|
||||
"books" => "book",
|
||||
"tickets" => "ticket",
|
||||
"games" => "game",
|
||||
"tournaments" => "tournament",
|
||||
"prizes" => "prize",
|
||||
"prices" => "price",
|
||||
"installations" => "installation",
|
||||
"dates" => "date",
|
||||
"schedules" => "schedule",
|
||||
"arenas" => "arena",
|
||||
"spams" => "spam",
|
||||
"rice" => "rice",
|
||||
|
||||
# ending with 'ss'
|
||||
'address' => 'address',
|
||||
'boss' => 'boss',
|
||||
'class' => 'class',
|
||||
'glass' => 'glass',
|
||||
'kiss' => 'kiss',
|
||||
"address" => "address",
|
||||
"boss" => "boss",
|
||||
"class" => "class",
|
||||
"glass" => "glass",
|
||||
"kiss" => "kiss",
|
||||
|
||||
# ending with 'sses'
|
||||
'addresses' => 'address',
|
||||
'bosses' => 'boss',
|
||||
'classes' => 'class',
|
||||
'glasses' => 'glass',
|
||||
'kisses' => 'kiss',
|
||||
"addresses" => "address",
|
||||
"bosses" => "boss",
|
||||
"classes" => "class",
|
||||
"glasses" => "glass",
|
||||
"kisses" => "kiss",
|
||||
|
||||
# uncountable
|
||||
'Swiss' => 'Swiss'
|
||||
"Swiss" => "Swiss"
|
||||
}.freeze
|
||||
|
||||
# Missing exceptions or missing rules?
|
||||
PENDING = {
|
||||
'cacti' => 'cactus',
|
||||
'cactuses' => 'cactus',
|
||||
'thesauri' => 'thesaurus',
|
||||
'phenomena' => 'phenomenon',
|
||||
'drives' => 'drive',
|
||||
'pluses' => 'plus',
|
||||
'thieves' => 'thief',
|
||||
'criteria' => 'criterion',
|
||||
'postgres' => 'postgres'
|
||||
"cacti" => "cactus",
|
||||
"cactuses" => "cactus",
|
||||
"thesauri" => "thesaurus",
|
||||
"phenomena" => "phenomenon",
|
||||
"drives" => "drive",
|
||||
"pluses" => "plus",
|
||||
"thieves" => "thief",
|
||||
"criteria" => "criterion",
|
||||
"postgres" => "postgres"
|
||||
}.freeze
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,40 +3,40 @@
|
|||
RSpec.describe Dry::Inflector do
|
||||
subject do
|
||||
Dry::Inflector.new do |inflect|
|
||||
inflect.acronym('API', 'RESTful', 'RoR', 'PhD', 'W3C', 'SSL', 'HTML')
|
||||
inflect.acronym("API", "RESTful", "RoR", "PhD", "W3C", "SSL", "HTML")
|
||||
end
|
||||
end
|
||||
|
||||
describe 'acronyms' do
|
||||
it 'uses acronyms' do
|
||||
describe "acronyms" do
|
||||
it "uses acronyms" do
|
||||
aggregate_failures do
|
||||
# These examples were taken from ActiveSupport's test suite
|
||||
# camelize underscore humanize
|
||||
[
|
||||
['API', 'api', 'API'],
|
||||
['APIController', 'api_controller', 'API controller'],
|
||||
['Nokogiri::HTML', 'nokogiri/html', 'Nokogiri/HTML'],
|
||||
['HTTPAPI', 'http_api', 'HTTP API'],
|
||||
['HTTP::Get', 'http/get', 'HTTP/get'],
|
||||
['SSLError', 'ssl_error', 'SSL error'],
|
||||
['RESTful', 'restful', 'RESTful'],
|
||||
['RESTfulController', 'restful_controller', 'RESTful controller'],
|
||||
['Nested::RESTful', 'nested/restful', 'Nested/RESTful'],
|
||||
['IHeartW3C', 'i_heart_w3c', 'I heart W3C'],
|
||||
['PhDRequired', 'phd_required', 'PhD required'],
|
||||
['IRoRU', 'i_ror_u', 'I RoR u'],
|
||||
['RESTfulHTTPAPI', 'restful_http_api', 'RESTful HTTP API'],
|
||||
['HTTP::RESTful', 'http/restful', 'HTTP/RESTful'],
|
||||
['HTTP::RESTfulAPI', 'http/restful_api', 'HTTP/RESTful API'],
|
||||
['APIRESTful', 'api_restful', 'API RESTful'],
|
||||
%w[API api API],
|
||||
["APIController", "api_controller", "API controller"],
|
||||
["Nokogiri::HTML", "nokogiri/html", "Nokogiri/HTML"],
|
||||
["HTTPAPI", "http_api", "HTTP API"],
|
||||
["HTTP::Get", "http/get", "HTTP/get"],
|
||||
["SSLError", "ssl_error", "SSL error"],
|
||||
%w[RESTful restful RESTful],
|
||||
["RESTfulController", "restful_controller", "RESTful controller"],
|
||||
["Nested::RESTful", "nested/restful", "Nested/RESTful"],
|
||||
["IHeartW3C", "i_heart_w3c", "I heart W3C"],
|
||||
["PhDRequired", "phd_required", "PhD required"],
|
||||
["IRoRU", "i_ror_u", "I RoR u"],
|
||||
["RESTfulHTTPAPI", "restful_http_api", "RESTful HTTP API"],
|
||||
["HTTP::RESTful", "http/restful", "HTTP/RESTful"],
|
||||
["HTTP::RESTfulAPI", "http/restful_api", "HTTP/RESTful API"],
|
||||
["APIRESTful", "api_restful", "API RESTful"],
|
||||
|
||||
# misdirection
|
||||
['Capistrano', 'capistrano', 'Capistrano'],
|
||||
['CapiController', 'capi_controller', 'Capi controller'],
|
||||
['HttpsApis', 'https_apis', 'Https apis'],
|
||||
['Html5', 'html5', 'Html5'],
|
||||
['Restfully', 'restfully', 'Restfully'],
|
||||
['RoRails', 'ro_rails', 'Ro rails']
|
||||
%w[Capistrano capistrano Capistrano],
|
||||
["CapiController", "capi_controller", "Capi controller"],
|
||||
["HttpsApis", "https_apis", "Https apis"],
|
||||
%w[Html5 html5 Html5],
|
||||
%w[Restfully restfully Restfully],
|
||||
["RoRails", "ro_rails", "Ro rails"]
|
||||
].each do |camel, under, human|
|
||||
expect(subject.camelize(under)).to eql(camel)
|
||||
expect(subject.camelize(camel)).to eql(camel)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Dry::Inflector do
|
||||
describe '#camelize_lower' do
|
||||
describe "#camelize_lower" do
|
||||
Fixtures::CamelizeLower.cases.each do |input, camelized|
|
||||
it "lower camelizes #{input} => #{camelized}" do
|
||||
expect(subject.camelize_lower(i(input))).to eq(camelized)
|
||||
|
@ -12,31 +12,31 @@ RSpec.describe Dry::Inflector do
|
|||
pending "missing exception or rule for #{input} => #{camelized}"
|
||||
end
|
||||
|
||||
it 'accepts symbols' do
|
||||
expect(subject.camelize_lower(:data_mapper)).to eq('dataMapper')
|
||||
it "accepts symbols" do
|
||||
expect(subject.camelize_lower(:data_mapper)).to eq("dataMapper")
|
||||
end
|
||||
|
||||
it 'handles acronyms' do
|
||||
expect(subject.camelize_lower(i('json'))).to eql('JSON')
|
||||
expect(subject.camelize_lower(i('http_error'))).to eql('HTTPError')
|
||||
expect(subject.camelize_lower(i('openssl/hmac'))).to eql('OpenSSL::HMAC')
|
||||
expect(subject.camelize_lower(i('openssl/digest'))).to eql('OpenSSL::Digest')
|
||||
it "handles acronyms" do
|
||||
expect(subject.camelize_lower(i("json"))).to eql("JSON")
|
||||
expect(subject.camelize_lower(i("http_error"))).to eql("HTTPError")
|
||||
expect(subject.camelize_lower(i("openssl/hmac"))).to eql("OpenSSL::HMAC")
|
||||
expect(subject.camelize_lower(i("openssl/digest"))).to eql("OpenSSL::Digest")
|
||||
end
|
||||
|
||||
context 'custom acronyms' do
|
||||
context "custom acronyms" do
|
||||
subject do
|
||||
Dry::Inflector.new do |inflect|
|
||||
inflect.acronym('IP', 'HTML', 'XML', 'BSD')
|
||||
inflect.acronym("IP", "HTML", "XML", "BSD")
|
||||
end
|
||||
end
|
||||
|
||||
it 'handles acronyms' do
|
||||
expect(subject.camelize_lower(i('ip'))).to eql('IP')
|
||||
expect(subject.camelize_lower(i('ip_sec'))).to eql('IPSec')
|
||||
expect(subject.camelize_lower(i('html_tidy'))).to eql('HTMLTidy')
|
||||
expect(subject.camelize_lower(i('html_tidy_generator'))).to eql('HTMLTidyGenerator')
|
||||
expect(subject.camelize_lower(i('force_xml_controller'))).to eql('forceXMLController')
|
||||
expect(subject.camelize_lower(i('free_bsd'))).to eql('freeBSD')
|
||||
it "handles acronyms" do
|
||||
expect(subject.camelize_lower(i("ip"))).to eql("IP")
|
||||
expect(subject.camelize_lower(i("ip_sec"))).to eql("IPSec")
|
||||
expect(subject.camelize_lower(i("html_tidy"))).to eql("HTMLTidy")
|
||||
expect(subject.camelize_lower(i("html_tidy_generator"))).to eql("HTMLTidyGenerator")
|
||||
expect(subject.camelize_lower(i("force_xml_controller"))).to eql("forceXMLController")
|
||||
expect(subject.camelize_lower(i("free_bsd"))).to eql("freeBSD")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Dry::Inflector do
|
||||
describe '#camelize_upper' do
|
||||
describe "#camelize_upper" do
|
||||
Fixtures::CamelizeUpper.cases.each do |input, camelized|
|
||||
it "upper camelizes #{input} => #{camelized}" do
|
||||
expect(subject.camelize_upper(i(input))).to eq(camelized)
|
||||
|
@ -12,35 +12,35 @@ RSpec.describe Dry::Inflector do
|
|||
pending "missing exception or rule for #{input} => #{camelized}"
|
||||
end
|
||||
|
||||
it 'accepts symbols' do
|
||||
expect(subject.camelize_upper(:data_mapper)).to eq('DataMapper')
|
||||
it "accepts symbols" do
|
||||
expect(subject.camelize_upper(:data_mapper)).to eq("DataMapper")
|
||||
end
|
||||
|
||||
it 'have alias' do
|
||||
expect(subject.camelize('camelize_upper')).to eq('CamelizeUpper')
|
||||
it "have alias" do
|
||||
expect(subject.camelize("camelize_upper")).to eq("CamelizeUpper")
|
||||
end
|
||||
|
||||
it 'handles acronyms' do
|
||||
expect(subject.camelize_upper(i('json'))).to eql('JSON')
|
||||
expect(subject.camelize_upper(i('http_error'))).to eql('HTTPError')
|
||||
expect(subject.camelize_upper(i('openssl/hmac'))).to eql('OpenSSL::HMAC')
|
||||
expect(subject.camelize_upper(i('openssl/digest'))).to eql('OpenSSL::Digest')
|
||||
it "handles acronyms" do
|
||||
expect(subject.camelize_upper(i("json"))).to eql("JSON")
|
||||
expect(subject.camelize_upper(i("http_error"))).to eql("HTTPError")
|
||||
expect(subject.camelize_upper(i("openssl/hmac"))).to eql("OpenSSL::HMAC")
|
||||
expect(subject.camelize_upper(i("openssl/digest"))).to eql("OpenSSL::Digest")
|
||||
end
|
||||
|
||||
context 'custom acronyms' do
|
||||
context "custom acronyms" do
|
||||
subject do
|
||||
Dry::Inflector.new do |inflect|
|
||||
inflect.acronym('IP', 'HTML', 'XML', 'BSD')
|
||||
inflect.acronym("IP", "HTML", "XML", "BSD")
|
||||
end
|
||||
end
|
||||
|
||||
it 'handles acronyms' do
|
||||
expect(subject.camelize_upper(i('ip'))).to eql('IP')
|
||||
expect(subject.camelize_upper(i('ip_sec'))).to eql('IPSec')
|
||||
expect(subject.camelize_upper(i('html_tidy'))).to eql('HTMLTidy')
|
||||
expect(subject.camelize_upper(i('html_tidy_generator'))).to eql('HTMLTidyGenerator')
|
||||
expect(subject.camelize_upper(i('force_xml_controller'))).to eql('ForceXMLController')
|
||||
expect(subject.camelize_upper(i('free_bsd'))).to eql('FreeBSD')
|
||||
it "handles acronyms" do
|
||||
expect(subject.camelize_upper(i("ip"))).to eql("IP")
|
||||
expect(subject.camelize_upper(i("ip_sec"))).to eql("IPSec")
|
||||
expect(subject.camelize_upper(i("html_tidy"))).to eql("HTMLTidy")
|
||||
expect(subject.camelize_upper(i("html_tidy_generator"))).to eql("HTMLTidyGenerator")
|
||||
expect(subject.camelize_upper(i("force_xml_controller"))).to eql("ForceXMLController")
|
||||
expect(subject.camelize_upper(i("free_bsd"))).to eql("FreeBSD")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Dry::Inflector do
|
||||
describe '#classify' do
|
||||
it 'classifies data_mapper as DataMapper' do
|
||||
expect(subject.classify(i('data_mapper'))).to eq('DataMapper')
|
||||
describe "#classify" do
|
||||
it "classifies data_mapper as DataMapper" do
|
||||
expect(subject.classify(i("data_mapper"))).to eq("DataMapper")
|
||||
end
|
||||
|
||||
it 'classifies data.mapper as Mapper' do
|
||||
expect(subject.classify(i('data.mapper'))).to eq('Mapper')
|
||||
it "classifies data.mapper as Mapper" do
|
||||
expect(subject.classify(i("data.mapper"))).to eq("Mapper")
|
||||
end
|
||||
|
||||
it 'classifies enlarged_testes as EnlargedTestis' do
|
||||
expect(subject.classify(i('enlarged_testes'))).to eq('EnlargedTestis')
|
||||
it "classifies enlarged_testes as EnlargedTestis" do
|
||||
expect(subject.classify(i("enlarged_testes"))).to eq("EnlargedTestis")
|
||||
end
|
||||
|
||||
it 'singularizes string first: classifies data_mappers as egg_and_hams as EggAndHam' do
|
||||
expect(subject.classify(i('egg_and_hams'))).to eq('EggAndHam')
|
||||
it "singularizes string first: classifies data_mappers as egg_and_hams as EggAndHam" do
|
||||
expect(subject.classify(i("egg_and_hams"))).to eq("EggAndHam")
|
||||
end
|
||||
|
||||
it 'accepts symbols' do
|
||||
expect(subject.classify(:data_mapper)).to eq('DataMapper')
|
||||
it "accepts symbols" do
|
||||
expect(subject.classify(:data_mapper)).to eq("DataMapper")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Dry::Inflector do
|
||||
describe '#constantize' do
|
||||
it 'constantizes Module' do
|
||||
expect(subject.constantize(i('Module'))).to eq Module
|
||||
describe "#constantize" do
|
||||
it "constantizes Module" do
|
||||
expect(subject.constantize(i("Module"))).to eq Module
|
||||
end
|
||||
|
||||
it 'constantizes ::Module' do
|
||||
expect(subject.constantize(i('::Module'))).to eq Module
|
||||
it "constantizes ::Module" do
|
||||
expect(subject.constantize(i("::Module"))).to eq Module
|
||||
end
|
||||
|
||||
it 'accepts symbols' do
|
||||
it "accepts symbols" do
|
||||
expect(subject.constantize(i(:Module))).to eq Module
|
||||
end
|
||||
|
||||
it 'constantizes nested constant Dry::Inflector::Inflections' do
|
||||
expect(subject.constantize(i('Dry::Inflector::Inflections'))).to eq Dry::Inflector::Inflections
|
||||
it "constantizes nested constant Dry::Inflector::Inflections" do
|
||||
expect(subject.constantize(i("Dry::Inflector::Inflections"))).to eq Dry::Inflector::Inflections
|
||||
end
|
||||
|
||||
it 'does not search ancestors' do
|
||||
it "does not search ancestors" do
|
||||
module Foo
|
||||
class Bar
|
||||
VAL = 10
|
||||
|
@ -27,38 +27,38 @@ RSpec.describe Dry::Inflector do
|
|||
class Baz < Bar; end
|
||||
end
|
||||
|
||||
expect(subject.constantize(i('Foo::Bar::VAL'))).to be(10)
|
||||
expect { subject.constantize(i('Foo::Baz::VAL')) }.to raise_error(NameError)
|
||||
expect(subject.constantize(i("Foo::Bar::VAL"))).to be(10)
|
||||
expect { subject.constantize(i("Foo::Baz::VAL")) }.to raise_error(NameError)
|
||||
end
|
||||
|
||||
it 'searches in const_missing' do
|
||||
it "searches in const_missing" do
|
||||
module Foo
|
||||
class Bar
|
||||
def self.const_missing(name)
|
||||
name.to_s == 'Const' ? Baz : super
|
||||
name.to_s == "Const" ? Baz : super
|
||||
end
|
||||
end
|
||||
|
||||
class Baz < Bar; end
|
||||
|
||||
def self.const_missing(name)
|
||||
name.to_s == 'Autoloaded' ? Bar : super
|
||||
name.to_s == "Autoloaded" ? Bar : super
|
||||
end
|
||||
end
|
||||
|
||||
expect(subject.constantize(i('Foo::Autoloaded::Const'))).to eq Foo::Baz
|
||||
expect(subject.constantize(i('Foo::Bar::Const'))).to eq Foo::Baz
|
||||
expect(subject.constantize(i("Foo::Autoloaded::Const"))).to eq Foo::Baz
|
||||
expect(subject.constantize(i("Foo::Bar::Const"))).to eq Foo::Baz
|
||||
end
|
||||
|
||||
it 'raises exception when empty string given' do
|
||||
it "raises exception when empty string given" do
|
||||
expect do
|
||||
subject.constantize(i(''))
|
||||
subject.constantize(i(""))
|
||||
end.to raise_error(NameError)
|
||||
end
|
||||
|
||||
it 'raises exception when constant not found' do
|
||||
it "raises exception when constant not found" do
|
||||
expect do
|
||||
subject.constantize(i('Qwerty'))
|
||||
subject.constantize(i("Qwerty"))
|
||||
end.to raise_error(NameError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Dry::Inflector do
|
||||
describe '#dasherize' do
|
||||
it 'dasherizes data_mapper_rspec as data-mapper-rspec' do
|
||||
expect(subject.dasherize(i('data_mapper_rspec'))).to eq('data-mapper-rspec')
|
||||
describe "#dasherize" do
|
||||
it "dasherizes data_mapper_rspec as data-mapper-rspec" do
|
||||
expect(subject.dasherize(i("data_mapper_rspec"))).to eq("data-mapper-rspec")
|
||||
end
|
||||
|
||||
it 'accepts symbols' do
|
||||
expect(subject.dasherize(:data_mapper_rspec)).to eq('data-mapper-rspec')
|
||||
it "accepts symbols" do
|
||||
expect(subject.dasherize(:data_mapper_rspec)).to eq("data-mapper-rspec")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Dry::Inflector do
|
||||
describe '#demodulize' do
|
||||
it 'demodulizes module name: DataMapper::Inflecto => Inflecto' do
|
||||
expect(subject.demodulize(i('DataMapper::Inflecto'))).to eq('Inflecto')
|
||||
describe "#demodulize" do
|
||||
it "demodulizes module name: DataMapper::Inflecto => Inflecto" do
|
||||
expect(subject.demodulize(i("DataMapper::Inflecto"))).to eq("Inflecto")
|
||||
end
|
||||
|
||||
it 'demodulizes module name: A::B::C::D::E => E' do
|
||||
expect(subject.demodulize(i('A::B::C::D::E'))).to eq('E')
|
||||
it "demodulizes module name: A::B::C::D::E => E" do
|
||||
expect(subject.demodulize(i("A::B::C::D::E"))).to eq("E")
|
||||
end
|
||||
|
||||
it 'accepts symbols' do
|
||||
expect(subject.demodulize(:"DataMapper::Inflecto")).to eq('Inflecto')
|
||||
it "accepts symbols" do
|
||||
expect(subject.demodulize(:"DataMapper::Inflecto")).to eq("Inflecto")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Dry::Inflector do
|
||||
describe '#foreign_key' do
|
||||
it 'adds _id to downcased string: Message => message_id' do
|
||||
expect(subject.foreign_key(i('Message'))).to eq 'message_id'
|
||||
describe "#foreign_key" do
|
||||
it "adds _id to downcased string: Message => message_id" do
|
||||
expect(subject.foreign_key(i("Message"))).to eq "message_id"
|
||||
end
|
||||
|
||||
it 'demodulizes string first: Admin::Post => post_id' do
|
||||
expect(subject.foreign_key(i('Admin::Post'))).to eq 'post_id'
|
||||
it "demodulizes string first: Admin::Post => post_id" do
|
||||
expect(subject.foreign_key(i("Admin::Post"))).to eq "post_id"
|
||||
end
|
||||
|
||||
it 'accepts symbols' do
|
||||
expect(subject.foreign_key(i(:message))).to eq 'message_id'
|
||||
it "accepts symbols" do
|
||||
expect(subject.foreign_key(i(:message))).to eq "message_id"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,33 +1,33 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Dry::Inflector do
|
||||
describe '#humanize' do
|
||||
it 'replaces _ with space: humanizes employee_salary as Employee salary' do
|
||||
expect(subject.humanize(i('employee_salary'))).to eq('Employee salary')
|
||||
describe "#humanize" do
|
||||
it "replaces _ with space: humanizes employee_salary as Employee salary" do
|
||||
expect(subject.humanize(i("employee_salary"))).to eq("Employee salary")
|
||||
end
|
||||
|
||||
it 'strips _id endings: humanizes author_id as Author' do
|
||||
expect(subject.humanize(i('author_id'))).to eq('Author')
|
||||
it "strips _id endings: humanizes author_id as Author" do
|
||||
expect(subject.humanize(i("author_id"))).to eq("Author")
|
||||
end
|
||||
|
||||
it 'uses user added rules when possible' do
|
||||
it "uses user added rules when possible" do
|
||||
subject = described_class.new do |inflect|
|
||||
inflect.human('Question', 'Fancy question')
|
||||
inflect.human('questionary', 'Questionnaire')
|
||||
inflect.human("Question", "Fancy question")
|
||||
inflect.human("questionary", "Questionnaire")
|
||||
end
|
||||
|
||||
expect(subject.humanize(i('questionary'))).to eq('Questionnaire')
|
||||
expect(subject.humanize(i("questionary"))).to eq("Questionnaire")
|
||||
end
|
||||
|
||||
it 'accepts symbols' do
|
||||
expect(subject.humanize(:employee_salary)).to eq('Employee salary')
|
||||
it "accepts symbols" do
|
||||
expect(subject.humanize(:employee_salary)).to eq("Employee salary")
|
||||
end
|
||||
|
||||
it 'handles acronyms' do
|
||||
expect(subject.humanize(i('json'))).to eql('JSON')
|
||||
expect(subject.humanize(i('http_error'))).to eql('HTTP error')
|
||||
expect(subject.humanize(i('openssl/hmac'))).to eql('OpenSSL/HMAC')
|
||||
expect(subject.humanize(i('openssl/digest'))).to eql('OpenSSL/digest')
|
||||
it "handles acronyms" do
|
||||
expect(subject.humanize(i("json"))).to eql("JSON")
|
||||
expect(subject.humanize(i("http_error"))).to eql("HTTP error")
|
||||
expect(subject.humanize(i("openssl/hmac"))).to eql("OpenSSL/HMAC")
|
||||
expect(subject.humanize(i("openssl/digest"))).to eql("OpenSSL/digest")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,56 +1,56 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Dry::Inflector do
|
||||
describe '#ordinalize' do
|
||||
describe "#ordinalize" do
|
||||
Fixtures::Ordinalize.cases.each do |n, expected|
|
||||
it "ordinalizes #{n} => #{expected}" do
|
||||
expect(subject.ordinalize(n)).to eq(expected)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when number ends with digit 1' do
|
||||
it 'adds -th suffix when number ends with 11' do
|
||||
context "when number ends with digit 1" do
|
||||
it "adds -th suffix when number ends with 11" do
|
||||
[-1011, -111, -11, 11, 111, 1011].each do |number|
|
||||
expect(subject.ordinalize(number)).to eq("#{number}th")
|
||||
end
|
||||
end
|
||||
|
||||
it 'adds -st suffix when number does not end with 11' do
|
||||
it "adds -st suffix when number does not end with 11" do
|
||||
[-1001, -101, -21, -1, 1, 21, 101, 1001].each do |number|
|
||||
expect(subject.ordinalize(number)).to eq("#{number}st")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when number ends with digit 2' do
|
||||
it 'adds -th suffix when number ends with 12' do
|
||||
context "when number ends with digit 2" do
|
||||
it "adds -th suffix when number ends with 12" do
|
||||
[-1012, -112, -12, 12, 112, 1012].each do |number|
|
||||
expect(subject.ordinalize(number)).to eq("#{number}th")
|
||||
end
|
||||
end
|
||||
|
||||
it 'adds -nd suffix when number does not end with 12' do
|
||||
it "adds -nd suffix when number does not end with 12" do
|
||||
[-1002, -102, -22, -2, 2, 22, 102, 1002].each do |number|
|
||||
expect(subject.ordinalize(number)).to eq("#{number}nd")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when number ends with digit 3' do
|
||||
it 'adds -th suffix when number ends with 13' do
|
||||
context "when number ends with digit 3" do
|
||||
it "adds -th suffix when number ends with 13" do
|
||||
[-1013, -113, -13, 13, 113, 1013].each do |number|
|
||||
expect(subject.ordinalize(number)).to eq("#{number}th")
|
||||
end
|
||||
end
|
||||
|
||||
it 'adds -rd suffix when number does not end with 13' do
|
||||
it "adds -rd suffix when number does not end with 13" do
|
||||
[-1003, -103, -23, -3, 3, 23, 103, 1003].each do |number|
|
||||
expect(subject.ordinalize(number)).to eq("#{number}rd")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it 'ordinalizes other numbers with -th suffix' do
|
||||
it "ordinalizes other numbers with -th suffix" do
|
||||
[-4, 4, 5, 6, 7, 8, 9, 10, 14, 15, 16].each do |number|
|
||||
expect(subject.ordinalize(number)).to eq("#{number}th")
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Dry::Inflector do
|
||||
describe '#pluralize' do
|
||||
describe "#pluralize" do
|
||||
Fixtures::Pluralize.cases.each do |singular, plural|
|
||||
it "pluralizes #{singular} => #{plural}" do
|
||||
expect(subject.pluralize(i(singular))).to eq(plural)
|
||||
|
@ -18,30 +18,30 @@ RSpec.describe Dry::Inflector do
|
|||
pending "missing exception or rule for #{singular} => #{plural}"
|
||||
end
|
||||
|
||||
it 'accepts symbols' do
|
||||
expect(subject.pluralize(:user)).to eq('users')
|
||||
expect(subject.pluralize(:money)).to eq('money')
|
||||
it "accepts symbols" do
|
||||
expect(subject.pluralize(:user)).to eq("users")
|
||||
expect(subject.pluralize(:money)).to eq("money")
|
||||
end
|
||||
|
||||
context 'with custom inflection rules' do
|
||||
context "with custom inflection rules" do
|
||||
subject do
|
||||
described_class.new do |inflections|
|
||||
inflections.plural 'virus', 'viruses'
|
||||
inflections.irregular 'plus', 'plusses'
|
||||
inflections.uncountable 'dry-inflector'
|
||||
inflections.plural "virus", "viruses"
|
||||
inflections.irregular "plus", "plusses"
|
||||
inflections.uncountable "dry-inflector"
|
||||
end
|
||||
end
|
||||
|
||||
it "pluralizes using '#plural' rule" do
|
||||
expect(subject.pluralize('virus')).to eq('viruses')
|
||||
expect(subject.pluralize("virus")).to eq("viruses")
|
||||
end
|
||||
|
||||
it "pluralizes using '#irregular' rule" do
|
||||
expect(subject.pluralize('plus')).to eq('plusses')
|
||||
expect(subject.pluralize("plus")).to eq("plusses")
|
||||
end
|
||||
|
||||
it "doesn't pluralize uncountable" do
|
||||
expect(subject.pluralize('dry-inflector')).to eq('dry-inflector')
|
||||
expect(subject.pluralize("dry-inflector")).to eq("dry-inflector")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Dry::Inflector do
|
||||
describe '#singularize' do
|
||||
describe "#singularize" do
|
||||
Fixtures::Singularize.cases.each do |plural, singular|
|
||||
it "singularizes #{plural} => #{singular}" do
|
||||
expect(subject.singularize(i(plural))).to eq(singular)
|
||||
|
@ -12,30 +12,30 @@ RSpec.describe Dry::Inflector do
|
|||
pending "missing exception or rule for #{plural} => #{singular}"
|
||||
end
|
||||
|
||||
it 'accepts symbols' do
|
||||
expect(subject.singularize(:users)).to eq('user')
|
||||
expect(subject.singularize(:money)).to eq('money')
|
||||
it "accepts symbols" do
|
||||
expect(subject.singularize(:users)).to eq("user")
|
||||
expect(subject.singularize(:money)).to eq("money")
|
||||
end
|
||||
|
||||
context 'with custom inflection rules' do
|
||||
context "with custom inflection rules" do
|
||||
subject do
|
||||
described_class.new do |inflections|
|
||||
inflections.singular 'viruses', 'virus'
|
||||
inflections.irregular 'plus', 'plusses'
|
||||
inflections.uncountable 'dry-inflector'
|
||||
inflections.singular "viruses", "virus"
|
||||
inflections.irregular "plus", "plusses"
|
||||
inflections.uncountable "dry-inflector"
|
||||
end
|
||||
end
|
||||
|
||||
it "pluralizes using '#singular' rule" do
|
||||
expect(subject.singularize('viruses')).to eq('virus')
|
||||
expect(subject.singularize("viruses")).to eq("virus")
|
||||
end
|
||||
|
||||
it "pluralizes using '#irregular' rule" do
|
||||
expect(subject.singularize('plusses')).to eq('plus')
|
||||
expect(subject.singularize("plusses")).to eq("plus")
|
||||
end
|
||||
|
||||
it "doesn't singularize uncountable" do
|
||||
expect(subject.singularize('dry-inflector')).to eq('dry-inflector')
|
||||
expect(subject.singularize("dry-inflector")).to eq("dry-inflector")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,33 +1,33 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Dry::Inflector do
|
||||
describe '#tableize' do
|
||||
it 'pluralizes last word in snake_case strings: fancy_category => fancy_categories' do
|
||||
expect(subject.tableize(i('fancy_category'))).to eq('fancy_categories')
|
||||
describe "#tableize" do
|
||||
it "pluralizes last word in snake_case strings: fancy_category => fancy_categories" do
|
||||
expect(subject.tableize(i("fancy_category"))).to eq("fancy_categories")
|
||||
end
|
||||
|
||||
it 'underscores CamelCase strings before pluralization: enlarged_testis => enlarged_testes' do
|
||||
expect(subject.tableize(i('enlarged_testis'))).to eq('enlarged_testes')
|
||||
it "underscores CamelCase strings before pluralization: enlarged_testis => enlarged_testes" do
|
||||
expect(subject.tableize(i("enlarged_testis"))).to eq("enlarged_testes")
|
||||
end
|
||||
|
||||
it 'underscores CamelCase strings before pluralization: FancyCategory => fancy_categories' do
|
||||
expect(subject.tableize(i('FancyCategory'))).to eq('fancy_categories')
|
||||
it "underscores CamelCase strings before pluralization: FancyCategory => fancy_categories" do
|
||||
expect(subject.tableize(i("FancyCategory"))).to eq("fancy_categories")
|
||||
end
|
||||
|
||||
it 'underscores CamelCase strings before pluralization: EnlargedTestis => enlarged_testes' do
|
||||
expect(subject.tableize(i('EnlargedTestis'))).to eq('enlarged_testes')
|
||||
it "underscores CamelCase strings before pluralization: EnlargedTestis => enlarged_testes" do
|
||||
expect(subject.tableize(i("EnlargedTestis"))).to eq("enlarged_testes")
|
||||
end
|
||||
|
||||
it 'replaces :: with underscores: My::Fancy::Category => my_fancy_categories' do
|
||||
expect(subject.tableize(i('My::Fancy::Category'))).to eq('my_fancy_categories')
|
||||
it "replaces :: with underscores: My::Fancy::Category => my_fancy_categories" do
|
||||
expect(subject.tableize(i("My::Fancy::Category"))).to eq("my_fancy_categories")
|
||||
end
|
||||
|
||||
it 'underscores CamelCase strings before pluralization: Enlarged::Testis => enlarged_testes' do
|
||||
expect(subject.tableize(i('Enlarged::Testis'))).to eq('enlarged_testes')
|
||||
it "underscores CamelCase strings before pluralization: Enlarged::Testis => enlarged_testes" do
|
||||
expect(subject.tableize(i("Enlarged::Testis"))).to eq("enlarged_testes")
|
||||
end
|
||||
|
||||
it 'accepts symbols' do
|
||||
expect(subject.tableize(:fancy_category)).to eq('fancy_categories')
|
||||
it "accepts symbols" do
|
||||
expect(subject.tableize(:fancy_category)).to eq("fancy_categories")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Dry::Inflector do
|
||||
describe '#uncountable?' do
|
||||
it 'returns true when empty string' do
|
||||
expect(subject.uncountable?(i(''))).to be(true)
|
||||
describe "#uncountable?" do
|
||||
it "returns true when empty string" do
|
||||
expect(subject.uncountable?(i(""))).to be(true)
|
||||
end
|
||||
|
||||
it 'returns true when blank string' do
|
||||
expect(subject.uncountable?(i(' '))).to be(true)
|
||||
it "returns true when blank string" do
|
||||
expect(subject.uncountable?(i(" "))).to be(true)
|
||||
end
|
||||
|
||||
it 'returns true when word is present in list' do
|
||||
expect(subject.uncountable?(i('grass'))).to be(true)
|
||||
it "returns true when word is present in list" do
|
||||
expect(subject.uncountable?(i("grass"))).to be(true)
|
||||
end
|
||||
|
||||
it 'returns false when word is not present in list' do
|
||||
expect(subject.uncountable?(i('user'))).to be(false)
|
||||
it "returns false when word is not present in list" do
|
||||
expect(subject.uncountable?(i("user"))).to be(false)
|
||||
end
|
||||
|
||||
it 'returns true when word is present in list but in different case' do
|
||||
expect(subject.uncountable?(i('FiSH'))).to be(true)
|
||||
it "returns true when word is present in list but in different case" do
|
||||
expect(subject.uncountable?(i("FiSH"))).to be(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,48 +1,48 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Dry::Inflector do
|
||||
describe '#underscore' do
|
||||
it 'underscores DataMapper as data_mapper' do
|
||||
expect(subject.underscore(i('DataMapper'))).to eq('data_mapper')
|
||||
describe "#underscore" do
|
||||
it "underscores DataMapper as data_mapper" do
|
||||
expect(subject.underscore(i("DataMapper"))).to eq("data_mapper")
|
||||
end
|
||||
|
||||
it 'underscores Merb as merb' do
|
||||
expect(subject.underscore(i('Merb'))).to eq('merb')
|
||||
it "underscores Merb as merb" do
|
||||
expect(subject.underscore(i("Merb"))).to eq("merb")
|
||||
end
|
||||
|
||||
it 'underscores DataMapper::Resource as data_mapper/resource' do
|
||||
expect(subject.underscore(i('DataMapper::Resource'))).to eq('data_mapper/resource')
|
||||
it "underscores DataMapper::Resource as data_mapper/resource" do
|
||||
expect(subject.underscore(i("DataMapper::Resource"))).to eq("data_mapper/resource")
|
||||
end
|
||||
|
||||
it 'underscores Merb::BootLoader::Rackup as merb/boot_loader/rackup' do
|
||||
expect(subject.underscore(i('Merb::BootLoader::Rackup'))).to eq('merb/boot_loader/rackup')
|
||||
it "underscores Merb::BootLoader::Rackup as merb/boot_loader/rackup" do
|
||||
expect(subject.underscore(i("Merb::BootLoader::Rackup"))).to eq("merb/boot_loader/rackup")
|
||||
end
|
||||
|
||||
it 'underscores data-mapper as data_mapper' do
|
||||
expect(subject.underscore(i('data-mapper'))).to eq('data_mapper')
|
||||
it "underscores data-mapper as data_mapper" do
|
||||
expect(subject.underscore(i("data-mapper"))).to eq("data_mapper")
|
||||
end
|
||||
|
||||
it 'underscores CLI as cli' do
|
||||
expect(subject.underscore(i('CLI'))).to eq('cli')
|
||||
it "underscores CLI as cli" do
|
||||
expect(subject.underscore(i("CLI"))).to eq("cli")
|
||||
end
|
||||
|
||||
it 'underscores castleKing as castle_king' do
|
||||
expect(subject.underscore(i('castleKing'))).to eq('castle_king')
|
||||
it "underscores castleKing as castle_king" do
|
||||
expect(subject.underscore(i("castleKing"))).to eq("castle_king")
|
||||
end
|
||||
|
||||
it 'underscores CLIRunner as cli_runner' do
|
||||
expect(subject.underscore(i('CLIRunner'))).to eq('cli_runner')
|
||||
it "underscores CLIRunner as cli_runner" do
|
||||
expect(subject.underscore(i("CLIRunner"))).to eq("cli_runner")
|
||||
end
|
||||
|
||||
it 'accepts symbols' do
|
||||
expect(subject.underscore(:DataMapper)).to eq('data_mapper')
|
||||
it "accepts symbols" do
|
||||
expect(subject.underscore(:DataMapper)).to eq("data_mapper")
|
||||
end
|
||||
|
||||
it 'handles acronyms' do
|
||||
expect(subject.underscore(i('JSON'))).to eql('json')
|
||||
expect(subject.underscore(i('HTTPError'))).to eql('http_error')
|
||||
expect(subject.underscore(i('OpenSSL::HMAC'))).to eql('openssl/hmac')
|
||||
expect(subject.underscore(i('OpenSSL::Digest'))).to eql('openssl/digest')
|
||||
it "handles acronyms" do
|
||||
expect(subject.underscore(i("JSON"))).to eql("json")
|
||||
expect(subject.underscore(i("HTTPError"))).to eql("http_error")
|
||||
expect(subject.underscore(i("OpenSSL::HMAC"))).to eql("openssl/hmac")
|
||||
expect(subject.underscore(i("OpenSSL::Digest"))).to eql("openssl/digest")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
RSpec.describe Dry::Inflector do
|
||||
subject(:inflector) { described_class.new }
|
||||
|
||||
describe '#to_s' do
|
||||
describe "#to_s" do
|
||||
specify do
|
||||
expect(inflector.to_s).to eql('#<Dry::Inflector>')
|
||||
expect(inflector.to_s).to eql("#<Dry::Inflector>")
|
||||
end
|
||||
end
|
||||
|
||||
describe '#inspect' do
|
||||
describe "#inspect" do
|
||||
specify do
|
||||
expect(inflector.method(:inspect)).to eql(inflector.method(:to_s))
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue