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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c20deb43b88203e9d604ab4e2d2ead00bf82827b46a314227b39db47ef97a2f4
4
- data.tar.gz: 6defacad19d9f964029239d717eae54cff49a875a73821b24f9d7073a9e01343
3
+ metadata.gz: 3582720f27ecdb616e05b23036ea46c292ff4fbfb76571f2ea812d72b8e317c7
4
+ data.tar.gz: 887553284b96cf0a8b6b8b42e86261dc436a739c6660bf37095944a7159ccfa2
5
5
  SHA512:
6
- metadata.gz: 745fd0ef44520341de21921343a01f3226d537956fa1ec21b4534af9225d9adc7de94b475b8f31dca136321fb44bd1b95125640a9c93516c147f76e13b4c2630
7
- data.tar.gz: 8a397f78ae1b1f11806485cd43741f6978f772d0a8f33a3cb3c7aaaeb976e7dbb45fc6261ac9d548e9f69f860129e0b535a2ed818a5a2634a099debb5071ec7b
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
@@ -1,3 +1,3 @@
1
1
  module Hellobase
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
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.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.2
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.2
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