localized 0.0.6 → 0.0.7
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/Gemfile.lock +1 -1
- data/lib/localized/helper.rb +5 -1
- data/localized.gemspec +1 -1
- data/spec/lib/localized/helper_spec.rb +15 -1
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/lib/localized/helper.rb
CHANGED
@@ -16,7 +16,7 @@ module Localized::Helper
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def url_for(options = nil)
|
19
|
-
if options.kind_of?(Hash)
|
19
|
+
if options.kind_of?(Hash) and not ip?(request.host)
|
20
20
|
options[:host] = with_locale(options.delete(:site))
|
21
21
|
end
|
22
22
|
super options
|
@@ -24,6 +24,10 @@ module Localized::Helper
|
|
24
24
|
|
25
25
|
protected
|
26
26
|
|
27
|
+
def ip?(hostname)
|
28
|
+
/\A[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}\Z/.match(hostname).present?
|
29
|
+
end
|
30
|
+
|
27
31
|
def with_locale(site = nil)
|
28
32
|
current_site = Localized::Config.locale_to_site_map[I18n.locale]
|
29
33
|
site = if site.blank? and current_site != Localized::Config.default_site
|
data/localized.gemspec
CHANGED
@@ -2,7 +2,7 @@ Gem::Specification.new do |s|
|
|
2
2
|
s.name = 'localized'
|
3
3
|
s.author = 'Paul Hepworth'
|
4
4
|
s.email = 'paul<dot>hepworth<at>peppyheppy<dot>com'
|
5
|
-
s.version = '0.0.
|
5
|
+
s.version = '0.0.7'
|
6
6
|
s.homepage = 'https://github.com/peppyheppy/localized'
|
7
7
|
s.date = '2011-07-09'
|
8
8
|
s.summary = "A ruby on rails gem that provides locale setting support through the subdomain (in a box)"
|
@@ -19,7 +19,7 @@ describe FoobarController , "locale specific routes", :type => :controller do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should error if site is not supported" do
|
22
|
-
expect {
|
22
|
+
expect {
|
23
23
|
root_url(:site => 'cz')
|
24
24
|
}.to raise_error(ArgumentError)
|
25
25
|
end
|
@@ -37,6 +37,20 @@ describe FoobarController , "locale specific routes", :type => :controller do
|
|
37
37
|
|
38
38
|
end
|
39
39
|
|
40
|
+
describe "when host is an ip address" do
|
41
|
+
it "should not override the hostname if the ip address is local" do
|
42
|
+
@request.host = '127.0.0.1'
|
43
|
+
get :test
|
44
|
+
root_url.should == 'http://127.0.0.1/'
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should not override the hostname if the ip address is local" do
|
48
|
+
@request.host = '64.24.234.234'
|
49
|
+
get :test
|
50
|
+
root_url.should == 'http://64.24.234.234/'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
40
54
|
describe "subdomain locale" do
|
41
55
|
|
42
56
|
it "should set the current locale to that of the subdomain" do
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: localized
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.7
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Paul Hepworth
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-07-09 00:00:00 -
|
13
|
+
date: 2011-07-09 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|