hellobase 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hellobase.rb +3 -29
- data/lib/hellobase/core_ext.rb +32 -0
- data/lib/hellobase/{array_access.rb → core_ext/array_access.rb} +0 -0
- data/lib/hellobase/{date_creation.rb → core_ext/date_creation.rb} +1 -1
- data/lib/hellobase/{datetime_creation.rb → core_ext/datetime_creation.rb} +7 -2
- data/lib/hellobase/{divide_by_zero.rb → core_ext/divide_by_zero.rb} +0 -0
- data/lib/hellobase/{duration_arithmetic.rb → core_ext/duration_arithmetic.rb} +0 -0
- data/lib/hellobase/{string_access.rb → core_ext/string_access.rb} +0 -0
- data/lib/hellobase/{time_creation.rb → core_ext/time_creation.rb} +1 -1
- data/lib/hellobase/formtastic.rb +6 -0
- data/lib/hellobase/formtastic/inline_checkbox_input.rb +9 -0
- data/lib/hellobase/formtastic/read_only_input.rb +8 -0
- data/lib/hellobase/formtastic/time_of_day_input.rb +19 -0
- data/lib/hellobase/time_zones.rb +13 -0
- data/lib/hellobase/version.rb +1 -1
- metadata +15 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46694043401a358a06c4d8cc43fed3e74ddf49e756da77bf3e501f5368d587a1
|
4
|
+
data.tar.gz: 425faddf86643febe8bed91dd8d8da3e44806f6279f57f7a4a40b690112f811b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87c87f82adc496b5126a32a373998521c79dd61a45111323c5247c78064921873dd7655eb4f26693d57197644813d1d16cbee5ec6d0e99647482d1a96eab6885
|
7
|
+
data.tar.gz: 8dfddd47d74040a1edaf77c6e90f24ddb0660a1fc00d5b2fdfe006a201e6973d3c3fb195f403e1196b9fab1c397f9dc3a0c5860110783e304435a28ecc36ec79
|
data/lib/hellobase.rb
CHANGED
@@ -1,32 +1,6 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require '
|
4
|
-
require 'active_support/core_ext/time'
|
5
|
-
require 'active_support/duration'
|
6
|
-
require 'tod'
|
7
|
-
|
8
|
-
require 'hellobase/array_access'
|
9
|
-
require 'hellobase/date_creation'
|
10
|
-
require 'hellobase/datetime_creation'
|
11
|
-
require 'hellobase/divide_by_zero'
|
12
|
-
require 'hellobase/duration_arithmetic'
|
13
|
-
require 'hellobase/string_access'
|
14
|
-
require 'hellobase/time_creation'
|
1
|
+
require 'hellobase/core_ext'
|
2
|
+
require 'hellobase/formtastic'
|
3
|
+
require 'hellobase/time_zones'
|
15
4
|
|
16
5
|
module Hellobase
|
17
|
-
DATE_FORMAT = /^\d{4}-\d{2}-\d{2}$/
|
18
|
-
TIME_FORMAT = /^\d{2}:\d{2}:\d{2}$/
|
19
|
-
DATETIME_FORMAT = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} UTC$/
|
20
|
-
|
21
|
-
class Error < StandardError
|
22
|
-
attr_reader :type, :object
|
23
|
-
|
24
|
-
def initialize(type, object, *args)
|
25
|
-
@type = type
|
26
|
-
@object = object
|
27
|
-
@args = args
|
28
|
-
|
29
|
-
super "#{type}: #{object.inspect}, #{args.inspect}"
|
30
|
-
end
|
31
|
-
end
|
32
6
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'bigdecimal'
|
2
|
+
require 'date'
|
3
|
+
require 'active_support/core_ext/date'
|
4
|
+
require 'active_support/core_ext/time'
|
5
|
+
require 'active_support/duration'
|
6
|
+
require 'tod'
|
7
|
+
|
8
|
+
require 'hellobase/core_ext/array_access'
|
9
|
+
require 'hellobase/core_ext/date_creation'
|
10
|
+
require 'hellobase/core_ext/datetime_creation'
|
11
|
+
require 'hellobase/core_ext/divide_by_zero'
|
12
|
+
require 'hellobase/core_ext/duration_arithmetic'
|
13
|
+
require 'hellobase/core_ext/string_access'
|
14
|
+
require 'hellobase/core_ext/time_creation'
|
15
|
+
|
16
|
+
module Hellobase
|
17
|
+
DATE_FORMAT = /^\d{4}-\d{2}-\d{2}$/
|
18
|
+
TIME_FORMAT = /^\d{2}:\d{2}:\d{2}$/
|
19
|
+
DATETIME_FORMAT = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} UTC$/
|
20
|
+
|
21
|
+
class Error < StandardError
|
22
|
+
attr_reader :type, :object
|
23
|
+
|
24
|
+
def initialize(type, object, *args)
|
25
|
+
@type = type
|
26
|
+
@object = object
|
27
|
+
@args = args
|
28
|
+
|
29
|
+
super "#{type}: #{object.inspect}, #{args.inspect}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
File without changes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Date.singleton_class.prepend(
|
2
2
|
Module.new do
|
3
3
|
def parse(string)
|
4
|
-
raise Hellobase::Error.new(:date_format, nil, string) unless string =~ Hellobase::DATE_FORMAT
|
4
|
+
raise Hellobase::Error.new(:date_format, nil, string) unless (string =~ Hellobase::DATE_FORMAT) || string.blank?
|
5
5
|
|
6
6
|
begin
|
7
7
|
super
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Time.singleton_class.prepend(
|
2
2
|
Module.new do
|
3
3
|
def parse(string)
|
4
|
-
raise Hellobase::Error.new(:datetime_format, nil, string) unless string =~ Hellobase::DATETIME_FORMAT
|
4
|
+
raise Hellobase::Error.new(:datetime_format, nil, string) unless (string =~ Hellobase::DATETIME_FORMAT) || string.blank?
|
5
5
|
|
6
6
|
begin
|
7
7
|
super
|
@@ -19,7 +19,12 @@ Time.singleton_class.prepend(
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def new(*args)
|
22
|
-
|
22
|
+
# only allow ActiveSupport::TimeZone to use Time.new
|
23
|
+
unless caller_locations(1, 1)[0].path.end_with? 'active_support/values/time_zone.rb'
|
24
|
+
raise Hellobase::Error.new(:datetime_new, nil)
|
25
|
+
end
|
26
|
+
|
27
|
+
super
|
23
28
|
end
|
24
29
|
end
|
25
30
|
)
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Tod::TimeOfDay.singleton_class.prepend(
|
2
2
|
Module.new do
|
3
3
|
def parse(string)
|
4
|
-
raise Hellobase::Error.new(:time_format, nil, string) unless string =~ Hellobase::TIME_FORMAT
|
4
|
+
raise Hellobase::Error.new(:time_format, nil, string) unless (string =~ Hellobase::TIME_FORMAT) || string.blank?
|
5
5
|
|
6
6
|
begin
|
7
7
|
super
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class TimeOfDayInput < ::Formtastic::Inputs::SelectInput
|
2
|
+
def initialize(*)
|
3
|
+
super
|
4
|
+
|
5
|
+
@options[:collection] ||= build_times_collection
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def build_times_collection
|
11
|
+
hours = 0..23
|
12
|
+
minutes = (0..59).select {|m| m % 5 == 0 }
|
13
|
+
seconds = (0..59).select {|m| m % 60 == 0 }
|
14
|
+
times = hours.map {|h| minutes.map {|m| seconds.map {|s| Tod::TimeOfDay.new(h, m, s) } } }.flatten
|
15
|
+
|
16
|
+
format = '%I:%M %p'
|
17
|
+
times.map {|t| [t.strftime(format), t.to_s] }
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'tzinfo'
|
2
|
+
|
3
|
+
module Hellobase
|
4
|
+
class << self
|
5
|
+
def domestic_time_zone_select_values(country_code)
|
6
|
+
TZInfo::Country.get(country_code).zone_info.map {|z| [z.description || z.timezone.friendly_identifier(true), z.identifier] }
|
7
|
+
end
|
8
|
+
|
9
|
+
def foreign_time_zone_select_values(country_code)
|
10
|
+
TZInfo::Country.all.reject {|c| c.code == country_code }.map(&:zone_info).flatten.uniq.map {|z| [z.description || z.timezone.friendly_identifier(false), z.identifier] }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/hellobase/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hellobase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Wang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -81,13 +81,19 @@ extra_rdoc_files: []
|
|
81
81
|
files:
|
82
82
|
- MIT-LICENSE
|
83
83
|
- lib/hellobase.rb
|
84
|
-
- lib/hellobase/
|
85
|
-
- lib/hellobase/
|
86
|
-
- lib/hellobase/
|
87
|
-
- lib/hellobase/
|
88
|
-
- lib/hellobase/
|
89
|
-
- lib/hellobase/
|
90
|
-
- lib/hellobase/
|
84
|
+
- lib/hellobase/core_ext.rb
|
85
|
+
- lib/hellobase/core_ext/array_access.rb
|
86
|
+
- lib/hellobase/core_ext/date_creation.rb
|
87
|
+
- lib/hellobase/core_ext/datetime_creation.rb
|
88
|
+
- lib/hellobase/core_ext/divide_by_zero.rb
|
89
|
+
- lib/hellobase/core_ext/duration_arithmetic.rb
|
90
|
+
- lib/hellobase/core_ext/string_access.rb
|
91
|
+
- lib/hellobase/core_ext/time_creation.rb
|
92
|
+
- lib/hellobase/formtastic.rb
|
93
|
+
- lib/hellobase/formtastic/inline_checkbox_input.rb
|
94
|
+
- lib/hellobase/formtastic/read_only_input.rb
|
95
|
+
- lib/hellobase/formtastic/time_of_day_input.rb
|
96
|
+
- lib/hellobase/time_zones.rb
|
91
97
|
- lib/hellobase/version.rb
|
92
98
|
homepage:
|
93
99
|
licenses: []
|