stringex 2.5.0 → 2.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +0 -10
- data/VERSION +1 -1
- data/lib/stringex/localization/backend/i18n.rb +7 -0
- data/stringex.gemspec +4 -4
- data/test/unit/acts_as_url/adapter/activerecord.rb +0 -1
- data/test/unit/acts_as_url/adapter/datamapper.rb +0 -1
- data/test/unit/acts_as_url/adapter/mongoid.rb +0 -1
- data/test/unit/localization/ru_test.rb +1 -1
- data/test/unit/localization_test.rb +15 -11
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66b139aab9ec7f3b0f1cbec1f474f3f6307df83b
|
4
|
+
data.tar.gz: 960c862cd978bdcfce385b45f0d51df7f08bb16d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6823ed7e9f8fbd25cf3d175bece789e43f9d75b9483561511c812dcce41770ed28a8766405ec777180c7904c48593634ac67581fe09b26609c045d0687f7dd6
|
7
|
+
data.tar.gz: ae397076658784254012e5c2772634d52527f3c3d3bed869e0f807ada7bf9e3fddb93f915bfd0fab802d41a83eddc162b61098cf7e248a459ef8ba27eaf55fd8
|
data/README.rdoc
CHANGED
@@ -87,16 +87,6 @@ This library converts Unicode [and accented ASCII] characters to their plain-tex
|
|
87
87
|
|
88
88
|
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.
|
89
89
|
|
90
|
-
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:
|
91
|
-
|
92
|
-
# Using a Hash
|
93
|
-
Stringex.localize_from :en => {"é" => "ee"}
|
94
|
-
|
95
|
-
# Loading from a file. NOTE: The path to file should be absolute.
|
96
|
-
Stringex.localize_from "/path/to/yaml_file"
|
97
|
-
|
98
|
-
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.
|
99
|
-
|
100
90
|
== StringExtensions
|
101
91
|
|
102
92
|
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.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.5.
|
1
|
+
2.5.1
|
@@ -48,12 +48,19 @@ module Stringex
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def i18n_translations_for(locale)
|
51
|
+
ensure_locales_enforced_or_not
|
51
52
|
::I18n.translate("stringex", :locale => locale, :default => {})
|
52
53
|
end
|
53
54
|
|
54
55
|
def reset_translations_cache
|
55
56
|
@translations = nil
|
56
57
|
end
|
58
|
+
|
59
|
+
def ensure_locales_enforced_or_not
|
60
|
+
return unless ::I18n.respond_to?(:enforce_available_locales)
|
61
|
+
# Allow users to have set this to false manually but default to true
|
62
|
+
::I18n.enforce_available_locales ||= ::I18n.available_locales != []
|
63
|
+
end
|
57
64
|
end
|
58
65
|
end
|
59
66
|
|
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.5.
|
5
|
+
# stub: stringex 2.5.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "stringex"
|
9
|
-
s.version = "2.5.
|
9
|
+
s.version = "2.5.1"
|
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 = "2014-
|
14
|
+
s.date = "2014-04-04"
|
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 = [
|
@@ -270,7 +270,7 @@ Gem::Specification.new do |s|
|
|
270
270
|
s.homepage = "http://github.com/rsl/stringex"
|
271
271
|
s.licenses = ["MIT"]
|
272
272
|
s.rdoc_options = ["--main", "README.rdoc", "--charset", "utf-8", "--line-numbers"]
|
273
|
-
s.rubygems_version = "2.2.
|
273
|
+
s.rubygems_version = "2.2.2"
|
274
274
|
s.summary = "Some [hopefully] useful extensions to Ruby's String class"
|
275
275
|
|
276
276
|
if s.respond_to? :specification_version then
|
@@ -123,7 +123,7 @@ class RussianYAMLLocalizationTest < Test::Unit::TestCase
|
|
123
123
|
"4 ÷ 2 is 2" => "4-dielit-na-2-is-2",
|
124
124
|
"webcrawler.com" => "webcrawler-tochka-com",
|
125
125
|
}.each do |original, converted|
|
126
|
-
define_method "
|
126
|
+
define_method "test_character_conversion_to_url: '#{original}'" do
|
127
127
|
assert_equal converted, original.to_url
|
128
128
|
end
|
129
129
|
end
|
@@ -123,20 +123,24 @@ class LocalizationTest < Test::Unit::TestCase
|
|
123
123
|
end
|
124
124
|
|
125
125
|
def test_assigns_locale_in_i18n_backend
|
126
|
-
I18n.locale
|
127
|
-
|
126
|
+
if other_locale = I18n.available_locales.find{|locale| ![:en, :de].include?(locale)}
|
127
|
+
I18n.locale = :en
|
128
|
+
Stringex::Localization.backend = :i18n
|
128
129
|
|
129
|
-
|
130
|
+
assert_equal :en, Stringex::Localization.locale
|
130
131
|
|
131
|
-
|
132
|
-
|
132
|
+
I18n.locale = other_locale
|
133
|
+
assert_equal other_locale, Stringex::Localization.locale
|
133
134
|
|
134
|
-
|
135
|
-
|
136
|
-
|
135
|
+
Stringex::Localization.locale = :de
|
136
|
+
assert_equal :de, Stringex::Localization.locale
|
137
|
+
assert_equal other_locale, I18n.locale
|
137
138
|
|
138
|
-
|
139
|
-
|
140
|
-
|
139
|
+
Stringex::Localization.locale = nil
|
140
|
+
assert_equal other_locale, Stringex::Localization.locale
|
141
|
+
assert_equal other_locale, I18n.locale
|
142
|
+
else
|
143
|
+
flunk "No I18n locales are available except :de and :en so test will not work"
|
144
|
+
end
|
141
145
|
end
|
142
146
|
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.5.
|
4
|
+
version: 2.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Russell Norris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jeweler
|
@@ -377,7 +377,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
377
377
|
version: '0'
|
378
378
|
requirements: []
|
379
379
|
rubyforge_project:
|
380
|
-
rubygems_version: 2.2.
|
380
|
+
rubygems_version: 2.2.2
|
381
381
|
signing_key:
|
382
382
|
specification_version: 4
|
383
383
|
summary: Some [hopefully] useful extensions to Ruby's String class
|