canada 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +50 -0
- data/Rakefile +12 -0
- data/canada.gemspec +23 -0
- data/canada.png +0 -0
- data/lib/canada.rb +27 -0
- data/lib/canada/version.rb +3 -0
- data/test/canada_test.rb +40 -0
- data/test/minitest_helper.rb +3 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a3318175d31eafd3fd8396391072a3e283b925c8
|
4
|
+
data.tar.gz: 578bb1206226e579cdcf50fe13970a83398dff54
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f6baff8a4a2e9527578fc7cbf6b4d7628f6a80d0439ed6c3e014dce0e4ec648bc7764938c59578fc89c07dc67b225e8eb12cd92f293efe942ca0d82e4003e8ae
|
7
|
+
data.tar.gz: cf4a58b4fa4ca231eca31a9aca07531ad53aee95a4f951f377f9045fee2da328faf9b1f6e6632e47385d50f716befbc0d79413e49f633f537a635ed51b42cf9b
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Godfrey Chan
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Canada
|
2
|
+
|
3
|
+
![Canadian flag](https://raw.github.com/vanruby/canada/master/canada.png)
|
4
|
+
|
5
|
+
It's well known that we have [different conventions](http://programmers.stackexchange.com/questions/1483/do-people-in-non-english-speaking-countries-code-in-english#answer-5576) for programming in Canada. This gem attempts to make life easier for Canadian Rubyists by integrating these conventions into the Ruby language:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
>> require 'canada'
|
9
|
+
=> true
|
10
|
+
>> [].empty_eh?
|
11
|
+
=> true
|
12
|
+
>> [1,2,3].empty_eh?
|
13
|
+
=> false
|
14
|
+
>> [].respond_to_eh?(:empty_eh?)
|
15
|
+
=> true
|
16
|
+
>> aboot Object.new
|
17
|
+
=> "#<Object:0x007f802b8b92c0>"
|
18
|
+
```
|
19
|
+
|
20
|
+
Cool, eh?
|
21
|
+
|
22
|
+
## Production Ready™, eh?
|
23
|
+
|
24
|
+
Yes.
|
25
|
+
|
26
|
+
## What about performacne?
|
27
|
+
|
28
|
+
We tuned the gem's performacne so that it's inline with everything else in Canada.
|
29
|
+
|
30
|
+
## Installation
|
31
|
+
|
32
|
+
Add this line to your application's Gemfile:
|
33
|
+
|
34
|
+
gem 'canada'
|
35
|
+
|
36
|
+
And then execute:
|
37
|
+
|
38
|
+
$ bundle
|
39
|
+
|
40
|
+
Or install it yourself as:
|
41
|
+
|
42
|
+
$ gem install canada
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
1. Fork it
|
47
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
48
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
49
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
50
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/canada.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'canada/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "canada"
|
8
|
+
spec.version = Canada::VERSION
|
9
|
+
spec.authors = ["Godfrey Chan"]
|
10
|
+
spec.email = ["godfreykfc@gmail.com"]
|
11
|
+
spec.description = %q{Adds support for Canadian programming conventions to the Ruby language}
|
12
|
+
spec.summary = %q{[1,2,3].empty_eh? # => false}
|
13
|
+
spec.homepage = "https://github.com/vanruby/canada"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
data/canada.png
ADDED
Binary file
|
data/lib/canada.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require "canada/version"
|
2
|
+
|
3
|
+
class Object
|
4
|
+
EH_METHOD_REGEXP = /\A(?<method_name>.+)_eh\?\z/
|
5
|
+
|
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
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
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
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
module Kernel
|
24
|
+
def aboot(obj)
|
25
|
+
obj.inspect
|
26
|
+
end
|
27
|
+
end
|
data/test/canada_test.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
require 'canada'
|
3
|
+
|
4
|
+
class CanadaTest < MiniTest::Test
|
5
|
+
def test_eh?
|
6
|
+
assert [].empty_eh?
|
7
|
+
refute [1,2,3].empty_eh?
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_respond_to_eh?
|
11
|
+
yes = [:empty?, :empty_eh?, :respond_to?, :respond_to_eh?]
|
12
|
+
no = [:not_there, :not_there?, :not_there_eh, :not_there_eh?]
|
13
|
+
|
14
|
+
yes.each { |y| assert([].respond_to_eh?(y), "Array should respond_to_eh? #{y}") }
|
15
|
+
no.each { |n| refute([].respond_to_eh?(n), "Array should not respond_to_eh? #{n}") }
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_respond_to?
|
19
|
+
yes = [:empty?, :empty_eh?, :respond_to?, :respond_to_eh?]
|
20
|
+
no = [:not_there, :not_there?, :not_there_eh, :not_there_eh?]
|
21
|
+
|
22
|
+
yes.each { |y| assert([].respond_to?(y), "Array should respond_to_eh? #{y}") }
|
23
|
+
no.each { |n| refute([].respond_to?(n), "Array should not respond_to_eh? #{n}") }
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_aboot
|
27
|
+
cases = [
|
28
|
+
[],
|
29
|
+
[1,2,3],
|
30
|
+
{},
|
31
|
+
{a: 1, b: 2},
|
32
|
+
Object.new,
|
33
|
+
true,
|
34
|
+
false,
|
35
|
+
nil
|
36
|
+
]
|
37
|
+
|
38
|
+
cases.each { |c| assert_equal c.inspect, aboot(c) }
|
39
|
+
end
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: canada
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Godfrey Chan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Adds support for Canadian programming conventions to the Ruby language
|
42
|
+
email:
|
43
|
+
- godfreykfc@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- canada.gemspec
|
54
|
+
- canada.png
|
55
|
+
- lib/canada.rb
|
56
|
+
- lib/canada/version.rb
|
57
|
+
- test/canada_test.rb
|
58
|
+
- test/minitest_helper.rb
|
59
|
+
homepage: https://github.com/vanruby/canada
|
60
|
+
licenses:
|
61
|
+
- MIT
|
62
|
+
metadata: {}
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 2.0.3
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: '[1,2,3].empty_eh? # => false'
|
83
|
+
test_files:
|
84
|
+
- test/canada_test.rb
|
85
|
+
- test/minitest_helper.rb
|