gigantron 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +22 -0
- data/License.txt +20 -0
- data/Manifest.txt +65 -0
- data/PostInstall.txt +4 -0
- data/README.txt +77 -0
- data/Rakefile +4 -0
- data/app_generators/gigantron/USAGE +7 -0
- data/app_generators/gigantron/gigantron_generator.rb +87 -0
- data/app_generators/gigantron/templates/Rakefile +12 -0
- data/app_generators/gigantron/templates/database.yml.example +9 -0
- data/app_generators/gigantron/templates/initialize.rb +34 -0
- data/app_generators/gigantron/templates/lib/shoulda/active_record_helpers.rb +604 -0
- data/app_generators/gigantron/templates/lib/shoulda/general.rb +118 -0
- data/app_generators/gigantron/templates/lib/shoulda/private_helpers.rb +22 -0
- data/app_generators/gigantron/templates/tasks/import.rake +10 -0
- data/app_generators/gigantron/templates/test/tasks/test_import.rb +23 -0
- data/app_generators/gigantron/templates/test/test_helper.rb +22 -0
- data/bin/gigantron +15 -0
- data/config/hoe.rb +82 -0
- data/config/requirements.rb +15 -0
- data/gigantron_generators/mapreduce_task/USAGE +5 -0
- data/gigantron_generators/mapreduce_task/mapreduce_task_generator.rb +54 -0
- data/gigantron_generators/mapreduce_task/templates/mapreduce/mr_task.rb +22 -0
- data/gigantron_generators/mapreduce_task/templates/tasks/task.rake +5 -0
- data/gigantron_generators/mapreduce_task/templates/test/tasks/test_task.rb +22 -0
- data/gigantron_generators/migration/USAGE +5 -0
- data/gigantron_generators/migration/migration_generator.rb +61 -0
- data/gigantron_generators/migration/templates/db/migrate/migration.rb +7 -0
- data/gigantron_generators/model/USAGE +11 -0
- data/gigantron_generators/model/model_generator.rb +54 -0
- data/gigantron_generators/model/templates/models/model.rb +3 -0
- data/gigantron_generators/model/templates/test/models/test_model.rb +13 -0
- data/gigantron_generators/task/USAGE +10 -0
- data/gigantron_generators/task/task_generator.rb +51 -0
- data/gigantron_generators/task/templates/tasks/task.rake +4 -0
- data/gigantron_generators/task/templates/test/tasks/test_task.rb +22 -0
- data/lib/gigantron.rb +0 -0
- data/lib/gigantron/migrator.rb +10 -0
- data/lib/gigantron/tasks/db.rb +11 -0
- data/lib/gigantron/tasks/test.rb +30 -0
- data/lib/gigantron/version.rb +9 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +82 -0
- data/setup.rb +1585 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/template_database.yml +3 -0
- data/test/template_database.yml.example +9 -0
- data/test/template_migration.rb +16 -0
- data/test/test_generator_helper.rb +29 -29
- data/test/test_gigantron.rb +11 -11
- data/test/test_gigantron_generator.rb +118 -118
- data/test/test_helper.rb +4 -4
- data/test/test_mapreduce_task_generator.rb +50 -50
- data/test/test_migration_generator.rb +49 -49
- data/test/test_model_generator.rb +53 -53
- data/test/test_task_generator.rb +48 -48
- data/website/index.html +224 -0
- data/website/index.txt +154 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.html.erb +48 -0
- metadata +152 -46
@@ -1,49 +1,49 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
|
2
|
-
|
3
|
-
|
4
|
-
class TestMigrationGenerator < 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
|
-
name = "CreateFoo"
|
31
|
-
run_generator('migration', [name], sources)
|
32
|
-
assert_directory_exists "db/"
|
33
|
-
assert_directory_exists "db/migrate/"
|
34
|
-
assert_generated_file "db/migrate/001_create_foo.rb"
|
35
|
-
name2 = "AlterFoo"
|
36
|
-
run_generator('migration', [name2], sources)
|
37
|
-
assert_generated_file "db/migrate/002_alter_foo.rb"
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
def sources
|
42
|
-
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
|
43
|
-
]
|
44
|
-
end
|
45
|
-
|
46
|
-
def generator_path
|
47
|
-
"gigantron_generators"
|
48
|
-
end
|
49
|
-
end
|
1
|
+
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
|
2
|
+
|
3
|
+
|
4
|
+
class TestMigrationGenerator < 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
|
+
name = "CreateFoo"
|
31
|
+
run_generator('migration', [name], sources)
|
32
|
+
assert_directory_exists "db/"
|
33
|
+
assert_directory_exists "db/migrate/"
|
34
|
+
assert_generated_file "db/migrate/001_create_foo.rb"
|
35
|
+
name2 = "AlterFoo"
|
36
|
+
run_generator('migration', [name2], sources)
|
37
|
+
assert_generated_file "db/migrate/002_alter_foo.rb"
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
def sources
|
42
|
+
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
|
43
|
+
]
|
44
|
+
end
|
45
|
+
|
46
|
+
def generator_path
|
47
|
+
"gigantron_generators"
|
48
|
+
end
|
49
|
+
end
|
@@ -1,53 +1,53 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
|
2
|
-
|
3
|
-
|
4
|
-
class TestModelGenerator < 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
|
-
name = "FooBaz"
|
31
|
-
run_generator('model', [name], sources)
|
32
|
-
assert_directory_exists "models/"
|
33
|
-
assert_generated_file "models/foo_baz.rb"
|
34
|
-
assert_directory_exists "test/"
|
35
|
-
assert_directory_exists "test/models/"
|
36
|
-
assert_generated_file "test/models/test_foo_baz.rb"
|
37
|
-
|
38
|
-
#check migration
|
39
|
-
assert_directory_exists "db/"
|
40
|
-
assert_directory_exists "db/migrate/"
|
41
|
-
assert_generated_file "db/migrate/001_create_foo_bazs.rb"
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
def sources
|
46
|
-
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
|
47
|
-
]
|
48
|
-
end
|
49
|
-
|
50
|
-
def generator_path
|
51
|
-
"gigantron_generators"
|
52
|
-
end
|
53
|
-
end
|
1
|
+
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
|
2
|
+
|
3
|
+
|
4
|
+
class TestModelGenerator < 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
|
+
name = "FooBaz"
|
31
|
+
run_generator('model', [name], sources)
|
32
|
+
assert_directory_exists "models/"
|
33
|
+
assert_generated_file "models/foo_baz.rb"
|
34
|
+
assert_directory_exists "test/"
|
35
|
+
assert_directory_exists "test/models/"
|
36
|
+
assert_generated_file "test/models/test_foo_baz.rb"
|
37
|
+
|
38
|
+
#check migration
|
39
|
+
assert_directory_exists "db/"
|
40
|
+
assert_directory_exists "db/migrate/"
|
41
|
+
assert_generated_file "db/migrate/001_create_foo_bazs.rb"
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
def sources
|
46
|
+
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
|
47
|
+
]
|
48
|
+
end
|
49
|
+
|
50
|
+
def generator_path
|
51
|
+
"gigantron_generators"
|
52
|
+
end
|
53
|
+
end
|
data/test/test_task_generator.rb
CHANGED
@@ -1,48 +1,48 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
|
2
|
-
|
3
|
-
|
4
|
-
class TestTaskGenerator < 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
|
-
name = "FooBar"
|
31
|
-
run_generator('task', [name], sources)
|
32
|
-
assert_directory_exists "tasks/"
|
33
|
-
assert_generated_file "tasks/foo_bar.rake"
|
34
|
-
assert_directory_exists "test/"
|
35
|
-
assert_directory_exists "test/tasks"
|
36
|
-
assert_generated_file "test/tasks/test_foo_bar.rb"
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
def sources
|
41
|
-
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
|
42
|
-
]
|
43
|
-
end
|
44
|
-
|
45
|
-
def generator_path
|
46
|
-
"gigantron_generators"
|
47
|
-
end
|
48
|
-
end
|
1
|
+
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
|
2
|
+
|
3
|
+
|
4
|
+
class TestTaskGenerator < 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
|
+
name = "FooBar"
|
31
|
+
run_generator('task', [name], sources)
|
32
|
+
assert_directory_exists "tasks/"
|
33
|
+
assert_generated_file "tasks/foo_bar.rake"
|
34
|
+
assert_directory_exists "test/"
|
35
|
+
assert_directory_exists "test/tasks"
|
36
|
+
assert_generated_file "test/tasks/test_foo_bar.rb"
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def sources
|
41
|
+
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
|
42
|
+
]
|
43
|
+
end
|
44
|
+
|
45
|
+
def generator_path
|
46
|
+
"gigantron_generators"
|
47
|
+
end
|
48
|
+
end
|
data/website/index.html
ADDED
@@ -0,0 +1,224 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
7
|
+
<title>
|
8
|
+
Gigantron: Processor of Data
|
9
|
+
</title>
|
10
|
+
<script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script>
|
11
|
+
<style>
|
12
|
+
|
13
|
+
</style>
|
14
|
+
<script type="text/javascript">
|
15
|
+
window.onload = function() {
|
16
|
+
settings = {
|
17
|
+
tl: { radius: 10 },
|
18
|
+
tr: { radius: 10 },
|
19
|
+
bl: { radius: 10 },
|
20
|
+
br: { radius: 10 },
|
21
|
+
antiAlias: true,
|
22
|
+
autoPad: true,
|
23
|
+
validTags: ["div"]
|
24
|
+
}
|
25
|
+
var versionBox = new curvyCorners(settings, document.getElementById("version"));
|
26
|
+
versionBox.applyCornersToAll();
|
27
|
+
}
|
28
|
+
</script>
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="main">
|
32
|
+
|
33
|
+
<h1>Gigantron: Processor of Data</h1>
|
34
|
+
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/gigantron"; return false'>
|
35
|
+
<p>Get Version</p>
|
36
|
+
<a href="http://rubyforge.org/projects/gigantron" class="numbers">0.1.3</a>
|
37
|
+
</div>
|
38
|
+
<h1>→ ‘gigantron’</h1>
|
39
|
+
|
40
|
+
|
41
|
+
<h2>What</h2>
|
42
|
+
|
43
|
+
|
44
|
+
<p>Gigantron is a simple framework for the creation and organization of
|
45
|
+
data processing projects. Data-processing transforms are created as Rake tasks
|
46
|
+
and data is handled through ActiveRecord models. (DataMapper was the original
|
47
|
+
plan, but it has problems playing nicely with JRuby for now).</p>
|
48
|
+
|
49
|
+
|
50
|
+
<p>Ruby is great for exploratory data processing. Data processing projects tend
|
51
|
+
to grow up and encompass large numbers of random scripts and input files. It
|
52
|
+
is easy to get lost in coding and lose organization. Gigantron is an attempt
|
53
|
+
to use code generation and random magic to make maintaining organized DP
|
54
|
+
projects simple. Code is separated into data (models) and operations on the
|
55
|
+
data (tasks). Code generators stub out these files and the associated tests
|
56
|
+
for the user.</p>
|
57
|
+
|
58
|
+
|
59
|
+
<p>Gigantron was written for my own needs working with atmospheric data and will
|
60
|
+
evolve through use to reduce the trivialities that can sometimes dominate the
|
61
|
+
work of developers.</p>
|
62
|
+
|
63
|
+
|
64
|
+
<h2>Installing</h2>
|
65
|
+
|
66
|
+
|
67
|
+
<p><pre class='syntax'><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">gigantron</span></pre></p>
|
68
|
+
|
69
|
+
|
70
|
+
<p>This should handle the major dependencies automatically except for your
|
71
|
+
database adapter. If you are on JRuby the gem is
|
72
|
+
<code>activerecord-jdbcsqlite3-adapter</code> for sqlite3 and
|
73
|
+
<code>activerecord-jdbcmysql-adapter</code> for mysql. On <span class="caps">MRI</span> be sure to install
|
74
|
+
<code>sqlite3-ruby</code> if you are using sqlite.</p>
|
75
|
+
|
76
|
+
|
77
|
+
<p>Note: JDBCSqlite3 is still a work in progress and migrations are basically
|
78
|
+
broken for it.</p>
|
79
|
+
|
80
|
+
|
81
|
+
<h2>The basics</h2>
|
82
|
+
|
83
|
+
|
84
|
+
<pre>
|
85
|
+
# Generate new project
|
86
|
+
shell> $ gigantron project
|
87
|
+
create
|
88
|
+
create tasks
|
89
|
+
create db
|
90
|
+
create models
|
91
|
+
create lib
|
92
|
+
create test
|
93
|
+
create Rakefile
|
94
|
+
create database.yml
|
95
|
+
create initialize.rb
|
96
|
+
create tasks/import.rake
|
97
|
+
create test/test_helper.rb
|
98
|
+
create test/models
|
99
|
+
create test/tasks
|
100
|
+
create test/tasks/test_import.rb
|
101
|
+
dependency install_rubigen_scripts
|
102
|
+
create script
|
103
|
+
create script/generate
|
104
|
+
create script/destroy
|
105
|
+
shell> $ cd project
|
106
|
+
# Create new model
|
107
|
+
shell> $ script/generate model modis
|
108
|
+
exists models/
|
109
|
+
create models/modis.rb
|
110
|
+
exists test/
|
111
|
+
exists test/models/
|
112
|
+
create test/models/test_modis.rb
|
113
|
+
shell> $ script/generate task modis_to_kml
|
114
|
+
exists tasks/
|
115
|
+
create tasks/modis_to_kml.rake
|
116
|
+
exists test/
|
117
|
+
exists test/tasks/
|
118
|
+
create test/tasks/test_modis_to_kml.rb
|
119
|
+
</pre>
|
120
|
+
|
121
|
+
<p>One can edit these files to add functionality. Gigantron by default includes
|
122
|
+
ActiveSupport for convenience.</p>
|
123
|
+
|
124
|
+
|
125
|
+
<h2>Hacking</h2>
|
126
|
+
|
127
|
+
|
128
|
+
<p>Gigantron is super minimal now, so modifying it is pretty easy. The gigantron
|
129
|
+
application generator (that which is invoked by the <code>gigantron</code> command) lives
|
130
|
+
in <code>app_generators/gigantron/</code>. The template files and the template dir
|
131
|
+
structure are in <code>app_generators/gigantron/templates/</code>. When adding new
|
132
|
+
templates, directories, or files, add the names first to the tests in
|
133
|
+
<code>test/test_gigantron_generator.rb</code>, then the stubs to
|
134
|
+
<code>app_generators/gigantron/templates</code>, and then finally describe them in the
|
135
|
+
manifest section of <code>app_generators/gigantron/gigantron_generator.rb</code>. It
|
136
|
+
should look something like</p>
|
137
|
+
|
138
|
+
|
139
|
+
<p><pre class='syntax'>
|
140
|
+
<span class="keyword">def </span><span class="method">manifest</span>
|
141
|
+
<span class="ident">record</span> <span class="keyword">do</span> <span class="punct">|</span><span class="ident">m</span><span class="punct">|</span>
|
142
|
+
<span class="punct">...</span>
|
143
|
+
<span class="ident">m</span><span class="punct">.</span><span class="ident">file</span> <span class="punct">"</span><span class="string">new_file</span><span class="punct">",</span> <span class="punct">"</span><span class="string">new_file</span><span class="punct">"</span> <span class="comment">#straight file copy</span>
|
144
|
+
<span class="ident">m</span><span class="punct">.</span><span class="ident">directory</span> <span class="punct">"</span><span class="string">my_new_dir</span><span class="punct">"</span> <span class="comment">#create directory</span>
|
145
|
+
<span class="ident">m</span><span class="punct">.</span><span class="ident">template</span> <span class="punct">"</span><span class="string">new_thing</span><span class="punct">",</span> <span class="punct">"</span><span class="string">new_thing</span><span class="punct">"</span> <span class="comment">#runs file through ERB when copying</span>
|
146
|
+
<span class="keyword">end</span>
|
147
|
+
<span class="keyword">end</span>
|
148
|
+
</pre></p>
|
149
|
+
|
150
|
+
|
151
|
+
<p>It might be handy to know that in <code>gigantron_generator.rb</code> the name provided to the generator can be referenced as <code>@name</code>. This can be used like</p>
|
152
|
+
|
153
|
+
|
154
|
+
<p><pre class='syntax'>
|
155
|
+
<span class="ident">record</span> <span class="keyword">do</span> <span class="punct">|</span><span class="ident">m</span><span class="punct">|</span>
|
156
|
+
<span class="ident">m</span><span class="punct">.</span><span class="ident">file</span> <span class="punct">"</span><span class="string">renamed_file</span><span class="punct">",</span> <span class="punct">"</span><span class="string"><span class="expr">#{@name}</span>_file</span><span class="punct">"</span>
|
157
|
+
<span class="keyword">end</span>
|
158
|
+
</pre></p>
|
159
|
+
|
160
|
+
|
161
|
+
<p>The same value is available to your templates as just <code>name</code>. You can template
|
162
|
+
a file like</p>
|
163
|
+
|
164
|
+
|
165
|
+
<p><pre class='syntax'>
|
166
|
+
<span class="keyword">class </span><span class="class">Test</span><span class="punct"><%=</span><span class="string"> name.camelcase %> < Test::Unit::TestCase
|
167
|
+
...
|
168
|
+
end<span class="normal">
|
169
|
+
</span></span></pre></p>
|
170
|
+
|
171
|
+
|
172
|
+
<p>The same process applies to the model and task generator for gigantron
|
173
|
+
projects. These generators live in <code>gigantron_generators/</code>. Modifying them
|
174
|
+
is exactly the same as modifying the application generator.</p>
|
175
|
+
|
176
|
+
|
177
|
+
<p>All of this is pretty vanilla <a href="http://rubigen.rubyforge.org">RubiGen</a>, so if in doubt, check out the docos on that fine piece of work.</p>
|
178
|
+
|
179
|
+
|
180
|
+
<p>The only other place for code in Gigantron is is <code>lib/gigantron/tasks/</code> where a few boilerplate test and db tasks live. I think I ripped the test tasks off of rails.</p>
|
181
|
+
|
182
|
+
|
183
|
+
<p>If you have any questions, do contact me. I am interested in anything that will make Gigantron suck less and be useful to people.</p>
|
184
|
+
|
185
|
+
|
186
|
+
<h2>How to submit patches</h2>
|
187
|
+
|
188
|
+
|
189
|
+
<ul>
|
190
|
+
<li>github: <a href="http://github.com/schleyfox/gigantron/tree/master">http://github.com/schleyfox/gigantron/tree/master</a></li>
|
191
|
+
</ul>
|
192
|
+
|
193
|
+
|
194
|
+
<pre>git clone git://github.com/schleyfox/gigantron.git</pre>
|
195
|
+
|
196
|
+
<h3>Build and test instructions</h3>
|
197
|
+
|
198
|
+
|
199
|
+
<pre>cd gigantron
|
200
|
+
cp test/template_database.yml.example test/template_database.yml
|
201
|
+
vim test/template_database.yml
|
202
|
+
rake test
|
203
|
+
rake install_gem</pre>
|
204
|
+
|
205
|
+
<h2>License</h2>
|
206
|
+
|
207
|
+
|
208
|
+
<p>This code is free to use under the terms of the <span class="caps">MIT</span> license.</p>
|
209
|
+
|
210
|
+
|
211
|
+
<h2>Contact</h2>
|
212
|
+
|
213
|
+
|
214
|
+
<p>Comments are welcome. Send an email to <a href="mailto:ben@pixelmachine.org">Ben Hughes</a></p>
|
215
|
+
<p class="coda">
|
216
|
+
<a href="ben@pixelmachine.org">Ben Hughes</a>, 24th June 2008<br>
|
217
|
+
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
218
|
+
</p>
|
219
|
+
</div>
|
220
|
+
|
221
|
+
<!-- insert site tracking codes here, like Google Urchin -->
|
222
|
+
|
223
|
+
</body>
|
224
|
+
</html>
|