canada 0.0.1 → 0.0.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
  SHA1:
3
- metadata.gz: a3318175d31eafd3fd8396391072a3e283b925c8
4
- data.tar.gz: 578bb1206226e579cdcf50fe13970a83398dff54
3
+ metadata.gz: 0f2804cc192f2768996a53201950ede6b51ca617
4
+ data.tar.gz: 5e0ef95b37b86da47626fdf502842734f8af9acf
5
5
  SHA512:
6
- metadata.gz: f6baff8a4a2e9527578fc7cbf6b4d7628f6a80d0439ed6c3e014dce0e4ec648bc7764938c59578fc89c07dc67b225e8eb12cd92f293efe942ca0d82e4003e8ae
7
- data.tar.gz: cf4a58b4fa4ca231eca31a9aca07531ad53aee95a4f951f377f9045fee2da328faf9b1f6e6632e47385d50f716befbc0d79413e49f633f537a635ed51b42cf9b
6
+ metadata.gz: d109bf6159a1925e6a3056f4fb1ed2339c7df6653b334dda91023cd14294f64d30a691bd860ecbc96e14ecf1f8344d83fbc02e7cafbef6f79ca21aa648ba2a18
7
+ data.tar.gz: 9fb080a74ffe0708ad6b6670c97569cb19fdc5821e9b2df4ec5d29b52babbe9578e54ea3b3dc51af5822eab91bcaa38212faba4f0513fe2184e25b225431a001
data/README.md CHANGED
@@ -15,6 +15,10 @@ It's well known that we have [different conventions](http://programmers.stackexc
15
15
  => true
16
16
  >> aboot Object.new
17
17
  => "#<Object:0x007f802b8b92c0>"
18
+ >> raise "something went wrong..."
19
+ RuntimeError: I'm sorry, but something went wrong...
20
+ from (irb):6
21
+ from /Users/godfrey/.rvm/rubies/ruby-2.0.0-p195/bin/irb:16:in `<main>'
18
22
  ```
19
23
 
20
24
  Cool, eh?
@@ -23,9 +27,9 @@ Cool, eh?
23
27
 
24
28
  Yes.
25
29
 
26
- ## What about performacne?
30
+ ## What about performance?
27
31
 
28
- We tuned the gem's performacne so that it's inline with everything else in Canada.
32
+ We hand-tuned the gem's performance to keep it in line with everything else in Canada.
29
33
 
30
34
  ## Installation
31
35
 
@@ -48,3 +52,7 @@ Or install it yourself as:
48
52
  3. Commit your changes (`git commit -am 'Add some feature'`)
49
53
  4. Push to the branch (`git push origin my-new-feature`)
50
54
  5. Create new Pull Request
55
+
56
+ ## Product of Canada
57
+
58
+ This gem is a 100% Canadian product. We hack on open-source projects like this every other Tuesday at [#VANRUBY](http://vanruby.org). If you would like to join us, check out our [meetup page](http://www.meetup.com/vancouver-ruby/) for details.
@@ -1,27 +1,39 @@
1
1
  require "canada/version"
2
2
 
3
- class Object
4
- EH_METHOD_REGEXP = /\A(?<method_name>.+)_eh\?\z/
3
+ module Canada
4
+ module ObjectExtensions
5
+ EH_METHOD_REGEXP = /\A(?<method_name>.+)_eh\?\z/
5
6
 
6
- def respond_to?(meth, include_private = false)
7
- if (m = EH_METHOD_REGEXP.match(meth))
8
- super || super("#{m[:method_name]}?", include_private)
9
- else
10
- super
7
+ def respond_to_missing?(meth, include_all = false)
8
+ if (m = EH_METHOD_REGEXP.match(meth))
9
+ super || self.respond_to?("#{m[:method_name]}?", include_all)
10
+ else
11
+ super
12
+ end
13
+ end
14
+
15
+ def method_missing(meth, *args, &block)
16
+ if (m = EH_METHOD_REGEXP.match(meth))
17
+ self.public_send("#{m[:method_name]}?", *args, &block)
18
+ else
19
+ super
20
+ end
11
21
  end
12
22
  end
13
23
 
14
- def method_missing(meth, *args, &block)
15
- if (m = EH_METHOD_REGEXP.match(meth))
16
- self.public_send("#{m[:method_name]}?", *args, &block)
17
- else
18
- super
24
+ ::Object.send(:include, ObjectExtensions)
25
+
26
+ module ExceptionExtensions
27
+ def to_s
28
+ "I'm sorry, but #{super}"
19
29
  end
20
30
  end
21
- end
22
31
 
23
- module Kernel
24
- def aboot(obj)
25
- obj.inspect
32
+ ::Exception.send(:prepend, ExceptionExtensions)
33
+
34
+ module ::Kernel
35
+ def aboot(obj)
36
+ obj.inspect
37
+ end
26
38
  end
27
39
  end
@@ -1,3 +1,3 @@
1
1
  module Canada
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -37,4 +37,9 @@ class CanadaTest < MiniTest::Test
37
37
 
38
38
  cases.each { |c| assert_equal c.inspect, aboot(c) }
39
39
  end
40
+
41
+ def test_exceptions_to_s
42
+ assert_equal "I'm sorry, but something went wrong...", Exception.new("something went wrong...").to_s
43
+ assert_equal "I'm sorry, but something went wrong...", Exception.new("something went wrong...").message
44
+ end
40
45
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canada
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Godfrey Chan