gigantron 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/License.txt +20 -0
- data/Manifest.txt +48 -0
- data/PostInstall.txt +4 -0
- data/README.txt +70 -0
- data/Rakefile +4 -0
- data/app_generators/gigantron/USAGE +7 -0
- data/app_generators/gigantron/gigantron_generator.rb +80 -0
- data/app_generators/gigantron/templates/Rakefile +12 -0
- data/app_generators/gigantron/templates/database.yml +9 -0
- data/app_generators/gigantron/templates/initialize.rb +26 -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 +5 -0
- data/bin/gigantron +15 -0
- data/config/hoe.rb +80 -0
- data/config/requirements.rb +15 -0
- data/gigantron_generators/model/USAGE +11 -0
- data/gigantron_generators/model/model_generator.rb +51 -0
- data/gigantron_generators/model/templates/models/model.rb +6 -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 +50 -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/tasks/db.rb +8 -0
- data/lib/gigantron/tasks/test.rb +30 -0
- data/lib/gigantron/version.rb +9 -0
- data/lib/gigantron.rb +0 -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/test_generator_helper.rb +29 -0
- data/test/test_gigantron.rb +11 -0
- data/test/test_gigantron_generator.rb +56 -0
- data/test/test_helper.rb +4 -0
- data/test/test_model_generator.rb +48 -0
- data/test/test_task_generator.rb +48 -0
- data/website/index.html +149 -0
- data/website/index.txt +93 -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 +110 -0
data/History.txt
ADDED
data/License.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Ben Hughes
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
History.txt
|
2
|
+
License.txt
|
3
|
+
Manifest.txt
|
4
|
+
PostInstall.txt
|
5
|
+
README.txt
|
6
|
+
Rakefile
|
7
|
+
app_generators/gigantron/USAGE
|
8
|
+
app_generators/gigantron/gigantron_generator.rb
|
9
|
+
app_generators/gigantron/templates/Rakefile
|
10
|
+
app_generators/gigantron/templates/database.yml
|
11
|
+
app_generators/gigantron/templates/initialize.rb
|
12
|
+
app_generators/gigantron/templates/tasks/import.rake
|
13
|
+
app_generators/gigantron/templates/test/tasks/test_import.rb
|
14
|
+
app_generators/gigantron/templates/test/test_helper.rb
|
15
|
+
bin/gigantron
|
16
|
+
config/hoe.rb
|
17
|
+
config/requirements.rb
|
18
|
+
gigantron_generators/model/USAGE
|
19
|
+
gigantron_generators/model/model_generator.rb
|
20
|
+
gigantron_generators/model/templates/models/model.rb
|
21
|
+
gigantron_generators/model/templates/test/models/test_model.rb
|
22
|
+
gigantron_generators/task/USAGE
|
23
|
+
gigantron_generators/task/task_generator.rb
|
24
|
+
gigantron_generators/task/templates/tasks/task.rake
|
25
|
+
gigantron_generators/task/templates/test/tasks/test_task.rb
|
26
|
+
lib/gigantron.rb
|
27
|
+
lib/gigantron/tasks/db.rb
|
28
|
+
lib/gigantron/tasks/test.rb
|
29
|
+
lib/gigantron/version.rb
|
30
|
+
script/console
|
31
|
+
script/destroy
|
32
|
+
script/generate
|
33
|
+
script/txt2html
|
34
|
+
setup.rb
|
35
|
+
tasks/deployment.rake
|
36
|
+
tasks/environment.rake
|
37
|
+
tasks/website.rake
|
38
|
+
test/test_generator_helper.rb
|
39
|
+
test/test_gigantron.rb
|
40
|
+
test/test_gigantron_generator.rb
|
41
|
+
test/test_helper.rb
|
42
|
+
test/test_model_generator.rb
|
43
|
+
test/test_task_generator.rb
|
44
|
+
website/index.html
|
45
|
+
website/index.txt
|
46
|
+
website/javascripts/rounded_corners_lite.inc.js
|
47
|
+
website/stylesheets/screen.css
|
48
|
+
website/template.html.erb
|
data/PostInstall.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
= Gigantron: Processor of Data
|
2
|
+
|
3
|
+
http://gigantron.rubyforge.org
|
4
|
+
http://github.com/schleyfox/gigantron
|
5
|
+
|
6
|
+
== DESCRIPTION:
|
7
|
+
|
8
|
+
Gigantron is a simple framework for the creation and organization of
|
9
|
+
data processing projects. Data-processing transforms are created as Rake tasks
|
10
|
+
and data is handled through DataMapper models.
|
11
|
+
|
12
|
+
== FEATURES/PROBLEMS:
|
13
|
+
|
14
|
+
Features:
|
15
|
+
* Generates folder/file structure for new DP projects
|
16
|
+
* Contains generators for both models and tasks
|
17
|
+
|
18
|
+
== SYNOPSIS:
|
19
|
+
|
20
|
+
Use:
|
21
|
+
|
22
|
+
shell> $ gigantron projectname
|
23
|
+
|
24
|
+
to generate the project folder and then
|
25
|
+
|
26
|
+
shell> $ script/generate model modelname
|
27
|
+
|
28
|
+
OR
|
29
|
+
|
30
|
+
shell> $ script/generate task taskname
|
31
|
+
|
32
|
+
to add code.
|
33
|
+
|
34
|
+
== REQUIREMENTS:
|
35
|
+
|
36
|
+
* RubyGems
|
37
|
+
* RubiGen
|
38
|
+
* Rake
|
39
|
+
* DataMapper
|
40
|
+
* ActiveSupport
|
41
|
+
* Shoulda
|
42
|
+
|
43
|
+
== INSTALL:
|
44
|
+
|
45
|
+
sudo gem install gigantron
|
46
|
+
|
47
|
+
== LICENSE:
|
48
|
+
|
49
|
+
(The MIT License)
|
50
|
+
|
51
|
+
Copyright (c) 2008 FIX
|
52
|
+
|
53
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
54
|
+
a copy of this software and associated documentation files (the
|
55
|
+
'Software'), to deal in the Software without restriction, including
|
56
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
57
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
58
|
+
permit persons to whom the Software is furnished to do so, subject to
|
59
|
+
the following conditions:
|
60
|
+
|
61
|
+
The above copyright notice and this permission notice shall be
|
62
|
+
included in all copies or substantial portions of the Software.
|
63
|
+
|
64
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
65
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
66
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
67
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
68
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
69
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
70
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
class GigantronGenerator < 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
|
+
# Create stubs
|
25
|
+
m.file "Rakefile", "Rakefile"
|
26
|
+
m.file "database.yml", "database.yml"
|
27
|
+
m.file "initialize.rb", "initialize.rb"
|
28
|
+
|
29
|
+
m.file "tasks/import.rake", "tasks/import.rake"
|
30
|
+
|
31
|
+
m.file "test/test_helper.rb", "test/test_helper.rb"
|
32
|
+
|
33
|
+
m.directory "test/models"
|
34
|
+
m.directory "test/tasks"
|
35
|
+
|
36
|
+
m.file "test/tasks/test_import.rb", "test/tasks/test_import.rb"
|
37
|
+
|
38
|
+
|
39
|
+
m.dependency "install_rubigen_scripts", [destination_root, 'gigantron'],
|
40
|
+
:shebang => options[:shebang], :collision => :force
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
protected
|
45
|
+
def banner
|
46
|
+
<<-EOS
|
47
|
+
Creates a ...
|
48
|
+
|
49
|
+
USAGE: #{spec.name} name
|
50
|
+
EOS
|
51
|
+
end
|
52
|
+
|
53
|
+
def add_options!(opts)
|
54
|
+
opts.separator ''
|
55
|
+
opts.separator 'Options:'
|
56
|
+
# For each option below, place the default
|
57
|
+
# at the top of the file next to "default_options"
|
58
|
+
# opts.on("-a", "--author=\"Your Name\"", String,
|
59
|
+
# "Some comment about this option",
|
60
|
+
# "Default: none") { |options[:author]| }
|
61
|
+
opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
62
|
+
end
|
63
|
+
|
64
|
+
def extract_options
|
65
|
+
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
66
|
+
# Templates can access these value via the attr_reader-generated methods, but not the
|
67
|
+
# raw instance variable value.
|
68
|
+
# @author = options[:author]
|
69
|
+
end
|
70
|
+
|
71
|
+
# Installation skeleton. Intermediate directories are automatically
|
72
|
+
# created so don't sweat their absence here.
|
73
|
+
BASEDIRS = %w(
|
74
|
+
tasks
|
75
|
+
db
|
76
|
+
models
|
77
|
+
lib
|
78
|
+
test
|
79
|
+
)
|
80
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# This file handles all the background initialization work that the programmer
|
2
|
+
# shouldn't have to worry about.
|
3
|
+
# This includes database startup, common requires, activesupport, and other
|
4
|
+
# magic. I'm not sure if this is a good idea or not.
|
5
|
+
|
6
|
+
# ENV works like in rails, except is :real or :test
|
7
|
+
GTRON_ENV rescue GTRON_ENV = :real
|
8
|
+
|
9
|
+
GTRON_ROOT = File.dirname(__FILE__)
|
10
|
+
|
11
|
+
require 'rubygems'
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'activesupport'
|
15
|
+
#set up autoload paths
|
16
|
+
Dependencies.load_paths << "#{GTRON_ROOT}/lib/"
|
17
|
+
|
18
|
+
gem 'dm-core'
|
19
|
+
require 'data_mapper'
|
20
|
+
|
21
|
+
|
22
|
+
def get_db_conn(env)
|
23
|
+
DataMapper.setup(:default, YAML::load(File.read("database.yml"))[env])
|
24
|
+
Dir["models/**/*.rb"].each {|r| load r }
|
25
|
+
nil
|
26
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
desc "Import data into the database"
|
2
|
+
task :import do
|
3
|
+
# Acquire your data (e.g. from input/ or something) and parse it into
|
4
|
+
# your database. Your models should probably be the ones doing the heavy
|
5
|
+
# lifting on this one.
|
6
|
+
#
|
7
|
+
# Ex:
|
8
|
+
# Foo.import_yaml(FileList["input/*.yml"].to_a)
|
9
|
+
get_db_conn(GTRON_ENV)
|
10
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
class TestImport < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
get_db_conn(GTRON_ENV)
|
6
|
+
@rake = Rake::Application.new
|
7
|
+
Rake.application = @rake
|
8
|
+
load File.dirname(__FILE__) + '/../../tasks/import.rake'
|
9
|
+
end
|
10
|
+
|
11
|
+
should "import data" do
|
12
|
+
# Testing rake is a bit different
|
13
|
+
# http://blog.nicksieger.com/articles/2007/06/11/test-your-rake-tasks
|
14
|
+
# Example:
|
15
|
+
# @rake["task_name"].invoke
|
16
|
+
@rake["import"].invoke
|
17
|
+
assert true
|
18
|
+
end
|
19
|
+
|
20
|
+
def teardown
|
21
|
+
Rake.application = nil
|
22
|
+
end
|
23
|
+
end
|
data/bin/gigantron
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rubigen'
|
3
|
+
|
4
|
+
if %w(-v --version).include? ARGV.first
|
5
|
+
require 'gigantron/version'
|
6
|
+
puts "#{File.basename($0)} #{Gigantron::VERSION::STRING}"
|
7
|
+
exit(0)
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
source = RubiGen::PathSource.new(:application,
|
12
|
+
File.join(File.dirname(__FILE__), "../app_generators"))
|
13
|
+
RubiGen::Base.reset_sources
|
14
|
+
RubiGen::Base.append_sources source
|
15
|
+
RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'gigantron')
|
data/config/hoe.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'gigantron/version'
|
2
|
+
|
3
|
+
AUTHOR = 'Ben Hughes' # can also be an array of Authors
|
4
|
+
EMAIL = "ben@pixelmachine.org"
|
5
|
+
DESCRIPTION = "description of gem"
|
6
|
+
GEM_NAME = 'gigantron' # what ppl will type to install your gem
|
7
|
+
RUBYFORGE_PROJECT = 'gigantron' # The unix name for your project
|
8
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
9
|
+
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
10
|
+
EXTRA_DEPENDENCIES = [
|
11
|
+
['activesupport', '>= 2.0.2'],
|
12
|
+
['rubigen', '>= 1.3.2'],
|
13
|
+
['rake', '>= 0.8.1'],
|
14
|
+
['Shoulda', '>= 1.1.1'],
|
15
|
+
['dm-core', '>= 0.9.1'],
|
16
|
+
['do_sqlite3', '>= 0.9.1'],
|
17
|
+
['data_objects', '>= 0.9.1'],
|
18
|
+
['dm-more', '>= 0.9.1']
|
19
|
+
] # An array of rubygem dependencies [name, version]
|
20
|
+
|
21
|
+
@config_file = "~/.rubyforge/user-config.yml"
|
22
|
+
@config = nil
|
23
|
+
RUBYFORGE_USERNAME = "unknown"
|
24
|
+
def rubyforge_username
|
25
|
+
unless @config
|
26
|
+
begin
|
27
|
+
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
28
|
+
rescue
|
29
|
+
puts <<-EOS
|
30
|
+
ERROR: No rubyforge config file found: #{@config_file}
|
31
|
+
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
32
|
+
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
33
|
+
EOS
|
34
|
+
exit
|
35
|
+
end
|
36
|
+
end
|
37
|
+
RUBYFORGE_USERNAME.replace @config["username"]
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
REV = nil
|
42
|
+
# UNCOMMENT IF REQUIRED:
|
43
|
+
# REV = YAML.load(`svn info`)['Revision']
|
44
|
+
VERS = Gigantron::VERSION::STRING + (REV ? ".#{REV}" : "")
|
45
|
+
RDOC_OPTS = ['--quiet', '--title', 'gigantron documentation',
|
46
|
+
"--opname", "index.html",
|
47
|
+
"--line-numbers",
|
48
|
+
"--main", "README",
|
49
|
+
"--inline-source"]
|
50
|
+
|
51
|
+
class Hoe
|
52
|
+
def extra_deps
|
53
|
+
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
54
|
+
@extra_deps
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# Generate all the Rake tasks
|
59
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
60
|
+
$hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
61
|
+
p.developer(AUTHOR, EMAIL)
|
62
|
+
p.description = DESCRIPTION
|
63
|
+
p.summary = DESCRIPTION
|
64
|
+
p.url = HOMEPATH
|
65
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
66
|
+
p.test_globs = ["test/**/test_*.rb"]
|
67
|
+
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
|
68
|
+
|
69
|
+
# == Optional
|
70
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
71
|
+
#p.extra_deps = EXTRA_DEPENDENCIES
|
72
|
+
|
73
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
74
|
+
end
|
75
|
+
|
76
|
+
CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
77
|
+
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
78
|
+
$hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
79
|
+
$hoe.rsync_args = '-av --delete --ignore-errors'
|
80
|
+
$hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
include FileUtils
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
%w[rake hoe newgem rubigen].each do |req_gem|
|
6
|
+
begin
|
7
|
+
require req_gem
|
8
|
+
rescue LoadError
|
9
|
+
puts "This Rakefile requires the '#{req_gem}' RubyGem."
|
10
|
+
puts "Installation: gem install #{req_gem} -y"
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Description:
|
2
|
+
Generate a DataMapper model for your Gigantron project.
|
3
|
+
|
4
|
+
|
5
|
+
Usage:
|
6
|
+
shell> $ script/generate model modelname
|
7
|
+
|
8
|
+
1. edit models/modelname.rb to create the table schema
|
9
|
+
2. write tests in test/models/test_modelname.rb
|
10
|
+
3. run 'rake db:automigrate' to have changes updated
|
11
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
class ModelGenerator < RubiGen::Base
|
2
|
+
|
3
|
+
default_options :author => nil
|
4
|
+
|
5
|
+
attr_reader :name
|
6
|
+
|
7
|
+
def initialize(runtime_args, runtime_options = {})
|
8
|
+
super
|
9
|
+
usage if args.empty?
|
10
|
+
@name = args.shift
|
11
|
+
extract_options
|
12
|
+
end
|
13
|
+
|
14
|
+
def manifest
|
15
|
+
record do |m|
|
16
|
+
m.directory "models/"
|
17
|
+
m.template "models/model.rb", "models/#{@name}.rb"
|
18
|
+
|
19
|
+
m.directory "test/"
|
20
|
+
m.directory "test/models/"
|
21
|
+
m.template "test/models/test_model.rb", "test/models/test_#{name}.rb"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
protected
|
26
|
+
def banner
|
27
|
+
<<-EOS
|
28
|
+
Creates a ...
|
29
|
+
|
30
|
+
USAGE: #{$0} #{spec.name} name
|
31
|
+
EOS
|
32
|
+
end
|
33
|
+
|
34
|
+
def add_options!(opts)
|
35
|
+
# opts.separator ''
|
36
|
+
# opts.separator 'Options:'
|
37
|
+
# For each option below, place the default
|
38
|
+
# at the top of the file next to "default_options"
|
39
|
+
# opts.on("-a", "--author=\"Your Name\"", String,
|
40
|
+
# "Some comment about this option",
|
41
|
+
# "Default: none") { |options[:author]| }
|
42
|
+
# opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
43
|
+
end
|
44
|
+
|
45
|
+
def extract_options
|
46
|
+
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
47
|
+
# Templates can access these value via the attr_reader-generated methods, but not the
|
48
|
+
# raw instance variable value.
|
49
|
+
# @author = options[:author]
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
class Test<%= name.capitalize %> < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
get_db_conn(GTRON_ENV)
|
6
|
+
DataMapper.auto_migrate!
|
7
|
+
end
|
8
|
+
|
9
|
+
#replace with real tests
|
10
|
+
should "be true" do
|
11
|
+
assert true
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class TaskGenerator < RubiGen::Base
|
2
|
+
|
3
|
+
default_options :author => nil
|
4
|
+
|
5
|
+
attr_reader :name
|
6
|
+
|
7
|
+
def initialize(runtime_args, runtime_options = {})
|
8
|
+
super
|
9
|
+
usage if args.empty?
|
10
|
+
@name = args.shift
|
11
|
+
extract_options
|
12
|
+
end
|
13
|
+
|
14
|
+
def manifest
|
15
|
+
record do |m|
|
16
|
+
m.directory "tasks/"
|
17
|
+
m.template "tasks/task.rake", "tasks/#{@name}.rake"
|
18
|
+
m.directory "test/"
|
19
|
+
m.directory "test/tasks/"
|
20
|
+
m.template "test/tasks/test_task.rb", "test/tasks/test_#{@name}.rb"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
def banner
|
26
|
+
<<-EOS
|
27
|
+
Creates a ...
|
28
|
+
|
29
|
+
USAGE: #{$0} #{spec.name} name
|
30
|
+
EOS
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_options!(opts)
|
34
|
+
# opts.separator ''
|
35
|
+
# opts.separator 'Options:'
|
36
|
+
# For each option below, place the default
|
37
|
+
# at the top of the file next to "default_options"
|
38
|
+
# opts.on("-a", "--author=\"Your Name\"", String,
|
39
|
+
# "Some comment about this option",
|
40
|
+
# "Default: none") { |options[:author]| }
|
41
|
+
# opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
42
|
+
end
|
43
|
+
|
44
|
+
def extract_options
|
45
|
+
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
46
|
+
# Templates can access these value via the attr_reader-generated methods, but not the
|
47
|
+
# raw instance variable value.
|
48
|
+
# @author = options[:author]
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
class Test<%= name.capitalize %> < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
get_db_conn(GTRON_ENV)
|
6
|
+
@rake = Rake::Application.new
|
7
|
+
Rake.application = @rake
|
8
|
+
load File.dirname(__FILE__) + '/../../tasks/<%= name %>.rake'
|
9
|
+
end
|
10
|
+
|
11
|
+
should "be true" do
|
12
|
+
# Testing rake is a bit different
|
13
|
+
# http://blog.nicksieger.com/articles/2007/06/11/test-your-rake-tasks
|
14
|
+
# Example:
|
15
|
+
# @rake["task_name"].invoke
|
16
|
+
assert true
|
17
|
+
end
|
18
|
+
|
19
|
+
def teardown
|
20
|
+
Rake.application = nil
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rake/testtask'
|
2
|
+
|
3
|
+
desc "Test all models and tasks"
|
4
|
+
task :test do
|
5
|
+
errors = %w(test:models test:tasks).collect do |task|
|
6
|
+
begin
|
7
|
+
Rake::Task[task].invoke
|
8
|
+
nil
|
9
|
+
rescue => e
|
10
|
+
task
|
11
|
+
end
|
12
|
+
end.compact
|
13
|
+
abort "Errors running #{errors.to_sentence}!" if errors.any?
|
14
|
+
end
|
15
|
+
|
16
|
+
namespace :test do
|
17
|
+
Rake::TestTask.new(:models) do |t|
|
18
|
+
t.libs << "test"
|
19
|
+
t.pattern = 'test/models/test_*.rb'
|
20
|
+
t.verbose = true
|
21
|
+
end
|
22
|
+
Rake::Task['test:models'].comment = "Run model tests"
|
23
|
+
|
24
|
+
Rake::TestTask.new(:tasks) do |t|
|
25
|
+
t.libs << "test"
|
26
|
+
t.pattern = 'test/tasks/test_*.rb'
|
27
|
+
t.verbose = true
|
28
|
+
end
|
29
|
+
Rake::Task['test:tasks'].comment = "Run task tests"
|
30
|
+
end
|