subdomain_locale 1.0.beta → 1.0.beta2

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: faeaa8c630da1a8aaea5ec82125d459d60cc026f
4
- data.tar.gz: c2d984aaa1f3027ea35641ff757913b694c6242f
3
+ metadata.gz: 1d876d5f0c2e358943ce4c36ddfcf32540ada100
4
+ data.tar.gz: a10f6871505cada6b31b354d97622fc8935e0b8f
5
5
  SHA512:
6
- metadata.gz: 20f97bd6745d902651120fbcc8dfb2bc44b21ee7e10a9e5b939071d9a84c8457f6ddd28ccd9b1d433e4f02bfab0cb521bfd20b89d2a2e2e500bfcba684d516ef
7
- data.tar.gz: 8847cd159a0b90131bebf98ff93bfbd042b9beedfdf082ca93e912a5d0a0bbb4c895cd37e28fc8e31525e4ac40b5f6854ee41cd9b1430ffd37050fc31191c799
6
+ metadata.gz: 58f34c367ab4da79d17af2146b902af133eda0724701216dad5cb62d077d51d333b177b1a13754a844ccd26ea859e09a9b9b9219d987323ad0577fc532deb435
7
+ data.tar.gz: 0987bcc9054604098dd5e15590679508f6b098bf6e41baac7d34004fadec25193e09a6846c5dac6dccaf35831b31298265d12188753a3b966f61229cc2249ce8
data/Isolate CHANGED
@@ -1,6 +1,7 @@
1
1
  options system: false, cleanup: false
2
2
 
3
3
  gem 'bundler', '~> 1.5.0'
4
+ gem 'i18n', '~> 0.6.9'
4
5
 
5
6
  case ENV['RAILS']
6
7
  when '3'
@@ -8,13 +9,11 @@ when '3'
8
9
  gem 'actionpack', version
9
10
  gem 'actionmailer', version
10
11
  gem 'railties', version
11
- gem 'i18n', '0.6.5'
12
12
  when nil
13
13
  version = '~> 4.0.0'
14
14
  gem 'actionpack', version
15
15
  gem 'actionmailer', version
16
16
  gem 'railties', version
17
- gem 'i18n', '~> 0.6.9'
18
17
  else
19
18
  raise "Unrecognized Rails version: #{ENV['RAILS']}"
20
19
  end
@@ -16,7 +16,7 @@ module SubdomainLocale
16
16
  end
17
17
 
18
18
  def subdomain_for(locale)
19
- locale and @repository.invert[locale.to_s] || locale.to_s
19
+ locale and @repository.invert.fetch(locale.to_s, locale.to_s).presence
20
20
  end
21
21
  end
22
22
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "subdomain_locale"
5
- spec.version = "1.0.beta"
5
+ spec.version = "1.0.beta2"
6
6
  spec.authors = ["Semyon Perepelitsa"]
7
7
  spec.email = ["sema@sema.in"]
8
8
  spec.summary = "Set I18n locale based on subdomain"
@@ -12,5 +12,5 @@ Gem::Specification.new do |spec|
12
12
  spec.files = File.read("Manifest.txt").split("\n")
13
13
  spec.test_files = spec.files.grep(%r{^test/})
14
14
 
15
- spec.add_dependency "i18n", "~> 0.2"
15
+ spec.add_dependency "i18n", "~> 0.6.9"
16
16
  end
data/test/mapping_test.rb CHANGED
@@ -1,12 +1,13 @@
1
1
  require "isolate/now"
2
2
  require "minitest/autorun"
3
3
  require "subdomain_locale/mapping"
4
+ require "active_support/core_ext"
4
5
 
5
6
  class MappingTest < MiniTest::Unit::TestCase
6
7
  include SubdomainLocale
7
8
 
8
9
  def setup
9
- @mapping = Mapping.new("ua" => :uk)
10
+ @mapping = Mapping.new("ua" => :uk, "" => :en)
10
11
  end
11
12
 
12
13
  def test_custom
@@ -19,6 +20,14 @@ class MappingTest < MiniTest::Unit::TestCase
19
20
  assert_equal "ru", @mapping.subdomain_for(:ru)
20
21
  end
21
22
 
23
+ def test_no_subdomain
24
+ # request.subdomain returns "" for test.host
25
+ assert_equal "en", @mapping.locale_for("")
26
+
27
+ # "" results in .test.host, nil produces correct test.host
28
+ assert_equal nil, @mapping.subdomain_for(:en)
29
+ end
30
+
22
31
  def test_nil
23
32
  assert_nil @mapping.subdomain_for(nil)
24
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: subdomain_locale
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.beta
4
+ version: 1.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Semyon Perepelitsa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-17 00:00:00.000000000 Z
11
+ date: 2014-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.2'
19
+ version: 0.6.9
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.2'
26
+ version: 0.6.9
27
27
  description:
28
28
  email:
29
29
  - sema@sema.in