It's your lucky day. I just spent this morning optimizing this code.
Save this as 'snoop.rb'. Usage is 'ruby snoop.rb <filename>'.
require 'rubygems'
require "rake"
class ASSnoop
CLASSPATH = ["vendor", "lib", "lib/std", "lib/std8"]
def initialize
@scanned_files = Hash.new
@files = Hash.new
@toplevels = []
CLASSPATH.each do |cp|
FileList["#{cp}/*"].each do |path|
@toplevels.push File.basename(path, ".as")
end
end
end
def get_dependencies file
#puts "get_dependencies #{file}"
@scanned_files[file] = 1
classes = []
# get list of classes from file
top_levels_joined = @toplevels.join("|") # join here for optimization
open(file).each_line do |line|
if line =~ /(?!class\s+)((?:#{top_levels_joined})\.(?:\w|\.)+)/o
classes.push $1.gsub(".", "/") + ".as"
end
end
# check againsts classpath
classes.each do |klass|
CLASSPATH.each do |classpath|
path = classpath+"/"+klass
if File.exists? path
@files[path] = 1
unless @scanned_files.has_key? path
get_dependencies(path)
end
break
end
end
end
@files.keys
end
end
snoop = ASSnoop.new
puts snoop.get_dependencies(ARGV[0]).sort.uniq
On 9/4/06, Scott Hyndman <[EMAIL PROTECTED]> wrote:
> UML doesn't necessarily help you with dependencies. What about local
> variables?
>
> Scott
>
> On 04/09/06, Andrew Eatherington <[EMAIL PROTECTED]> wrote:
> >
> > Oh okay, Enterprise Architect. I thought EA5 was an open source offering.
> >
> > Don't suppose anyone knows of a utility (cheap/free) that does do this?
> > (create UML diagrams from AS classes).
> >
> > Xcode has what sounds like a great tool, class modeling. It doesn't work
> > with AS though. I would love to be able to move back and forward from a
> > design (UML) view to a class view.
> >
> > Xcode help extract:
> > When you create a model, you add the source or the header files (or both),
> > or containers (such as groups, targets, or projects, but not smartgroups,
> > build phases, find results, and so on) that you want to contribute to the
> > model. A model is dynamic, though. It is continuously updated in response to
> > changes in your source code and the organization of your project.
> >
> > Thanks, Andrew.
> >
> >
> >
> > On 4 Sep 2006, at 21:15, Marcelo de Moraes Serpa wrote:
> >
> > www.sparxsystems.com (copied directly from google :P)
> >
> > On 9/4/06, Andrew Eatherington <[EMAIL PROTECTED]> wrote:
> > >
> > >
> > >
> > >
> > > You could also use EA5 and reverse engineer your code to uml class
> > diagrams...
> > >
> > >
> > > Sounds interesting. Do you have a link?
> > >
> > >
> > > Thanks,
> > >
> > > Andrew
> > >
> > >
> > >
> > >
> > > On 4 Sep 2006, at 15:09, Marcelo de Moraes Serpa wrote:
> > >
> > > Have you taken a look at SexieR?
> > >
> > > You could also use EA5 and reverse engineer your code to uml class
> > diagrams...
> > >
> > > Marcelo.
> > >
> > >
> > > On 9/4/06, Zárate <[EMAIL PROTECTED]> wrote:
> > > > Hi all,
> > > >
> > > > Is there any tool which you give it a class and you get all the
> > > > classes that are going to be compiled with in the swf? That's
> > > > something that compilers should know anyway, isn't it?
> > > >
> > > > Cheers,
> > > >
> > > > Juan
> > > >
> > > > --
> > > > Juan Delgado - Zárate
> > > > http://www.zarate.tv
> > > >
> > > > _______________________________________________
> > > > osflash mailing list
> > > > [email protected]
> > > > http://osflash.org/mailman/listinfo/osflash_osflash.org
> > > >
> > >
> > >
> > > _______________________________________________
> > > osflash mailing list
> > > [email protected]
> > > http://osflash.org/mailman/listinfo/osflash_osflash.org
> > >
> > >
> > > _______________________________________________
> > > osflash mailing list
> > > [email protected]
> > > http://osflash.org/mailman/listinfo/osflash_osflash.org
> > >
> > >
> > >
> >
> >
> > _______________________________________________
> > osflash mailing list
> > [email protected]
> > http://osflash.org/mailman/listinfo/osflash_osflash.org
> >
> >
> > _______________________________________________
> > osflash mailing list
> > [email protected]
> > http://osflash.org/mailman/listinfo/osflash_osflash.org
> >
> >
> >
>
> _______________________________________________
> osflash mailing list
> [email protected]
> http://osflash.org/mailman/listinfo/osflash_osflash.org
>
_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org