stringex 2.6.1 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d9873c1bd3db8c441ab3daa62fe317e3497d5a06
4
- data.tar.gz: dd04a038329594f84844c3e636b54a98e1d95717
3
+ metadata.gz: 14a1e9e04c5e4e2afcd9dfafbdeac75e4d3c5555
4
+ data.tar.gz: 6c161b8ad91a99fc8762c433e0a487e8854bf99e
5
5
  SHA512:
6
- metadata.gz: 6da7370b5e50eb31c5ecdc5914181334cc7dd4e3230bb7baced02c67aef3cbac4ef3d1a3d3715b5d24cb72f3313ad85424567ce32d0d95b8528e42fe4e6c6552
7
- data.tar.gz: 4ccd3f0efd3b3607afd93fe1e1bbe8e344657568d2db48e583ed92d6d3e5a34dadcc8f97bae0211a6b5fd6902a129728edfb1d35e0b5f68a51400cd4d7996633
6
+ metadata.gz: e8561c1e15f08e85444491d99169a2c4ef78c8be7dff5dfd49122a661cbdf362809590ab9c6aa4d6cdcc4575a812c97262dfd49f1322f4a0058d7f44763896ec
7
+ data.tar.gz: 5f8a82933cab72a549f614702c57703cf20f98397fd2e52a49b8f708f022923f1bca2ce9c5ed5ca3a43b1802ab2b89bb7af259ce3fb09d29a68706de48f1e2e0
data/Rakefile CHANGED
@@ -30,14 +30,16 @@ end
30
30
  Rake::TestTask.new do |t|
31
31
  t.libs << 'lib' << 'test'
32
32
  t.pattern = 'test/unit/**/*_test.rb'
33
- t.verbose = true
33
+ t.verbose = false
34
+ t.warning = false
34
35
  end
35
36
 
36
37
  namespace :test do
37
38
  Rake::TestTask.new(:performance) do |t|
38
39
  t.libs << 'lib' << 'test'
39
40
  t.pattern = 'test/performance/**/*_test.rb'
40
- t.verbose = true
41
+ t.verbose = false
42
+ t.warning = false
41
43
  end
42
44
  end
43
45
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.6.1
1
+ 2.7.0
@@ -33,6 +33,11 @@ module Stringex
33
33
  # differentiate between urls. Default is false[y]. See note on <tt>:scope</tt>.
34
34
  # <tt>:duplicate_count_separator</tt>:: String to use when forcing unique urls from non-unique strings.
35
35
  # Default is "-".
36
+ # <tt>:duplicate_sequence</tt>:: Supply an enumerator to generate the values used to generate
37
+ # unique urls (when <tt>:allow_duplicates</tt> is false).
38
+ # By default, generates positive integers in sequence from 1.
39
+ # <strong>Note:</strong> The sequence is restarted for each record
40
+ # (by calling <tt>#rewind</tt>).
36
41
  # <tt>:force_downcase</tt>:: If false, allows generated url to contain uppercased letters. Default is false.
37
42
  # <tt>:exclude_list</tt>:: List of complete strings that should not be transformed by <tt>acts_as_url</tt>.
38
43
  # Default is empty.
@@ -120,13 +120,26 @@ module Stringex
120
120
 
121
121
  def handle_duplicate_url!
122
122
  return if !url_taken?(base_url)
123
- n = 1
124
- while url_taken?(duplicate_for_base_url(n))
125
- n = n.succ
123
+ n = nil
124
+ sequence = duplicate_url_sequence.tap(&:rewind)
125
+ loop do
126
+ n = sequence.next
127
+ break unless url_taken?(duplicate_for_base_url(n))
126
128
  end
127
129
  write_url_attribute duplicate_for_base_url(n)
128
130
  end
129
131
 
132
+ def duplicate_url_sequence
133
+ settings.duplicate_sequence ||
134
+ Enumerator.new do |enum|
135
+ n = 1
136
+ loop do
137
+ enum.yield n
138
+ n += 1
139
+ end
140
+ end
141
+ end
142
+
130
143
  def url_taken?(url)
131
144
  if settings.url_taken_method
132
145
  instance.send(settings.url_taken_method, url)
@@ -33,7 +33,7 @@ module Stringex
33
33
  end
34
34
 
35
35
  def klass_previous_instances(&block)
36
- klass.all(:conditions => {settings.url_attribute => [nil]}).each(&block)
36
+ klass.all(conditions: {settings.url_attribute => [nil]}).each(&block)
37
37
  end
38
38
 
39
39
  def primary_key
@@ -45,7 +45,7 @@ module Stringex
45
45
  end
46
46
 
47
47
  def url_owners
48
- @url_owners ||= url_owners_class.all(:conditions => url_owner_conditions)
48
+ @url_owners ||= url_owners_class.all(conditions: url_owner_conditions)
49
49
  end
50
50
 
51
51
  def read_attribute(instance, name)
@@ -62,4 +62,4 @@ module Stringex
62
62
  end
63
63
  end
64
64
  end
65
- end
65
+ end
@@ -11,7 +11,7 @@ module Stringex
11
11
 
12
12
  def add_new_record_url_owner_conditions
13
13
  return if instance.new_record?
14
- @url_owner_conditions.merge! :id => {'$ne' => instance.id}
14
+ @url_owner_conditions.merge! id: {'$ne' => instance.id}
15
15
  end
16
16
 
17
17
  def add_scoped_url_owner_conditions
@@ -34,4 +34,4 @@ module Stringex
34
34
  end
35
35
  end
36
36
  end
37
- end
37
+ end
@@ -31,16 +31,16 @@ module Stringex
31
31
 
32
32
  def self.default_settings
33
33
  @default_settings ||= {
34
- :allow_duplicates => false,
35
- :callback_method => :before_validation,
36
- :duplicate_count_separator => "-",
37
- :enforce_uniqueness_on_sti_base_class => false,
38
- :only_when_blank => false,
39
- :scope_for_url => nil,
40
- :sync_url => false,
41
- :url_attribute => "url",
42
- :blacklist => %w[new],
43
- :blacklist_policy => lambda { |instance, url|
34
+ allow_duplicates: false,
35
+ callback_method: :before_validation,
36
+ duplicate_count_separator: "-",
37
+ enforce_uniqueness_on_sti_base_class: false,
38
+ only_when_blank: false,
39
+ scope_for_url: nil,
40
+ sync_url: false,
41
+ url_attribute: "url",
42
+ blacklist: %w[new],
43
+ blacklist_policy: lambda { |instance, url|
44
44
  "#{url}-#{instance.class.to_s.downcase}"
45
45
  }
46
46
  }.merge(Stringex::Configuration::StringExtensions.new.default_settings)
@@ -7,14 +7,14 @@ module Stringex
7
7
 
8
8
  def self.default_settings
9
9
  @default_settings ||= {
10
- :allow_slash => false,
11
- :exclude => [],
12
- :force_downcase => true,
13
- :limit => nil,
14
- :replace_whitespace_with => "-",
15
- :truncate_words => true
10
+ allow_slash: false,
11
+ exclude: [],
12
+ force_downcase: true,
13
+ limit: nil,
14
+ replace_whitespace_with: "-",
15
+ truncate_words: true
16
16
  }
17
17
  end
18
18
  end
19
19
  end
20
- end
20
+ end
@@ -45,7 +45,7 @@ module Stringex
45
45
  return translation unless translation.nil?
46
46
 
47
47
  if locale != default_locale
48
- translate scope, key, options.merge(:locale => default_locale)
48
+ translate scope, key, options.merge(locale: default_locale)
49
49
  else
50
50
  default_conversion(scope, key) || options[:default]
51
51
  end
@@ -7,6 +7,7 @@ module Stringex
7
7
  class << self
8
8
  def reset!
9
9
  super
10
+ @locale = nil
10
11
  ::I18n.reload! if defined?(::I18n) && ::I18n.respond_to?(:reload!)
11
12
  end
12
13
 
@@ -31,7 +32,7 @@ module Stringex
31
32
  end
32
33
 
33
34
  def store_translations(locale, scope, data)
34
- ::I18n.backend.store_translations(locale, { :stringex => { scope => data } })
35
+ ::I18n.backend.store_translations(locale, {stringex: {scope => data}})
35
36
  reset_translations_cache
36
37
  end
37
38
 
@@ -54,7 +55,7 @@ module Stringex
54
55
 
55
56
  def i18n_translations_for(locale)
56
57
  ensure_locales_enforced_or_not
57
- ::I18n.translate("stringex", :locale => locale, :default => {})
58
+ ::I18n.translate("stringex", locale: locale, default: {})
58
59
  end
59
60
 
60
61
  def reset_translations_cache
@@ -10,18 +10,18 @@ module Stringex
10
10
  APOSTROPHE = /(^|[[:alpha:]])'|`([[:alpha:]]|$)/
11
11
 
12
12
  CHARACTERS = {
13
- :and => /\s*&\s*/,
14
- :at => /\s*@\s*/,
15
- :degrees => /\s*°\s*/,
16
- :divide => /\s*÷\s*/,
17
- :dot => /(\S|^)\.(\S)/,
18
- :ellipsis => /\s*\.{3,}\s*/,
19
- :equals => /\s*=\s*/,
20
- :number => /\s*#/,
21
- :percent => /\s*%\s*/,
22
- :plus => /\s*\+\s*/,
23
- :slash => /\s*(\\|\/|/)\s*/,
24
- :star => /\s*\*\s*/,
13
+ and: /\s*&\s*/,
14
+ at: /\s*@\s*/,
15
+ degrees: /\s*°\s*/,
16
+ divide: /\s*÷\s*/,
17
+ dot: /(\S|^)\.(\S)/,
18
+ ellipsis: /\s*\.{3,}\s*/,
19
+ equals: /\s*=\s*/,
20
+ number: /\s*#/,
21
+ percent: /\s*%\s*/,
22
+ plus: /\s*\+\s*/,
23
+ slash: /\s*(\\|\/|/)\s*/,
24
+ star: /\s*\*\s*/,
25
25
  }
26
26
 
27
27
  # Things that just get converted to spaces
@@ -29,18 +29,18 @@ module Stringex
29
29
  CLEANUP_HTML_ENTITIES = /&[^;]+;/
30
30
 
31
31
  CURRENCIES_SUPPORTED_SIMPLE = {
32
- :generic => /¤/,
33
- :dollars => /\$/,
34
- :euros => /€/,
35
- :pounds => /£/,
36
- :yen => /¥/,
37
- :reais => /R\$/
32
+ generic: /¤/,
33
+ dollars: /\$/,
34
+ euros: /€/,
35
+ pounds: /£/,
36
+ yen: /¥/,
37
+ reais: /R\$/
38
38
  }
39
39
  CURRENCIES_SUPPORTED_COMPLEX = {
40
- :dollars => :dollars_cents,
41
- :euros => :euros_cents,
42
- :pounds => :pounds_pence,
43
- :reais => :reais_cents
40
+ dollars: :dollars_cents,
41
+ euros: :euros_cents,
42
+ pounds: :pounds_pence,
43
+ reais: :reais_cents
44
44
  }
45
45
  CURRENCIES_SUPPORTED = Regexp.new(CURRENCIES_SUPPORTED_SIMPLE.values.join('|'))
46
46
  CURRENCIES_SIMPLE = CURRENCIES_SUPPORTED_SIMPLE.inject({}) do |hash, content|
@@ -61,27 +61,27 @@ module Stringex
61
61
 
62
62
  HTML_ENTITIES = Proc.new(){
63
63
  base = {
64
- :amp => %w{#38 amp},
65
- :cent => %w{#162 cent},
66
- :copy => %w{#169 copy},
67
- :deg => %w{#176 deg},
68
- :divide => %w{#247 divide},
69
- :double_quote => %w{#34 #822[012] quot ldquo rdquo dbquo},
70
- :ellipsis => %w{#8230 hellip},
71
- :en_dash => %w{#8211 ndash},
72
- :em_dash => %w{#8212 mdash},
73
- :frac14 => %w{#188 frac14},
74
- :frac12 => %w{#189 frac12},
75
- :frac34 => %w{#190 frac34},
76
- :gt => %w{#62 gt},
77
- :lt => %w{#60 lt},
78
- :nbsp => %w{#160 nbsp},
79
- :pound => %w{#163 pound},
80
- :reg => %w{#174 reg},
81
- :single_quote => %w{#39 #821[678] apos lsquo rsquo sbquo},
82
- :times => %w{#215 times},
83
- :trade => %w{#8482 trade},
84
- :yen => %w{#165 yen},
64
+ amp: %w{#38 amp},
65
+ cent: %w{#162 cent},
66
+ copy: %w{#169 copy},
67
+ deg: %w{#176 deg},
68
+ divide: %w{#247 divide},
69
+ double_quote: %w{#34 #822[012] quot ldquo rdquo dbquo},
70
+ ellipsis: %w{#8230 hellip},
71
+ en_dash: %w{#8211 ndash},
72
+ em_dash: %w{#8212 mdash},
73
+ frac14: %w{#188 frac14},
74
+ frac12: %w{#189 frac12},
75
+ frac34: %w{#190 frac34},
76
+ gt: %w{#62 gt},
77
+ lt: %w{#60 lt},
78
+ nbsp: %w{#160 nbsp},
79
+ pound: %w{#163 pound},
80
+ reg: %w{#174 reg},
81
+ single_quote: %w{#39 #821[678] apos lsquo rsquo sbquo},
82
+ times: %w{#215 times},
83
+ trade: %w{#8482 trade},
84
+ yen: %w{#165 yen},
85
85
  }
86
86
  base.inject({}) do |hash, content|
87
87
  key, expression = content
@@ -107,21 +107,21 @@ module Stringex
107
107
 
108
108
  # Ordered by denominator then numerator of the value
109
109
  VULGAR_FRACTIONS = {
110
- :half => /(&#189;|&frac12;|½)/,
111
- :one_third => /(&#8531;|⅓)/,
112
- :two_thirds => /(&#8532;|⅔)/,
113
- :one_fourth => /(&#188;|&frac14;|¼)/,
114
- :three_fourths => /(&#190;|&frac34;|¾)/,
115
- :one_fifth => /(&#8533;|⅕)/,
116
- :two_fifths => /(&#8534;|⅖)/,
117
- :three_fifths => /(&#8535;|⅗)/,
118
- :four_fifths => /(&#8536;|⅘)/,
119
- :one_sixth => /(&#8537;|⅙)/,
120
- :five_sixths => /(&#8538;|⅚)/,
121
- :one_eighth => /(&#8539;|⅛)/,
122
- :three_eighths => /(&#8540;|⅜)/,
123
- :five_eighths => /(&#8541;|⅝)/,
124
- :seven_eighths => /(&#8542;|⅞)/,
110
+ half: /(&#189;|&frac12;|½)/,
111
+ one_third: /(&#8531;|⅓)/,
112
+ two_thirds: /(&#8532;|⅔)/,
113
+ one_fourth: /(&#188;|&frac14;|¼)/,
114
+ three_fourths: /(&#190;|&frac34;|¾)/,
115
+ one_fifth: /(&#8533;|⅕)/,
116
+ two_fifths: /(&#8534;|⅖)/,
117
+ three_fifths: /(&#8535;|⅗)/,
118
+ four_fifths: /(&#8536;|⅘)/,
119
+ one_sixth: /(&#8537;|⅙)/,
120
+ five_sixths: /(&#8538;|⅚)/,
121
+ one_eighth: /(&#8539;|⅛)/,
122
+ three_eighths: /(&#8540;|⅜)/,
123
+ five_eighths: /(&#8541;|⅝)/,
124
+ seven_eighths: /(&#8542;|⅞)/,
125
125
  }
126
126
 
127
127
  WHITESPACE = /\s+/
@@ -4,77 +4,77 @@ module Stringex
4
4
  module Localization
5
5
  module DefaultConversions
6
6
  CHARACTERS = {
7
- :and => "and",
8
- :at => "at",
9
- :degrees => "degrees",
10
- :divide => "divided by",
11
- :dot => '\1 dot \2',
12
- :ellipsis => "dot dot dot",
13
- :equals => "equals",
14
- :number => "number",
15
- :percent => "percent",
16
- :plus => "plus",
17
- :slash => "slash",
18
- :star => "star",
7
+ and: "and",
8
+ at: "at",
9
+ degrees: "degrees",
10
+ divide: "divided by",
11
+ dot: '\1 dot \2',
12
+ ellipsis: "dot dot dot",
13
+ equals: "equals",
14
+ number: "number",
15
+ percent: "percent",
16
+ plus: "plus",
17
+ slash: "slash",
18
+ star: "star",
19
19
  }
20
20
 
21
21
  CURRENCIES_SIMPLE = {
22
- :generic => '\1 dollars',
23
- :dollars => '\1 dollars',
24
- :euros => '\1 euros',
25
- :pounds => '\1 pounds',
26
- :yen => '\1 yen',
22
+ generic: '\1 dollars',
23
+ dollars: '\1 dollars',
24
+ euros: '\1 euros',
25
+ pounds: '\1 pounds',
26
+ yen: '\1 yen',
27
27
  }
28
28
  CURRENCIES_COMPLEX = {
29
- :dollars_cents => '\1 dollars \2 cents',
30
- :euros_cents => '\1 euros \2 cents',
31
- :pounds_pence => '\1 pounds \2 pence',
29
+ dollars_cents: '\1 dollars \2 cents',
30
+ euros_cents: '\1 euros \2 cents',
31
+ pounds_pence: '\1 pounds \2 pence',
32
32
  }
33
33
  CURRENCIES = CURRENCIES_SIMPLE.merge(CURRENCIES_COMPLEX)
34
34
 
35
35
  HTML_ENTITIES = {
36
- :amp => "and",
37
- :cent => " cents",
38
- :copy => "(c)",
39
- :deg => " degrees ",
40
- :divide => " divided by ",
41
- :double_quote => '"',
42
- :ellipsis => "...",
43
- :en_dash => "-",
44
- :em_dash => "--",
45
- :frac14 => "one fourth",
46
- :frac12 => "half",
47
- :frac34 => "three fourths",
48
- :gt => ">",
49
- :lt => "<",
50
- :nbsp => " ",
51
- :pound => " pounds ",
52
- :reg => "(r)",
53
- :single_quote => "'",
54
- :times => "x",
55
- :trade => "(tm)",
56
- :yen => " yen "
36
+ amp: "and",
37
+ cent: " cents",
38
+ copy: "(c)",
39
+ deg: " degrees ",
40
+ divide: " divided by ",
41
+ double_quote: '"',
42
+ ellipsis: "...",
43
+ en_dash: "-",
44
+ em_dash: "--",
45
+ frac14: "one fourth",
46
+ frac12: "half",
47
+ frac34: "three fourths",
48
+ gt: ">",
49
+ lt: "<",
50
+ nbsp: " ",
51
+ pound: " pounds ",
52
+ reg: "(r)",
53
+ single_quote: "'",
54
+ times: "x",
55
+ trade: "(tm)",
56
+ yen: " yen "
57
57
  }
58
58
 
59
59
  TRANSLITERATIONS = {}
60
60
 
61
61
  # Ordered by denominator then numerator of the value
62
62
  VULGAR_FRACTIONS = {
63
- :half => "half",
64
- :one_third => "one third",
65
- :two_thirds => "two thirds",
66
- :one_fourth => "one fourth",
67
- :three_fourths => "three fourths",
68
- :one_fifth => "one fifth",
69
- :two_fifths => "two fifths",
70
- :three_fifths => "three fifths",
71
- :four_fifths => "four fifths",
72
- :one_sixth => "one sixth",
73
- :five_sixths => "five sixths",
74
- :one_eighth => "one eighth",
75
- :three_eighths => "three eighths",
76
- :five_eighths => "five eighths",
77
- :seven_eighths => "seven eighths",
63
+ half: "half",
64
+ one_third: "one third",
65
+ two_thirds: "two thirds",
66
+ one_fourth: "one fourth",
67
+ three_fourths: "three fourths",
68
+ one_fifth: "one fifth",
69
+ two_fifths: "two fifths",
70
+ three_fifths: "three fifths",
71
+ four_fifths: "four fifths",
72
+ one_sixth: "one sixth",
73
+ five_sixths: "five sixths",
74
+ one_eighth: "one eighth",
75
+ three_eighths: "three eighths",
76
+ five_eighths: "five eighths",
77
+ seven_eighths: "seven eighths",
78
78
  }
79
79
 
80
80
  class << self
@@ -52,7 +52,7 @@ module Stringex
52
52
  # It allows localization of conversions so you can use it to convert characters into your own language.
53
53
  # Example:
54
54
  #
55
- # I18n.backend.store_translations :de, { :stringex => { :characters => { :and => "und" } } }
55
+ # I18n.backend.store_translations :de, { stringex: { characters: { and: "und" } } }
56
56
  # I18n.locale = :de
57
57
  # "ich & dich".convert_misc_characters # => "ich und dich"
58
58
  #
data/stringex.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: stringex 2.6.1 ruby lib
5
+ # stub: stringex 2.7.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "stringex"
9
- s.version = "2.6.1"
9
+ s.version = "2.7.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Russell Norris"]
14
- s.date = "2016-07-14"
14
+ s.date = "2017-01-18"
15
15
  s.description = "Some [hopefully] useful extensions to Ruby's String class. Stringex is made up of three libraries: ActsAsUrl [permalink solution with better character translation], Unidecoder [Unicode to ASCII transliteration], and StringExtensions [miscellaneous helper methods for the String class]."
16
16
  s.email = "rsl@luckysneaks.com"
17
17
  s.extra_rdoc_files = [
@@ -8,15 +8,15 @@ puts "-------------------------------------------------"
8
8
  puts "Running ActsAsUrl tests with ActiveRecord adapter"
9
9
  puts "-------------------------------------------------"
10
10
 
11
- ActiveRecord::Base.establish_connection :adapter => "sqlite3", :database => ":memory:"
11
+ ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
12
12
 
13
13
  ActiveRecord::Migration.verbose = false
14
14
  ActiveRecord::Schema.define do
15
- create_table :documents, :force => true do |t|
15
+ create_table :documents, force: true do |t|
16
16
  t.string :title, :other, :another, :url
17
17
  end
18
18
 
19
- create_table :sti_base_documents, :force => true do |t|
19
+ create_table :sti_base_documents, force: true do |t|
20
20
  t.string :title, :other, :another, :url, :type
21
21
  end
22
22
  end
@@ -25,7 +25,7 @@ DefineTestClasses = proc do
25
25
  property :title, String
26
26
  property :other, String
27
27
  property :another, String
28
- property :url, String, :lazy => false
28
+ property :url, String, lazy: false
29
29
 
30
30
  acts_as_url :title
31
31
  end
@@ -36,7 +36,7 @@ DefineTestClasses = proc do
36
36
  property :title, String
37
37
  property :other, String
38
38
  property :another, String
39
- property :url, String, :lazy => false
39
+ property :url, String, lazy: false
40
40
  property :type, String
41
41
 
42
42
  # This gets redefined in the only test that uses it but I want to be uniform
@@ -14,10 +14,10 @@ end
14
14
 
15
15
  class Document
16
16
  include Mongoid::Document
17
- field :title, :type => String
18
- field :other, :type => String
19
- field :another, :type => String
20
- field :url, :type => String
17
+ field :title, type: String
18
+ field :other, type: String
19
+ field :another, type: String
20
+ field :url, type: String
21
21
 
22
22
  acts_as_url :title
23
23
  end
@@ -32,11 +32,11 @@ end
32
32
 
33
33
  class STIBaseDocument
34
34
  include Mongoid::Document
35
- field :title, :type => String
36
- field :other, :type => String
37
- field :another, :type => String
38
- field :url, :type => String
39
- field :type, :type => String
35
+ field :title, type: String
36
+ field :other, type: String
37
+ field :another, type: String
38
+ field :url, type: String
39
+ field :type, type: String
40
40
 
41
41
  # This gets redefined in the only test that uses it but I want to be uniform
42
42
  # in setting configuration details in the tests themselves
@@ -9,7 +9,7 @@ class ActsAsUrlConfigurationTest < Test::Unit::TestCase
9
9
  end
10
10
 
11
11
  def test_can_set_base_settings
12
- default_configuration = Stringex::Configuration::ActsAsUrl.new(:url_attribute => "original")
12
+ default_configuration = Stringex::Configuration::ActsAsUrl.new(url_attribute: "original")
13
13
  assert_equal "original", default_configuration.settings.url_attribute
14
14
 
15
15
  Stringex::ActsAsUrl.configure do |c|
@@ -26,7 +26,7 @@ class ActsAsUrlConfigurationTest < Test::Unit::TestCase
26
26
  system_configuration = Stringex::Configuration::ActsAsUrl.new
27
27
  assert_equal "special", system_configuration.settings.url_attribute
28
28
 
29
- local_configuration = Stringex::Configuration::ActsAsUrl.new(:url_attribute => "local")
29
+ local_configuration = Stringex::Configuration::ActsAsUrl.new(url_attribute: "local")
30
30
  assert_equal "local", local_configuration.settings.url_attribute
31
31
  end
32
32
 
@@ -9,20 +9,53 @@ class ActsAsUrlIntegrationTest < Test::Unit::TestCase
9
9
  include AdapterSpecificTestBehaviors
10
10
 
11
11
  def test_should_create_url
12
- @doc = Document.create(:title => "Let's Make a Test Title, <em>Okay</em>?")
12
+ @doc = Document.create(title: "Let's Make a Test Title, <em>Okay</em>?")
13
13
  assert_equal "lets-make-a-test-title-okay", @doc.url
14
14
  end
15
15
 
16
16
  def test_should_create_unique_url
17
- @doc = Document.create(:title => "Unique")
18
- @other_doc = Document.create(:title => "Unique")
17
+ @doc = Document.create(title: "Unique")
18
+ @other_doc = Document.create(title: "Unique")
19
19
  assert_equal "unique", @doc.url
20
20
  assert_equal "unique-1", @other_doc.url
21
21
  end
22
22
 
23
+ def test_should_allow_custom_duplicates
24
+ sequence = Enumerator.new { |enum| loop { enum.yield 12345 } }
25
+ Document.class_eval do
26
+ acts_as_url :title, duplicate_sequence: sequence
27
+ end
28
+
29
+ @doc = Document.create(title: "New")
30
+ @other_doc = Document.create(title: "New")
31
+ assert_equal "new-document", @doc.url
32
+ assert_equal "new-document-12345", @other_doc.url
33
+ end
34
+
35
+ def test_should_restart_duplicate_sequence_each_time
36
+ sequence = Enumerator.new do |enum|
37
+ n = 1
38
+ loop do
39
+ enum.yield n
40
+ n += 1
41
+ end
42
+ end
43
+ Document.class_eval do
44
+ acts_as_url :title, duplicate_sequence: sequence
45
+ end
46
+ @doc = Document.create(title: "Unique")
47
+ @other_doc = Document.create(title: "Unique")
48
+ @third_doc = Document.create(title: "Another")
49
+ @fourth_doc = Document.create(title: "Another")
50
+ assert_equal "unique", @doc.url
51
+ assert_equal "unique-1", @other_doc.url
52
+ assert_equal "another", @third_doc.url
53
+ assert_equal "another-1", @fourth_doc.url
54
+ end
55
+
23
56
  def test_should_avoid_blacklist
24
- @doc = Document.create(:title => "New")
25
- @other_doc = Document.create(:title => "new")
57
+ @doc = Document.create(title: "New")
58
+ @other_doc = Document.create(title: "new")
26
59
  assert_equal "new-document", @doc.url
27
60
  assert_equal "new-document-1", @other_doc.url
28
61
  end
@@ -30,60 +63,60 @@ class ActsAsUrlIntegrationTest < Test::Unit::TestCase
30
63
  def test_should_allow_customizing_blacklist
31
64
  Document.class_eval do
32
65
  # Un-blacklisting 'new' isn't advisable
33
- acts_as_url :title, :blacklist => %w{special}
66
+ acts_as_url :title, blacklist: %w{special}
34
67
  end
35
68
 
36
- @doc = Document.create(:title => "New")
37
- @other_doc = Document.create(:title => "Special")
69
+ @doc = Document.create(title: "New")
70
+ @other_doc = Document.create(title: "Special")
38
71
  assert_equal 'new', @doc.url
39
72
  assert_equal 'special-document', @other_doc.url
40
73
  end
41
74
 
42
75
  def test_should_allow_customizing_blacklist_policy
43
76
  Document.class_eval do
44
- acts_as_url :title, :blacklist_policy => Proc.new(){|instance, url|
77
+ acts_as_url :title, blacklist_policy: Proc.new(){|instance, url|
45
78
  "#{url}-customized"
46
79
  }
47
80
  end
48
81
 
49
- @doc = Document.create(:title => "New")
50
- @other_doc = Document.create(:title => "New")
82
+ @doc = Document.create(title: "New")
83
+ @other_doc = Document.create(title: "New")
51
84
  assert_equal 'new-customized', @doc.url
52
85
  assert_equal 'new-customized-1', @other_doc.url
53
86
  end
54
87
 
55
88
  def test_should_create_unique_url_when_partial_url_already_exists
56
- @doc = Document.create(:title => "House Farms")
57
- @other_doc = Document.create(:title => "House Farm")
89
+ @doc = Document.create(title: "House Farms")
90
+ @other_doc = Document.create(title: "House Farm")
58
91
 
59
92
  assert_equal "house-farms", @doc.url
60
93
  assert_equal "house-farm", @other_doc.url
61
94
  end
62
95
 
63
96
  def test_should_not_sync_url_by_default
64
- @doc = Document.create(:title => "Stable as Stone")
97
+ @doc = Document.create(title: "Stable as Stone")
65
98
  @original_url = @doc.url
66
- adapter_specific_update @doc, :title => "New Unstable Madness"
99
+ adapter_specific_update @doc, title: "New Unstable Madness"
67
100
  assert_equal @original_url, @doc.url
68
101
  end
69
102
 
70
103
  def test_should_allow_syncing_url
71
104
  Document.class_eval do
72
- acts_as_url :title, :sync_url => true
105
+ acts_as_url :title, sync_url: true
73
106
  end
74
107
 
75
- @doc = Document.create(:title => "Original")
108
+ @doc = Document.create(title: "Original")
76
109
  @original_url = @doc.url
77
- adapter_specific_update @doc, :title => "New and Improved"
110
+ adapter_specific_update @doc, title: "New and Improved"
78
111
  assert_not_equal @original_url, @doc.url
79
112
  end
80
113
 
81
114
  def test_should_not_increment_count_on_repeated_saves
82
115
  Document.class_eval do
83
- acts_as_url :title, :sync_url => true
116
+ acts_as_url :title, sync_url: true
84
117
  end
85
118
 
86
- @doc = Document.create(:title => "Continuous or Constant")
119
+ @doc = Document.create(title: "Continuous or Constant")
87
120
  assert_equal "continuous-or-constant", @doc.url
88
121
  5.times do |n|
89
122
  @doc.save!
@@ -93,54 +126,54 @@ class ActsAsUrlIntegrationTest < Test::Unit::TestCase
93
126
 
94
127
  def test_should_allow_allowing_duplicate_url
95
128
  Document.class_eval do
96
- acts_as_url :title, :allow_duplicates => true
129
+ acts_as_url :title, allow_duplicates: true
97
130
  end
98
131
 
99
- @doc = Document.create(:title => "I am not a clone")
100
- @other_doc = Document.create(:title => "I am not a clone")
132
+ @doc = Document.create(title: "I am not a clone")
133
+ @other_doc = Document.create(title: "I am not a clone")
101
134
  assert_equal @doc.url, @other_doc.url
102
135
  end
103
136
 
104
137
  def test_should_allow_scoping_url_uniqueness
105
138
  Document.class_eval do
106
- acts_as_url :title, :scope => :other
139
+ acts_as_url :title, scope: :other
107
140
  end
108
141
 
109
- @doc = Document.create(:title => "Mocumentary", :other => "I don't care if I'm unique for some reason")
110
- @other_doc = Document.create(:title => "Mocumentary", :other => "Me either")
142
+ @doc = Document.create(title: "Mocumentary", other: "I don't care if I'm unique for some reason")
143
+ @other_doc = Document.create(title: "Mocumentary", other: "Me either")
111
144
  assert_equal @doc.url, @other_doc.url
112
145
  end
113
146
 
114
147
  def test_should_still_create_unique_urls_if_scoped_attribute_is_the_same
115
148
  Document.class_eval do
116
- acts_as_url :title, :scope => :other
149
+ acts_as_url :title, scope: :other
117
150
  end
118
151
 
119
- @doc = Document.create(:title => "Mocumentary", :other => "Suddenly, I care if I'm unique")
120
- @other_doc = Document.create(:title => "Mocumentary", :other => "Suddenly, I care if I'm unique")
152
+ @doc = Document.create(title: "Mocumentary", other: "Suddenly, I care if I'm unique")
153
+ @other_doc = Document.create(title: "Mocumentary", other: "Suddenly, I care if I'm unique")
121
154
  assert_not_equal @doc.url, @other_doc.url
122
155
  end
123
156
 
124
157
  def test_should_allow_multiple_scopes
125
158
  Document.class_eval do
126
- acts_as_url :title, :scope => [:other, :another]
159
+ acts_as_url :title, scope: [:other, :another]
127
160
  end
128
161
 
129
- @doc = Document.create(:title => "Mocumentary", :other => "I don't care if I'm unique for some reason",
130
- :another => "Whatever")
131
- @other_doc = Document.create(:title => "Mocumentary", :other => "Me either", :another => "Whatever")
162
+ @doc = Document.create(title: "Mocumentary", other: "I don't care if I'm unique for some reason",
163
+ another: "Whatever")
164
+ @other_doc = Document.create(title: "Mocumentary", other: "Me either", another: "Whatever")
132
165
  assert_equal @doc.url, @other_doc.url
133
166
  end
134
167
 
135
168
  def test_should_only_create_unique_urls_for_multiple_scopes_if_both_attributes_are_same
136
169
  Document.class_eval do
137
- acts_as_url :title, :scope => [:other, :another]
170
+ acts_as_url :title, scope: [:other, :another]
138
171
  end
139
172
 
140
- @doc = Document.create(:title => "Mocumentary", :other => "Suddenly, I care if I'm unique",
141
- :another => "Whatever")
142
- @other_doc = Document.create(:title => "Mocumentary", :other => "Suddenly, I care if I'm unique",
143
- :another => "Whatever")
173
+ @doc = Document.create(title: "Mocumentary", other: "Suddenly, I care if I'm unique",
174
+ another: "Whatever")
175
+ @other_doc = Document.create(title: "Mocumentary", other: "Suddenly, I care if I'm unique",
176
+ another: "Whatever")
144
177
  assert_not_equal @doc.url, @other_doc.url
145
178
  end
146
179
 
@@ -149,10 +182,10 @@ class ActsAsUrlIntegrationTest < Test::Unit::TestCase
149
182
  # Manually undefining the url method on Document which, in a real class not reused for tests,
150
183
  # would never have been defined to begin with.
151
184
  remove_method :url
152
- acts_as_url :title, :url_attribute => :other
185
+ acts_as_url :title, url_attribute: :other
153
186
  end
154
187
 
155
- @doc = Document.create(:title => "Anything at This Point")
188
+ @doc = Document.create(title: "Anything at This Point")
156
189
  assert_equal "anything-at-this-point", @doc.other
157
190
  assert_nil @doc.url
158
191
  ensure
@@ -164,21 +197,21 @@ class ActsAsUrlIntegrationTest < Test::Unit::TestCase
164
197
 
165
198
  def test_should_allow_updating_url_only_when_blank
166
199
  Document.class_eval do
167
- acts_as_url :title, :only_when_blank => true
200
+ acts_as_url :title, only_when_blank: true
168
201
  end
169
202
 
170
203
  @string = 'the-url-of-concrete'
171
- @doc = Document.create(:title => "Stable as Stone", :url => @string)
204
+ @doc = Document.create(title: "Stable as Stone", url: @string)
172
205
  assert_equal @string, @doc.url
173
- @other_doc = Document.create(:title => "Stable as Stone")
206
+ @other_doc = Document.create(title: "Stable as Stone")
174
207
  assert_equal 'stable-as-stone', @other_doc.url
175
208
  end
176
209
 
177
210
  def test_should_mass_initialize_urls
178
- @doc = Document.create(:title => "Initial")
179
- @other_doc = Document.create(:title => "Subsequent")
180
- adapter_specific_update @doc, :url => nil
181
- adapter_specific_update @other_doc, :url => nil
211
+ @doc = Document.create(title: "Initial")
212
+ @other_doc = Document.create(title: "Subsequent")
213
+ adapter_specific_update @doc, url: nil
214
+ adapter_specific_update @other_doc, url: nil
182
215
  # Just making sure this got unset before the real test
183
216
  assert_nil @doc.url
184
217
  assert_nil @other_doc.url
@@ -196,13 +229,13 @@ class ActsAsUrlIntegrationTest < Test::Unit::TestCase
196
229
  # Manually undefining the url method on Document which, in a real class not reused for tests,
197
230
  # would never have been defined to begin with.
198
231
  remove_method :url
199
- acts_as_url :title, :url_attribute => :other
232
+ acts_as_url :title, url_attribute: :other
200
233
  end
201
234
 
202
- @doc = Document.create(:title => "Initial")
203
- @other_doc = Document.create(:title => "Subsequent")
204
- adapter_specific_update @doc, :other => nil
205
- adapter_specific_update @other_doc, :other => nil
235
+ @doc = Document.create(title: "Initial")
236
+ @other_doc = Document.create(title: "Subsequent")
237
+ adapter_specific_update @doc, other: nil
238
+ adapter_specific_update @other_doc, other: nil
206
239
  # Just making sure this got unset before the real test
207
240
  assert_nil @doc.other
208
241
  assert_nil @other_doc.other
@@ -221,10 +254,10 @@ class ActsAsUrlIntegrationTest < Test::Unit::TestCase
221
254
  end
222
255
 
223
256
  def test_should_mass_initialize_empty_string_urls
224
- @doc = Document.create(:title => "Initial")
225
- @other_doc = Document.create(:title => "Subsequent")
226
- adapter_specific_update @doc, :url => ''
227
- adapter_specific_update @other_doc, :url => ''
257
+ @doc = Document.create(title: "Initial")
258
+ @other_doc = Document.create(title: "Subsequent")
259
+ adapter_specific_update @doc, url: ''
260
+ adapter_specific_update @other_doc, url: ''
228
261
  # Just making sure this got unset before the real test
229
262
  assert_equal '', @doc.url
230
263
  assert_equal '', @other_doc.url
@@ -246,7 +279,7 @@ class ActsAsUrlIntegrationTest < Test::Unit::TestCase
246
279
  end
247
280
  end
248
281
 
249
- @doc = Document.create(:title => "Title String")
282
+ @doc = Document.create(title: "Title String")
250
283
  assert_equal "title-string-got-massaged", @doc.url
251
284
  ensure
252
285
  Document.class_eval do
@@ -257,22 +290,22 @@ class ActsAsUrlIntegrationTest < Test::Unit::TestCase
257
290
 
258
291
  def test_should_allow_customizing_duplicate_count_separator
259
292
  Document.class_eval do
260
- acts_as_url :title, :duplicate_count_separator => "---"
293
+ acts_as_url :title, duplicate_count_separator: "---"
261
294
  end
262
295
 
263
- @doc = Document.create(:title => "Unique")
264
- @other_doc = Document.create(:title => "Unique")
296
+ @doc = Document.create(title: "Unique")
297
+ @other_doc = Document.create(title: "Unique")
265
298
  assert_equal "unique", @doc.url
266
299
  assert_equal "unique---1", @other_doc.url
267
300
  end
268
301
 
269
302
  def test_should_only_update_url_if_url_attribute_is_valid
270
303
  Document.class_eval do
271
- acts_as_url :title, :sync_url => true
304
+ acts_as_url :title, sync_url: true
272
305
  end
273
306
  add_validation_on_document_title
274
307
 
275
- @doc = Document.create(:title => "Valid Record", :other => "Present")
308
+ @doc = Document.create(title: "Valid Record", other: "Present")
276
309
  assert_equal "valid-record", @doc.url
277
310
  @doc.title = nil
278
311
  assert_equal false, @doc.valid?
@@ -283,61 +316,61 @@ class ActsAsUrlIntegrationTest < Test::Unit::TestCase
283
316
 
284
317
  def test_should_allow_customizing_url_limit
285
318
  Document.class_eval do
286
- acts_as_url :title, :limit => 13
319
+ acts_as_url :title, limit: 13
287
320
  end
288
321
 
289
- @doc = Document.create(:title => "I am much too long")
322
+ @doc = Document.create(title: "I am much too long")
290
323
  assert_equal "i-am-much-too", @doc.url
291
324
  end
292
325
 
293
326
  def test_handling_duplicate_urls_with_limits
294
327
  Document.class_eval do
295
- acts_as_url :title, :limit => 13
328
+ acts_as_url :title, limit: 13
296
329
  end
297
330
 
298
- @doc = Document.create(:title => "I am much too long and also duplicated")
331
+ @doc = Document.create(title: "I am much too long and also duplicated")
299
332
  assert_equal "i-am-much-too", @doc.url
300
- @other_doc = Document.create(:title => "I am much too long and also duplicated")
333
+ @other_doc = Document.create(title: "I am much too long and also duplicated")
301
334
  assert_equal "i-am-much-too-1", @other_doc.url
302
335
  end
303
336
 
304
337
  def test_should_allow_excluding_specific_values_from_being_run_through_to_url
305
338
  Document.class_eval do
306
- acts_as_url :title, :exclude => ["_So_Fucking_Special"]
339
+ acts_as_url :title, exclude: ["_So_Fucking_Special"]
307
340
  end
308
341
 
309
- @doc = Document.create(:title => "_So_Fucking_Special")
342
+ @doc = Document.create(title: "_So_Fucking_Special")
310
343
  assert_equal "_So_Fucking_Special", @doc.url
311
- @doc_2 = Document.create(:title => "But I'm a creep")
344
+ @doc_2 = Document.create(title: "But I'm a creep")
312
345
  assert_equal "but-im-a-creep", @doc_2.url
313
346
  end
314
347
 
315
348
  def test_should_allow_not_forcing_downcasing
316
349
  Document.class_eval do
317
- acts_as_url :title, :force_downcase => false
350
+ acts_as_url :title, force_downcase: false
318
351
  end
319
352
 
320
- @doc = Document.create(:title => "I have CAPS!")
353
+ @doc = Document.create(title: "I have CAPS!")
321
354
  assert_equal "I-have-CAPS", @doc.url
322
355
  end
323
356
 
324
357
  def test_should_allow_alternate_whitespace_replacements
325
358
  Document.class_eval do
326
- acts_as_url :title, :replace_whitespace_with => "~"
359
+ acts_as_url :title, replace_whitespace_with: "~"
327
360
  end
328
361
 
329
- @doc = Document.create(:title => "now with tildes")
362
+ @doc = Document.create(title: "now with tildes")
330
363
  assert_equal "now~with~tildes", @doc.url
331
364
  end
332
365
 
333
366
  def test_should_allow_enforcing_uniqueness_on_sti_base_class
334
367
  STIBaseDocument.class_eval do
335
- acts_as_url :title, :enforce_uniqueness_on_sti_base_class => true
368
+ acts_as_url :title, enforce_uniqueness_on_sti_base_class: true
336
369
  end
337
370
 
338
- @doc = STIChildDocument.create(:title => "Unique")
371
+ @doc = STIChildDocument.create(title: "Unique")
339
372
  assert_equal "unique", @doc.url
340
- @doc_2 = AnotherSTIChildDocument.create(:title => "Unique")
373
+ @doc_2 = AnotherSTIChildDocument.create(title: "Unique")
341
374
  assert_equal "unique-1", @doc_2.url
342
375
  end
343
376
 
@@ -346,47 +379,47 @@ class ActsAsUrlIntegrationTest < Test::Unit::TestCase
346
379
  acts_as_url :title
347
380
  end
348
381
 
349
- @doc = Document.create(:title => "a b/c d")
382
+ @doc = Document.create(title: "a b/c d")
350
383
  assert_equal "a-b-slash-c-d", @doc.url
351
384
  end
352
385
 
353
386
  def test_should_allow_slashes_to_be_allowed
354
387
  Document.class_eval do
355
- acts_as_url :title, :allow_slash => true
388
+ acts_as_url :title, allow_slash: true
356
389
  end
357
390
 
358
- @doc = Document.create(:title => "a b/c d")
391
+ @doc = Document.create(title: "a b/c d")
359
392
  assert_equal "a-b/c-d", @doc.url
360
393
  end
361
394
 
362
395
  def test_should_truncate_words_by_default
363
396
  Document.class_eval do
364
- acts_as_url :title, :limit => 20
397
+ acts_as_url :title, limit: 20
365
398
  end
366
399
 
367
- @doc = Document.create(:title => "title with many whole words")
400
+ @doc = Document.create(title: "title with many whole words")
368
401
  assert_equal 'title-with-many-whol', @doc.url
369
402
  end
370
403
 
371
404
  def test_should_not_truncate_words
372
405
  Document.class_eval do
373
- acts_as_url :title, :limit => 20, :truncate_words => false
406
+ acts_as_url :title, limit: 20, truncate_words: false
374
407
  end
375
408
 
376
- @doc = Document.create(:title => "title with many whole words")
409
+ @doc = Document.create(title: "title with many whole words")
377
410
  assert_equal 'title-with-many', @doc.url
378
411
  end
379
412
 
380
413
  def test_should_allow_overriding_url_taken_method
381
414
  Document.class_eval do
382
- acts_as_url :title, :url_taken_method => :url_taken?
415
+ acts_as_url :title, url_taken_method: :url_taken?
383
416
 
384
417
  def url_taken?(url)
385
418
  ["unique", "unique-1", "unique-2"].include?(url)
386
419
  end
387
420
  end
388
421
 
389
- @doc = Document.create(:title => "unique")
422
+ @doc = Document.create(title: "unique")
390
423
  assert_equal "unique-3", @doc.url
391
424
  end
392
425
  end
@@ -11,7 +11,7 @@ class LocalizationTest < Test::Unit::TestCase
11
11
  def test_stores_translations
12
12
  Stringex::Localization.backend = :internal
13
13
 
14
- data = { :one => "number one", :two => "number two" }
14
+ data = { one: "number one", two: "number two" }
15
15
  Stringex::Localization.store_translations :en, :test_store, data
16
16
 
17
17
  data.each do |key, value|
@@ -34,7 +34,7 @@ class LocalizationTest < Test::Unit::TestCase
34
34
  def test_can_translate
35
35
  Stringex::Localization.backend = :internal
36
36
 
37
- data = { :one => "number one", :two => "number two" }
37
+ data = { one: "number one", two: "number two" }
38
38
  Stringex::Localization.store_translations :en, :test_translate, data
39
39
 
40
40
  data.each do |key, value|
@@ -45,7 +45,7 @@ class LocalizationTest < Test::Unit::TestCase
45
45
  def test_can_translate_when_given_string_as_key
46
46
  Stringex::Localization.backend = :internal
47
47
 
48
- data = { :one => "number one", :two => "number two" }
48
+ data = { one: "number one", two: "number two" }
49
49
  Stringex::Localization.store_translations :en, :test_translate, data
50
50
 
51
51
  data.each do |key, value|
@@ -55,7 +55,7 @@ class LocalizationTest < Test::Unit::TestCase
55
55
 
56
56
  def test_returns_default_if_none_found
57
57
  Stringex::Localization.backend = :internal
58
- assert_equal "my default", Stringex::Localization.translate(:test_default, :nonexistent, :default => "my default")
58
+ assert_equal "my default", Stringex::Localization.translate(:test_default, :nonexistent, default: "my default")
59
59
  end
60
60
 
61
61
  def test_returns_nil_if_no_default
@@ -91,7 +91,7 @@ class LocalizationTest < Test::Unit::TestCase
91
91
  def test_stores_translations_in_i18n
92
92
  Stringex::Localization.backend = :i18n
93
93
 
94
- data = { :one => "number one", :two => "number two" }
94
+ data = { one: "number one", two: "number two" }
95
95
  Stringex::Localization.store_translations :en, :test_i18n_store, data
96
96
 
97
97
  data.each do |key, value|
@@ -102,9 +102,9 @@ class LocalizationTest < Test::Unit::TestCase
102
102
  def test_can_translate_using_i18n
103
103
  Stringex::Localization.backend = :i18n
104
104
 
105
- data = { :one => "number one", :two => "number two" }
105
+ data = { one: "number one", two: "number two" }
106
106
 
107
- I18n.backend.store_translations :en, { :stringex => { :test_i18n_translation => data } }
107
+ I18n.backend.store_translations :en, { stringex: { test_i18n_translation: data } }
108
108
 
109
109
  data.each do |key, value|
110
110
  assert_equal value, Stringex::Localization.translate(:test_i18n_translation, key)
@@ -117,7 +117,7 @@ class LocalizationTest < Test::Unit::TestCase
117
117
 
118
118
  assert_equal "Test blank", "Test&nbsp;blank".convert_miscellaneous_html_entities
119
119
 
120
- Stringex::Localization.store_translations :en, :html_entities, { :nbsp => "" }
120
+ Stringex::Localization.store_translations :en, :html_entities, { nbsp: "" }
121
121
  assert_equal "Testblank", "Test&nbsp;blank".convert_miscellaneous_html_entities
122
122
  end
123
123
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stringex
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.1
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Russell Norris
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-14 00:00:00.000000000 Z
11
+ date: 2017-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jeweler