|
From: <luk...@us...> - 2006-09-05 04:19:31
|
Revision: 71
http://svn.sourceforge.net/asunit/?rev=71&view=rev
Author: lukebayes
Date: 2006-09-04 21:19:18 -0700 (Mon, 04 Sep 2006)
Log Message:
-----------
working on ruby tools
Modified Paths:
--------------
trunk/ruby/src/asunit.rb
Added Paths:
-----------
trunk/ruby/demo/
trunk/ruby/src/createclass.rb
trunk/ruby/src/createclass_test.rb
trunk/ruby/src/project.rb
trunk/ruby/src/project_test.rb
trunk/ruby/src/settings.rb
trunk/ruby/src/settings_test.rb
trunk/ruby/test/
Modified: trunk/ruby/src/asunit.rb
===================================================================
--- trunk/ruby/src/asunit.rb 2006-09-02 06:12:17 UTC (rev 70)
+++ trunk/ruby/src/asunit.rb 2006-09-05 04:19:18 UTC (rev 71)
@@ -1,4 +1,4 @@
-#!/usr/bin/env ruby
+#!/bin/ruby
module AsUnit
# ------------------------------------------------------------------
@@ -39,17 +39,50 @@
end
end
- class Application
- def initialize
+ require 'optparse'
+
+ class Application
+ def initialize
+ super
+ arguments = AsUnitArguments.new(ARGV)
+ counter = 0
+ eol =
+ ARGF.each do |line|
+ line.sub!(/$/, arguments[:show_ends])
+ print '%6.d ' % (counter += 1) if arguments[:number_lines]
+ print line
+ end
+ end
+ end
+
+ class AsUnitArguments < Hash
+ def initialize(args)
super
+ self[:show_ends] = ''
+ self[:number_lines] = false
+
+ opts = OptionParser.new do |opts|
+ opts.banner = "Usage: #$0 [options]"
+ opts.on('-E', '--show-ends [STRING]',
+ 'display [STRING] at end of each line') do |string|
+ self[:show_ends] = string || '$'
+ end
+
+ opts.on('-n', '--number', 'number all output lines') do
+ self[:number_lines] = true
+ end
+
+ opts.on_tail('-h', '--help', 'display this help and exit') do
+ puts opts
+ exit
+ end
+ opts.parse!(args)
+
+ end
end
-
- def run
- printf "Hello Nancy"
- end
end
end
if __FILE__ == $0 then
- AsUnit::Application.new.run
+ AsUnit::Application.new
end
Added: trunk/ruby/src/createclass.rb
===================================================================
--- trunk/ruby/src/createclass.rb (rev 0)
+++ trunk/ruby/src/createclass.rb 2006-09-05 04:19:18 UTC (rev 71)
@@ -0,0 +1,12 @@
+
+module AsUnit
+ class CreateClass
+ def initialize name
+ @classname = name;
+ end
+
+ def full_class_name
+ return @classname
+ end
+ end
+end
Added: trunk/ruby/src/createclass_test.rb
===================================================================
--- trunk/ruby/src/createclass_test.rb (rev 0)
+++ trunk/ruby/src/createclass_test.rb 2006-09-05 04:19:18 UTC (rev 71)
@@ -0,0 +1,20 @@
+
+require 'test/unit'
+require 'createclass.rb'
+
+class CreateClassTest < Test::Unit::TestCase
+
+ def setup
+ @full_class_name = "org.asunit.SomeClass"
+ @instance = AsUnit::CreateClass.new @full_class_name
+ end
+
+ def test_instantiated
+ assert_not_nil(@instance)
+ end
+
+ def test_class_name
+ assert(@instance.full_class_name == @full_class_name)
+ end
+
+end
\ No newline at end of file
Added: trunk/ruby/src/project.rb
===================================================================
--- trunk/ruby/src/project.rb (rev 0)
+++ trunk/ruby/src/project.rb 2006-09-05 04:19:18 UTC (rev 71)
@@ -0,0 +1,67 @@
+#!/bin/ruby
+
+require 'settings.rb'
+
+module AsUnit
+ #################################
+ # Project Class
+ #################################
+ # Should be able to enter something like:
+ # asunit project Lifebin
+ # and get an auto-configured ready-to-go
+ # actionscript project file, folders etc...
+ # -src [source dir name]
+ # -test [test dir name]
+ # -path [colon-separated, space-escaped directory paths]
+ # -lib [lib dir name]
+ # -bin [binary dir name]
+
+ class Project
+ attr_reader :name, :settings
+
+ def initialize(name, dir=nil)
+ @name = name;
+ @settings = AsUnit::Settings.new
+ if(!dir.nil?)
+ @dir = dir
+ end
+ content = create_dirs
+ create_project_file('.asunit_' + name.downcase, content)
+ end
+
+ def create_dirs
+ create_dir(@settings.src)
+ create_dir(@settings.test)
+ create_dir(@settings.lib)
+
+ contents = ['src=\'' + File.expand_path(@settings.src) + '\'']
+ contents.push('test=\'' + File.expand_path(@settings.test) + '\'')
+ contents.push('lib=\'' + File.expand_path(@settings.lib) + '\'')
+ end
+
+ def create_project_file(name, contents)
+ open(name, 'w') do |f|
+ contents.each { |i|
+ f.puts i
+ }
+ f.flush
+ end
+ end
+
+ def dir
+ if(@dir.nil?)
+ @dir = Dir.pwd
+ end
+ @dir
+ end
+
+ def create_dir(name)
+ # Don't overwrite existing dirs
+ if(!File.exists? name)
+ Dir.mkdir name
+ end
+ return File.new name
+ end
+
+ end
+end
\ No newline at end of file
Added: trunk/ruby/src/project_test.rb
===================================================================
--- trunk/ruby/src/project_test.rb (rev 0)
+++ trunk/ruby/src/project_test.rb 2006-09-05 04:19:18 UTC (rev 71)
@@ -0,0 +1,21 @@
+#!/bin/ruby
+
+require 'test/unit'
+require 'project.rb'
+require 'settings.rb'
+
+class ProjectTest < Test::Unit::TestCase
+
+ def setup
+ @default_name = 'Lifebin'
+ @instance = AsUnit::Project.new @default_name
+ end
+
+ def test_instantiated
+ assert_not_nil(@instance)
+ end
+
+ def test_name
+ assert_equal(@instance.name, @default_name)
+ end
+end
Added: trunk/ruby/src/settings.rb
===================================================================
--- trunk/ruby/src/settings.rb (rev 0)
+++ trunk/ruby/src/settings.rb 2006-09-05 04:19:18 UTC (rev 71)
@@ -0,0 +1,12 @@
+
+module AsUnit
+ class Settings
+ attr_accessor :src, :test, :lib
+
+ def initialize()
+ @src = 'src'
+ @test = 'test'
+ @lib = 'lib'
+ end
+ end
+end
\ No newline at end of file
Added: trunk/ruby/src/settings_test.rb
===================================================================
--- trunk/ruby/src/settings_test.rb (rev 0)
+++ trunk/ruby/src/settings_test.rb 2006-09-05 04:19:18 UTC (rev 71)
@@ -0,0 +1,14 @@
+
+require 'test/unit'
+require 'settings.rb'
+
+class SettingsTest < Test::Unit::TestCase
+
+ def setup
+ @instance = AsUnit::Settings.new
+ end
+
+ def test_instantiated
+ assert_not_nil(@instance)
+ end
+end
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|