types 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data/lib/types/any.rb +87 -0
- data/lib/types/array.rb +70 -0
- data/lib/types/block.rb +53 -0
- data/lib/types/boolean.rb +39 -0
- data/lib/types/class.rb +68 -0
- data/lib/types/decimal.rb +40 -0
- data/lib/types/float.rb +33 -0
- data/lib/types/generic.rb +43 -0
- data/lib/types/hash.rb +67 -0
- data/lib/types/integer.rb +33 -0
- data/lib/types/lambda.rb +65 -0
- data/lib/types/method.rb +77 -0
- data/lib/types/nil.rb +37 -0
- data/lib/types/numeric.rb +37 -0
- data/lib/types/string.rb +33 -0
- data/lib/types/symbol.rb +33 -0
- data/lib/types/tuple.rb +69 -0
- data/lib/types/version.rb +25 -0
- data/lib/types.rb +48 -126
- data.tar.gz.sig +2 -0
- metadata +77 -105
- metadata.gz.sig +0 -0
- data/.document +0 -5
- data/Gemfile +0 -11
- data/Gemfile.lock +0 -18
- data/LICENSE.txt +0 -20
- data/README.md +0 -52
- data/Rakefile +0 -37
- data/VERSION +0 -1
- data/types.gemspec +0 -54
data/README.md
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
Ruby Types
|
2
|
-
==========
|
3
|
-
|
4
|
-
**Ruby Types** introduces *group of classes* as eqivalent to some data
|
5
|
-
types in other languages such as `boolean` and allows introspection
|
6
|
-
according to type of class too. In fact, partially replaces multiple
|
7
|
-
inheritance because introduces unlimited formal genericity for every
|
8
|
-
class.
|
9
|
-
|
10
|
-
For example define:
|
11
|
-
|
12
|
-
class Boolean < Type
|
13
|
-
def type_classes
|
14
|
-
[TrueClass, FalseClass]
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
Then you can call:
|
19
|
-
|
20
|
-
foo = 5
|
21
|
-
bar = true
|
22
|
-
|
23
|
-
foo.type_of? Boolean # returns false
|
24
|
-
bar.type_of? Boolean # returns true
|
25
|
-
|
26
|
-
Binding back to classic behaviour works:
|
27
|
-
|
28
|
-
foo.type_of? Numeric # returns true
|
29
|
-
|
30
|
-
By overriding `#type_types` method of the `Type` class you can achieve
|
31
|
-
also types inheritance by the same way as mentioned above.
|
32
|
-
|
33
|
-
|
34
|
-
Contributing
|
35
|
-
------------
|
36
|
-
|
37
|
-
1. Fork it.
|
38
|
-
2. Create a branch (`git checkout -b 20101220-my-change`).
|
39
|
-
3. Commit your changes (`git commit -am "Added something"`).
|
40
|
-
4. Push to the branch (`git push origin 20101220-my-change`).
|
41
|
-
5. Create an [Issue][1] with a link to your branch.
|
42
|
-
6. Enjoy a refreshing Diet Coke and wait.
|
43
|
-
|
44
|
-
|
45
|
-
Copyright
|
46
|
-
---------
|
47
|
-
|
48
|
-
Copyright © 2011 [Martin Kozák][2]. See `LICENSE.txt` for
|
49
|
-
further details.
|
50
|
-
|
51
|
-
[1]: http://github.com/martinkozak/types/issues
|
52
|
-
[2]: http://www.martinkozak.net/
|
data/Rakefile
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'rubygems'
|
3
|
-
require 'bundler'
|
4
|
-
begin
|
5
|
-
Bundler.setup(:default, :development)
|
6
|
-
rescue Bundler::BundlerError => e
|
7
|
-
$stderr.puts e.message
|
8
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
9
|
-
exit e.status_code
|
10
|
-
end
|
11
|
-
require 'rake'
|
12
|
-
|
13
|
-
require 'jeweler'
|
14
|
-
Jeweler::Tasks.new do |gem|
|
15
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
16
|
-
gem.name = "types"
|
17
|
-
gem.homepage = "http://github.com/martinkozak/types"
|
18
|
-
gem.license = "MIT"
|
19
|
-
gem.summary = 'Introduces group of classes as eqivalent to some data types in other languages such as boolean and allows introspection according to type of class too. In fact, partially replaces multiple inheritance because introduces unlimited formal genericity for every class.'
|
20
|
-
gem.email = "martinkozak@martinkozak.net"
|
21
|
-
gem.authors = ["Martin Kozák"]
|
22
|
-
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
|
-
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
|
-
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
25
|
-
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
26
|
-
end
|
27
|
-
Jeweler::RubygemsDotOrgTasks.new
|
28
|
-
|
29
|
-
require 'rake/rdoctask'
|
30
|
-
Rake::RDocTask.new do |rdoc|
|
31
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
32
|
-
|
33
|
-
rdoc.rdoc_dir = 'rdoc'
|
34
|
-
rdoc.title = "types #{version}"
|
35
|
-
rdoc.rdoc_files.include('README*')
|
36
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
37
|
-
end
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.1
|
data/types.gemspec
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{types}
|
8
|
-
s.version = "0.1.1"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Martin Kozák"]
|
12
|
-
s.date = %q{2011-01-19}
|
13
|
-
s.email = %q{martinkozak@martinkozak.net}
|
14
|
-
s.extra_rdoc_files = [
|
15
|
-
"LICENSE.txt",
|
16
|
-
"README.md"
|
17
|
-
]
|
18
|
-
s.files = [
|
19
|
-
".document",
|
20
|
-
"Gemfile",
|
21
|
-
"Gemfile.lock",
|
22
|
-
"LICENSE.txt",
|
23
|
-
"README.md",
|
24
|
-
"Rakefile",
|
25
|
-
"VERSION",
|
26
|
-
"lib/types.rb",
|
27
|
-
"types.gemspec"
|
28
|
-
]
|
29
|
-
s.homepage = %q{http://github.com/martinkozak/types}
|
30
|
-
s.licenses = ["MIT"]
|
31
|
-
s.require_paths = ["lib"]
|
32
|
-
s.rubygems_version = %q{1.3.7}
|
33
|
-
s.summary = %q{Introduces group of classes as eqivalent to some data types in other languages such as boolean and allows introspection according to type of class too. In fact, partially replaces multiple inheritance because introduces unlimited formal genericity for every class.}
|
34
|
-
|
35
|
-
if s.respond_to? :specification_version then
|
36
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
37
|
-
s.specification_version = 3
|
38
|
-
|
39
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
40
|
-
s.add_runtime_dependency(%q<multitype-introspection>, [">= 0.1.0"])
|
41
|
-
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
42
|
-
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
43
|
-
else
|
44
|
-
s.add_dependency(%q<multitype-introspection>, [">= 0.1.0"])
|
45
|
-
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
46
|
-
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
47
|
-
end
|
48
|
-
else
|
49
|
-
s.add_dependency(%q<multitype-introspection>, [">= 0.1.0"])
|
50
|
-
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
51
|
-
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|