what_methods 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
File without changes
data/README ADDED
@@ -0,0 +1,3 @@
1
+ README for what_methods
2
+ =======================
3
+
data/Rakefile ADDED
@@ -0,0 +1,79 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/clean'
4
+ require 'rake/packagetask'
5
+ require 'rake/gempackagetask'
6
+ require 'rake/rdoctask'
7
+ require 'rake/contrib/rubyforgepublisher'
8
+ require 'fileutils'
9
+ include FileUtils
10
+ require File.join(File.dirname(__FILE__), 'lib', 'what_methods', 'version')
11
+
12
+ AUTHOR = "you"
13
+ EMAIL = "your contact email for bug fixes and info"
14
+ DESCRIPTION = "description of gem"
15
+ HOMEPATH = 'http://what_methods.rubyforge.org'
16
+
17
+
18
+ NAME = "what_methods"
19
+ REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
20
+ VERS = ENV['VERSION'] || (WhatMethod::VERSION::STRING + (REV ? ".#{REV}" : ""))
21
+ CLEAN.include ['**/.*.sw?', '*.gem', '.config']
22
+ RDOC_OPTS = ['--quiet', '--title', "what_methods documentation",
23
+ "--opname", "index.html",
24
+ "--line-numbers",
25
+ "--main", "README",
26
+ "--inline-source"]
27
+ BIN_FILES = %w( )
28
+
29
+ desc "Packages up what_methods gem."
30
+ task :default => [:test]
31
+ task :package => [:clean]
32
+
33
+ task :test do
34
+ require File.dirname(__FILE__) + '/test/all_tests.rb'
35
+ end
36
+
37
+ spec =
38
+ Gem::Specification.new do |s|
39
+ s.name = NAME
40
+ s.version = VERS
41
+ s.platform = Gem::Platform::RUBY
42
+ s.has_rdoc = true
43
+ s.extra_rdoc_files = ["README", "CHANGELOG"]
44
+ s.rdoc_options += RDOC_OPTS + ['--exclude', '^(examples|extras)/']
45
+ s.summary = DESCRIPTION
46
+ s.description = DESCRIPTION
47
+ s.author = AUTHOR
48
+ s.email = EMAIL
49
+ s.homepage = HOMEPATH
50
+ s.executables = BIN_FILES
51
+ s.bindir = "bin"
52
+ s.require_path = "lib"
53
+
54
+ #s.add_dependency('activesupport', '>=1.3.1')
55
+ #s.required_ruby_version = '>= 1.8.2'
56
+
57
+ s.files = %w(README CHANGELOG Rakefile) +
58
+ Dir.glob("{bin,doc,test,lib,templates,extras,website,script}/**/*") +
59
+ Dir.glob("ext/**/*.{h,c,rb}") +
60
+ Dir.glob("examples/**/*.rb") +
61
+ Dir.glob("tools/*.rb")
62
+
63
+ # s.extensions = FileList["ext/**/extconf.rb"].to_a
64
+ end
65
+
66
+ Rake::GemPackageTask.new(spec) do |p|
67
+ p.need_tar = false
68
+ p.gem_spec = spec
69
+ end
70
+
71
+ task :install do
72
+ name = "#{NAME}-#{VERS}.gem"
73
+ sh %{rake package}
74
+ sh %{sudo gem install pkg/#{name}}
75
+ end
76
+
77
+ task :uninstall => [:clean] do
78
+ sh %{sudo gem uninstall #{NAME}}
79
+ end
@@ -0,0 +1,79 @@
1
+ # Some credits:
2
+ # Code this verions is based on: Andrew Birkett
3
+ # http://www.nobugs.org/developer/ruby/method_finder.html
4
+ # Improvements from Why's blog entry
5
+ # * what? == - Why
6
+ # * @@blacklist - llasram
7
+ # * clone alias - Daniel Schierbeck
8
+ # * $stdout redirect - Why
9
+ # http://redhanded.hobix.com/inspect/stickItInYourIrbrcMethodfinder.html
10
+ # Improvements from Nikolas Coukouma
11
+ # * Varargs and block support
12
+ # * Improved catching
13
+ # * Redirecting $stdout and $stderr (independently of Why)
14
+ # http://atrustheotaku.livejournal.com/339449.html
15
+ #
16
+ # A version posted in 2002 by Steven Grady:
17
+ # http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/32844
18
+ # David Tran's versions:
19
+ # * Simple
20
+ # http://www.doublegifts.com/pub/ruby/methodfinder.rb.html
21
+ # * Checks permutations of arguments
22
+ # http://www.doublegifts.com/pub/ruby/methodfinder2.rb.html
23
+ #
24
+ # Last updated: 2006/05/20
25
+
26
+ class Object
27
+ def what?(*a)
28
+ WhatMethods::MethodFinder.show(self, *a)
29
+ end
30
+ alias_method :__clone__, :clone
31
+ def clone
32
+ __clone__
33
+ rescue TypeError
34
+ self
35
+ end
36
+ end
37
+
38
+ class DummyOut
39
+ def write(*args)
40
+ end
41
+ end
42
+
43
+ module WhatMethods
44
+ class MethodFinder
45
+ @@blacklist = %w(daemonize display exec exit! fork sleep system syscall what?)
46
+
47
+ def initialize( obj, *args )
48
+ @obj = obj
49
+ @args = args
50
+ end
51
+ def ==( val )
52
+ MethodFinder.show( @obj, val, *@args )
53
+ end
54
+
55
+ # Find all methods on [anObject] which, when called with [args] return [expectedResult]
56
+ def self.find( anObject, expectedResult, *args, &block )
57
+ stdout, stderr = $stdout, $stderr
58
+ $stdout = $stderr = DummyOut.new
59
+ # change this back to == if you become worried about speed and warnings.
60
+ res = anObject.methods.
61
+ select { |name| anObject.method(name).arity <= args.size }.
62
+ select { |name| not @@blacklist.include? name }.
63
+ select { |name| begin
64
+ anObject.clone.method( name ).call( *args, &block ) == expectedResult;
65
+ rescue Object; end }
66
+ $stdout, $stderr = stdout, stderr
67
+ res
68
+ end
69
+
70
+ # Pretty-prints the results of the previous method
71
+ def self.show( anObject, expectedResult, *args, &block)
72
+ find( anObject, expectedResult, *args, &block).each { |name|
73
+ print "#{anObject.inspect}.#{name}"
74
+ print "(" + args.map { |o| o.inspect }.join(", ") + ")" unless args.empty?
75
+ puts " == #{expectedResult.inspect}"
76
+ }
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,9 @@
1
+ module WhatMethod #:nodoc:
2
+ module VERSION #:nodoc:
3
+ MAJOR = 1
4
+ MINOR = 0
5
+ TINY = 0
6
+
7
+ STRING = [MAJOR, MINOR, TINY].join('.')
8
+ end
9
+ end
data/test/all_tests.rb ADDED
@@ -0,0 +1 @@
1
+ Dir['**/*_test.rb'].each { |test_case| require test_case }
@@ -0,0 +1,2 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../lib/what_methods'
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.11
3
+ specification_version: 1
4
+ name: what_methods
5
+ version: !ruby/object:Gem::Version
6
+ version: 1.0.0
7
+ date: 2006-10-10 00:00:00 +02:00
8
+ summary: description of gem
9
+ require_paths:
10
+ - lib
11
+ email: your contact email for bug fixes and info
12
+ homepage: http://what_methods.rubyforge.org
13
+ rubyforge_project:
14
+ description: description of gem
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ authors:
29
+ - you
30
+ files:
31
+ - README
32
+ - CHANGELOG
33
+ - Rakefile
34
+ - test/all_tests.rb
35
+ - test/test_helper.rb
36
+ - lib/what_methods.rb
37
+ - lib/what_methods
38
+ - lib/what_methods/version.rb
39
+ test_files: []
40
+
41
+ rdoc_options:
42
+ - --quiet
43
+ - --title
44
+ - what_methods documentation
45
+ - --opname
46
+ - index.html
47
+ - --line-numbers
48
+ - --main
49
+ - README
50
+ - --inline-source
51
+ - --exclude
52
+ - ^(examples|extras)/
53
+ extra_rdoc_files:
54
+ - README
55
+ - CHANGELOG
56
+ executables: []
57
+
58
+ extensions: []
59
+
60
+ requirements: []
61
+
62
+ dependencies: []
63
+