hellobase 0.1.0 → 0.1.1

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: 798908bb2b7735772d7100ce87932279a23f4d5cbf8c74134f9992c45de401ca
4
- data.tar.gz: 9d7bfcb9651d552b5559b26872c63cb129cbcea1932db30fb172edbaa2c511d5
3
+ metadata.gz: c20deb43b88203e9d604ab4e2d2ead00bf82827b46a314227b39db47ef97a2f4
4
+ data.tar.gz: 6defacad19d9f964029239d717eae54cff49a875a73821b24f9d7073a9e01343
5
5
  SHA512:
6
- metadata.gz: 6ad3bcf71449db59ae76449a58670b968ee8f6747374b3c8c0b0238e1313e42b4a739b5be225365e91989497eb6731d3c2f35e9ffa0a1c387b5e32d3410fa0d0
7
- data.tar.gz: c4ff400d7e30542f5ff53302793c65e272ca4ac78beee5393c2755cee3d8982040459dea8454b55d5c9eeac271d380e89109d999ae411d21146547a8bd8664ce
6
+ metadata.gz: 745fd0ef44520341de21921343a01f3226d537956fa1ec21b4534af9225d9adc7de94b475b8f31dca136321fb44bd1b95125640a9c93516c147f76e13b4c2630
7
+ data.tar.gz: 8a397f78ae1b1f11806485cd43741f6978f772d0a8f33a3cb3c7aaaeb976e7dbb45fc6261ac9d548e9f69f860129e0b535a2ed818a5a2634a099debb5071ec7b
@@ -1,19 +1,21 @@
1
- class Date
2
- def self.hb_parse(string)
3
- raise Error.new(:date_parse, string) unless string =~ Hellobase::DATE_FORMAT
1
+ Date.singleton_class.prepend(
2
+ Module.new do
3
+ def parse(string)
4
+ raise Hellobase::Error.new(:date_parse, string) unless string =~ Hellobase::DATE_FORMAT
4
5
 
5
- begin
6
- parse(string)
7
- rescue ArgumentError
8
- raise Error.new(:date_parse, string)
6
+ begin
7
+ super
8
+ rescue ArgumentError
9
+ raise Hellobase::Error.new(:date_parse, string)
10
+ end
9
11
  end
10
- end
11
12
 
12
- def self.hb_new(*args)
13
- begin
14
- new(*args)
15
- rescue ArgumentError
16
- raise Error.new(:date_new, string)
13
+ def new(*args)
14
+ begin
15
+ super
16
+ rescue ArgumentError
17
+ raise Hellobase::Error.new(:date_new, *args)
18
+ end
17
19
  end
18
20
  end
19
- end
21
+ )
@@ -1,19 +1,21 @@
1
- class DateTime
2
- def self.hb_parse(string)
3
- raise Error.new(:datetime_parse, string) unless string =~ Hellobase::DATETIME_FORMAT
1
+ DateTime.singleton_class.prepend(
2
+ Module.new do
3
+ def parse(string)
4
+ raise Hellobase::Error.new(:datetime_parse, string) unless string =~ Hellobase::DATETIME_FORMAT
4
5
 
5
- begin
6
- parse(string)
7
- rescue ArgumentError
8
- raise Error.new(:datetime_parse, string)
6
+ begin
7
+ super
8
+ rescue ArgumentError
9
+ raise Hellobase::Error.new(:datetime_parse, string)
10
+ end
9
11
  end
10
- end
11
12
 
12
- def self.hb_new(*args)
13
- begin
14
- new(*args)
15
- rescue ArgumentError
16
- raise Error.new(:datetime_new, string)
13
+ def new(*args)
14
+ begin
15
+ super
16
+ rescue ArgumentError
17
+ raise Hellobase::Error.new(:datetime_new, *args)
18
+ end
17
19
  end
18
20
  end
19
- end
21
+ )
@@ -1,21 +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
1
+ Tod::TimeOfDay.singleton_class.prepend(
2
+ Module.new do
3
+ def parse(string)
4
+ raise Hellobase::Error.new(:time_parse, string) unless string =~ Hellobase::TIME_FORMAT
5
5
 
6
6
  begin
7
- parse(string)
7
+ super
8
8
  rescue ArgumentError
9
- raise Error.new(:time_parse, string)
9
+ raise Hellobase::Error.new(:time_parse, string)
10
10
  end
11
11
  end
12
12
 
13
- def self.hb_new(*args)
13
+ def new(*args)
14
14
  begin
15
- new(*args)
15
+ super
16
16
  rescue ArgumentError
17
- raise Error.new(:time_new, string)
17
+ raise Hellobase::Error.new(:time_new, *args)
18
18
  end
19
19
  end
20
20
  end
21
- end
21
+ )
@@ -1,3 +1,3 @@
1
1
  module Hellobase
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
data/lib/hellobase.rb CHANGED
@@ -16,6 +16,8 @@ module Hellobase
16
16
  DATETIME_FORMAT = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/
17
17
 
18
18
  class Error < StandardError
19
+ attr_reader :type
20
+
19
21
  def initialize(type, *args)
20
22
  @type = type
21
23
  @args = args
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.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Wang
@@ -64,6 +64,20 @@ dependencies:
64
64
  - - "<"
65
65
  - !ruby/object:Gem::Version
66
66
  version: '5.14'
67
+ - !ruby/object:Gem::Dependency
68
+ name: warning
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '1.0'
74
+ type: :development
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: '1.0'
67
81
  description:
68
82
  email:
69
83
  - awang@hellobase.com