aa 1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +24 -0
- data/lib/aa.rb +31 -0
- data/spec/aa_spec.rb +38 -0
- metadata +65 -0
data/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# Aa
|
2
|
+
|
3
|
+
class Beer; end
|
4
|
+
|
5
|
+
a.beer
|
6
|
+
# equivalent to Beer.new
|
7
|
+
|
8
|
+
x = a.beer
|
9
|
+
the.beer
|
10
|
+
# equivalent to x
|
11
|
+
|
12
|
+
class Animal; end
|
13
|
+
|
14
|
+
an.animal
|
15
|
+
# equivalent to Animal.new
|
16
|
+
|
17
|
+
## Install
|
18
|
+
|
19
|
+
$ gem install aa
|
20
|
+
|
21
|
+
## Author
|
22
|
+
|
23
|
+
Tatsuhiro Ujihisa
|
24
|
+
<http:/ujihisa.blogspot.com>
|
data/lib/aa.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
class Aa
|
2
|
+
@@latests = {}
|
3
|
+
|
4
|
+
def method_missing(name, *args, &block)
|
5
|
+
super if !args.empty? || block
|
6
|
+
@@latests[name] = self.class.const_get(name.to_s.capitalize).new
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.the(x)
|
10
|
+
@@latests[x]
|
11
|
+
end
|
12
|
+
|
13
|
+
class The
|
14
|
+
def method_missing(name, *args, &block)
|
15
|
+
super if !args.empty? || block
|
16
|
+
A.the(name)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def a
|
22
|
+
Aa.new
|
23
|
+
end
|
24
|
+
|
25
|
+
def an
|
26
|
+
Aa.new
|
27
|
+
end
|
28
|
+
|
29
|
+
def the
|
30
|
+
Aa::The.new
|
31
|
+
end
|
data/spec/aa_spec.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative '../lib/aa'
|
2
|
+
|
3
|
+
context 'Global methods generated by Aa library' do
|
4
|
+
before do
|
5
|
+
class Beer; end
|
6
|
+
end
|
7
|
+
|
8
|
+
describe 'a.beer' do
|
9
|
+
it 'creates an instance of Beer' do
|
10
|
+
a.beer.should be_an_instance_of Beer
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'is different to the one created in the past trial' do
|
14
|
+
x = a.beer
|
15
|
+
y = a.beer
|
16
|
+
x.should_not equal y
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'an.beer' do
|
21
|
+
it 'is equivalent to use a.beer' do
|
22
|
+
an.beer.should be_an_instance_of Beer
|
23
|
+
|
24
|
+
x = an.beer
|
25
|
+
y = an.beer
|
26
|
+
x.should_not equal y
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'the.beer' do
|
31
|
+
it 'is the beer of the latest on you created by a.beer' do
|
32
|
+
x = a.beer
|
33
|
+
y = a.beer
|
34
|
+
the.beer.should_not equal x
|
35
|
+
the.beer.should equal y
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: aa
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
version: "1.0"
|
9
|
+
platform: ruby
|
10
|
+
authors:
|
11
|
+
- ujihisa
|
12
|
+
autorequire:
|
13
|
+
bindir: bin
|
14
|
+
cert_chain: []
|
15
|
+
|
16
|
+
date: 2010-08-05 00:00:00 -07:00
|
17
|
+
default_executable:
|
18
|
+
dependencies: []
|
19
|
+
|
20
|
+
description: Aa
|
21
|
+
email: ujihisa at gmail.com
|
22
|
+
executables: []
|
23
|
+
|
24
|
+
extensions: []
|
25
|
+
|
26
|
+
extra_rdoc_files:
|
27
|
+
- README.md
|
28
|
+
files:
|
29
|
+
- lib/aa.rb
|
30
|
+
- README.md
|
31
|
+
- spec/aa_spec.rb
|
32
|
+
has_rdoc: true
|
33
|
+
homepage: https://github.com/ujihisa/aa
|
34
|
+
licenses: []
|
35
|
+
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
|
39
|
+
require_paths:
|
40
|
+
- lib
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
version: "0"
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
requirements: []
|
58
|
+
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 1.3.7
|
61
|
+
signing_key:
|
62
|
+
specification_version: 3
|
63
|
+
summary: Aa
|
64
|
+
test_files: []
|
65
|
+
|