knjrbfw 0.0.85 → 0.0.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/knjrbfw.gemspec +3 -2
- data/lib/knj/locales.rb +13 -2
- data/spec/locales_spec.rb +9 -0
- metadata +4 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.86
|
data/knjrbfw.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{knjrbfw}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.86"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kasper Johansen"]
|
12
|
-
s.date = %q{2012-08-
|
12
|
+
s.date = %q{2012-08-17}
|
13
13
|
s.description = %q{Including stuff for HTTP, SSH and much more.}
|
14
14
|
s.email = %q{k@spernj.org}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -257,6 +257,7 @@ Gem::Specification.new do |s|
|
|
257
257
|
"spec/db_spec.rb",
|
258
258
|
"spec/db_spec_encoding_test_file.txt",
|
259
259
|
"spec/knjrbfw_spec.rb",
|
260
|
+
"spec/locales_spec.rb",
|
260
261
|
"spec/objects_spec.rb",
|
261
262
|
"spec/process_meta_spec.rb",
|
262
263
|
"spec/process_spec.rb",
|
data/lib/knj/locales.rb
CHANGED
@@ -1,11 +1,20 @@
|
|
1
1
|
#This module can be used to handel various language-stuff.
|
2
2
|
module Knj::Locales
|
3
|
+
LANG_CONVERTIONS = {
|
4
|
+
"en" => "en_GB"
|
5
|
+
}
|
6
|
+
|
3
7
|
#Returns the primary locale, secondary locale and the two put together.
|
4
8
|
#===Examples
|
5
9
|
# Knj::Locales.lang #=> {"first" => "en", "second" => "GB", "full" => "en_GB"}
|
6
10
|
def self.lang
|
7
|
-
|
8
|
-
|
11
|
+
locale_str = self.locale.to_s
|
12
|
+
|
13
|
+
#Sometimes language can be 'en'. Convert that to 'en_GB' if that is so.
|
14
|
+
locale_str = Knj::Locales::LANG_CONVERTIONS[locale_str] if Knj::Locales::LANG_CONVERTIONS.key?(locale_str)
|
15
|
+
|
16
|
+
match = locale_str.match(/^([a-z]{2})_([A-Z]{2})/)
|
17
|
+
raise "Could not understand language: '#{locale_str}'." if !match
|
9
18
|
|
10
19
|
return {
|
11
20
|
"first" => match[1],
|
@@ -51,6 +60,8 @@ module Knj::Locales
|
|
51
60
|
# Knj::Locales.number_out(123456.68) #=> "123,456.68"
|
52
61
|
def self.number_out(num_str, dec = 2)
|
53
62
|
lc = Knj::Locales.localeconv
|
63
|
+
|
64
|
+
require "php4r"
|
54
65
|
return Php4r.number_format(num_str, dec, lc["decimal_point"], lc["thousands_sep"])
|
55
66
|
end
|
56
67
|
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Locales" do
|
4
|
+
it "should do convertions of short formats" do
|
5
|
+
Thread.current[:locale] = "en"
|
6
|
+
res = Knj::Locales.lang
|
7
|
+
raise "Result wasnt as expected: '#{res}'." if res["first"] != "en" or res["second"] != "GB" or res["full"] != "en_GB"
|
8
|
+
end
|
9
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: knjrbfw
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.86
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Kasper Johansen
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-08-
|
13
|
+
date: 2012-08-17 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -373,6 +373,7 @@ files:
|
|
373
373
|
- spec/db_spec.rb
|
374
374
|
- spec/db_spec_encoding_test_file.txt
|
375
375
|
- spec/knjrbfw_spec.rb
|
376
|
+
- spec/locales_spec.rb
|
376
377
|
- spec/objects_spec.rb
|
377
378
|
- spec/process_meta_spec.rb
|
378
379
|
- spec/process_spec.rb
|
@@ -394,7 +395,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
394
395
|
requirements:
|
395
396
|
- - ">="
|
396
397
|
- !ruby/object:Gem::Version
|
397
|
-
hash:
|
398
|
+
hash: 1505749877110619661
|
398
399
|
segments:
|
399
400
|
- 0
|
400
401
|
version: "0"
|