timezone_detection 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +5 -0
- data/Rakefile +40 -0
- data/app/assets/javascripts/timezone_detection/application.js +15 -0
- data/app/assets/stylesheets/timezone_detection/application.css +13 -0
- data/app/controllers/timezone_detection/application_controller.rb +6 -0
- data/app/helpers/timezone_detection/application_helper.rb +4 -0
- data/app/models/timezone_detection/ip_timezone.rb +19 -0
- data/app/views/layouts/timezone_detection/application.html.erb +14 -0
- data/config/initializers/root_app_extension.rb +3 -0
- data/config/routes.rb +2 -0
- data/lib/generators/timezone_detection/install_generator.rb +25 -0
- data/lib/generators/timezone_detection/migrations/ip_timezone.rb +10 -0
- data/lib/tasks/timezone_detection_tasks.rake +4 -0
- data/lib/timezone_detection/application_controller_extension.rb +10 -0
- data/lib/timezone_detection/engine.rb +7 -0
- data/lib/timezone_detection/ip_convertion.rb +20 -0
- data/lib/timezone_detection/ip_info_db.rb +44 -0
- data/lib/timezone_detection/version.rb +3 -0
- data/lib/timezone_detection.rb +14 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20120808173854_create_ip_timezones.rb +10 -0
- data/test/dummy/db/schema.rb +23 -0
- data/test/dummy/db/structure.sql +5 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +114 -0
- data/test/dummy/log/test.log +766 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/test_helper.rb +19 -0
- data/test/timezone_detection_test.rb +40 -0
- metadata +141 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</html>
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
require "rails/test_help"
|
6
|
+
|
7
|
+
Rails.backtrace_cleaner.remove_silencers!
|
8
|
+
|
9
|
+
# Load support files
|
10
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
11
|
+
|
12
|
+
# Load fixtures from the engine
|
13
|
+
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
|
14
|
+
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
15
|
+
end
|
16
|
+
|
17
|
+
TimezoneDetection.config do |obj|
|
18
|
+
obj.api_key = "10d1bb75dbefa046219723f1046019122f0d4fe56ec4f7ffe13f1f6d7893fb2b"
|
19
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
class TimezoneDetectionTest < ActiveSupport::TestCase
|
4
|
+
test "truth" do
|
5
|
+
assert_kind_of Module, TimezoneDetection
|
6
|
+
end
|
7
|
+
|
8
|
+
test "config api_key presence" do
|
9
|
+
key = "10d1bb75dbefa046219723f1046019122f0d4fe56ec4f7ffe13f1f6d7893fb2b"
|
10
|
+
assert_equal key, TimezoneDetection.api_key #Set in test_helper
|
11
|
+
end
|
12
|
+
|
13
|
+
test "ip convertion" do
|
14
|
+
fake_ip = "80.70.60.50"
|
15
|
+
test_obj = Class.send(:include, TimezoneDetection::IpConvertion).new
|
16
|
+
assert_equal 842810960, test_obj.ip2long(fake_ip)
|
17
|
+
assert_equal fake_ip, test_obj.long2ip(842810960)
|
18
|
+
end
|
19
|
+
|
20
|
+
test "timezone lookup by IP" do
|
21
|
+
ip = "78.137.57.74"
|
22
|
+
ip_info = TimezoneDetection::IpInfoDB.new
|
23
|
+
assert_equal 3, ip_info.get_timezone_offset(ip)
|
24
|
+
end
|
25
|
+
|
26
|
+
test "ip_timezone record creation" do
|
27
|
+
ip = "78.137.57.74"
|
28
|
+
TimezoneDetection::IpTimezone.destroy_all
|
29
|
+
TimezoneDetection::IpTimezone.create(ip: ip, utc_offset: 3)
|
30
|
+
assert_equal 1, TimezoneDetection::IpTimezone.count
|
31
|
+
end
|
32
|
+
|
33
|
+
test "ip_timezone record should not be created (same already exists)" do
|
34
|
+
ip = "78.137.57.74"
|
35
|
+
TimezoneDetection::IpTimezone.create(ip: ip, utc_offset: 3)
|
36
|
+
TimezoneDetection::IpTimezone.create(ip: ip, utc_offset: 3)
|
37
|
+
assert_equal 1, TimezoneDetection::IpTimezone.count
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: timezone_detection
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Boris Babusenko
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-09 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Gem for detecting users timezone by IP address.
|
15
|
+
email:
|
16
|
+
- boris.bbk@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- app/views/layouts/timezone_detection/application.html.erb
|
22
|
+
- app/helpers/timezone_detection/application_helper.rb
|
23
|
+
- app/models/timezone_detection/ip_timezone.rb
|
24
|
+
- app/assets/stylesheets/timezone_detection/application.css
|
25
|
+
- app/assets/javascripts/timezone_detection/application.js
|
26
|
+
- app/controllers/timezone_detection/application_controller.rb
|
27
|
+
- config/initializers/root_app_extension.rb
|
28
|
+
- config/routes.rb
|
29
|
+
- lib/generators/timezone_detection/migrations/ip_timezone.rb
|
30
|
+
- lib/generators/timezone_detection/install_generator.rb
|
31
|
+
- lib/tasks/timezone_detection_tasks.rake
|
32
|
+
- lib/timezone_detection/ip_info_db.rb
|
33
|
+
- lib/timezone_detection/application_controller_extension.rb
|
34
|
+
- lib/timezone_detection/ip_convertion.rb
|
35
|
+
- lib/timezone_detection/engine.rb
|
36
|
+
- lib/timezone_detection/version.rb
|
37
|
+
- lib/timezone_detection.rb
|
38
|
+
- MIT-LICENSE
|
39
|
+
- Rakefile
|
40
|
+
- README.rdoc
|
41
|
+
- test/dummy/Rakefile
|
42
|
+
- test/dummy/script/rails
|
43
|
+
- test/dummy/config/environments/production.rb
|
44
|
+
- test/dummy/config/environments/test.rb
|
45
|
+
- test/dummy/config/environments/development.rb
|
46
|
+
- test/dummy/config/boot.rb
|
47
|
+
- test/dummy/config/application.rb
|
48
|
+
- test/dummy/config/database.yml
|
49
|
+
- test/dummy/config/initializers/inflections.rb
|
50
|
+
- test/dummy/config/initializers/session_store.rb
|
51
|
+
- test/dummy/config/initializers/secret_token.rb
|
52
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
53
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
54
|
+
- test/dummy/config/initializers/mime_types.rb
|
55
|
+
- test/dummy/config/environment.rb
|
56
|
+
- test/dummy/config/routes.rb
|
57
|
+
- test/dummy/config/locales/en.yml
|
58
|
+
- test/dummy/log/test.log
|
59
|
+
- test/dummy/log/development.log
|
60
|
+
- test/dummy/db/structure.sql
|
61
|
+
- test/dummy/db/migrate/20120808173854_create_ip_timezones.rb
|
62
|
+
- test/dummy/db/development.sqlite3
|
63
|
+
- test/dummy/db/schema.rb
|
64
|
+
- test/dummy/db/test.sqlite3
|
65
|
+
- test/dummy/README.rdoc
|
66
|
+
- test/dummy/config.ru
|
67
|
+
- test/dummy/public/500.html
|
68
|
+
- test/dummy/public/404.html
|
69
|
+
- test/dummy/public/favicon.ico
|
70
|
+
- test/dummy/public/422.html
|
71
|
+
- test/dummy/app/views/layouts/application.html.erb
|
72
|
+
- test/dummy/app/helpers/application_helper.rb
|
73
|
+
- test/dummy/app/assets/stylesheets/application.css
|
74
|
+
- test/dummy/app/assets/javascripts/application.js
|
75
|
+
- test/dummy/app/controllers/application_controller.rb
|
76
|
+
- test/test_helper.rb
|
77
|
+
- test/timezone_detection_test.rb
|
78
|
+
- test/integration/navigation_test.rb
|
79
|
+
homepage: https://github.com/Bor1s/timezone-detection
|
80
|
+
licenses: []
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ! '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 1.8.24
|
100
|
+
signing_key:
|
101
|
+
specification_version: 3
|
102
|
+
summary: Gem for detecting users timezone by IP address.
|
103
|
+
test_files:
|
104
|
+
- test/dummy/Rakefile
|
105
|
+
- test/dummy/script/rails
|
106
|
+
- test/dummy/config/environments/production.rb
|
107
|
+
- test/dummy/config/environments/test.rb
|
108
|
+
- test/dummy/config/environments/development.rb
|
109
|
+
- test/dummy/config/boot.rb
|
110
|
+
- test/dummy/config/application.rb
|
111
|
+
- test/dummy/config/database.yml
|
112
|
+
- test/dummy/config/initializers/inflections.rb
|
113
|
+
- test/dummy/config/initializers/session_store.rb
|
114
|
+
- test/dummy/config/initializers/secret_token.rb
|
115
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
116
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
117
|
+
- test/dummy/config/initializers/mime_types.rb
|
118
|
+
- test/dummy/config/environment.rb
|
119
|
+
- test/dummy/config/routes.rb
|
120
|
+
- test/dummy/config/locales/en.yml
|
121
|
+
- test/dummy/log/test.log
|
122
|
+
- test/dummy/log/development.log
|
123
|
+
- test/dummy/db/structure.sql
|
124
|
+
- test/dummy/db/migrate/20120808173854_create_ip_timezones.rb
|
125
|
+
- test/dummy/db/development.sqlite3
|
126
|
+
- test/dummy/db/schema.rb
|
127
|
+
- test/dummy/db/test.sqlite3
|
128
|
+
- test/dummy/README.rdoc
|
129
|
+
- test/dummy/config.ru
|
130
|
+
- test/dummy/public/500.html
|
131
|
+
- test/dummy/public/404.html
|
132
|
+
- test/dummy/public/favicon.ico
|
133
|
+
- test/dummy/public/422.html
|
134
|
+
- test/dummy/app/views/layouts/application.html.erb
|
135
|
+
- test/dummy/app/helpers/application_helper.rb
|
136
|
+
- test/dummy/app/assets/stylesheets/application.css
|
137
|
+
- test/dummy/app/assets/javascripts/application.js
|
138
|
+
- test/dummy/app/controllers/application_controller.rb
|
139
|
+
- test/test_helper.rb
|
140
|
+
- test/timezone_detection_test.rb
|
141
|
+
- test/integration/navigation_test.rb
|