ruby 1.8.5: cannot use rdoc/usage from a gem executable

Discussion in 'Ruby' started by Suraj N. Kurapati, Aug 29, 2006.

  1. -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Hello,

    In Ruby 1.8.5, RDoc::usage_no_exit parses usage information from the
    earliest file in the Kernel#caller list. This works well if you directly
    invoke the file containing the usage information.

    However, when a Ruby program (containing usage information in the same
    file) is shipped as part of the Gem::Specification#executables array,
    RubyGems creates a proxy for that program in the system bin/ directory.
    Because of the proxy, the Ruby program is not invoked directly, and
    therefore RDoc::usage_no_exit is parsing the usage information of the proxy!

    The way I've solved it, for now, is to define a RDoc::usage_from_file
    method that parses usage information from a given file, as follows.


    $ diff -bc lib/rdoc/usage.rb{.orig,}
    *** lib/rdoc/usage.rb.orig 2006-08-28 23:39:39.000000000 -0700
    - --- lib/rdoc/usage.rb 2006-08-28 23:41:41.000000000 -0700
    ***************
    *** 97,103 ****
    # Display usage
    def RDoc.usage_no_exit(*args)
    main_program_file = caller[-1].sub(/:\d+$/, '')
    ! comment = File.open(main_program_file) do |file|
    find_comment(file)
    end

    - --- 97,108 ----
    # Display usage
    def RDoc.usage_no_exit(*args)
    main_program_file = caller[-1].sub(/:\d+$/, '')
    ! usage_from_file(main_program_file)
    ! end
    !
    ! # Display usage from the given file
    ! def RDoc.usage_from_file(input_file, *args)
    ! comment = File.open(input_file) do |file|
    find_comment(file)
    end


    Does anyone have other ideas or solutions? Is it too brash to suggest that
    such functionality be added to RDoc?

    Thanks for your consideration.
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.2.2 (GNU/Linux)

    iD8DBQFE8+T5mV9O7RYnKMcRAmzFAJsGZ0RRKII/BqmRh5TBUejmOtrAfACdG7Kz
    o2kBe93ypOFMlSPmGaarGN4=
    =Aycb
    -----END PGP SIGNATURE-----
    Suraj N. Kurapati, Aug 29, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul Van Delst

    How to use rdoc parsers outside of rdoc?

    Paul Van Delst, Jul 27, 2006, in forum: Ruby
    Replies:
    0
    Views:
    94
    Paul Van Delst
    Jul 27, 2006
  2. Austin 7873
    Replies:
    5
    Views:
    173
    Eric Hodel
    Jan 27, 2007
  3. braver
    Replies:
    4
    Views:
    121
  4. Greg Hauptmann
    Replies:
    2
    Views:
    130
    Greg Hauptmann
    Nov 8, 2008
  5. Tom Cloyd
    Replies:
    0
    Views:
    168
    Tom Cloyd
    Sep 3, 2009
Loading...

Share This Page