auto_timezone 0.0.2 → 0.0.3
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.
- checksums.yaml +5 -5
- data/.github/workflows/test.yml +29 -0
- data/auto_timezone.gemspec +1 -2
- data/lib/auto_timezone/version.rb +1 -1
- data/test/cookie.test.js +12 -0
- data/test/smoke_test.rb +17 -0
- data/vendor/assets/javascripts/auto_timezone.js +1 -1
- metadata +18 -31
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 96abf5ddcba8f310d77998cb033434601c933a4f8185aff5ea4ef81d14f8dcec
|
|
4
|
+
data.tar.gz: 5d76f8d8bcc4e6a66f3ab1a0cf829d1a3eaa55ea22f566dfc0131a5771fc9919
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4b7ff1a81a7148aa484b127a8d449a37596bdbe80a4628c4ce3e093218627cb8292b24172c70862d6bd38d2f910a582ee77d3553d3294d9e7e00508f71168504
|
|
7
|
+
data.tar.gz: b5dd461ed8981d36f467f8139f31a0616d7370215688802db42fa8e5f3d47080083ca8a9057a0b201d8b54222114950519ad47a206b4452975c150b133f0aab4
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: Test
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
pull_request:
|
|
5
|
+
jobs:
|
|
6
|
+
ruby:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
steps:
|
|
9
|
+
- uses: actions/checkout@v4
|
|
10
|
+
- uses: ruby/setup-ruby@v1
|
|
11
|
+
with:
|
|
12
|
+
ruby-version: '2.7'
|
|
13
|
+
bundler: '2.4.22'
|
|
14
|
+
bundler-cache: true
|
|
15
|
+
- run: bundle exec ruby -Ilib test/smoke_test.rb
|
|
16
|
+
- name: Build and install gem
|
|
17
|
+
run: |
|
|
18
|
+
bundle exec rake build
|
|
19
|
+
gem install --local --ignore-dependencies --no-document --install-dir "$RUNNER_TEMP/installed" pkg/auto_timezone-*.gem
|
|
20
|
+
ruby -I "$RUNNER_TEMP/installed/gems/auto_timezone-$(ruby -Ilib -rauto_timezone/version -e 'print AutoTimezone::VERSION')/lib" test/smoke_test.rb
|
|
21
|
+
|
|
22
|
+
javascript:
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v4
|
|
26
|
+
- uses: actions/setup-node@v4
|
|
27
|
+
with:
|
|
28
|
+
node-version: '22'
|
|
29
|
+
- run: node --test test/*.test.js
|
data/auto_timezone.gemspec
CHANGED
data/test/cookie.test.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const assert = require('node:assert/strict');
|
|
2
|
+
const fs = require('node:fs');
|
|
3
|
+
const vm = require('node:vm');
|
|
4
|
+
const test = require('node:test');
|
|
5
|
+
|
|
6
|
+
test('timezone offset cookie applies across the site', () => {
|
|
7
|
+
const document = { cookie: '' };
|
|
8
|
+
const context = vm.createContext({ document, Date });
|
|
9
|
+
const script = fs.readFileSync('vendor/assets/javascripts/auto_timezone.js', 'utf8');
|
|
10
|
+
vm.runInContext(script, context);
|
|
11
|
+
assert.match(document.cookie, /^auto_timezone_offset=-?\d+; path=\/$/);
|
|
12
|
+
});
|
data/test/smoke_test.rb
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'auto_timezone/version'
|
|
2
|
+
require 'auto_timezone/config'
|
|
3
|
+
|
|
4
|
+
raise 'Invalid gem version' unless /\A\d+\.\d+\.\d+\z/.match?(AutoTimezone::VERSION)
|
|
5
|
+
|
|
6
|
+
config = AutoTimezone.config
|
|
7
|
+
raise 'Missing default timezone preferences' unless config.preferred_timezones == %w(US/Eastern US/Central US/Mountain US/Pacific)
|
|
8
|
+
|
|
9
|
+
AutoTimezone.configure do |options|
|
|
10
|
+
options.preferred_timezones = %w(UTC US/Eastern)
|
|
11
|
+
options.default_timezone { 'UTC' }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
raise 'Timezone preferences not configurable' unless AutoTimezone.config.preferred_timezones == %w(UTC US/Eastern)
|
|
15
|
+
raise 'Default timezone block not retained' unless AutoTimezone.config.default_timezone_block.call == 'UTC'
|
|
16
|
+
|
|
17
|
+
puts 'AutoTimezone configuration smoke test passed'
|
|
@@ -4,4 +4,4 @@ Date.prototype.getDSTTimezoneOffset = function() {
|
|
|
4
4
|
return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
document.cookie = "auto_timezone_offset=" + -60 * new Date().getDSTTimezoneOffset();
|
|
7
|
+
document.cookie = "auto_timezone_offset=" + -60 * new Date().getDSTTimezoneOffset() + "; path=/";
|
metadata
CHANGED
|
@@ -1,57 +1,42 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: auto_timezone
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- smudge
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: railties
|
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
|
16
15
|
requirements:
|
|
17
|
-
- - ~>
|
|
16
|
+
- - "~>"
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
18
|
version: '3.2'
|
|
20
19
|
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
|
-
- - ~>
|
|
23
|
+
- - "~>"
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
25
|
version: '3.2'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: bundler
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - ~>
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '1.7'
|
|
34
|
-
type: :development
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - ~>
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '1.7'
|
|
41
26
|
- !ruby/object:Gem::Dependency
|
|
42
27
|
name: rake
|
|
43
28
|
requirement: !ruby/object:Gem::Requirement
|
|
44
29
|
requirements:
|
|
45
|
-
- - ~>
|
|
30
|
+
- - "~>"
|
|
46
31
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '
|
|
32
|
+
version: '13.0'
|
|
48
33
|
type: :development
|
|
49
34
|
prerelease: false
|
|
50
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
36
|
requirements:
|
|
52
|
-
- - ~>
|
|
37
|
+
- - "~>"
|
|
53
38
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '
|
|
39
|
+
version: '13.0'
|
|
55
40
|
description: Automatically infer and set `Time.zone` with each web request.
|
|
56
41
|
email:
|
|
57
42
|
- nathan@ngriffith.com
|
|
@@ -59,7 +44,8 @@ executables: []
|
|
|
59
44
|
extensions: []
|
|
60
45
|
extra_rdoc_files: []
|
|
61
46
|
files:
|
|
62
|
-
- .
|
|
47
|
+
- ".github/workflows/test.yml"
|
|
48
|
+
- ".gitignore"
|
|
63
49
|
- Gemfile
|
|
64
50
|
- LICENSE.txt
|
|
65
51
|
- README.md
|
|
@@ -72,29 +58,30 @@ files:
|
|
|
72
58
|
- lib/auto_timezone/version.rb
|
|
73
59
|
- lib/generators/auto_timezone/install_generator.rb
|
|
74
60
|
- lib/generators/auto_timezone/templates/config_initializer.rb
|
|
61
|
+
- test/cookie.test.js
|
|
62
|
+
- test/smoke_test.rb
|
|
75
63
|
- vendor/assets/javascripts/auto_timezone.js
|
|
76
64
|
homepage: http://github.com/smudge/auto_timezone
|
|
77
65
|
licenses:
|
|
78
66
|
- MIT
|
|
79
67
|
metadata: {}
|
|
80
|
-
post_install_message:
|
|
81
68
|
rdoc_options: []
|
|
82
69
|
require_paths:
|
|
83
70
|
- lib
|
|
84
71
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
72
|
requirements:
|
|
86
|
-
- -
|
|
73
|
+
- - ">="
|
|
87
74
|
- !ruby/object:Gem::Version
|
|
88
75
|
version: '0'
|
|
89
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
77
|
requirements:
|
|
91
|
-
- -
|
|
78
|
+
- - ">="
|
|
92
79
|
- !ruby/object:Gem::Version
|
|
93
80
|
version: '0'
|
|
94
81
|
requirements: []
|
|
95
|
-
|
|
96
|
-
rubygems_version: 2.4.1
|
|
97
|
-
signing_key:
|
|
82
|
+
rubygems_version: 4.0.24
|
|
98
83
|
specification_version: 4
|
|
99
84
|
summary: Simple and unobtrusive timezone configuration for Rails
|
|
100
|
-
test_files:
|
|
85
|
+
test_files:
|
|
86
|
+
- test/cookie.test.js
|
|
87
|
+
- test/smoke_test.rb
|