[ANN] Saikuro v0.2 Released

Z

Zev Blut

Saikuro is a Ruby cyclomatic complexity analyzer.

http://saikuro.rubyforge.org

When given Ruby source code Saikuro will generate a report listing the
cyclomatic complexity of each method found. In addition, Saikuro
counts the number of lines per method and can generate a listing of
the number of tokens on each line of code.

Usage:
Saikuro is a command line program.
Running "saikuro -h" will output a usage statement describing all
the various arguments you can pass it.

"saikuro -c -p tests/samples.rb"

The above command is a simple example that generates a cyclomatic
complexity report on the samples.rb file, using the default filter,
warning and error settings. The report is saved in the current
directory.

Changes:
=3Dv0.2
* Adding setup.rb installer
* Fixing an infinite loop that the lexer goes into if a file is
missing a newline at the end.

Note:
Ruby 1.8.5 has a bug in ri_options that will prevent Saikuro from
running. If you are using 1.8.5 please apply this patch :
http://www.ruby-lang.org/cgi-bin/cvsweb.cgi/ruby/lib/rdoc/ri/ri_options.=
rb.diff?r1=3D1.2.2.13;r2=3D1.2.2.14

Any feedback is appreciated.

Thanks,
Zev
 
E

Eric Hodel

Saikuro is a Ruby cyclomatic complexity analyzer.

http://saikuro.rubyforge.org

When given Ruby source code Saikuro will generate a report listing the
cyclomatic complexity of each method found. In addition, Saikuro
counts the number of lines per method and can generate a listing of
the number of tokens on each line of code.

Where's the gem?
 
Z

Zev Blut

Where's the gem?


My attempts to make a gem have failed. I think because Saikuro wants
to be installed as an application in /bin. I can put my current
gemspec up on SVN if you want to show me what I am doing wrong.

Thanks,
Zev
 
Z

Zev Blut

Take a look at the 'executables' setting within the gemspec

http://rubygems.org/read/chapter/20#executables

This will install the listed executable files into the bin directory =
where the ruby executable is, which will commonly be in PATH (eg =
/usr/local/bin)

Yes thank you I have already looked into this.

It appears I have made two mistakes when it comes to using RubyGems.

I did use the executables option, but I am not sure it was designed to
work the way I wrote Saikuro. Here are the two problems:

1)
Saikuro uses the "if __FILE__ =3D=3D $0" check before doing the
"application work". When RubyGems creates a new gemified saikuro
wrapper to call the real saikuro bin "$0" is the gemified saikuro and
not the real one. Thus, by default nothing happens.

For fun I cheated and commented out the "if __FILE__" check and
replaced it with "if true". I then ran "saikuro -?" to get a usage
message and found the next problem:

2)
I was reading through the Programming Ruby book and found a part that
showed how to use rdoc to create usage messages. I figured this might
be better than my normal technique so I used it in saikuro. This has
caused a number of problems actually.

* With the above cheat I get the gem message:
--
/usr/bin/saikuro: invalid option -- ?
This file was generated by RubyGems.

The application 'Saikuro' is installed as part of a gem, and this file
is here to facilitate running it.
--

Which is not the usage message I wanted.

* Part two is only somewhat related to gems but also a bug in Ruby
1.8.5 's rdoc API that makes this actually give an error due to it
not being able to require an options file. This is fixed in the
Ruby head, but not in the official release.

So I am wondering what is the best practice for this?

I could always separate saikuro into a lib and bin file. The bin file
will not do the if __FILE__ check. This should then work with
RubyGems, but of course I need to drop the rdoc usage technique.

My original goal was to keep saikuro simple so that as a single file
nothing complicated was needed. But now I suppose that should change.

Here is my basic gemspec file if someone wants to show me a better
technique.

----------------------------------------------------------------------
require 'rubygems'

spec =3D Gem::Specification.new do |s|
s.name =3D "Saikuro"
s.version =3D "1.0.0"
s.author =3D "Zev Blut"
s.homepage =3D "http://saikuro.rubyforge.org/"
s.rubyforge_project =3D 'saikuro'
s.platform =3D Gem::platform::RUBY
candidates =3D Dir.glob("{bin,tests}/**/*")
s.files =3D candidates.delete_if do |item|
item.include?(".svn") || item.include?("rdoc")
end
s.executables =3D ['saikuro']
s.has_rdoc =3D true
s.extra_rdoc_files =3D ["README"]
end

if __FILE__ =3D=3D $0
Gem::manage_gems
Gem::Builder.new(spec).build
end
----------------------------------------------------------------------


Thanks,
Zev
=
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top