bobbyno-tbox 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +10 -0
- data/MIT-LICENSE +22 -0
- data/Manifest.txt +25 -0
- data/PostInstall.txt +6 -0
- data/README.rdoc +48 -0
- data/Rakefile +31 -0
- data/app_generators/tbox/USAGE +12 -0
- data/app_generators/tbox/tbox_generator.rb +84 -0
- data/app_generators/tbox/templates/README +45 -0
- data/app_generators/tbox/templates/file.txt +3 -0
- data/app_generators/tbox/templates/rakefile.rb +9 -0
- data/app_generators/tbox/templates/right_triangle.rb +24 -0
- data/app_generators/tbox/templates/tbox.rb +6 -0
- data/app_generators/tbox/templates/test_helper.rb +9 -0
- data/app_generators/tbox/templates/test_io.rb +15 -0
- data/app_generators/tbox/templates/test_right_triangle.rb +21 -0
- data/bin/tbox +17 -0
- data/lib/tbox.rb +6 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/tbox.gemspec +47 -0
- data/test/test_generator_helper.rb +29 -0
- data/test/test_helper.rb +4 -0
- data/test/test_tbox_generator.rb +63 -0
- metadata +101 -0
data/History.txt
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2009 Bobby Norton
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
History.txt
|
2
|
+
MIT-LICENSE
|
3
|
+
Manifest.txt
|
4
|
+
PostInstall.txt
|
5
|
+
README.rdoc
|
6
|
+
Rakefile
|
7
|
+
app_generators/tbox/USAGE
|
8
|
+
app_generators/tbox/tbox_generator.rb
|
9
|
+
app_generators/tbox/templates/README
|
10
|
+
app_generators/tbox/templates/file.txt
|
11
|
+
app_generators/tbox/templates/rakefile.rb
|
12
|
+
app_generators/tbox/templates/right_triangle.rb
|
13
|
+
app_generators/tbox/templates/tbox.rb
|
14
|
+
app_generators/tbox/templates/test_helper.rb
|
15
|
+
app_generators/tbox/templates/test_io.rb
|
16
|
+
app_generators/tbox/templates/test_right_triangle.rb
|
17
|
+
bin/tbox
|
18
|
+
lib/tbox.rb
|
19
|
+
script/console
|
20
|
+
script/destroy
|
21
|
+
script/generate
|
22
|
+
tbox.gemspec
|
23
|
+
test/test_generator_helper.rb
|
24
|
+
test/test_helper.rb
|
25
|
+
test/test_tbox_generator.rb
|
data/PostInstall.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
= tbox - A test-driven learning sandbox creation tool
|
2
|
+
|
3
|
+
Project Home: http://github.com/bobbyno/tbox/tree/master
|
4
|
+
|
5
|
+
More on Test-Driven Learning: http://www.bobbynorton.com/?p=36
|
6
|
+
|
7
|
+
== DESCRIPTION:
|
8
|
+
|
9
|
+
tbox lowers the barrier to entry for test-driven learning* by providing a basic infrastructure in which
|
10
|
+
to start coding: A directory structure, some classes and unit tests to get started, and a Rakefile to run
|
11
|
+
all tests. For now, tbox is geared toward Ruby, though the technique is applicable to any language that
|
12
|
+
lends itself to TDD.
|
13
|
+
|
14
|
+
== BASIC USAGE:
|
15
|
+
|
16
|
+
Go to the folder where you want to create your new test sandbox, and run the <code>tbox</code> command to generate your test scaffolding.
|
17
|
+
|
18
|
+
<code>$ cd ~/ruby_projects</code>
|
19
|
+
|
20
|
+
<code>$ tbox learning_ruby</code>
|
21
|
+
|
22
|
+
<code>$ rake</code>
|
23
|
+
|
24
|
+
== SYNOPSIS:
|
25
|
+
|
26
|
+
tbox is built using newgem. Although tbox was initially designed with Ruby and Test::Unit in mind, new generator
|
27
|
+
scripts can easily be added to support other testing techniques in multiple languages. tbox can therefore become
|
28
|
+
a starting point for test-driven learning in any language with any dependencies.
|
29
|
+
|
30
|
+
== REQUIREMENTS:
|
31
|
+
|
32
|
+
* newgem
|
33
|
+
|
34
|
+
== INSTALL:
|
35
|
+
|
36
|
+
The <code>tbox</code> application is distributed as a RubyGem and is available immediately after installation.
|
37
|
+
|
38
|
+
<code>$ gem sources -a http://gems.github.com </code> (add http to the address)
|
39
|
+
|
40
|
+
<code>$ sudo gem install bobbyno-tbox</code>
|
41
|
+
|
42
|
+
Alternately, download the gem and install manually from github.
|
43
|
+
|
44
|
+
== CREDITS:
|
45
|
+
|
46
|
+
Bobby Norton, DRW Trading Group
|
47
|
+
|
48
|
+
Dr. Nic Williams for newgem and rubigen: {RubyConf 2007 Presentation}[http://rubyconf2007.confreaks.com/d3t1p1_rubigen.html]
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
2
|
+
%w[rake rake/clean fileutils newgem rubigen].each { |f| require f }
|
3
|
+
require File.dirname(__FILE__) + '/lib/tbox'
|
4
|
+
|
5
|
+
# Generate all the Rake tasks
|
6
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
7
|
+
$hoe = Hoe.new('tbox', Tbox::VERSION) do |p|
|
8
|
+
p.developer('Bobby Norton', 'codeculturist@gmail.com')
|
9
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
10
|
+
p.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
|
11
|
+
p.rubyforge_name = p.name # TODO this is default value
|
12
|
+
# p.extra_deps = [
|
13
|
+
# ['activesupport','>= 2.0.2'],
|
14
|
+
# ]
|
15
|
+
p.extra_dev_deps = [
|
16
|
+
['newgem', ">= #{::Newgem::VERSION}"]
|
17
|
+
]
|
18
|
+
|
19
|
+
p.clean_globs |= %w[**/.DS_Store tmp *.log]
|
20
|
+
path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
|
21
|
+
p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
|
22
|
+
p.rsync_args = '-av --delete --ignore-errors'
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'newgem/tasks' # load /tasks/*.rake
|
26
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
27
|
+
|
28
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
29
|
+
# task :default => [:spec, :features]
|
30
|
+
|
31
|
+
task :package => [:gemspec]
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Description:
|
2
|
+
|
3
|
+
tbox lowers the barrier to entry for test-driven learning by providing a basic infrastructure in which
|
4
|
+
to start coding: A directory structure, some classes and unit tests to get started, and a Rakefile to run
|
5
|
+
all tests. For now, tbox is geared toward Ruby, though the technique is applicable to any language that
|
6
|
+
lends itself to TDD.
|
7
|
+
|
8
|
+
Usage:
|
9
|
+
|
10
|
+
$ cd ~/ruby_projects
|
11
|
+
$ tbox learning_ruby
|
12
|
+
$ rake
|
@@ -0,0 +1,84 @@
|
|
1
|
+
class TboxGenerator < RubiGen::Base
|
2
|
+
|
3
|
+
DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
|
4
|
+
Config::CONFIG['ruby_install_name'])
|
5
|
+
|
6
|
+
default_options :author => nil
|
7
|
+
|
8
|
+
attr_reader :name
|
9
|
+
|
10
|
+
def initialize(runtime_args, runtime_options = {})
|
11
|
+
super
|
12
|
+
usage if args.empty?
|
13
|
+
@destination_root = File.expand_path(args.shift)
|
14
|
+
@name = base_name
|
15
|
+
extract_options
|
16
|
+
end
|
17
|
+
|
18
|
+
def manifest
|
19
|
+
record do |m|
|
20
|
+
# Ensure appropriate folder(s) exists
|
21
|
+
m.directory ''
|
22
|
+
BASEDIRS.each { |path| m.directory path }
|
23
|
+
|
24
|
+
m.file "rakefile.rb", "rakefile.rb"
|
25
|
+
m.file "README", "README"
|
26
|
+
m.file "../../../MIT-LICENSE", "MIT-LICENSE"
|
27
|
+
# Create stubs
|
28
|
+
# m.template "template.rb", "some_file_after_erb.rb"
|
29
|
+
# m.template_copy_each ["template.rb", "template2.rb"]
|
30
|
+
# m.file "file", "some_file_copied"
|
31
|
+
# m.file_copy_each ["path/to/file", "path/to/file2"]
|
32
|
+
m.directory "lib/samples"
|
33
|
+
m.file "right_triangle.rb", "lib/samples/right_triangle.rb"
|
34
|
+
m.file "tbox.rb", "lib/tbox.rb"
|
35
|
+
m.directory "test/samples"
|
36
|
+
m.directory "test/data"
|
37
|
+
m.file "test_right_triangle.rb", "test/samples/test_right_triangle.rb"
|
38
|
+
m.file "test_io.rb", "test/test_io.rb"
|
39
|
+
m.file "file.txt", "test/data/file.txt"
|
40
|
+
m.file "test_helper.rb", "test/test_helper.rb"
|
41
|
+
|
42
|
+
m.dependency "install_rubigen_scripts", [destination_root, 'tbox'],
|
43
|
+
:shebang => options[:shebang], :collision => :force
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
protected
|
48
|
+
def banner
|
49
|
+
<<-EOS
|
50
|
+
Creates a test-driven learning environment: A directory structure, some sample classes and unit tests,
|
51
|
+
and a Rakefile to run all tests.
|
52
|
+
|
53
|
+
USAGE: #{spec.name} dir_name
|
54
|
+
EOS
|
55
|
+
end
|
56
|
+
|
57
|
+
def add_options!(opts)
|
58
|
+
opts.separator ''
|
59
|
+
opts.separator 'Options:'
|
60
|
+
# For each option below, place the default
|
61
|
+
# at the top of the file next to "default_options"
|
62
|
+
# opts.on("-a", "--author=\"Your Name\"", String,
|
63
|
+
# "Some comment about this option",
|
64
|
+
# "Default: none") { |o| options[:author] = o }
|
65
|
+
opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
66
|
+
end
|
67
|
+
|
68
|
+
def extract_options
|
69
|
+
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
70
|
+
# Templates can access these value via the attr_reader-generated methods, but not the
|
71
|
+
# raw instance variable value.
|
72
|
+
# @author = options[:author]
|
73
|
+
end
|
74
|
+
|
75
|
+
# Installation skeleton. Intermediate directories are automatically
|
76
|
+
# created so don't sweat their absence here.
|
77
|
+
BASEDIRS = %w(
|
78
|
+
lib
|
79
|
+
log
|
80
|
+
script
|
81
|
+
test
|
82
|
+
tmp
|
83
|
+
)
|
84
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
= tbox - A test-driven learning sandbox creation tool
|
2
|
+
|
3
|
+
* See http://www.bobbynorton.com/?p=36 for more on tbox and test-driven learning.
|
4
|
+
|
5
|
+
== Description:
|
6
|
+
|
7
|
+
tbox lowers the barrier to entry for test-driven learning by providing a basic infrastructure in which
|
8
|
+
to start coding: A directory structure, some classes and unit tests to get started, and a Rakefile to run
|
9
|
+
all tests. For now, tbox is geared toward Ruby, though the technique is applicable to any language that
|
10
|
+
lends itself to TDD.
|
11
|
+
|
12
|
+
== Learning Ruby by Testing:
|
13
|
+
|
14
|
+
If you're completely new to Ruby, you should start with "Ruby in Twenty Minutes" -
|
15
|
+
http://www.ruby-lang.org/en/documentation/quickstart/. This will help you get Ruby installed and will
|
16
|
+
explain the basics of Ruby programming.
|
17
|
+
|
18
|
+
If you already have Ruby and rake (http://rake.rubyforge.org/files/README.html) installed and you're
|
19
|
+
ready to start, then fire up a command prompt and run the starter tests that ship with tbox:
|
20
|
+
|
21
|
+
$ cd ~/ruby_projects
|
22
|
+
$ tbox learning_ruby
|
23
|
+
$ rake
|
24
|
+
|
25
|
+
This uses the rake TestTask to run all the unit tests in your test folder. If everything goes as planned,
|
26
|
+
running this command should produce something like:
|
27
|
+
|
28
|
+
Loaded suite /Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake/rake_test_loader
|
29
|
+
Started
|
30
|
+
...
|
31
|
+
Finished in 0.000706 seconds.
|
32
|
+
|
33
|
+
3 tests, 4 assertions, 0 failures, 0 errors
|
34
|
+
|
35
|
+
Open up the test cases in your favorite editor and have a look at what's going on. Change the tests. Add
|
36
|
+
some new cases. Run them again every time you want to experiment with something new. Make sure you run
|
37
|
+
all the tests in your suite before you check in at the end of your session.
|
38
|
+
|
39
|
+
If you don't yet have a copy of Pickaxe, get one (http://www.pragprog.com/titles/ruby/programming-ruby).
|
40
|
+
Add to your tbox repository as you read through the book to code up examples of what you're reading.
|
41
|
+
|
42
|
+
== Credits:
|
43
|
+
|
44
|
+
Bobby Norton, DRW Trading Group
|
45
|
+
Dr. Nic Williams for newgem and rubigen: http://rubyconf2007.confreaks.com/d3t1p1_rubigen.html
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Encapsulates the geometry of a 3-sided polygon with a right angle.
|
2
|
+
# http://mathworld.wolfram.com/RightTriangle.html
|
3
|
+
class RightTriangle
|
4
|
+
|
5
|
+
def initialize(base, height)
|
6
|
+
@a, @b = base, height
|
7
|
+
@c = hypotenuse
|
8
|
+
end
|
9
|
+
|
10
|
+
def hypotenuse
|
11
|
+
Math.sqrt((@a**2) + (@b**2))
|
12
|
+
end
|
13
|
+
|
14
|
+
def area
|
15
|
+
0.5 * @a * @b
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def s
|
21
|
+
semiperimeter
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
# Expo usage note: Keeping an inline bookmark to the rdocs for the class under study
|
4
|
+
# makes it easy to continue your learning later.
|
5
|
+
|
6
|
+
# Exploring the methods of the IO class: http://www.ruby-doc.org/core/classes/IO.html
|
7
|
+
class TestIO < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def test_readlines
|
10
|
+
contents = IO.readlines(File.join(Constants::TEST_DATA_DIR, "file.txt"))
|
11
|
+
# See String Match for =~ syntax: http://www.ruby-doc.org/core/classes/String.html#M000792
|
12
|
+
assert(contents[0] =~ /Salam/)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
require 'samples/right_triangle'
|
3
|
+
|
4
|
+
# An example of testing a class in the lib folder.
|
5
|
+
class TestRightTriangle < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@small = RightTriangle.new(3, 4)
|
9
|
+
@big = RightTriangle.new(120, 160)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_hypotenuse
|
13
|
+
assert_equal(5, @small.hypotenuse)
|
14
|
+
assert_equal(200, @big.hypotenuse)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_area
|
18
|
+
assert_equal(6, @small.area)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/bin/tbox
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rubigen'
|
5
|
+
|
6
|
+
if %w(-v --version).include? ARGV.first
|
7
|
+
require File.dirname(__FILE__) + "/../lib/tbox"
|
8
|
+
puts "#{File.basename($0)} #{Tbox::VERSION}"
|
9
|
+
exit(0)
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'rubigen/scripts/generate'
|
13
|
+
source = RubiGen::PathSource.new(:application,
|
14
|
+
File.join(File.dirname(__FILE__), "../app_generators"))
|
15
|
+
RubiGen::Base.reset_sources
|
16
|
+
RubiGen::Base.append_sources source
|
17
|
+
RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'tbox')
|
data/lib/tbox.rb
ADDED
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/tbox.rb'}"
|
9
|
+
puts "Loading tbox gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/tbox.gemspec
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{tbox}
|
5
|
+
s.version = "0.5.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Bobby Norton"]
|
9
|
+
s.date = %q{2009-06-15}
|
10
|
+
s.default_executable = %q{tbox}
|
11
|
+
s.description = %q{Provides a basic directory structure for test-driven learning.}
|
12
|
+
s.email = %q{codeculturist@gmail.com}
|
13
|
+
s.executables = ["tbox"]
|
14
|
+
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "app_generators/tbox/templates/file.txt"]
|
15
|
+
s.files = ["History.txt", "MIT-LICENSE", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "app_generators/tbox/USAGE", "app_generators/tbox/tbox_generator.rb", "app_generators/tbox/templates/README", "app_generators/tbox/templates/file.txt", "app_generators/tbox/templates/rakefile.rb", "app_generators/tbox/templates/right_triangle.rb", "app_generators/tbox/templates/tbox.rb", "app_generators/tbox/templates/test_helper.rb", "app_generators/tbox/templates/test_io.rb", "app_generators/tbox/templates/test_right_triangle.rb", "bin/tbox", "lib/tbox.rb", "script/console", "script/destroy", "script/generate", "tbox.gemspec", "test/test_generator_helper.rb", "test/test_helper.rb", "test/test_tbox_generator.rb"]
|
16
|
+
s.has_rdoc = true
|
17
|
+
s.homepage = %q{http://github.com/bobbyno/tbox/tree/master}
|
18
|
+
s.post_install_message = %q{PostInstall.txt}
|
19
|
+
s.rdoc_options = ["--inline-source", "--charset=UTF-8"]
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
s.rubyforge_project = %q{tbox}
|
22
|
+
s.rubygems_version = %q{1.3.1}
|
23
|
+
s.summary = %q{tbox lowers the barrier to entry for test-driven learning* by providing a basic infrastructure in which to start coding: A directory structure, some classes and unit tests to get started, and a Rakefile to run all tests}
|
24
|
+
|
25
|
+
if s.respond_to? :specification_version then
|
26
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
27
|
+
s.specification_version = 2
|
28
|
+
|
29
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
30
|
+
s.add_development_dependency(%q<newgem>, [">= 1.4.1"])
|
31
|
+
s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
|
32
|
+
else
|
33
|
+
s.add_dependency(%q<newgem>, [">= 1.4.1"])
|
34
|
+
s.add_dependency(%q<hoe>, [">= 1.8.0"])
|
35
|
+
end
|
36
|
+
else
|
37
|
+
s.add_dependency(%q<newgem>, [">= 1.4.1"])
|
38
|
+
s.add_dependency(%q<hoe>, [">= 1.8.0"])
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
begin
|
2
|
+
require File.dirname(__FILE__) + '/test_helper'
|
3
|
+
rescue LoadError
|
4
|
+
require 'test/unit'
|
5
|
+
end
|
6
|
+
require 'fileutils'
|
7
|
+
|
8
|
+
# Must set before requiring generator libs.
|
9
|
+
TMP_ROOT = File.dirname(__FILE__) + "/tmp" unless defined?(TMP_ROOT)
|
10
|
+
PROJECT_NAME = "myproject" unless defined?(PROJECT_NAME)
|
11
|
+
app_root = File.join(TMP_ROOT, PROJECT_NAME)
|
12
|
+
if defined?(APP_ROOT)
|
13
|
+
APP_ROOT.replace(app_root)
|
14
|
+
else
|
15
|
+
APP_ROOT = app_root
|
16
|
+
end
|
17
|
+
if defined?(RAILS_ROOT)
|
18
|
+
RAILS_ROOT.replace(app_root)
|
19
|
+
else
|
20
|
+
RAILS_ROOT = app_root
|
21
|
+
end
|
22
|
+
|
23
|
+
begin
|
24
|
+
require 'rubigen'
|
25
|
+
rescue LoadError
|
26
|
+
require 'rubygems'
|
27
|
+
require 'rubigen'
|
28
|
+
end
|
29
|
+
require 'rubigen/helpers/generator_test_helper'
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
class TestTboxGenerator < Test::Unit::TestCase
|
5
|
+
include RubiGen::GeneratorTestHelper
|
6
|
+
|
7
|
+
def setup
|
8
|
+
bare_setup
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
bare_teardown
|
13
|
+
end
|
14
|
+
|
15
|
+
# Some generator-related assertions:
|
16
|
+
# assert_generated_file(name, &block) # block passed the file contents
|
17
|
+
# assert_directory_exists(name)
|
18
|
+
# assert_generated_class(name, &block)
|
19
|
+
# assert_generated_module(name, &block)
|
20
|
+
# assert_generated_test_for(name, &block)
|
21
|
+
# The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
|
22
|
+
# assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
|
23
|
+
#
|
24
|
+
# Other helper methods are:
|
25
|
+
# app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
|
26
|
+
# bare_setup - place this in setup method to create the APP_ROOT folder for each test
|
27
|
+
# bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
|
28
|
+
|
29
|
+
def test_generator_without_options
|
30
|
+
run_generator('tbox', [APP_ROOT], sources)
|
31
|
+
|
32
|
+
assert_generated_file "rakefile.rb"
|
33
|
+
assert_generated_file "README"
|
34
|
+
assert_generated_file "MIT-LICENSE"
|
35
|
+
assert_directory_exists "lib/samples"
|
36
|
+
assert_generated_file "lib/samples/right_triangle.rb"
|
37
|
+
assert_generated_file "lib/tbox.rb"
|
38
|
+
assert_directory_exists "test/samples"
|
39
|
+
assert_generated_file "test/samples/test_right_triangle.rb"
|
40
|
+
assert_directory_exists "test/data"
|
41
|
+
assert_generated_file "test/data/file.txt"
|
42
|
+
assert_generated_file "test/test_io.rb"
|
43
|
+
assert_generated_file "test/test_helper.rb"
|
44
|
+
|
45
|
+
FileUtils::cd(APP_ROOT) do
|
46
|
+
puts "Running generated rakefile in #{FileUtils::pwd}"
|
47
|
+
`rake`
|
48
|
+
raise "Error occured while running generated rakefile" if ($?.to_s != "0")
|
49
|
+
end
|
50
|
+
|
51
|
+
p app_root_files
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
def sources
|
56
|
+
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
|
57
|
+
]
|
58
|
+
end
|
59
|
+
|
60
|
+
def generator_path
|
61
|
+
"app_generators"
|
62
|
+
end
|
63
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bobbyno-tbox
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bobby Norton
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-06-15 00:00:00 -07:00
|
13
|
+
default_executable: tbox
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: newgem
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.4.1
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: hoe
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.8.0
|
34
|
+
version:
|
35
|
+
description: Provides a basic directory structure for test-driven learning.
|
36
|
+
email: codeculturist@gmail.com
|
37
|
+
executables:
|
38
|
+
- tbox
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- History.txt
|
43
|
+
- Manifest.txt
|
44
|
+
- PostInstall.txt
|
45
|
+
- README.rdoc
|
46
|
+
- app_generators/tbox/templates/file.txt
|
47
|
+
files:
|
48
|
+
- History.txt
|
49
|
+
- MIT-LICENSE
|
50
|
+
- Manifest.txt
|
51
|
+
- PostInstall.txt
|
52
|
+
- README.rdoc
|
53
|
+
- Rakefile
|
54
|
+
- app_generators/tbox/USAGE
|
55
|
+
- app_generators/tbox/tbox_generator.rb
|
56
|
+
- app_generators/tbox/templates/README
|
57
|
+
- app_generators/tbox/templates/file.txt
|
58
|
+
- app_generators/tbox/templates/rakefile.rb
|
59
|
+
- app_generators/tbox/templates/right_triangle.rb
|
60
|
+
- app_generators/tbox/templates/tbox.rb
|
61
|
+
- app_generators/tbox/templates/test_helper.rb
|
62
|
+
- app_generators/tbox/templates/test_io.rb
|
63
|
+
- app_generators/tbox/templates/test_right_triangle.rb
|
64
|
+
- bin/tbox
|
65
|
+
- lib/tbox.rb
|
66
|
+
- script/console
|
67
|
+
- script/destroy
|
68
|
+
- script/generate
|
69
|
+
- tbox.gemspec
|
70
|
+
- test/test_generator_helper.rb
|
71
|
+
- test/test_helper.rb
|
72
|
+
- test/test_tbox_generator.rb
|
73
|
+
has_rdoc: true
|
74
|
+
homepage: http://github.com/bobbyno/tbox/tree/master
|
75
|
+
post_install_message: PostInstall.txt
|
76
|
+
rdoc_options:
|
77
|
+
- --inline-source
|
78
|
+
- --charset=UTF-8
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: "0"
|
86
|
+
version:
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: "0"
|
92
|
+
version:
|
93
|
+
requirements: []
|
94
|
+
|
95
|
+
rubyforge_project: tbox
|
96
|
+
rubygems_version: 1.2.0
|
97
|
+
signing_key:
|
98
|
+
specification_version: 2
|
99
|
+
summary: "tbox lowers the barrier to entry for test-driven learning* by providing a basic infrastructure in which to start coding: A directory structure, some classes and unit tests to get started, and a Rakefile to run all tests"
|
100
|
+
test_files: []
|
101
|
+
|