hellobase 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 798908bb2b7735772d7100ce87932279a23f4d5cbf8c74134f9992c45de401ca
4
+ data.tar.gz: 9d7bfcb9651d552b5559b26872c63cb129cbcea1932db30fb172edbaa2c511d5
5
+ SHA512:
6
+ metadata.gz: 6ad3bcf71449db59ae76449a58670b968ee8f6747374b3c8c0b0238e1313e42b4a739b5be225365e91989497eb6731d3c2f35e9ffa0a1c387b5e32d3410fa0d0
7
+ data.tar.gz: c4ff400d7e30542f5ff53302793c65e272ca4ac78beee5393c2755cee3d8982040459dea8454b55d5c9eeac271d380e89109d999ae411d21146547a8bd8664ce
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2020 AENEA LLC
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ class Date
2
+ def self.hb_parse(string)
3
+ raise Error.new(:date_parse, string) unless string =~ Hellobase::DATE_FORMAT
4
+
5
+ begin
6
+ parse(string)
7
+ rescue ArgumentError
8
+ raise Error.new(:date_parse, string)
9
+ end
10
+ end
11
+
12
+ def self.hb_new(*args)
13
+ begin
14
+ new(*args)
15
+ rescue ArgumentError
16
+ raise Error.new(:date_new, string)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ class DateTime
2
+ def self.hb_parse(string)
3
+ raise Error.new(:datetime_parse, string) unless string =~ Hellobase::DATETIME_FORMAT
4
+
5
+ begin
6
+ parse(string)
7
+ rescue ArgumentError
8
+ raise Error.new(:datetime_parse, string)
9
+ end
10
+ end
11
+
12
+ def self.hb_new(*args)
13
+ begin
14
+ new(*args)
15
+ rescue ArgumentError
16
+ raise Error.new(:datetime_new, string)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ module Hellobase
2
+ module DivideByZero
3
+ def /(arg)
4
+ begin
5
+ result = super
6
+ result == BigDecimal::INFINITY || result == -BigDecimal::INFINITY ? BigDecimal::NAN : result
7
+ rescue ZeroDivisionError
8
+ BigDecimal::NAN
9
+ end
10
+ end
11
+ end
12
+ end
13
+
14
+ Integer.prepend Hellobase::DivideByZero
15
+ BigDecimal.prepend Hellobase::DivideByZero
@@ -0,0 +1,21 @@
1
+ module Tod
2
+ class TimeOfDay
3
+ def self.hb_parse(string)
4
+ raise Error.new(:time_parse, string) unless string =~ Hellobase::TIME_FORMAT
5
+
6
+ begin
7
+ parse(string)
8
+ rescue ArgumentError
9
+ raise Error.new(:time_parse, string)
10
+ end
11
+ end
12
+
13
+ def self.hb_new(*args)
14
+ begin
15
+ new(*args)
16
+ rescue ArgumentError
17
+ raise Error.new(:time_new, string)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module Hellobase
2
+ VERSION = '0.1.0'
3
+ end
data/lib/hellobase.rb ADDED
@@ -0,0 +1,26 @@
1
+ require 'bigdecimal'
2
+ require 'date'
3
+ require 'active_support/core_ext/date'
4
+ require 'active_support/core_ext/date_time'
5
+ require 'active_support/duration'
6
+ require 'tod'
7
+
8
+ require 'hellobase/date_creation'
9
+ require 'hellobase/datetime_creation'
10
+ require 'hellobase/divide_by_zero'
11
+ require 'hellobase/time_creation'
12
+
13
+ module Hellobase
14
+ DATE_FORMAT = /^\d{4}-\d{2}-\d{2}$/
15
+ TIME_FORMAT = /^\d{2}:\d{2}:\d{2}$/
16
+ DATETIME_FORMAT = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/
17
+
18
+ class Error < StandardError
19
+ def initialize(type, *args)
20
+ @type = type
21
+ @args = args
22
+
23
+ super "#{type}: #{args.inspect}"
24
+ end
25
+ end
26
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hellobase
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Anthony Wang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-05-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 6.0.2
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 6.0.2.2
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 6.0.2
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 6.0.2.2
33
+ - !ruby/object:Gem::Dependency
34
+ name: tod
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '2.2'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '2.2'
47
+ - !ruby/object:Gem::Dependency
48
+ name: minitest
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '5.13'
54
+ - - "<"
55
+ - !ruby/object:Gem::Version
56
+ version: '5.14'
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '5.13'
64
+ - - "<"
65
+ - !ruby/object:Gem::Version
66
+ version: '5.14'
67
+ description:
68
+ email:
69
+ - awang@hellobase.com
70
+ executables: []
71
+ extensions: []
72
+ extra_rdoc_files: []
73
+ files:
74
+ - MIT-LICENSE
75
+ - lib/hellobase.rb
76
+ - lib/hellobase/date_creation.rb
77
+ - lib/hellobase/datetime_creation.rb
78
+ - lib/hellobase/divide_by_zero.rb
79
+ - lib/hellobase/time_creation.rb
80
+ - lib/hellobase/version.rb
81
+ homepage:
82
+ licenses: []
83
+ metadata: {}
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 2.7.10
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: Ruby runtime environment for Hellobase
104
+ test_files: []