rdp / ri_for Goto Github PK
View Code? Open in Web Editor NEWallows you to grab a method's docu at runtime
Home Page: http://github.com/rogerdpack/desc_methods/tree/master
allows you to grab a method's docu at runtime
Home Page: http://github.com/rogerdpack/desc_methods/tree/master
too heavy-weight makes the require take too long
C:\dev\ruby\arguments\spec>spec arguments_spec.rb
.....[42, 51] in ./arguments_spec.rb
42 it "should allow for class arguments" do
43 Klass.send( :named_arguments_for, :defaults_with_class)
44 @instance.defaults_with_class(1, 3).should == 3
45 @instance.defaults_with_class(:a => 3).should == 3
46 require '_dbg'
=> 47 @instance.defaults_with_class().should == 4
48 end
49
50 it "should allow overriding with nil" do
51 Klass.send( :named_arguments_for, :two )
arguments_spec.rb:47
@instance.defaults_with_class().should == 4
(rdb:1) require 'desc_method'
./../lib/arguments.rb:10: warning: already initialized constant VERSION
true
(rdb:1) @instance.desc_method :defaults_with_class
sig: #<Method: Klass#defaults_with_class> arity: -1
searching ri for Klass#defaults_with_class...
Nothing known about Klass
(end ri)
nil
irb(main):006:0> FFI::Library.desc_method :attach_function
NameError: undefined method attach_function' for class
Module'
from C:/installs/ruby-1.9.1-p243-tweaked/lib/ruby/gems/1.9.1/gems/desc_method-0.1.8/lib/method_describer/method_desc.rb:168:in method' from C:/installs/ruby-1.9.1-p243-tweaked/lib/ruby/gems/1.9.1/gems/desc_method-0.1.8/lib/method_describer/method_desc.rb:168:in
desc_method'
from (irb):6
from C:/installs/ruby-1.9.1-p243-tweaked/bin/irb.bat:20:in `
this is a bug
sweet!
add class.desc_class
oh boy
from within extconf.rb
doesn't stop right
(rdb:1) desc_method :xsystem sig: # arity: 1 at C:/installs/ruby19_mingw/lib/ruby/1.9.1/mkmf.rb:292 def xsystem command varpat = /\$((\w+))|\${(\w+)}/ if varpat =~ command vars = Hash.new {|h, k| h[k] = ''; ENV[k]} command = command.dup nil while command.gsub!(varpat) {vars[$1||$2]} end Logging::open do puts command.quote system(command) end end
shouldn't params be at the end?
(rdb:1) Order.instance_method(:billing_address).desc
even in non-verbose "uncommon" ancestors might work well.
non inherited class methods:
=> nil
irb(main):008:0> A.ancestors
=> [A, EventMachine, Object, RequireAll, Kernel]
-> EventMachine
it exists sometimes! Maybe! [make sure it wurx for REE...]
should call ri for Regexp.new
irb(main):004:0> Regexp.ri_for :new sig: Class#new arity -1 appears to be a c method Searching ri for sig: Class#new arity -1 ... -------------------------------------------------------------- Class#new class.new(args, ...) => obj From gem ruby_core_ri-0.5.1 ------------------------------------------------------------------------ Calls +allocate+ to create a new object of _class_'s class, then invokes that object's +initialize+ method, passing it _args_. This is the method that ends up getting called whenever an object is constructed using .new. (end ri) => "#" irb(main):005:0> Regexp.ri_for :new
(rdb:1) Order.desc_method :desc_method
ri for Object#desc_method
Nothing known about Object#desc_method
arity: -2
["#<UnboundMethod: Order(Object)#desc_method>", "arity: -2"]
no source?
good error, poor verbiage
irb(main):006:0> A.new.desc_method :go2 NameError: undefined method `go2' for class`A' from c:/ruby/lib/ruby/gems/1.8/gems/desc_method-0.1.0/lib/method_describer/method_desc.rb:144:in `method' from c:/ruby/lib/ruby/gems/1.8/gems/desc_method-0.1.0/lib/method_describer/method_desc.rb:144:in`desc_method' from (irb):6 from ♥:0
> > Promotion.ri_for :create! > > sig: Class#create! arity -1 > > appears to be a c method > > Searching ri for > > sig: Class#create! arity -1 > > ... > > Nothing known about Class#create! > > (end ri) > > => "sig: Class#create! arity -1" > > Promotion.ri_for :create > > sig: ActiveRecord::Timestamp#create arity 0 > > appears to be a c method > > Searching ri for > > sig: ActiveRecord::Timestamp#create arity 0 > > ... > > Nothing known about ActiveRecord > > (end ri) > > => "sig: ActiveRecord::Timestamp#create arity 0" > > ActiveRecord::Base.ri_for :create! > > sig: Class#create! arity -1 > > appears to be a c method > > Searching ri for > > sig: Class#create! arity -1 > > ... > > Nothing known about Class#create! > > (end ri) > > => "sig: Class#create! arity -1"
used the wrong class, yes indeed.
yep in 1.9
irb(main):005:0> EM.desc_class
NoMethodError: undefined method `desc_class' for EventMachine:Module
from (irb):5
from ♥:0
people might use that.
instead add methods_delin
also make sure it works...quite well, and pass out multiple arrays, possibly arrays of hashes?
sig: #<Method: Process.wait> arity: -1
appears to be a c method
searching ri for Process.wait...
Updating ri class cache with 0 classes...
Nothing known about Process
(end ri)
=> "#<Method: Process.wait>"
yes indeed!
(rdb:1) Order.desc_method :observers=
ri for Class#observers=
Nothing known about Class#observers=
(end ri)
nil
yup, add :verbose => true option :P
sure :)
> > File.desc_method :sanitize > > sig: # arity: 1 > > searching ri for File.sanitize... > > Nothing known about File.sanitize > > (end ri) > > Errno::ENOENT: No such file or directory - c > > from c:/ruby18/lib/ruby/gems/1.8/gems/desc_method-0.1.5/lib/method_describer/method_desc.rb:103:in `readlines' > > from c:/ruby18/lib/ruby/gems/1.8/gems/desc_method-0.1.5/lib/method_describer/method_desc.rb:103:in`__original_desc' > > from c:/ruby18/lib/ruby/gems/1.8/gems/rdp-arguments-0.6.1/lib/arguments/class.rb:62:in `desc' > > from c:/ruby18/lib/ruby/gems/1.8/gems/desc_method-0.1.5/lib/method_describer/method_desc.rb:157:in`desc_method' > > from (irb):4 > > from c:/ruby18/lib/ruby/1.8/fileutils.rb:1577 > > exit al
irb(main):004:0> A.desc_method :go
ri for A#go
Nothing known about A
A#go a
proc { |a|
they become proc's? huh? avoidable? ruby2ruby bug?
that is ugly
when convenient
yup
(rdb:1) require 'desc_method'
true
(rdb:1) Zlib::GzipReader.desc_method :new
searching ri for Class#new...
Nothing known about Class#new
yup it appears to indeed
(end ri)
def update_all(updates, conditions = nil, options = { })
sql = "UPDATE #{quoted_table_name} SET #{sanitize_sql_for_assignment(updates)} "
scope = scope(:find)
add_conditions!(sql, conditions, scope)
add_order!(sql, options[:order], nil)
add_limit!(sql, options, nil)
connection.update(sql, "#{name} Update")
end
Parameters: update_all()
"Parameters: update_all()"
(rdb:1)
at least not yet
(rdb:1) Tempfile.desc_method :open
should say "are you an instance method or a class method?" I suppose...
irb(main):003:0> File.ri_for :write
sig: IO#write arity 1
appears to be a c method
Searching ri for
sig: IO#write arity 1
yep that's the wrong one...
depending on verbose..?
yes indeed it should, after showing the source.
C:\dev\ruby\scene-skipper>ruby go.rb at go.rb:2 sig: A#go arity 0 def go 33 end Original code signature: def go # parameters signature: go( [] )
If there's class AND instance methods, display both :P
(end ri)
fail to parse tree: ActionController::Assertions::SelectorAssertions You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.last c:/ruby18/lib/ruby/gems/1.8/gems/ruby2ruby-1.1.9/lib/ruby2ruby.rb:192:in process_block_pass'c:/ruby18/lib/ruby/gems/1.8/gems/sexp_processor-3.0.2/lib/sexp_processor.rb:212:in
send'c:/ruby18/lib/ruby/gems/1.8/gems/sexp_processor-3.0.2/lib/sexp_processor.rb:212:in process'c:/ruby18/lib/ruby/gems/1.8/gems/sexp_processor-3.0.2/lib/sexp_processor.rb:264:in
error_handler'c:/ruby18/lib/ruby/gems/1.8/gems/sexp_processor-3.0.2/lib/sexp_processor.rb:211:in process'c:/ruby18/lib/ruby/gems/1.8/gems/ParseTree-3.0.4/lib/unified_ruby.rb:9:in
process'c:/ruby18/lib/ruby/gems/1.8/gems/ruby2ruby-1.1.9/lib/ruby2ruby.rb:46:in process'c:/ruby18/lib/ruby/gems/1.8/gems/ruby2ruby-1.1.9/lib/ruby2ruby.rb:95:in
process_arglist'c:/ruby18/lib/ruby/gems/1.8/gems/sexp_processor-3.0.2/lib/sexp_processor.rb:212:in send'c:/ruby18/lib/ruby/gems/1.8/gems/sexp_processor-3.0.2/lib/sexp_processor.rb:212:in
process'c:/ruby18/lib/ruby/g
Order.instance_method(:billing_address).desc
ri for Order#billing_address
Nothing known about Order<UnboundMethod: Order#billing_address>
arity: -1
=> nil
maybe just to trans'?
sure :)
turn off except for verbose mode [?]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.