mr_common 1.1.0 → 1.2.0
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 +4 -4
- data/app/assets/stylesheets/mr_common/_forms.scss +2 -0
- data/app/assets/stylesheets/mr_common/_layout.scss +2 -0
- data/app/assets/stylesheets/mr_common/_variables.scss +1 -0
- data/app/models/mr_common/reminder.rb +1 -7
- data/app/models/mr_common/timezone.rb +38 -0
- data/app/views/mr_common/reminders/reminders/_form.html.erb +2 -2
- data/config/locales/en.yml +78 -0
- data/lib/mr_common/version.rb +1 -1
- data/spec/dummy/config/database.yml +1 -0
- data/spec/dummy/db/schema.rb +3 -3
- data/spec/models/reminder_spec.rb +4 -4
- metadata +28 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb005c3dea79627be3524d98f143154af85c90fdeb4013dcce4f8e391b68ca39
|
4
|
+
data.tar.gz: ee4ee1651df5e88554ca34c7e43c5426fff69d77fe32cc65f8c74607cd51ff0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12f522e9b24e11d31b97f8ada700461fd997e568ab84c4f8e9a9d9d89d7e2f5f74c5d302ac15d95b0ba6e3d089d87b26ff9d19c261b95acf2dad949e9524c9a6
|
7
|
+
data.tar.gz: c2d7a1b9c9e8e8b7c8b5503ce16c0ce17dbc343ad6e7dcbaeb6cbe96079b46a8486d4e1aad581f74f72e96bff9ea3f73c813bfe6e87d346e8e8e73c5f7e68f97
|
@@ -52,6 +52,7 @@ input[type=time],
|
|
52
52
|
textarea {
|
53
53
|
display: block;
|
54
54
|
border-radius: 2px;
|
55
|
+
background-color: $default-bg;
|
55
56
|
border: 1px solid $primary;
|
56
57
|
padding: 0.4rem 0.8rem;
|
57
58
|
width: 100%;
|
@@ -79,6 +80,7 @@ select {
|
|
79
80
|
border-radius: 2px;
|
80
81
|
border: 1px solid $primary;
|
81
82
|
padding: 0.4rem 2rem 0.3rem 0.8rem;
|
83
|
+
background-color: $default-bg;
|
82
84
|
background-image: $down-chevron;
|
83
85
|
background-position: center;
|
84
86
|
background-position-x: calc(100% - 0.5rem);
|
@@ -4,12 +4,6 @@ require_dependency "mr_common/application_record"
|
|
4
4
|
|
5
5
|
module MrCommon
|
6
6
|
class Reminder < ApplicationRecord
|
7
|
-
class << self
|
8
|
-
def time_zone_options
|
9
|
-
ActiveSupport::TimeZone::MAPPING.values.sort
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
7
|
validates :start_time, presence: true
|
14
8
|
validates :end_time, presence: true
|
15
9
|
validates :location, presence: true
|
@@ -17,7 +11,7 @@ module MrCommon
|
|
17
11
|
validates :slug, presence: true, uniqueness: true
|
18
12
|
validates :start_time, presence: true
|
19
13
|
validates :all_day, inclusion: [true, false]
|
20
|
-
validates :time_zone, presence: true, inclusion:
|
14
|
+
validates :time_zone, presence: true, inclusion: MrCommon::Timezone.time_zone_options, if: -> { time_zone.present? }
|
21
15
|
|
22
16
|
before_validation :parameterize_slug
|
23
17
|
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MrCommon
|
4
|
+
class Timezone
|
5
|
+
class << self
|
6
|
+
def time_zone_options
|
7
|
+
filtered_time_zones.collect(&:name)
|
8
|
+
end
|
9
|
+
|
10
|
+
def time_zone_select_options
|
11
|
+
filtered_time_zones.collect do |tz|
|
12
|
+
["(UTC#{tz_utc_offset(tz)}) #{tz_friendly_name(tz)}", tz.name]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
def all_time_zones
|
18
|
+
@timezones ||= TZInfo::Timezone.all.sort_by { |tz| tz.current_period.utc_total_offset }
|
19
|
+
end
|
20
|
+
|
21
|
+
# Include only timezones that have a translation available
|
22
|
+
def filtered_time_zones
|
23
|
+
@filtered_timezones ||= all_time_zones.collect do |tz|
|
24
|
+
next unless tz_friendly_name(tz)
|
25
|
+
tz
|
26
|
+
end.compact
|
27
|
+
end
|
28
|
+
|
29
|
+
def tz_friendly_name(tz)
|
30
|
+
I18n.t(tz.name, scope: :timezones, default: false)
|
31
|
+
end
|
32
|
+
|
33
|
+
def tz_utc_offset(tz)
|
34
|
+
ActiveSupport::TimeZone.seconds_to_utc_offset(tz.current_period.utc_total_offset)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -33,7 +33,7 @@
|
|
33
33
|
|
34
34
|
<%= f.form_group :time_zone, required: true do %>
|
35
35
|
<%= f.label :time_zone %>
|
36
|
-
<%= f.select :time_zone, MrCommon::
|
36
|
+
<%= f.select :time_zone, MrCommon::Timezone.time_zone_select_options, include_blank: true %>
|
37
37
|
<%= f.errors :time_zone %>
|
38
38
|
<% end %>
|
39
39
|
|
@@ -69,4 +69,4 @@
|
|
69
69
|
<% end %>
|
70
70
|
</div>
|
71
71
|
</div>
|
72
|
-
<% end %>
|
72
|
+
<% end %>
|
@@ -0,0 +1,78 @@
|
|
1
|
+
en:
|
2
|
+
timezones:
|
3
|
+
"Etc/GMT+12": "International Date Line West"
|
4
|
+
"Pacific/Midway": "Midway Island, Samoa"
|
5
|
+
"Pacific/Honolulu": "Hawaii"
|
6
|
+
"America/Juneau": "Alaska"
|
7
|
+
"America/Los_Angeles": "Pacific Time (US and Canada); Tijuana"
|
8
|
+
"America/Phoenix": "Arizona"
|
9
|
+
"America/Chihuahua": "Chihuahua, La Paz, Mazatlan"
|
10
|
+
"America/Denver": "Mountain Time (US and Canada)"
|
11
|
+
"America/Belize": "Central America"
|
12
|
+
"America/Chicago": "Central Time (US and Canada)"
|
13
|
+
"America/Mexico_City": "Guadalajara, Mexico City, Monterrey"
|
14
|
+
"America/Regina": "Saskatchewan"
|
15
|
+
"America/Bogota": "Bogota, Lima, Quito"
|
16
|
+
"America/New_York": "Eastern Time (US and Canada)"
|
17
|
+
"America/Indiana/Indianapolis": "Indiana (East)"
|
18
|
+
"America/Glace_Bay": "Atlantic Time (Canada)"
|
19
|
+
"America/Caracas": "Caracas, La Paz"
|
20
|
+
"America/St_Johns": "Newfoundland and Labrador"
|
21
|
+
"America/Argentina/Buenos_Aires": "Buenos Aires, Georgetown"
|
22
|
+
"America/Godthab": "Greenland"
|
23
|
+
"America/Santiago": "Santiago"
|
24
|
+
"America/Sao_Paulo": "Brasilia"
|
25
|
+
"Etc/GMT+2": "Mid-Atlantic"
|
26
|
+
"Atlantic/Azores": "Azores"
|
27
|
+
"Atlantic/Cape_Verde": "Cape Verde Islands"
|
28
|
+
"Atlantic/Canary": "Canary Islands"
|
29
|
+
"Etc/UTC": "Dublin, Edinburgh, Lisbon, London"
|
30
|
+
"Europe/Amsterdam": "Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna"
|
31
|
+
"Europe/Belgrade": "Belgrade, Bratislava, Budapest, Ljubljana, Prague"
|
32
|
+
"Europe/Brussels": "Brussels, Copenhagen, Madrid, Paris"
|
33
|
+
"Africa/Casablanca": "Casablanca, Monrovia"
|
34
|
+
"Europe/Sarajevo": "Sarajevo, Skopje, Warsaw, Zagreb"
|
35
|
+
"Africa/Algiers": "West Central Africa"
|
36
|
+
"Europe/Athens": "Athens, Istanbul, Minsk"
|
37
|
+
"Europe/Bucharest": "Bucharest"
|
38
|
+
"Africa/Cairo": "Cairo"
|
39
|
+
"Africa/Harare": "Harare, Pretoria"
|
40
|
+
"Europe/Helsinki": "Helsinki, Kiev, Riga, Sofia, Tallinn, Vilnius"
|
41
|
+
"Asia/Jerusalem": "Jerusalem"
|
42
|
+
"Asia/Baghdad": "Baghdad"
|
43
|
+
"Europe/Moscow": "Moscow, St. Petersburg, Volgograd"
|
44
|
+
"Asia/Kuwait": "Kuwait, Riyadh"
|
45
|
+
"Africa/Nairobi": "Nairobi"
|
46
|
+
"Asia/Tehran": "Tehran"
|
47
|
+
"Asia/Dubai": "Abu Dhabi, Muscat"
|
48
|
+
"Asia/Baku": "Baku, Tbilisi, Yerevan"
|
49
|
+
"Asia/Kabul": "Kabul"
|
50
|
+
"Asia/Yekaterinburg": "Ekaterinburg"
|
51
|
+
"Asia/Karachi": "Islamabad, Karachi, Tashkent"
|
52
|
+
"Asia/Kolkata": "Chennai, Kolkata, Mumbai, New Delhi"
|
53
|
+
"Asia/Colombo": "Sri Jayawardenepura"
|
54
|
+
"Asia/Almaty": "Almaty, Novosibirsk"
|
55
|
+
"Asia/Kathmandu": "Kathmandu"
|
56
|
+
"Asia/Dhaka": "Astana, Dhaka"
|
57
|
+
"Asia/Rangoon": "Yangon Rangoon"
|
58
|
+
"Asia/Bangkok": "Bangkok, Hanoi, Jakarta"
|
59
|
+
"Asia/Krasnoyarsk": "Krasnoyarsk"
|
60
|
+
"Asia/Shanghai": "Beijing, Chongqing, Hong Kong SAR, Urumqi"
|
61
|
+
"Asia/Irkutsk": "Irkutsk, Ulaanbaatar"
|
62
|
+
"Asia/Kuala_Lumpur": "Kuala Lumpur, Singapore"
|
63
|
+
"Australia/Perth": "Perth"
|
64
|
+
"Asia/Taipei": "Taipei"
|
65
|
+
"Asia/Tokyo": "Osaka, Sapporo, Tokyo"
|
66
|
+
"Asia/Seoul": "Seoul"
|
67
|
+
"Asia/Yakutsk": "Yakutsk"
|
68
|
+
"Australia/Darwin": "Darwin"
|
69
|
+
"Australia/Brisbane": "Brisbane"
|
70
|
+
"Pacific/Guam": "Guam, Port Moresby"
|
71
|
+
"Asia/Vladivostok": "Vladivostok"
|
72
|
+
"Australia/Adelaide": "Adelaide"
|
73
|
+
"Australia/Sydney": "Canberra, Melbourne, Sydney"
|
74
|
+
"Australia/Hobart": "Hobart"
|
75
|
+
"Asia/Magadan": "Magadan, Solomon Islands, New Caledonia"
|
76
|
+
"Pacific/Fiji": "Fiji Islands, Kamchatka, Marshall Islands"
|
77
|
+
"Pacific/Auckland": "Auckland, Wellington"
|
78
|
+
"Pacific/Tongatapu": "Nuku'alofa"
|
data/lib/mr_common/version.rb
CHANGED
@@ -17,6 +17,7 @@
|
|
17
17
|
default: &default
|
18
18
|
adapter: postgresql
|
19
19
|
encoding: unicode
|
20
|
+
host: localhost
|
20
21
|
# For details on connection pooling, see Rails configuration guide
|
21
22
|
# http://guides.rubyonrails.org/configuring.html#database-pooling
|
22
23
|
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -30,16 +30,16 @@ ActiveRecord::Schema.define(version: 2019_01_24_160301) do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
create_table "mr_common_reminders", force: :cascade do |t|
|
33
|
-
t.datetime "start_time"
|
34
|
-
t.datetime "end_time"
|
33
|
+
t.datetime "start_time", null: false
|
34
|
+
t.datetime "end_time", null: false
|
35
35
|
t.string "location", default: "", null: false
|
36
36
|
t.string "summary", default: "", null: false
|
37
37
|
t.text "description", default: "", null: false
|
38
38
|
t.string "slug", default: "", null: false
|
39
39
|
t.boolean "all_day", default: false, null: false
|
40
|
+
t.string "time_zone", default: "Etc/UTC", null: false
|
40
41
|
t.datetime "created_at", null: false
|
41
42
|
t.datetime "updated_at", null: false
|
42
|
-
t.string "time_zone"
|
43
43
|
t.boolean "include_in_confirmation_mailer", default: false, null: false
|
44
44
|
t.index ["slug"], name: "index_reminders_on_slug", unique: true
|
45
45
|
end
|
@@ -75,10 +75,10 @@ module MrCommon
|
|
75
75
|
end
|
76
76
|
|
77
77
|
describe ".time_zone_options" do
|
78
|
-
it "is
|
79
|
-
expected =
|
80
|
-
actual = MrCommon::
|
81
|
-
expect(actual).to
|
78
|
+
it "is a subset of TZInfo::Timezone.all names" do
|
79
|
+
expected = TZInfo::Timezone.all.collect(&:name)
|
80
|
+
actual = MrCommon::Timezone.time_zone_options
|
81
|
+
expect(actual - expected).to be_empty
|
82
82
|
end
|
83
83
|
end
|
84
84
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mr_common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Corey Smedstad
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: carmen
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '0'
|
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:
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: icalendar
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,19 +39,19 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 5.2.2
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 5.2.2
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: sass
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: tzinfo-data
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.2018.9
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.2018.9
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: pg
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -208,6 +222,7 @@ files:
|
|
208
222
|
- app/models/mr_common/pattern.rb
|
209
223
|
- app/models/mr_common/registration.rb
|
210
224
|
- app/models/mr_common/reminder.rb
|
225
|
+
- app/models/mr_common/timezone.rb
|
211
226
|
- app/views/layouts/mr_common/_flash.html.erb
|
212
227
|
- app/views/layouts/mr_common/_footer.html.erb
|
213
228
|
- app/views/layouts/mr_common/_navigation.html.erb
|
@@ -230,6 +245,7 @@ files:
|
|
230
245
|
- app/views/mr_common/reminders/reminders/index.html.erb
|
231
246
|
- app/views/mr_common/reminders/reminders/new.html.erb
|
232
247
|
- app/views/mr_common/reminders/reminders/show.html.erb
|
248
|
+
- config/locales/en.yml
|
233
249
|
- config/routes.rb
|
234
250
|
- db/migrate/20190110202347_create_reminders.rb
|
235
251
|
- db/migrate/20190122185500_create_registrations.rb
|