multitype-introspection 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "bundler", "~> 1.0.0"
10
+ gem "jeweler", "~> 1.5.2"
11
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,16 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jeweler (1.5.2)
6
+ bundler (~> 1.0.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rake (0.8.7)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ bundler (~> 1.0.0)
16
+ jeweler (~> 1.5.2)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Martin Kozák
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ Multitype Introspection
2
+ =======================
3
+
4
+ **Multitype Introspection** allows multiple type introspection. Extends
5
+ the [Object][1] class with following methods:
6
+
7
+ * [#kind_of_any?][2]
8
+ * [#is_a_any?][3]
9
+ * [#instance_of_any][4]
10
+
11
+ Aim of these is probably evident -- they are equivalent of appropriate
12
+ methods without `any` suffix, but for multiple classes. An example of
13
+ use:
14
+
15
+ foo = "some string"
16
+ bar = :symbol
17
+ alfa = SomeClass::new
18
+
19
+ foo.kind_of_any? [String, Symbol] # returns true
20
+ bar.kind_of_any? [String, Symbol] # also returns true
21
+ alfa.kind_of_any? [String, Symbol] # returns false
22
+
23
+ Contributing
24
+ ------------
25
+
26
+ 1. Fork it.
27
+ 2. Create a branch (`git checkout -b 20101220-my-change`).
28
+ 3. Commit your changes (`git commit -am "Added something"`).
29
+ 4. Push to the branch (`git push origin 20101220-my-change`).
30
+ 5. Create an [Issue][5] with a link to your branch.
31
+ 6. Enjoy a refreshing Diet Coke and wait.
32
+
33
+
34
+ Copyright
35
+ ---------
36
+
37
+ Copyright (c) 2011 [Martin Kozák][6]. See `LICENSE.txt` for
38
+ further details.
39
+
40
+ [1]: http://www.ruby-doc.org/core/classes/Object.html
41
+ [2]: http://www.ruby-doc.org/core/classes/Object.html#M000372
42
+ [3]: http://www.ruby-doc.org/core/classes/Object.html#M000373
43
+ [4]: http://www.ruby-doc.org/core/classes/Object.html#M000371
44
+ [5]: http://github.com/martinkozak/multitype-introspection/issues
45
+ [6]: http://www.martinkozak.net/
data/Rakefile ADDED
@@ -0,0 +1,37 @@
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 = "multitype-introspection"
17
+ gem.homepage = "http://github.com/martinkozak/multitype-introspection"
18
+ gem.license = "MIT"
19
+ gem.summary = 'Allows multiple type introspection. Extends the Object class with #kind_of_any? and other appropriate methods of this family.'
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 = "multitype-introspection #{version}"
35
+ rdoc.rdoc_files.include('README*')
36
+ rdoc.rdoc_files.include('lib/**/*.rb')
37
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,47 @@
1
+ # encoding: utf-8
2
+ # (c) 2011 Martin Kozák (martinkozak@martinkozak.net)
3
+
4
+ class Object
5
+
6
+ ##
7
+ # Returns <tt>true</tt> if obj is an instance of the given classes.
8
+ # See also Object#kind_of_any?.
9
+ #
10
+
11
+ def instance_of_any?(classes)
12
+ if not classes.kind_of? Array
13
+ raise Exception::new("Array expected.")
14
+ end
15
+
16
+ classes.each do |cls|
17
+ if self.instance_of? cls
18
+ return true
19
+ end
20
+ end
21
+
22
+ return false
23
+ end
24
+
25
+ ##
26
+ # Returns <tt>true</tt> if one of classes are the class of obj, or
27
+ # if one of classes are one of the superclasses of obj or modules
28
+ # included in obj.
29
+ #
30
+
31
+ def kind_of_any?(classes)
32
+ if not classes.kind_of? Array
33
+ raise Exception::new("Array expected.")
34
+ end
35
+
36
+ classes.each do |cls|
37
+ if self.kind_of? cls
38
+ return true
39
+ end
40
+ end
41
+
42
+ return false
43
+ end
44
+
45
+ alias :"is_a_any?" :"kind_of_any?"
46
+
47
+ end
@@ -0,0 +1,51 @@
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{multitype-introspection}
8
+ s.version = "0.1.0"
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-01}
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/multitype-introspection.rb",
27
+ "multitype-introspection.gemspec"
28
+ ]
29
+ s.homepage = %q{http://github.com/martinkozak/multitype-introspection}
30
+ s.licenses = ["MIT"]
31
+ s.require_paths = ["lib"]
32
+ s.rubygems_version = %q{1.3.7}
33
+ s.summary = %q{Allows multiple type introspection. Extends the Object class with #kind_of_any? and other appropriate methods of this family.}
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_development_dependency(%q<bundler>, ["~> 1.0.0"])
41
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
42
+ else
43
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
44
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
45
+ end
46
+ else
47
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
48
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
49
+ end
50
+ end
51
+
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: multitype-introspection
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - "Martin Koz\xC3\xA1k"
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-01-01 00:00:00 +01:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: bundler
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 0
30
+ - 0
31
+ version: 1.0.0
32
+ type: :development
33
+ prerelease: false
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: jeweler
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ segments:
43
+ - 1
44
+ - 5
45
+ - 2
46
+ version: 1.5.2
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: *id002
50
+ description:
51
+ email: martinkozak@martinkozak.net
52
+ executables: []
53
+
54
+ extensions: []
55
+
56
+ extra_rdoc_files:
57
+ - LICENSE.txt
58
+ - README.md
59
+ files:
60
+ - .document
61
+ - Gemfile
62
+ - Gemfile.lock
63
+ - LICENSE.txt
64
+ - README.md
65
+ - Rakefile
66
+ - VERSION
67
+ - lib/multitype-introspection.rb
68
+ - multitype-introspection.gemspec
69
+ has_rdoc: true
70
+ homepage: http://github.com/martinkozak/multitype-introspection
71
+ licenses:
72
+ - MIT
73
+ post_install_message:
74
+ rdoc_options: []
75
+
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ hash: -701154833876006788
84
+ segments:
85
+ - 0
86
+ version: "0"
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ requirements: []
96
+
97
+ rubyforge_project:
98
+ rubygems_version: 1.3.7
99
+ signing_key:
100
+ specification_version: 3
101
+ summary: "Allows multiple type introspection. Extends the Object class with #kind_of_any? and other appropriate methods of this family."
102
+ test_files: []
103
+