[DRE-commits] [ruby-stringex] 01/04: Imported Upstream version 2.5.2
Youhei SASAKI
uwabami-guest at moszumanska.debian.org
Thu May 29 16:16:24 UTC 2014
This is an automated email from the git hooks/post-receive script.
uwabami-guest pushed a commit to annotated tag debian/2.5.2-1
in repository ruby-stringex.
commit fa75d4cffc0b3a6463d30c63b69a0fb04441d11f
Author: Youhei SASAKI <uwabami at gfd-dennou.org>
Date: Fri May 30 00:58:40 2014 +0900
Imported Upstream version 2.5.2
---
Gemfile | 64 +++++++----
MIT-LICENSE | 2 +-
README.rdoc | 25 ++---
Rakefile | 30 +----
VERSION | 2 +-
checksums.yaml.gz | Bin 419 -> 269 bytes
lib/stringex/acts_as_url.rb | 8 +-
lib/stringex/acts_as_url/adapter/base.rb | 7 ++
lib/stringex/configuration/acts_as_url.rb | 10 +-
lib/stringex/localization/backend/i18n.rb | 8 ++
lib/stringex/unidecoder.rb | 33 +++---
locales/pl.yml | 88 +++++++++++++++
locales/sv.yml | 76 +++++++++++++
metadata.yml | 124 +++++----------------
stringex.gemspec | 56 ++++------
.../adapter/{active_record.rb => activerecord.rb} | 1 -
.../adapter/{data_mapper.rb => datamapper.rb} | 1 -
test/unit/acts_as_url/adapter/mongoid.rb | 9 +-
test/unit/acts_as_url_integration_test.rb | 34 +++++-
test/unit/localization/da_test.rb | 4 +-
test/unit/localization/pl_test.rb | 118 ++++++++++++++++++++
test/unit/localization/ru_test.rb | 2 +-
test/unit/localization/{da_test.rb => sv_test.rb} | 90 +++++++--------
test/unit/localization_test.rb | 39 +++++--
test/unit/unicode_point_suite/basic_latin_test.rb | 4 +-
25 files changed, 556 insertions(+), 279 deletions(-)
diff --git a/Gemfile b/Gemfile
index 18c6638..ace593e 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,26 +1,50 @@
# A sample Gemfile
-source "https://rubygems.org"
+source 'https://rubygems.org'
-group :development do
- gem "activerecord", "3.2.13"
- gem "dm-core", "1.2.0"
- gem "dm-migrations", "1.2.0"
- gem "dm-sqlite-adapter", "1.2.0"
- gem "dm-validations", "1.2.0"
- gem "jeweler", "1.8.4"
- if RUBY_VERSION > "1.8.x"
- gem "mongoid", "3.1.4"
+def activerecord?
+ adapter.nil? || adapter == 'activerecord'
+end
+
+def datamapper?
+ adapter == 'datamapper'
+end
+
+def mongoid?
+ if RUBY_VERSION > '1.8.x'
+ adapter == 'mongoid'
else
- puts "Mongoid requires Ruby higher than 1.8.x"
+ puts 'Mongoid requires Ruby higher than 1.8.x'
+ end
+end
+
+def adapter
+ ENV['ADAPTER']
+end
+
+group :development do
+ # Standard gems across gemfiles
+ gem 'jeweler', '2.0.1'
+ gem 'travis-lint', '1.7.0'
+ # Can I state that I really dislike camelcased gem names?
+ gem 'RedCloth', '4.2.9'
+ gem 'sqlite3', '1.3.7'
+
+ if activerecord?
+ gem 'activerecord', '4.0.3'
end
- gem "RedCloth", "4.2.9" # Can I state that I really dislike camelcased gem names?
- gem "travis-lint", "1.7.0"
- gem "i18n", "0.6.1"
- # For non-Jruby...
- gem "sqlite3", "1.3.7", :platform => [:ruby, :mswin, :mingw]
- # And for Jruby...
- platform :jruby do
- # gem "jdbc-sqlite3"
- # gem "activerecord-jdbcsqlite3-adapter"
+
+ if datamapper?
+ gem 'dm-core', '1.2.1'
+ gem 'dm-migrations', '1.2.0'
+ gem 'dm-sqlite-adapter', '1.2.0'
+ gem 'dm-validations', '1.2.0'
+ end
+
+ if mongoid?
+ gem 'mongoid', '3.1.6'
+ gem 'i18n', '0.6.1'
+ else
+ # Everyone else can get the most up-to-date I18n
+ gem 'i18n', '0.6.9'
end
end
diff --git a/MIT-LICENSE b/MIT-LICENSE
index 1c41b10..92ff691 100644
--- a/MIT-LICENSE
+++ b/MIT-LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2008-2012 Lucky Sneaks
+Copyright (c) 2008-2014 Lucky Sneaks
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
diff --git a/README.rdoc b/README.rdoc
index d2abd11..1793587 100644
--- a/README.rdoc
+++ b/README.rdoc
@@ -13,7 +13,8 @@ This library is designed to create URI-friendly representations of an attribute,
# Inside your model
acts_as_url :title
-which will populate the <tt>url</tt> attribute on the object with the converted contents of the <tt>title</tt> attribute. This behavior can be customized by adding the following options to the arguments of the <tt>acts_as_url</tt> method:
+which will populate the <tt>url</tt> attribute on the object with the converted contents of the <tt>title</tt> attribute.
+<tt>acts_as_url</tt> takes the following options:
<tt>:url_attribute</tt>:: The name of the attribute to use for storing the generated url string.
Default is <tt>:url</tt>
@@ -30,6 +31,11 @@ which will populate the <tt>url</tt> attribute on the object with the converted
<tt>:limit</tt>:: If set, will limit length of url generated. Default is nil.
<tt>:truncate_words</tt>:: Used with :limit. If set to false, the url will be truncated to the last
whole word before the limit was reached. Default is true.
+<tt>:blacklist</tt>:: List of urls that should not be allowed. Default is <tt>%w{new}</tt> [which avoids confusion
+ on urls like <tt>/documents/new</tt>].
+<tt>:blacklist_policy</tt>:: Proc or lambda defining new naming behavior when blacklisted urls are encountered.
+ Default converts <tt>/documents/new</tt> to </tt>/documents/new-document</tt>.
+
In order to use the generated url attribute, you will probably want to override <tt>to_param</tt> like so, in your Model:
@@ -53,7 +59,7 @@ Unlike other permalink solutions, ActsAsUrl doesn't rely on Iconv (which is inco
"$12 worth of Ruby power".to_url => "12-dollars-worth-of-ruby-power"
"10% off if you act now".to_url => "10-percent-off-if-you-act-now"
- # You don't even wanna trust Iconv for this next part
+ # You dont EVEN wanna rely on Iconv for this next part
"kick it en Français".to_url => "kick-it-en-francais"
"rock it Español style".to_url => "rock-it-espanol-style"
"tell your readers 你好".to_url => "tell-your-readers-ni-hao"
@@ -81,16 +87,6 @@ This library converts Unicode [and accented ASCII] characters to their plain-tex
You probably won't ever need to run Unidecoder by itself. StringExtensions adds String#to_ascii which wraps all of Unidecoder's functionality. For anyone interested, details of the implementation can be read about in the original implementation of Text::Unidecode[http://interglacial.com/~sburke/tpj/as_html/tpj22.html]. Extensive examples can be found in the tests.
-Unidecoder module also provides localization options for Stringex. You can use this functionality by loading either a YAML file or Hash like the following code snippets:
-
- # Using a Hash
- Stringex.localize_from :en => {"é" => "ee"}
-
- # Loading from a file. NOTE: The path to file should be absolute.
- Stringex.localize_from "/path/to/yaml_file"
-
-In both the YAML and pure Hash implementation, the end result should be a Hash with keys representing the locale and values being another Hash with those keys being the UTF character and the values the transliterated ASCII values. (I hope that made sense.) You can check the documentation for the Unidecoder module for more information about setting locales.
-
== StringExtensions
A small collection of extensions on Ruby's String class. Please see the documentation for StringExtensions module for more information. There's not much to explain about them really.
@@ -107,12 +103,13 @@ Currently, built-in translations are available for the following languages:
* English (en)
* Danish (da)
+ * Swedish (sv)
* Dutch (nl)
* German (de)
+ * Polish (pl)
* Portuguese Brazilian (pt-BR)
* Russian (ru)
-
You can easily add your own or customize the built-in translations - read here[https://github.com/rsl/stringex/wiki/Localization-of-Stringex-conversions]. If you add a new language, please submit a pull request so we can make it available to other users also.
If you don't want to use the Stringex built-in translations, you can force Stringex to use English (or another language), regardless what is in your +I18n.locale+. In an initializer, e.g. +config/initializers/stringex.rb+:
@@ -131,4 +128,4 @@ If it's not obvious, some of the code for ActsAsUrl is based on Rick Olsen's per
GIANT thanks to the many contributors who have helped make Stringex better and better: http://github.com/rsl/stringex/contributors
-copyright (c) 2008-2013 Lucky Sneaks, released under the MIT license
+copyright (c) 2008-2014 Lucky Sneaks, released under the MIT license
diff --git a/Rakefile b/Rakefile
index d21d86e..b418c34 100644
--- a/Rakefile
+++ b/Rakefile
@@ -41,35 +41,7 @@ namespace :test do
end
end
-desc 'Default: Run Stringex test suite using ActiveRecord as the ORM'
-task :default => [:setup_active_record_suite, :test]
-
-task :setup_active_record_suite do
- ENV['ADAPTER'] = 'active_record'
-end
-
-desc 'Run Stringex test suite using ActiveRecord as the ORM'
-namespace :test do
- task :active_record => [:setup_active_record_suite]
-end
-
-task :setup_mongoid_suite do
- ENV['ADAPTER'] = 'mongoid'
-end
-
-desc 'Run Stringex test suite using Mongoid as the ORM'
-namespace :test do
- task :mongoid => [:setup_mongoid_suite, :test]
-end
-
-task :setup_data_mapper_suite do
- ENV['ADAPTER'] = 'data_mapper'
-end
-
-desc 'Run Stringex test suite using DataMapper as the ORM'
-namespace :test do
- task :data_mapper => [:setup_data_mapper_suite, :test]
-end
+task :default => :test
desc 'Generate RDoc for Stringex'
Rake::RDocTask.new(:rdoc) do |rdoc|
diff --git a/VERSION b/VERSION
index e3a4f19..21b159d 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.2.0
\ No newline at end of file
+2.5.2
\ No newline at end of file
diff --git a/checksums.yaml.gz b/checksums.yaml.gz
index 295b2fd..7683b44 100644
Binary files a/checksums.yaml.gz and b/checksums.yaml.gz differ
diff --git a/lib/stringex/acts_as_url.rb b/lib/stringex/acts_as_url.rb
index 4cee612..6d310a0 100644
--- a/lib/stringex/acts_as_url.rb
+++ b/lib/stringex/acts_as_url.rb
@@ -72,11 +72,13 @@ module Stringex
# Some ORMs function as mixins not base classes and need to have a hook to reinclude
# and re-extend ActsAsUrl methods
- def included(base)
+ def included(base = nil, &block)
super
- base.send :include, Stringex::ActsAsUrl::ActsAsUrlInstanceMethods
- base.send :extend, Stringex::ActsAsUrl::ActsAsUrlClassMethods
+ if base
+ base.send :include, Stringex::ActsAsUrl::ActsAsUrlInstanceMethods
+ base.send :extend, Stringex::ActsAsUrl::ActsAsUrlClassMethods
+ end
end
# Initialize the url fields for the records that need it. Designed for people who add
diff --git a/lib/stringex/acts_as_url/adapter/base.rb b/lib/stringex/acts_as_url/adapter/base.rb
index 48b99af..afe5e41 100644
--- a/lib/stringex/acts_as_url/adapter/base.rb
+++ b/lib/stringex/acts_as_url/adapter/base.rb
@@ -22,6 +22,7 @@ module Stringex
self.instance = instance
handle_url!
+ handle_blacklisted_url!
handle_duplicate_url! unless settings.allow_duplicates
end
@@ -132,6 +133,12 @@ module Stringex
write_url_attribute base_url
end
+ def handle_blacklisted_url!
+ return unless settings.blacklist.to_set.include?(base_url)
+ self.base_url = settings.blacklist_policy.call(instance, base_url)
+ write_url_attribute base_url
+ end
+
def instance_from_db
instance.class.find(instance.id)
end
diff --git a/lib/stringex/configuration/acts_as_url.rb b/lib/stringex/configuration/acts_as_url.rb
index 7046f80..d796a9c 100644
--- a/lib/stringex/configuration/acts_as_url.rb
+++ b/lib/stringex/configuration/acts_as_url.rb
@@ -15,7 +15,7 @@ module Stringex
:force_downcase,
:limit,
:replace_whitespace_with,
- :truncate_words,
+ :truncate_words
].inject(Hash.new){|m, x| m[x] = settings.send(x); m}
end
@@ -34,13 +34,17 @@ module Stringex
:allow_duplicates => false,
:callback_method => :before_validation,
:duplicate_count_separator => "-",
- :enforce_uniqueness_on_sti_class => false,
+ :enforce_uniqueness_on_sti_base_class => false,
:only_when_blank => false,
:scope_for_url => nil,
:sync_url => false,
:url_attribute => "url",
+ :blacklist => %w[new],
+ :blacklist_policy => lambda { |instance, url|
+ "#{url}-#{instance.class.to_s.downcase}"
+ }
}.merge(Stringex::Configuration::StringExtensions.new.default_settings)
end
end
end
-end
\ No newline at end of file
+end
diff --git a/lib/stringex/localization/backend/i18n.rb b/lib/stringex/localization/backend/i18n.rb
index b290921..d5be33a 100644
--- a/lib/stringex/localization/backend/i18n.rb
+++ b/lib/stringex/localization/backend/i18n.rb
@@ -48,12 +48,20 @@ module Stringex
end
def i18n_translations_for(locale)
+ ensure_locales_enforced_or_not
::I18n.translate("stringex", :locale => locale, :default => {})
end
def reset_translations_cache
@translations = nil
end
+
+ def ensure_locales_enforced_or_not
+ return unless ::I18n.respond_to?(:enforce_available_locales)
+ # Allow users to have set this to false manually but default to true
+ return if ::I18n.enforce_available_locales != nil
+ ::I18n.enforce_available_locales = ::I18n.available_locales != []
+ end
end
end
diff --git a/lib/stringex/unidecoder.rb b/lib/stringex/unidecoder.rb
index 867b20a..3271610 100644
--- a/lib/stringex/unidecoder.rb
+++ b/lib/stringex/unidecoder.rb
@@ -14,20 +14,7 @@ module Stringex
#
# You're probably better off just using the added String#to_ascii
def decode(string)
- string.gsub(/[^\x00-\x00]/u) do |codepoint|
- if localized = translate(codepoint)
- localized
- else
- begin
- unpacked = codepoint.unpack("U")[0]
- CODEPOINTS[code_group(unpacked)][grouped_point(unpacked)]
- rescue
- # Hopefully this won't come up much
- # TODO: Make this note something to the user that is reportable to me perhaps
- "?"
- end
- end
- end
+ string.chars.map{|char| decoded(char)}.join
end
# Returns character for the given Unicode codepoint
@@ -49,8 +36,22 @@ module Stringex
private
- def translate(codepoint)
- Localization.translate(:transliterations, codepoint)
+ def decoded(character)
+ localized(character) || from_yaml(character)
+ end
+
+ def localized(character)
+ Localization.translate(:transliterations, character)
+ end
+
+ def from_yaml(character)
+ return character unless character.ord > 128
+ unpacked = character.unpack("U")[0]
+ CODEPOINTS[code_group(unpacked)][grouped_point(unpacked)]
+ rescue
+ # Hopefully this won't come up much
+ # TODO: Make this note something to the user that is reportable to me perhaps
+ "?"
end
# Returns the Unicode codepoint grouping for the given character
diff --git a/locales/pl.yml b/locales/pl.yml
new file mode 100644
index 0000000..2bbfe69
--- /dev/null
+++ b/locales/pl.yml
@@ -0,0 +1,88 @@
+# NOTE: Some translation keys make use of matches from regular expressions
+# to manipulate whitespace and order. Please consult the source code for
+# Stringex::Localization::ConversionExpressions to see what those
+# regular expressions look like if you need to manipulate the order
+# differently than the usage below.
+pl:
+ stringex:
+ characters:
+ and: i
+ at: o
+ divide: podzielone przez
+ degrees: stopni
+ dot: \1 kropka \2
+ ellipsis: kropka kropka kropka
+ equals: równy
+ number: numer
+ percent: procent
+ plus: plus
+ slash: ukośnik
+ star: gwiazdka
+ currencies:
+ generic: \1 złotych
+ dollars: \1 dolarów
+ dollars_cents: \1 dolarów \2 centów
+ pounds: \1 funtów
+ pounds_pence: \1 funtów \2 pensów
+ euros: \1 euro
+ euros_cents: \1 euro \2 centów
+ yen: \1 jenów
+ reais: \1 reali
+ reais_cents: \1 reali \2 centów
+ html_entities:
+ amp: i
+ cent: " centów"
+ copy: (c)
+ deg: " stopni "
+ divide: " podzielone przez "
+ double_quote: '"'
+ ellipsis: "..."
+ en_dash: "-"
+ em_dash: "--"
+ frac14: jedna czwarta
+ frac12: pół
+ frac34: trzy czwarte
+ gt: ">"
+ lt: <
+ nbsp: " "
+ pound: " funtów "
+ reg: (r)
+ single_quote: "'"
+ times: x
+ trade: (TM)
+ yen: " jen "
+ vulgar_fractions:
+ half: pół
+ one_third: jedna trzecia
+ two_thirds: dwie trzecie
+ one_fourth: jedna czwarta
+ three_fourths: trzy czwarte
+ one_fifth: jedna piąta
+ two_fifths: dwie piąte
+ three_fifths: trzy piąte
+ four_fifths: cztery piąte
+ one_sixth: jedna szósta
+ five_sixths: pięć szóstych
+ one_eighth: jedna ósma
+ three_eighths: trzy ósme
+ five_eighths: pięć ósmych
+ seven_eighths: siedem ósmych
+ transliterations:
+ Ą: A
+ Ć: C
+ Ę: E
+ Ł: L
+ Ń: N
+ Ó: O
+ Ś: S
+ Ź: Z
+ Ż: Z
+ ą: a
+ ć: c
+ ę: e
+ ł: l
+ ń: n
+ ó: o
+ ś: s
+ ź: z
+ ż: z
\ No newline at end of file
diff --git a/locales/sv.yml b/locales/sv.yml
new file mode 100644
index 0000000..52161ed
--- /dev/null
+++ b/locales/sv.yml
@@ -0,0 +1,76 @@
+# NOTE: Some translation keys make use of matches from regular expressions
+# to manipulate whitespace and order. Please consult the source code for
+# Stringex::Localization::ConversionExpressions to see what those
+# regular expressions look like if you need to manipulate the order
+# differently than the usage below.
+sv:
+ stringex:
+ characters:
+ and: och
+ at: snabel-a
+ divide: delat med
+ degrees: grader
+ dot: \1 punkt \2
+ ellipsis: punkt punkt punkt
+ equals: lika med
+ number: nummer
+ percent: procent
+ plus: plus
+ slash: slash
+ star: stjärna
+ currencies:
+ generic: \1 kronor
+ dollars: \1 dollar
+ dollars_cents: \1 dollar \2 cent
+ pounds: \1 pund
+ pounds_pence: \1 pund \2 pence
+ euros: \1 euro
+ euros_cents: \1 euro \2 cent
+ yen: \1 yen
+ reais: \1 reais
+ reais_cents: \1 reais \2 cent
+ html_entities:
+ amp: och
+ cent: " cents"
+ copy: (c)
+ deg: " grader "
+ divide: " delat med "
+ double_quote: '"'
+ ellipsis: "..."
+ en_dash: "-"
+ em_dash: "--"
+ frac14: en fjärdedel
+ frac12: halv
+ frac34: tre fjärdedelar
+ gt: ">"
+ lt: <
+ nbsp: " "
+ pound: " pund "
+ reg: (r)
+ single_quote: "'"
+ times: x
+ trade: (tm)
+ yen: " yen "
+ vulgar_fractions:
+ half: halv
+ one_third: en tredjedel
+ two_thirds: två tredjedelar
+ one_fourth: en fjärdedel
+ three_fourths: tre fjärdedelar
+ one_fifth: en femtedel
+ two_fifths: två femtedelar
+ three_fifths: tre femtedelar
+ four_fifths: fyra femtedelar
+ one_sixth: en sjättedel
+ five_sixths: fem sjättedelar
+ one_eighth: en åttondel
+ three_eighths: tre åttondelar
+ five_eighths: fem åttondelar
+ seven_eighths: sju åttondelar
+ transliterations:
+ Å: A
+ Ä: AE
+ Ö: OE
+ å: a
+ ä: ae
+ ö: oe
\ No newline at end of file
diff --git a/metadata.yml b/metadata.yml
index dbc8195..71a52ce 100644
--- a/metadata.yml
+++ b/metadata.yml
@@ -1,113 +1,43 @@
--- !ruby/object:Gem::Specification
name: stringex
version: !ruby/object:Gem::Version
- version: 2.2.0
+ version: 2.5.2
platform: ruby
authors:
- Russell Norris
autorequire:
bindir: bin
cert_chain: []
-date: 2014-02-03 00:00:00.000000000 Z
+date: 2014-04-09 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
- name: activerecord
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - '='
- - !ruby/object:Gem::Version
- version: 3.2.13
- type: :development
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - '='
- - !ruby/object:Gem::Version
- version: 3.2.13
-- !ruby/object:Gem::Dependency
- name: dm-core
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - '='
- - !ruby/object:Gem::Version
- version: 1.2.0
- type: :development
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - '='
- - !ruby/object:Gem::Version
- version: 1.2.0
-- !ruby/object:Gem::Dependency
- name: dm-migrations
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - '='
- - !ruby/object:Gem::Version
- version: 1.2.0
- type: :development
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - '='
- - !ruby/object:Gem::Version
- version: 1.2.0
-- !ruby/object:Gem::Dependency
- name: dm-sqlite-adapter
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - '='
- - !ruby/object:Gem::Version
- version: 1.2.0
- type: :development
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - '='
- - !ruby/object:Gem::Version
- version: 1.2.0
-- !ruby/object:Gem::Dependency
- name: dm-validations
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - '='
- - !ruby/object:Gem::Version
- version: 1.2.0
- type: :development
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - '='
- - !ruby/object:Gem::Version
- version: 1.2.0
-- !ruby/object:Gem::Dependency
name: jeweler
requirement: !ruby/object:Gem::Requirement
requirements:
- - '='
- !ruby/object:Gem::Version
- version: 1.8.4
+ version: 2.0.1
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - '='
- !ruby/object:Gem::Version
- version: 1.8.4
+ version: 2.0.1
- !ruby/object:Gem::Dependency
- name: mongoid
+ name: travis-lint
requirement: !ruby/object:Gem::Requirement
requirements:
- - '='
- !ruby/object:Gem::Version
- version: 3.1.4
+ version: 1.7.0
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - '='
- !ruby/object:Gem::Version
- version: 3.1.4
+ version: 1.7.0
- !ruby/object:Gem::Dependency
name: RedCloth
requirement: !ruby/object:Gem::Requirement
@@ -123,48 +53,48 @@ dependencies:
- !ruby/object:Gem::Version
version: 4.2.9
- !ruby/object:Gem::Dependency
- name: travis-lint
+ name: sqlite3
requirement: !ruby/object:Gem::Requirement
requirements:
- - '='
- !ruby/object:Gem::Version
- version: 1.7.0
+ version: 1.3.7
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - '='
- !ruby/object:Gem::Version
- version: 1.7.0
+ version: 1.3.7
- !ruby/object:Gem::Dependency
- name: i18n
+ name: activerecord
requirement: !ruby/object:Gem::Requirement
requirements:
- - '='
- !ruby/object:Gem::Version
- version: 0.6.1
+ version: 4.0.3
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - '='
- !ruby/object:Gem::Version
- version: 0.6.1
+ version: 4.0.3
- !ruby/object:Gem::Dependency
- name: sqlite3
+ name: i18n
requirement: !ruby/object:Gem::Requirement
requirements:
- - '='
- !ruby/object:Gem::Version
- version: 1.3.7
+ version: 0.6.9
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - '='
- !ruby/object:Gem::Version
- version: 1.3.7
-description: ! 'Some [hopefully] useful extensions to Ruby''s String class. Stringex
+ version: 0.6.9
+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].'
@@ -390,13 +320,15 @@ files:
- locales/de.yml
- locales/en.yml
- locales/nl.yml
+- locales/pl.yml
- locales/pt-BR.yml
- locales/ru.yml
+- locales/sv.yml
- stringex.gemspec
- test/performance/localization_performance_test.rb
- test/test_helper.rb
-- test/unit/acts_as_url/adapter/active_record.rb
-- test/unit/acts_as_url/adapter/data_mapper.rb
+- test/unit/acts_as_url/adapter/activerecord.rb
+- test/unit/acts_as_url/adapter/datamapper.rb
- test/unit/acts_as_url/adapter/mongoid.rb
- test/unit/acts_as_url_configuration_test.rb
- test/unit/acts_as_url_integration_test.rb
@@ -405,8 +337,10 @@ files:
- test/unit/localization/default_test.rb
- test/unit/localization/en_test.rb
- test/unit/localization/nl_test.rb
+- test/unit/localization/pl_test.rb
- test/unit/localization/pt_br_test.rb
- test/unit/localization/ru_test.rb
+- test/unit/localization/sv_test.rb
- test/unit/localization_18n_failure_test.rb
- test/unit/localization_test.rb
- test/unit/string_extensions_configuration_test.rb
@@ -424,26 +358,26 @@ licenses:
metadata: {}
post_install_message:
rdoc_options:
-- --main
+- "--main"
- README.rdoc
-- --charset
+- "--charset"
- utf-8
-- --line-numbers
+- "--line-numbers"
require_paths:
- lib
required_ruby_version: !ruby/object:Gem::Requirement
requirements:
- - - ! '>='
+ - - ">="
- !ruby/object:Gem::Version
version: '0'
required_rubygems_version: !ruby/object:Gem::Requirement
requirements:
- - - ! '>='
+ - - ">="
- !ruby/object:Gem::Version
version: '0'
requirements: []
rubyforge_project:
-rubygems_version: 2.0.3
+rubygems_version: 2.2.2
signing_key:
specification_version: 4
summary: Some [hopefully] useful extensions to Ruby's String class
diff --git a/stringex.gemspec b/stringex.gemspec
index b854c71..6f59345 100644
--- a/stringex.gemspec
+++ b/stringex.gemspec
@@ -2,14 +2,16 @@
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
+# stub: stringex 2.5.2 ruby lib
Gem::Specification.new do |s|
s.name = "stringex"
- s.version = "2.2.0"
+ s.version = "2.5.2"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.require_paths = ["lib"]
s.authors = ["Russell Norris"]
- s.date = "2014-02-03"
+ s.date = "2014-04-09"
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]."
s.email = "rsl at luckysneaks.com"
s.extra_rdoc_files = [
@@ -232,13 +234,15 @@ Gem::Specification.new do |s|
"locales/de.yml",
"locales/en.yml",
"locales/nl.yml",
+ "locales/pl.yml",
"locales/pt-BR.yml",
"locales/ru.yml",
+ "locales/sv.yml",
"stringex.gemspec",
"test/performance/localization_performance_test.rb",
"test/test_helper.rb",
- "test/unit/acts_as_url/adapter/active_record.rb",
- "test/unit/acts_as_url/adapter/data_mapper.rb",
+ "test/unit/acts_as_url/adapter/activerecord.rb",
+ "test/unit/acts_as_url/adapter/datamapper.rb",
"test/unit/acts_as_url/adapter/mongoid.rb",
"test/unit/acts_as_url_configuration_test.rb",
"test/unit/acts_as_url_integration_test.rb",
@@ -247,8 +251,10 @@ Gem::Specification.new do |s|
"test/unit/localization/default_test.rb",
"test/unit/localization/en_test.rb",
"test/unit/localization/nl_test.rb",
+ "test/unit/localization/pl_test.rb",
"test/unit/localization/pt_br_test.rb",
"test/unit/localization/ru_test.rb",
+ "test/unit/localization/sv_test.rb",
"test/unit/localization_18n_failure_test.rb",
"test/unit/localization_test.rb",
"test/unit/string_extensions_configuration_test.rb",
@@ -264,50 +270,34 @@ Gem::Specification.new do |s|
s.homepage = "http://github.com/rsl/stringex"
s.licenses = ["MIT"]
s.rdoc_options = ["--main", "README.rdoc", "--charset", "utf-8", "--line-numbers"]
- s.require_paths = ["lib"]
- s.rubygems_version = "2.0.3"
+ s.rubygems_version = "2.2.2"
s.summary = "Some [hopefully] useful extensions to Ruby's String class"
if s.respond_to? :specification_version then
s.specification_version = 4
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- s.add_development_dependency(%q<activerecord>, ["= 3.2.13"])
- s.add_development_dependency(%q<dm-core>, ["= 1.2.0"])
- s.add_development_dependency(%q<dm-migrations>, ["= 1.2.0"])
- s.add_development_dependency(%q<dm-sqlite-adapter>, ["= 1.2.0"])
- s.add_development_dependency(%q<dm-validations>, ["= 1.2.0"])
- s.add_development_dependency(%q<jeweler>, ["= 1.8.4"])
- s.add_development_dependency(%q<mongoid>, ["= 3.1.4"])
- s.add_development_dependency(%q<RedCloth>, ["= 4.2.9"])
+ s.add_development_dependency(%q<jeweler>, ["= 2.0.1"])
s.add_development_dependency(%q<travis-lint>, ["= 1.7.0"])
- s.add_development_dependency(%q<i18n>, ["= 0.6.1"])
+ s.add_development_dependency(%q<RedCloth>, ["= 4.2.9"])
s.add_development_dependency(%q<sqlite3>, ["= 1.3.7"])
+ s.add_development_dependency(%q<activerecord>, ["= 4.0.3"])
+ s.add_development_dependency(%q<i18n>, ["= 0.6.9"])
else
- s.add_dependency(%q<activerecord>, ["= 3.2.13"])
- s.add_dependency(%q<dm-core>, ["= 1.2.0"])
- s.add_dependency(%q<dm-migrations>, ["= 1.2.0"])
- s.add_dependency(%q<dm-sqlite-adapter>, ["= 1.2.0"])
- s.add_dependency(%q<dm-validations>, ["= 1.2.0"])
- s.add_dependency(%q<jeweler>, ["= 1.8.4"])
- s.add_dependency(%q<mongoid>, ["= 3.1.4"])
- s.add_dependency(%q<RedCloth>, ["= 4.2.9"])
+ s.add_dependency(%q<jeweler>, ["= 2.0.1"])
s.add_dependency(%q<travis-lint>, ["= 1.7.0"])
- s.add_dependency(%q<i18n>, ["= 0.6.1"])
+ s.add_dependency(%q<RedCloth>, ["= 4.2.9"])
s.add_dependency(%q<sqlite3>, ["= 1.3.7"])
+ s.add_dependency(%q<activerecord>, ["= 4.0.3"])
+ s.add_dependency(%q<i18n>, ["= 0.6.9"])
end
else
- s.add_dependency(%q<activerecord>, ["= 3.2.13"])
- s.add_dependency(%q<dm-core>, ["= 1.2.0"])
- s.add_dependency(%q<dm-migrations>, ["= 1.2.0"])
- s.add_dependency(%q<dm-sqlite-adapter>, ["= 1.2.0"])
- s.add_dependency(%q<dm-validations>, ["= 1.2.0"])
- s.add_dependency(%q<jeweler>, ["= 1.8.4"])
- s.add_dependency(%q<mongoid>, ["= 3.1.4"])
- s.add_dependency(%q<RedCloth>, ["= 4.2.9"])
+ s.add_dependency(%q<jeweler>, ["= 2.0.1"])
s.add_dependency(%q<travis-lint>, ["= 1.7.0"])
- s.add_dependency(%q<i18n>, ["= 0.6.1"])
+ s.add_dependency(%q<RedCloth>, ["= 4.2.9"])
s.add_dependency(%q<sqlite3>, ["= 1.3.7"])
+ s.add_dependency(%q<activerecord>, ["= 4.0.3"])
+ s.add_dependency(%q<i18n>, ["= 0.6.9"])
end
end
diff --git a/test/unit/acts_as_url/adapter/active_record.rb b/test/unit/acts_as_url/adapter/activerecord.rb
similarity index 98%
rename from test/unit/acts_as_url/adapter/active_record.rb
rename to test/unit/acts_as_url/adapter/activerecord.rb
index bc9664c..8e9b527 100644
--- a/test/unit/acts_as_url/adapter/active_record.rb
+++ b/test/unit/acts_as_url/adapter/activerecord.rb
@@ -1,4 +1,3 @@
-require 'rubygems'
gem 'activerecord'
require 'active_record'
require "stringex"
diff --git a/test/unit/acts_as_url/adapter/data_mapper.rb b/test/unit/acts_as_url/adapter/datamapper.rb
similarity index 99%
rename from test/unit/acts_as_url/adapter/data_mapper.rb
rename to test/unit/acts_as_url/adapter/datamapper.rb
index c2f4a8d..260e802 100644
--- a/test/unit/acts_as_url/adapter/data_mapper.rb
+++ b/test/unit/acts_as_url/adapter/datamapper.rb
@@ -1,4 +1,3 @@
-require 'rubygems'
gem 'dm-core'
gem 'dm-migrations'
gem 'dm-validations'
diff --git a/test/unit/acts_as_url/adapter/mongoid.rb b/test/unit/acts_as_url/adapter/mongoid.rb
index 33e3031..f003428 100644
--- a/test/unit/acts_as_url/adapter/mongoid.rb
+++ b/test/unit/acts_as_url/adapter/mongoid.rb
@@ -1,4 +1,3 @@
-require 'rubygems'
gem 'mongoid'
require 'mongoid'
require 'stringex'
@@ -23,6 +22,14 @@ class Document
acts_as_url :title
end
+begin
+ # Let's make sure we can connect to mongodb before we run our tests!
+ Mongoid::Sessions.default.databases
+rescue Moped::Errors::ConnectionFailure => err
+ puts 'Cannot connect to mongodb. Aborting.'
+ exit
+end
+
class STIBaseDocument
include Mongoid::Document
field :title, :type => String
diff --git a/test/unit/acts_as_url_integration_test.rb b/test/unit/acts_as_url_integration_test.rb
index 0780053..08f6909 100644
--- a/test/unit/acts_as_url_integration_test.rb
+++ b/test/unit/acts_as_url_integration_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-adapter = ENV['ADAPTER'] || 'active_record'
+adapter = ENV['ADAPTER'] || 'activerecord'
require File.join(File.expand_path(File.dirname(__FILE__)), "acts_as_url/adapter/#{adapter}.rb")
class ActsAsUrlIntegrationTest < Test::Unit::TestCase
@@ -20,6 +20,38 @@ class ActsAsUrlIntegrationTest < Test::Unit::TestCase
assert_equal "unique-1", @other_doc.url
end
+ def test_should_avoid_blacklist
+ @doc = Document.create(:title => "New")
+ @other_doc = Document.create(:title => "new")
+ assert_equal "new-document", @doc.url
+ assert_equal "new-document-1", @other_doc.url
+ end
+
+ def test_should_allow_customizing_blacklist
+ Document.class_eval do
+ # Un-blacklisting 'new' isn't advisable
+ acts_as_url :title, :blacklist => %w{special}
+ end
+
+ @doc = Document.create(:title => "New")
+ @other_doc = Document.create(:title => "Special")
+ assert_equal 'new', @doc.url
+ assert_equal 'special-document', @other_doc.url
+ end
+
+ def test_should_allow_customizing_blacklist_policy
+ Document.class_eval do
+ acts_as_url :title, :blacklist_policy => Proc.new(){|instance, url|
+ "#{url}-customized"
+ }
+ end
+
+ @doc = Document.create(:title => "New")
+ @other_doc = Document.create(:title => "New")
+ assert_equal 'new-customized', @doc.url
+ assert_equal 'new-customized-1', @other_doc.url
+ end
+
def test_should_create_unique_url_when_partial_url_already_exists
@doc = Document.create(:title => "House Farms")
@other_doc = Document.create(:title => "House Farm")
diff --git a/test/unit/localization/da_test.rb b/test/unit/localization/da_test.rb
index f36f866..e5e1c83 100644
--- a/test/unit/localization/da_test.rb
+++ b/test/unit/localization/da_test.rb
@@ -24,8 +24,8 @@ class DanishYAMLLocalizationTest < Test::Unit::TestCase
"100%" => "100 procent",
"cost+tax" => "cost plus tax",
"batman/robin fan fiction" => "batman skråstreg robin fan fiction",
- "dial *69" => "dial stjerne 69"
- # " i leave whitespace on ends unchanged " => " i leave whitespace on ends unchanged "
+ "dial *69" => "dial stjerne 69",
+ " i leave whitespace on ends unchanged " => " i leave whitespace on ends unchanged "
}.each do |original, converted|
define_method "test_character_conversion: '#{original}'" do
assert_equal converted, original.convert_miscellaneous_characters
diff --git a/test/unit/localization/pl_test.rb b/test/unit/localization/pl_test.rb
new file mode 100644
index 0000000..6e42996
--- /dev/null
+++ b/test/unit/localization/pl_test.rb
@@ -0,0 +1,118 @@
+# encoding: UTF-8
+
+require 'test_helper'
+require 'i18n'
+require 'stringex'
+
+class PolishYAMLLocalizationTest < Test::Unit::TestCase
+ def setup
+ Stringex::Localization.reset!
+ Stringex::Localization.backend = :i18n
+ Stringex::Localization.backend.load_translations :pl
+ Stringex::Localization.locale = :pl
+ end
+
+ {
+ "foo & bar" => "foo i bar",
+ "AT&T" => "AT i T",
+ "99° is normal" => "99 stopni is normal",
+ "4 ÷ 2 is 2" => "4 podzielone przez 2 is 2",
+ "webcrawler.com" => "webcrawler kropka com",
+ "Well..." => "Well kropka kropka kropka",
+ "x=1" => "x równy 1",
+ "a #2 pencil" => "a numer 2 pencil",
+ "100%" => "100 procent",
+ "cost+tax" => "cost plus tax",
+ "batman/robin fan fiction" => "batman ukośnik robin fan fiction",
+ "dial *69" => "dial gwiazdka 69",
+ " i leave whitespace on ends unchanged " => " i leave whitespace on ends unchanged "
+ }.each do |original, converted|
+ define_method "test_character_conversion: '#{original}'" do
+ assert_equal converted, original.convert_miscellaneous_characters
+ end
+ end
+
+ {
+ "¤20" => "20 złotych",
+ "$100" => "100 dolarów",
+ "$19.99" => "19 dolarów 99 centów",
+ "£100" => "100 funtów",
+ "£19.99" => "19 funtów 99 pensów",
+ "€100" => "100 euro",
+ "€19.99" => "19 euro 99 centów",
+ "¥1000" => "1000 jenów"
+ }.each do |original, converted|
+ define_method "test_currency_conversion: '#{original}'" do
+ assert_equal converted, original.convert_miscellaneous_characters
+ end
+ end
+
+ {
+ "Tea & Sympathy" => "Tea i Sympathy",
+ "10¢" => "10 centów",
+ "©2000" => "(c)2000",
+ "98° is fine" => "98 stopni is fine",
+ "10÷5" => "10 podzielone przez 5",
+ ""quoted"" => '"quoted"',
+ "to be continued…" => "to be continued...",
+ "2000–2004" => "2000-2004",
+ "I wish—oh, never mind" => "I wish--oh, never mind",
+ "½ ounce of gold" => "pół ounce of gold",
+ "1 and ¼ ounces of silver" => "1 and jedna czwarta ounces of silver",
+ "9 and ¾ ounces of platinum" => "9 and trzy czwarte ounces of platinum",
+ "3>2" => "3>2",
+ "2<3" => "2<3",
+ "two words" => "two words",
+ "£100" => "funtów 100",
+ "Walmart®" => "Walmart(r)",
+ "'single quoted'" => "'single quoted'",
+ "2×4" => "2x4",
+ "Programming™" => "Programming(TM)",
+ "¥20000" => "jen 20000",
+ " i leave whitespace on ends unchanged " => " i leave whitespace on ends unchanged "
+ }.each do |original, converted|
+ define_method "test_html_entity_conversion: '#{original}'" do
+ assert_equal converted, original.convert_miscellaneous_html_entities
+ end
+ end
+
+ {
+ "½" => "pół",
+ "½" => "pół",
+ "½" => "pół",
+ "⅓" => "jedna trzecia",
+ "⅓" => "jedna trzecia",
+ "⅔" => "dwie trzecie",
+ "⅔" => "dwie trzecie",
+ "¼" => "jedna czwarta",
+ "¼" => "jedna czwarta",
+ "¼" => "jedna czwarta",
+ "¾" => "trzy czwarte",
+ "¾" => "trzy czwarte",
+ "¾" => "trzy czwarte",
+ "⅕" => "jedna piąta",
+ "⅕" => "jedna piąta",
+ "⅖" => "dwie piąte",
+ "⅖" => "dwie piąte",
+ "⅗" => "trzy piąte",
+ "⅗" => "trzy piąte",
+ "⅘" => "cztery piąte",
+ "⅘" => "cztery piąte",
+ "⅙" => "jedna szósta",
+ "⅙" => "jedna szósta",
+ "⅚" => "pięć szóstych",
+ "⅚" => "pięć szóstych",
+ "⅛" => "jedna ósma",
+ "⅛" => "jedna ósma",
+ "⅜" => "trzy ósme",
+ "⅜" => "trzy ósme",
+ "⅝" => "pięć ósmych",
+ "⅝" => "pięć ósmych",
+ "⅞" => "siedem ósmych",
+ "⅞" => "siedem ósmych"
+ }.each do |original, converted|
+ define_method "test_vulgar_fractions_conversion: #{original}" do
+ assert_equal converted, original.convert_vulgar_fractions
+ end
+ end
+end
diff --git a/test/unit/localization/ru_test.rb b/test/unit/localization/ru_test.rb
index 8e145e5..8c1fa99 100644
--- a/test/unit/localization/ru_test.rb
+++ b/test/unit/localization/ru_test.rb
@@ -123,7 +123,7 @@ class RussianYAMLLocalizationTest < Test::Unit::TestCase
"4 ÷ 2 is 2" => "4-dielit-na-2-is-2",
"webcrawler.com" => "webcrawler-tochka-com",
}.each do |original, converted|
- define_method "test_character_conversion: '#{original}'" do
+ define_method "test_character_conversion_to_url: '#{original}'" do
assert_equal converted, original.to_url
end
end
diff --git a/test/unit/localization/da_test.rb b/test/unit/localization/sv_test.rb
similarity index 54%
copy from test/unit/localization/da_test.rb
copy to test/unit/localization/sv_test.rb
index f36f866..db899e7 100644
--- a/test/unit/localization/da_test.rb
+++ b/test/unit/localization/sv_test.rb
@@ -4,28 +4,28 @@ require 'test_helper'
require 'i18n'
require 'stringex'
-class DanishYAMLLocalizationTest < Test::Unit::TestCase
+class SwedishYAMLLocalizationTest < Test::Unit::TestCase
def setup
Stringex::Localization.reset!
Stringex::Localization.backend = :i18n
- Stringex::Localization.backend.load_translations :da
- Stringex::Localization.locale = :da
+ Stringex::Localization.backend.load_translations :sv
+ Stringex::Localization.locale = :sv
end
{
- "foo & bar" => "foo og bar",
- "AT&T" => "AT og T",
+ "foo & bar" => "foo och bar",
+ "AT&T" => "AT och T",
"99° is normal" => "99 grader is normal",
- "4 ÷ 2 is 2" => "4 divideret med 2 is 2",
- "webcrawler.com" => "webcrawler punktum com",
- "Well..." => "Well prik prik prik",
- "x=1" => "x lig med 1",
+ "4 ÷ 2 is 2" => "4 delat med 2 is 2",
+ "webcrawler.com" => "webcrawler punkt com",
+ "Well..." => "Well punkt punkt punkt",
+ "x=1" => "x lika med 1",
"a #2 pencil" => "a nummer 2 pencil",
"100%" => "100 procent",
"cost+tax" => "cost plus tax",
- "batman/robin fan fiction" => "batman skråstreg robin fan fiction",
- "dial *69" => "dial stjerne 69"
- # " i leave whitespace on ends unchanged " => " i leave whitespace on ends unchanged "
+ "batman/robin fan fiction" => "batman slash robin fan fiction",
+ "dial *69" => "dial stjärna 69",
+ " i leave whitespace on ends unchanged " => " i leave whitespace on ends unchanged "
}.each do |original, converted|
define_method "test_character_conversion: '#{original}'" do
assert_equal converted, original.convert_miscellaneous_characters
@@ -33,9 +33,9 @@ class DanishYAMLLocalizationTest < Test::Unit::TestCase
end
{
- "¤20" => "20 kroner",
- "$100" => "100 dollars",
- "$19.99" => "19 dollars 99 cents",
+ "¤20" => "20 kronor",
+ "$100" => "100 dollar",
+ "$19.99" => "19 dollar 99 cent",
"£100" => "100 pund",
"£19.99" => "19 pund 99 pence",
"€100" => "100 euro",
@@ -48,18 +48,18 @@ class DanishYAMLLocalizationTest < Test::Unit::TestCase
end
{
- "Tea & Sympathy" => "Tea og Sympathy",
+ "Tea & Sympathy" => "Tea och Sympathy",
"10¢" => "10 cents",
"©2000" => "(c)2000",
"98° is fine" => "98 grader is fine",
- "10÷5" => "10 divideret med 5",
+ "10÷5" => "10 delat med 5",
""quoted"" => '"quoted"',
"to be continued…" => "to be continued...",
"2000–2004" => "2000-2004",
"I wish—oh, never mind" => "I wish--oh, never mind",
"½ ounce of gold" => "halv ounce of gold",
- "1 and ¼ ounces of silver" => "1 and en fjerdedel ounces of silver",
- "9 and ¾ ounces of platinum" => "9 and tre fjerdedele ounces of platinum",
+ "1 and ¼ ounces of silver" => "1 and en fjärdedel ounces of silver",
+ "9 and ¾ ounces of platinum" => "9 and tre fjärdedelar ounces of platinum",
"3>2" => "3>2",
"2<3" => "2<3",
"two words" => "two words",
@@ -82,34 +82,34 @@ class DanishYAMLLocalizationTest < Test::Unit::TestCase
"½" => "halv",
"⅓" => "en tredjedel",
"⅓" => "en tredjedel",
- "⅔" => "to tredjedele",
- "⅔" => "to tredjedele",
- "¼" => "en fjerdedel",
- "¼" => "en fjerdedel",
- "¼" => "en fjerdedel",
- "¾" => "tre fjerdedele",
- "¾" => "tre fjerdedele",
- "¾" => "tre fjerdedele",
+ "⅔" => "två tredjedelar",
+ "⅔" => "två tredjedelar",
+ "¼" => "en fjärdedel",
+ "¼" => "en fjärdedel",
+ "¼" => "en fjärdedel",
+ "¾" => "tre fjärdedelar",
+ "¾" => "tre fjärdedelar",
+ "¾" => "tre fjärdedelar",
"⅕" => "en femtedel",
"⅕" => "en femtedel",
- "⅖" => "to femtedele",
- "⅖" => "to femtedele",
- "⅗" => "tre femtedele",
- "⅗" => "tre femtedele",
- "⅘" => "fire femtedele",
- "⅘" => "fire femtedele",
- "⅙" => "en sjettedel",
- "⅙" => "en sjettedel",
- "⅚" => "fem sjettedele",
- "⅚" => "fem sjettedele",
- "⅛" => "en ottendedel",
- "⅛" => "en ottendedel",
- "⅜" => "tre ottendedele",
- "⅜" => "tre ottendedele",
- "⅝" => "fem ottendedele",
- "⅝" => "fem ottendedele",
- "⅞" => "syv ottendedele",
- "⅞" => "syv ottendedele"
+ "⅖" => "två femtedelar",
+ "⅖" => "två femtedelar",
+ "⅗" => "tre femtedelar",
+ "⅗" => "tre femtedelar",
+ "⅘" => "fyra femtedelar",
+ "⅘" => "fyra femtedelar",
+ "⅙" => "en sjättedel",
+ "⅙" => "en sjättedel",
+ "⅚" => "fem sjättedelar",
+ "⅚" => "fem sjättedelar",
+ "⅛" => "en åttondel",
+ "⅛" => "en åttondel",
+ "⅜" => "tre åttondelar",
+ "⅜" => "tre åttondelar",
+ "⅝" => "fem åttondelar",
+ "⅝" => "fem åttondelar",
+ "⅞" => "sju åttondelar",
+ "⅞" => "sju åttondelar"
}.each do |original, converted|
define_method "test_vulgar_fractions_conversion: #{original}" do
assert_equal converted, original.convert_vulgar_fractions
diff --git a/test/unit/localization_test.rb b/test/unit/localization_test.rb
index 92b8a14..289ed1a 100644
--- a/test/unit/localization_test.rb
+++ b/test/unit/localization_test.rb
@@ -123,20 +123,37 @@ class LocalizationTest < Test::Unit::TestCase
end
def test_assigns_locale_in_i18n_backend
- I18n.locale = :en
- Stringex::Localization.backend = :i18n
+ if other_locale = I18n.available_locales.find{|locale| ![:en, :de].include?(locale)}
+ I18n.locale = :en
+ Stringex::Localization.backend = :i18n
+
+ assert_equal :en, Stringex::Localization.locale
- assert_equal :en, Stringex::Localization.locale
+ I18n.locale = other_locale
+ assert_equal other_locale, Stringex::Localization.locale
- I18n.locale = :jp
- assert_equal :jp, Stringex::Localization.locale
+ Stringex::Localization.locale = :de
+ assert_equal :de, Stringex::Localization.locale
+ assert_equal other_locale, I18n.locale
- Stringex::Localization.locale = :de
- assert_equal :de, Stringex::Localization.locale
- assert_equal :jp, I18n.locale
+ Stringex::Localization.locale = nil
+ assert_equal other_locale, Stringex::Localization.locale
+ assert_equal other_locale, I18n.locale
+ else
+ flunk "No I18n locales are available except :de and :en so test will not work"
+ end
+ end
- Stringex::Localization.locale = nil
- assert_equal :jp, Stringex::Localization.locale
- assert_equal :jp, I18n.locale
+ def test_defaults_enforce_available_locales_to_true
+ Stringex::Localization.backend = :i18n
+ 'Some String'.to_url
+ assert_equal true, I18n.enforce_available_locales
+ end
+
+ def test_respects_user_enforce_available_locales_setting
+ Stringex::Localization.backend = :i18n
+ I18n.enforce_available_locales = false
+ 'Some String'.to_url
+ assert_equal false, I18n.enforce_available_locales
end
end
diff --git a/test/unit/unicode_point_suite/basic_latin_test.rb b/test/unit/unicode_point_suite/basic_latin_test.rb
index 93e45aa..a2d636e 100644
--- a/test/unit/unicode_point_suite/basic_latin_test.rb
+++ b/test/unit/unicode_point_suite/basic_latin_test.rb
@@ -108,7 +108,9 @@ class BasicLatinTest < Test::Unit::TestCase
end
def test_grave_accents
- assert_equal_encoded "'", %w{0060 02cb 2035}
+ assert_equal_encoded "'", %w{02cb 2035}
+ # Ascii grave accent should remain as ascii!
+ assert_equal_encoded "`", "0060"
end
def test_bars
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-stringex.git
More information about the Pkg-ruby-extras-commits
mailing list