hellobase 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hellobase/array_index.rb +9 -0
- data/lib/hellobase/date_creation.rb +3 -3
- data/lib/hellobase/datetime_creation.rb +3 -3
- data/lib/hellobase/time_creation.rb +3 -3
- data/lib/hellobase/version.rb +1 -1
- data/lib/hellobase.rb +5 -3
- metadata +4 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3582720f27ecdb616e05b23036ea46c292ff4fbfb76571f2ea812d72b8e317c7
|
4
|
+
data.tar.gz: 887553284b96cf0a8b6b8b42e86261dc436a739c6660bf37095944a7159ccfa2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 971b8b131879deef0ae9b667a730d17059d64560524019edd313f3e1d8a3d2cb9ab33183c91781ae8ad108ceef61c5d5b160eaddc4f801dfdd56ddfe92255b15
|
7
|
+
data.tar.gz: 642626d5e88e24a377e46dbb3f49098be9cda15b2046461f11252340f3e63454d8e897fc6735571deed29753aa35665a44af23f3b1296be9795b9f30dd23fb2a
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class Array
|
2
|
+
def hb_elem(hb_index)
|
3
|
+
raise Hellobase::Error.new(:array_index, self, hb_index) if hb_index == 0
|
4
|
+
index = hb_index > 0 ? hb_index - 1 : hb_index
|
5
|
+
|
6
|
+
raise Hellobase::Error.new(:array_index, self, hb_index) if (index >= 0 && index > length - 1) || (index < 0 && (-1 * index > length))
|
7
|
+
self[index]
|
8
|
+
end
|
9
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
Date.singleton_class.prepend(
|
2
2
|
Module.new do
|
3
3
|
def parse(string)
|
4
|
-
raise Hellobase::Error.new(:date_parse, string) unless string =~ Hellobase::DATE_FORMAT
|
4
|
+
raise Hellobase::Error.new(:date_parse, nil, string) unless string =~ Hellobase::DATE_FORMAT
|
5
5
|
|
6
6
|
begin
|
7
7
|
super
|
8
8
|
rescue ArgumentError
|
9
|
-
raise Hellobase::Error.new(:date_parse, string)
|
9
|
+
raise Hellobase::Error.new(:date_parse, nil, string)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -14,7 +14,7 @@ Date.singleton_class.prepend(
|
|
14
14
|
begin
|
15
15
|
super
|
16
16
|
rescue ArgumentError
|
17
|
-
raise Hellobase::Error.new(:date_new, *args)
|
17
|
+
raise Hellobase::Error.new(:date_new, nil, *args)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
DateTime.singleton_class.prepend(
|
2
2
|
Module.new do
|
3
3
|
def parse(string)
|
4
|
-
raise Hellobase::Error.new(:datetime_parse, string) unless string =~ Hellobase::DATETIME_FORMAT
|
4
|
+
raise Hellobase::Error.new(:datetime_parse, nil, string) unless string =~ Hellobase::DATETIME_FORMAT
|
5
5
|
|
6
6
|
begin
|
7
7
|
super
|
8
8
|
rescue ArgumentError
|
9
|
-
raise Hellobase::Error.new(:datetime_parse, string)
|
9
|
+
raise Hellobase::Error.new(:datetime_parse, nil, string)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -14,7 +14,7 @@ DateTime.singleton_class.prepend(
|
|
14
14
|
begin
|
15
15
|
super
|
16
16
|
rescue ArgumentError
|
17
|
-
raise Hellobase::Error.new(:datetime_new, *args)
|
17
|
+
raise Hellobase::Error.new(:datetime_new, nil, *args)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
Tod::TimeOfDay.singleton_class.prepend(
|
2
2
|
Module.new do
|
3
3
|
def parse(string)
|
4
|
-
raise Hellobase::Error.new(:time_parse, string) unless string =~ Hellobase::TIME_FORMAT
|
4
|
+
raise Hellobase::Error.new(:time_parse, nil, string) unless string =~ Hellobase::TIME_FORMAT
|
5
5
|
|
6
6
|
begin
|
7
7
|
super
|
8
8
|
rescue ArgumentError
|
9
|
-
raise Hellobase::Error.new(:time_parse, string)
|
9
|
+
raise Hellobase::Error.new(:time_parse, nil, string)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -14,7 +14,7 @@ Tod::TimeOfDay.singleton_class.prepend(
|
|
14
14
|
begin
|
15
15
|
super
|
16
16
|
rescue ArgumentError
|
17
|
-
raise Hellobase::Error.new(:time_new, *args)
|
17
|
+
raise Hellobase::Error.new(:time_new, nil, *args)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
data/lib/hellobase/version.rb
CHANGED
data/lib/hellobase.rb
CHANGED
@@ -5,6 +5,7 @@ require 'active_support/core_ext/date_time'
|
|
5
5
|
require 'active_support/duration'
|
6
6
|
require 'tod'
|
7
7
|
|
8
|
+
require 'hellobase/array_index'
|
8
9
|
require 'hellobase/date_creation'
|
9
10
|
require 'hellobase/datetime_creation'
|
10
11
|
require 'hellobase/divide_by_zero'
|
@@ -16,13 +17,14 @@ module Hellobase
|
|
16
17
|
DATETIME_FORMAT = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/
|
17
18
|
|
18
19
|
class Error < StandardError
|
19
|
-
attr_reader :type
|
20
|
+
attr_reader :type, :object
|
20
21
|
|
21
|
-
def initialize(type, *args)
|
22
|
+
def initialize(type, object, *args)
|
22
23
|
@type = type
|
24
|
+
@object = object
|
23
25
|
@args = args
|
24
26
|
|
25
|
-
super "#{type}: #{args.inspect}"
|
27
|
+
super "#{type}: #{object.inspect}, #{args.inspect}"
|
26
28
|
end
|
27
29
|
end
|
28
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Wang
|
@@ -16,20 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 6.0
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 6.0.2.2
|
19
|
+
version: '6.0'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: 6.0
|
30
|
-
- - ">="
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 6.0.2.2
|
26
|
+
version: '6.0'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: tod
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,6 +81,7 @@ extra_rdoc_files: []
|
|
87
81
|
files:
|
88
82
|
- MIT-LICENSE
|
89
83
|
- lib/hellobase.rb
|
84
|
+
- lib/hellobase/array_index.rb
|
90
85
|
- lib/hellobase/date_creation.rb
|
91
86
|
- lib/hellobase/datetime_creation.rb
|
92
87
|
- lib/hellobase/divide_by_zero.rb
|