michaelbarton-gigantron 0.1.4
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/.gitignore +5 -0
- data/README.markdown +75 -0
- data/Rakefile +30 -0
- data/VERSION.yml +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.example +9 -0
- data/app_generators/gigantron/templates/initialize.rb +31 -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 +8 -0
- data/bin/gigantron +17 -0
- data/features/generators.feature +25 -0
- data/features/object_relational_management.feature +15 -0
- data/features/project_creation.feature +28 -0
- data/features/step_definitions/project_steps.rb +106 -0
- data/features/support/env.rb +9 -0
- data/features/testing.feature +10 -0
- data/gigantron.gemspec +85 -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/migrator.rb +10 -0
- data/lib/gigantron/tasks/db.rb +11 -0
- data/lib/gigantron/tasks/test.rb +24 -0
- data/lib/gigantron/version.rb +9 -0
- data/lib/gigantron.rb +0 -0
- metadata +137 -0
data/.gitignore
ADDED
data/README.markdown
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# Gigantron: Processor of Data
|
2
|
+
|
3
|
+
* http://github.com/schleyfox/gigantron
|
4
|
+
|
5
|
+
## DESCRIPTION:
|
6
|
+
|
7
|
+
Gigantron is a simple framework for the creation and organization of
|
8
|
+
data processing projects. Data-processing transforms are created as Rake tasks
|
9
|
+
and data is handled through ActiveRecord* models.
|
10
|
+
|
11
|
+
* Will switch back to DataMapper once it plays nice with JRuby
|
12
|
+
|
13
|
+
## FEATURES/PROBLEMS:
|
14
|
+
|
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
|
+
* ActiveRecord
|
40
|
+
* ActiveSupport
|
41
|
+
* Shoulda
|
42
|
+
|
43
|
+
## INSTALL:
|
44
|
+
|
45
|
+
sudo gem install gigantron
|
46
|
+
|
47
|
+
## HACKING:
|
48
|
+
|
49
|
+
Check out the website for a quick overview of how to fiddle with the generators
|
50
|
+
behind Gigantron. http://gigantron.rubyforge.org.
|
51
|
+
|
52
|
+
## LICENSE:
|
53
|
+
|
54
|
+
(The MIT License)
|
55
|
+
|
56
|
+
Copyright (c) 2008 Ben Hughes
|
57
|
+
|
58
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
59
|
+
a copy of this software and associated documentation files (the
|
60
|
+
'Software'), to deal in the Software without restriction, including
|
61
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
62
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
63
|
+
permit persons to whom the Software is furnished to do so, subject to
|
64
|
+
the following conditions:
|
65
|
+
|
66
|
+
The above copyright notice and this permission notice shall be
|
67
|
+
included in all copies or substantial portions of the Software.
|
68
|
+
|
69
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
70
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
71
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
72
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
73
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
74
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
75
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
task :default => :features
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'jeweler'
|
5
|
+
Jeweler::Tasks.new do |s|
|
6
|
+
s.name = "gigantron"
|
7
|
+
s.summary = "Ruby Framework for Data Processing"
|
8
|
+
s.homepage = "http://github.com/schleyfox/gigantron"
|
9
|
+
|
10
|
+
s.authors = ["Ben Hughes"]
|
11
|
+
s.email = "ben@pixelmachine.org"
|
12
|
+
|
13
|
+
s.add_dependency('activesupport', '>= 2.0.2')
|
14
|
+
s.add_dependency('rubigen', '>= 1.3.2')
|
15
|
+
s.add_dependency('rake', '>= 0.8.1')
|
16
|
+
s.add_dependency('Shoulda', '>= 1.1.1')
|
17
|
+
s.add_dependency('activerecord', '>= 2.0.2')
|
18
|
+
end
|
19
|
+
rescue LoadError
|
20
|
+
puts "Jeweler not available. Install it with: sudo gem install jeweler"
|
21
|
+
end
|
22
|
+
|
23
|
+
begin
|
24
|
+
require 'cucumber/rake/task'
|
25
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
26
|
+
t.cucumber_opts = "--format pretty"
|
27
|
+
end
|
28
|
+
rescue LoadError
|
29
|
+
puts "Cucumber not available. Install it with: sudo gem install cucumber"
|
30
|
+
end
|
data/VERSION.yml
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.example", "database.yml.example"
|
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
|
+
m.dependency "install_rubigen_scripts", [destination_root, 'gigantron'],
|
39
|
+
:shebang => options[:shebang], :collision => :force
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
protected
|
44
|
+
def banner
|
45
|
+
<<-EOS
|
46
|
+
Creates a ...
|
47
|
+
|
48
|
+
USAGE: #{spec.name} name
|
49
|
+
EOS
|
50
|
+
end
|
51
|
+
|
52
|
+
def add_options!(opts)
|
53
|
+
opts.separator ''
|
54
|
+
opts.separator 'Options:'
|
55
|
+
# For each option below, place the default
|
56
|
+
# at the top of the file next to "default_options"
|
57
|
+
# opts.on("-a", "--author=\"Your Name\"", String,
|
58
|
+
# "Some comment about this option",
|
59
|
+
# "Default: none") { |options[:author]| }
|
60
|
+
opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
61
|
+
end
|
62
|
+
|
63
|
+
def extract_options
|
64
|
+
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
65
|
+
# Templates can access these value via the attr_reader-generated methods, but not the
|
66
|
+
# raw instance variable value.
|
67
|
+
# @author = options[:author]
|
68
|
+
end
|
69
|
+
|
70
|
+
# Installation skeleton. Intermediate directories are automatically
|
71
|
+
# created so don't sweat their absence here.
|
72
|
+
BASEDIRS = %w(
|
73
|
+
tasks
|
74
|
+
db
|
75
|
+
models
|
76
|
+
lib
|
77
|
+
test
|
78
|
+
log
|
79
|
+
)
|
80
|
+
end
|
@@ -0,0 +1,31 @@
|
|
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
|
+
GTRON_ROOT = File.dirname(__FILE__)
|
9
|
+
|
10
|
+
#set up autoload paths
|
11
|
+
$: << "#{GTRON_ROOT}/lib/"
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'rake'
|
15
|
+
|
16
|
+
require 'active_record'
|
17
|
+
|
18
|
+
def get_db_conn(env)
|
19
|
+
env = env.to_sym
|
20
|
+
#set up logging
|
21
|
+
ActiveRecord::Base.logger = Logger.new("#{GTRON_ROOT}/log/#{env}.log")
|
22
|
+
|
23
|
+
#load in dbs from database.yml
|
24
|
+
ActiveRecord::Base.establish_connection(
|
25
|
+
YAML::load(File.read("#{GTRON_ROOT}/database.yml"))[env])
|
26
|
+
|
27
|
+
#load all models
|
28
|
+
Dir["#{GTRON_ROOT}/models/**/*.rb"].each {|r| load r }
|
29
|
+
|
30
|
+
nil
|
31
|
+
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(ENV["GTRON_ENV"] || 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,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rubigen'
|
5
|
+
|
6
|
+
if %w(-v --version).include? ARGV.first
|
7
|
+
require 'gigantron/version'
|
8
|
+
puts "#{File.basename($0)} #{Gigantron::VERSION::STRING}"
|
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 => 'gigantron')
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Feature: Generating new project files at the command line
|
2
|
+
In order to add features to a gigantron project
|
3
|
+
A user should be able to
|
4
|
+
generate new models, migrations, and tasks
|
5
|
+
|
6
|
+
Scenario: generate model
|
7
|
+
Given a working directory
|
8
|
+
When I use the gigantron command to generate a project named "new-project"
|
9
|
+
And I use script/generate to make a model named "bar"
|
10
|
+
Then a file named "new-project/models/bar.rb" is created
|
11
|
+
Then a file named "new-project/test/models/test_bar.rb" is created
|
12
|
+
And a file named "new-project/db/migrate/001_create_bars.rb" is created
|
13
|
+
|
14
|
+
Scenario: generate migration
|
15
|
+
Given a working directory
|
16
|
+
When I use the gigantron command to generate a project named "new-project"
|
17
|
+
And I use script/generate to make a migration named "bar"
|
18
|
+
Then a file named "new-project/db/migrate/001_bar.rb" is created
|
19
|
+
|
20
|
+
Scenario: generate task
|
21
|
+
Given a working directory
|
22
|
+
When I use the gigantron command to generate a project named "new-project"
|
23
|
+
And I use script/generate to make a task named "bar"
|
24
|
+
Then a file named "new-project/tasks/bar.rake" is created
|
25
|
+
And a file named "new-project/test/tasks/test_bar.rb" is created
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Feature: Using models for object relational management
|
2
|
+
In order manipulate data using ruby objects
|
3
|
+
A user should be able to
|
4
|
+
generate a new model, migrate up, and create records
|
5
|
+
|
6
|
+
Scenario: generate model and insert two rows
|
7
|
+
Given a working directory
|
8
|
+
When I use the gigantron command to generate a project named "foo"
|
9
|
+
And I configure an sqlite3 database named "db"
|
10
|
+
And I use script/generate to make a model named "bar"
|
11
|
+
And I create simple migration for the model "bar"
|
12
|
+
And I use rake to migrate the database up
|
13
|
+
And I create 2 "bar" records in the database
|
14
|
+
Then a file named "foo/db/db.sqlite3" is created
|
15
|
+
And 2 "bar" records are saved to the database
|
@@ -0,0 +1,28 @@
|
|
1
|
+
Feature: Creating gigantron projects at the command line
|
2
|
+
In order to start a new gigantron project
|
3
|
+
A user should be able to
|
4
|
+
generate a directory layout
|
5
|
+
|
6
|
+
Scenario: new project
|
7
|
+
Given a working directory
|
8
|
+
When I use the gigantron command to generate a project named "new-project"
|
9
|
+
Then a directory named "new-project" is created
|
10
|
+
|
11
|
+
And a file named "new-project/Rakefile" is created
|
12
|
+
And a file named "new-project/database.yml.example" is created
|
13
|
+
And a file named "new-project/initialize.rb" is created
|
14
|
+
|
15
|
+
And a directory named "new-project/log" is created
|
16
|
+
|
17
|
+
And a directory named "new-project/tasks" is created
|
18
|
+
And a file named "new-project/tasks/import.rake" is created
|
19
|
+
|
20
|
+
And a directory named "new-project/test" is created
|
21
|
+
And a file named "new-project/test/test_helper.rb" is created
|
22
|
+
And a directory named "new-project/test/tasks" is created
|
23
|
+
And a file named "new-project/test/tasks/test_import.rb" is created
|
24
|
+
And a directory named "new-project/test/models" is created
|
25
|
+
|
26
|
+
And a directory named "new-project/script" is created
|
27
|
+
And a file named "new-project/script/generate" is created
|
28
|
+
And a file named "new-project/script/destroy" is created
|
@@ -0,0 +1,106 @@
|
|
1
|
+
Given 'a working directory' do
|
2
|
+
@working_dir = File.expand_path File.join(File.dirname(__FILE__), '..', '..', 'tmp')
|
3
|
+
FileUtils.rm_rf @working_dir
|
4
|
+
FileUtils.mkdir_p @working_dir
|
5
|
+
end
|
6
|
+
|
7
|
+
When /^I use the gigantron command to generate a project named "([^\"]*)"$/ do |name|
|
8
|
+
@project_name = name
|
9
|
+
@project_dir = File.join(@working_dir,@project_name)
|
10
|
+
|
11
|
+
return_to = Dir.pwd
|
12
|
+
gigantron = File.expand_path File.join(File.dirname(__FILE__), '..', '..', 'bin', 'gigantron')
|
13
|
+
|
14
|
+
begin
|
15
|
+
FileUtils.cd @working_dir
|
16
|
+
@stdout = `#{gigantron} #{@project_name}`
|
17
|
+
ensure
|
18
|
+
FileUtils.cd return_to
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
When /^I use script\/generate to make a (.+) named "([^\"]*)"$/ do |type,created|
|
24
|
+
return_to = Dir.pwd
|
25
|
+
begin
|
26
|
+
FileUtils.cd(@project_dir)
|
27
|
+
@stdout = `script/generate #{type} #{created}`
|
28
|
+
ensure
|
29
|
+
FileUtils.cd return_to
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
When /^I configure an sqlite3 database named "([^\"]*)"$/ do |name|
|
34
|
+
file = File.expand_path(File.join(@project_dir,'db','db.sqlite3'))
|
35
|
+
File.open(File.join(@project_dir,'database.yml'),'w') do |out|
|
36
|
+
out.puts ":real:"
|
37
|
+
out.puts " :adapter: sqlite3"
|
38
|
+
out.puts " :database: #{file}"
|
39
|
+
out.puts ":test:"
|
40
|
+
out.puts " :adapter: sqlite3"
|
41
|
+
out.puts " :database: #{file}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
When /^I create simple migration for the model "([^\"]*)"$/ do |name|
|
46
|
+
migration = Dir.glob("#{@project_dir}/db/migrate/*_create_#{name}s.rb").first
|
47
|
+
File.open(migration,'w') do |f|
|
48
|
+
f.puts <<-EOF
|
49
|
+
class Create#{name.pluralize.camelcase} < ActiveRecord::Migration
|
50
|
+
def self.up
|
51
|
+
create_table :#{name.pluralize} do |t|
|
52
|
+
t.string :name
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.down
|
57
|
+
end
|
58
|
+
end
|
59
|
+
EOF
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
When /^I use rake to migrate the database up$/ do
|
64
|
+
FileUtils.cd(@project_dir) do
|
65
|
+
@stdout = `rake db:migrate`
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
When /^I create (\d) "([^\"]*)" records in the database$/ do |number, type|
|
70
|
+
require File.join(@project_dir,'initialize.rb')
|
71
|
+
get_db_conn(:real)
|
72
|
+
number.to_i.times do
|
73
|
+
Kernel.const_get(type.camelize).create :name => 'test'
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
Then /^a directory named "([^\"]*)" is created$/ do |directory|
|
78
|
+
directory = File.join(@working_dir, directory)
|
79
|
+
|
80
|
+
assert File.exists?(directory), "#{directory} did not exist"
|
81
|
+
assert File.directory?(directory), "#{directory} is not a directory"
|
82
|
+
end
|
83
|
+
|
84
|
+
Then /^a file named "([^\"]*)" is created$/ do |file|
|
85
|
+
file = File.join(@working_dir, file)
|
86
|
+
|
87
|
+
assert File.exists?(file), "#{file} did not exist"
|
88
|
+
assert !File.directory?(file), "#{file} is a directory"
|
89
|
+
end
|
90
|
+
|
91
|
+
Then /^(\d) "([^\"]*)" records are saved to the database$/ do |number, type|
|
92
|
+
require File.join(@project_dir,'initialize.rb')
|
93
|
+
get_db_conn(:real)
|
94
|
+
assert Kernel.const_get(type.camelize).count == number.to_i
|
95
|
+
end
|
96
|
+
|
97
|
+
Then /^calling the rake "([^\"]*)" task should not produce an error$/ do |task_name|
|
98
|
+
FileUtils.cd(@project_dir) do
|
99
|
+
@sucessful = system("rake #{task_name}")
|
100
|
+
end
|
101
|
+
assert @sucessful
|
102
|
+
end
|
103
|
+
|
104
|
+
After do
|
105
|
+
FileUtils.rm_rf @working_dir if @working_dir
|
106
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Feature: Automatically generated testing setup
|
2
|
+
In order to test functions in the application
|
3
|
+
A user should be able to
|
4
|
+
run all tests with rake
|
5
|
+
|
6
|
+
Scenario: generate model and insert two rows
|
7
|
+
Given a working directory
|
8
|
+
When I use the gigantron command to generate a project named "foo"
|
9
|
+
And I configure an sqlite3 database named "db"
|
10
|
+
Then calling the rake "test" task should not produce an error
|
data/gigantron.gemspec
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{gigantron}
|
5
|
+
s.version = "0.1.4"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Ben Hughes"]
|
9
|
+
s.date = %q{2009-05-12}
|
10
|
+
s.default_executable = %q{gigantron}
|
11
|
+
s.email = %q{ben@pixelmachine.org}
|
12
|
+
s.executables = ["gigantron"]
|
13
|
+
s.extra_rdoc_files = [
|
14
|
+
"README.markdown"
|
15
|
+
]
|
16
|
+
s.files = [
|
17
|
+
".gitignore",
|
18
|
+
"README.markdown",
|
19
|
+
"Rakefile",
|
20
|
+
"VERSION.yml",
|
21
|
+
"app_generators/gigantron/USAGE",
|
22
|
+
"app_generators/gigantron/gigantron_generator.rb",
|
23
|
+
"app_generators/gigantron/templates/Rakefile",
|
24
|
+
"app_generators/gigantron/templates/database.yml.example",
|
25
|
+
"app_generators/gigantron/templates/initialize.rb",
|
26
|
+
"app_generators/gigantron/templates/tasks/import.rake",
|
27
|
+
"app_generators/gigantron/templates/test/tasks/test_import.rb",
|
28
|
+
"app_generators/gigantron/templates/test/test_helper.rb",
|
29
|
+
"bin/gigantron",
|
30
|
+
"features/generators.feature",
|
31
|
+
"features/object_relational_management.feature",
|
32
|
+
"features/project_creation.feature",
|
33
|
+
"features/step_definitions/project_steps.rb",
|
34
|
+
"features/support/env.rb",
|
35
|
+
"features/testing.feature",
|
36
|
+
"gigantron.gemspec",
|
37
|
+
"gigantron_generators/migration/USAGE",
|
38
|
+
"gigantron_generators/migration/migration_generator.rb",
|
39
|
+
"gigantron_generators/migration/templates/db/migrate/migration.rb",
|
40
|
+
"gigantron_generators/model/USAGE",
|
41
|
+
"gigantron_generators/model/model_generator.rb",
|
42
|
+
"gigantron_generators/model/templates/models/model.rb",
|
43
|
+
"gigantron_generators/model/templates/test/models/test_model.rb",
|
44
|
+
"gigantron_generators/task/USAGE",
|
45
|
+
"gigantron_generators/task/task_generator.rb",
|
46
|
+
"gigantron_generators/task/templates/tasks/task.rake",
|
47
|
+
"gigantron_generators/task/templates/test/tasks/test_task.rb",
|
48
|
+
"lib/gigantron.rb",
|
49
|
+
"lib/gigantron/migrator.rb",
|
50
|
+
"lib/gigantron/tasks/db.rb",
|
51
|
+
"lib/gigantron/tasks/test.rb",
|
52
|
+
"lib/gigantron/version.rb"
|
53
|
+
]
|
54
|
+
s.has_rdoc = true
|
55
|
+
s.homepage = %q{http://github.com/schleyfox/gigantron}
|
56
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
57
|
+
s.require_paths = ["lib"]
|
58
|
+
s.rubygems_version = %q{1.3.1}
|
59
|
+
s.summary = %q{Ruby Framework for Data Processing}
|
60
|
+
|
61
|
+
if s.respond_to? :specification_version then
|
62
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
63
|
+
s.specification_version = 2
|
64
|
+
|
65
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
66
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 2.0.2"])
|
67
|
+
s.add_runtime_dependency(%q<rubigen>, [">= 1.3.2"])
|
68
|
+
s.add_runtime_dependency(%q<rake>, [">= 0.8.1"])
|
69
|
+
s.add_runtime_dependency(%q<Shoulda>, [">= 1.1.1"])
|
70
|
+
s.add_runtime_dependency(%q<activerecord>, [">= 2.0.2"])
|
71
|
+
else
|
72
|
+
s.add_dependency(%q<activesupport>, [">= 2.0.2"])
|
73
|
+
s.add_dependency(%q<rubigen>, [">= 1.3.2"])
|
74
|
+
s.add_dependency(%q<rake>, [">= 0.8.1"])
|
75
|
+
s.add_dependency(%q<Shoulda>, [">= 1.1.1"])
|
76
|
+
s.add_dependency(%q<activerecord>, [">= 2.0.2"])
|
77
|
+
end
|
78
|
+
else
|
79
|
+
s.add_dependency(%q<activesupport>, [">= 2.0.2"])
|
80
|
+
s.add_dependency(%q<rubigen>, [">= 1.3.2"])
|
81
|
+
s.add_dependency(%q<rake>, [">= 0.8.1"])
|
82
|
+
s.add_dependency(%q<Shoulda>, [">= 1.1.1"])
|
83
|
+
s.add_dependency(%q<activerecord>, [">= 2.0.2"])
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
class MigrationGenerator < 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
|
+
# Ensure appropriate folder(s) exists
|
17
|
+
m.directory "db/"
|
18
|
+
m.directory "db/migrate/"
|
19
|
+
m.template "db/migrate/migration.rb",
|
20
|
+
"db/migrate/#{next_migration_num}_#{name.underscore}.rb"
|
21
|
+
|
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
|
+
|
52
|
+
def next_migration_num
|
53
|
+
#blegh, catalog existing migrations, find next
|
54
|
+
current = Dir.glob(
|
55
|
+
"#{@destination_root}/db/migrate/[0-9][0-9][0-9]_*.rb").map{|x|
|
56
|
+
/(\d{3})_.*\.rb/.match(x)[1].to_i
|
57
|
+
}.max
|
58
|
+
current ||= 0
|
59
|
+
"%03d" % current.succ
|
60
|
+
end
|
61
|
+
end
|
@@ -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,54 @@
|
|
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.underscore}.rb"
|
18
|
+
|
19
|
+
m.directory "test/"
|
20
|
+
m.directory "test/models/"
|
21
|
+
m.template "test/models/test_model.rb",
|
22
|
+
"test/models/test_#{name.underscore}.rb"
|
23
|
+
|
24
|
+
m.dependency "migration", ["Create#{@name.pluralize.camelcase}"]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
protected
|
29
|
+
def banner
|
30
|
+
<<-EOS
|
31
|
+
Creates a ...
|
32
|
+
|
33
|
+
USAGE: #{$0} #{spec.name} name
|
34
|
+
EOS
|
35
|
+
end
|
36
|
+
|
37
|
+
def add_options!(opts)
|
38
|
+
# opts.separator ''
|
39
|
+
# opts.separator 'Options:'
|
40
|
+
# For each option below, place the default
|
41
|
+
# at the top of the file next to "default_options"
|
42
|
+
# opts.on("-a", "--author=\"Your Name\"", String,
|
43
|
+
# "Some comment about this option",
|
44
|
+
# "Default: none") { |options[:author]| }
|
45
|
+
# opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
46
|
+
end
|
47
|
+
|
48
|
+
def extract_options
|
49
|
+
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
50
|
+
# Templates can access these value via the attr_reader-generated methods, but not the
|
51
|
+
# raw instance variable value.
|
52
|
+
# @author = options[:author]
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
class Test<%= name.camelcase %> < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
get_db_conn(GTRON_ENV)
|
6
|
+
Gigantron.migrate_dbs
|
7
|
+
end
|
8
|
+
|
9
|
+
#replace with real tests
|
10
|
+
should "be true" do
|
11
|
+
assert true
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,51 @@
|
|
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.underscore}.rake"
|
18
|
+
m.directory "test/"
|
19
|
+
m.directory "test/tasks/"
|
20
|
+
m.template "test/tasks/test_task.rb",
|
21
|
+
"test/tasks/test_#{@name.underscore}.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,22 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
class Test<%= name.camelcase %> < 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,10 @@
|
|
1
|
+
|
2
|
+
# simple function to handle migrating Gigantron databases
|
3
|
+
module Gigantron
|
4
|
+
def self.migrate_dbs
|
5
|
+
ActiveRecord::Migration.verbose =
|
6
|
+
ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
|
7
|
+
ActiveRecord::Migrator.migrate("#{GTRON_ROOT}/db/migrate/",
|
8
|
+
ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rake/testtask'
|
2
|
+
|
3
|
+
desc "Run all tests"
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
|
+
t.libs << "test"
|
6
|
+
t.pattern = 'test/**/test_*.rb'
|
7
|
+
t.verbose = true
|
8
|
+
end
|
9
|
+
|
10
|
+
namespace :test do
|
11
|
+
Rake::TestTask.new(:models) do |t|
|
12
|
+
t.libs << "test"
|
13
|
+
t.pattern = 'test/models/test_*.rb'
|
14
|
+
t.verbose = true
|
15
|
+
end
|
16
|
+
Rake::Task['test:models'].comment = "Run model tests"
|
17
|
+
|
18
|
+
Rake::TestTask.new(:tasks) do |t|
|
19
|
+
t.libs << "test"
|
20
|
+
t.pattern = 'test/tasks/test_*.rb'
|
21
|
+
t.verbose = true
|
22
|
+
end
|
23
|
+
Rake::Task['test:tasks'].comment = "Run task tests"
|
24
|
+
end
|
data/lib/gigantron.rb
ADDED
File without changes
|
metadata
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: michaelbarton-gigantron
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ben Hughes
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-05-12 00:00:00 -07:00
|
13
|
+
default_executable: gigantron
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: activesupport
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.0.2
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rubigen
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.3.2
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rake
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.8.1
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: Shoulda
|
47
|
+
type: :runtime
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.1.1
|
54
|
+
version:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activerecord
|
57
|
+
type: :runtime
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 2.0.2
|
64
|
+
version:
|
65
|
+
description:
|
66
|
+
email: ben@pixelmachine.org
|
67
|
+
executables:
|
68
|
+
- gigantron
|
69
|
+
extensions: []
|
70
|
+
|
71
|
+
extra_rdoc_files:
|
72
|
+
- README.markdown
|
73
|
+
files:
|
74
|
+
- .gitignore
|
75
|
+
- README.markdown
|
76
|
+
- Rakefile
|
77
|
+
- VERSION.yml
|
78
|
+
- app_generators/gigantron/USAGE
|
79
|
+
- app_generators/gigantron/gigantron_generator.rb
|
80
|
+
- app_generators/gigantron/templates/Rakefile
|
81
|
+
- app_generators/gigantron/templates/database.yml.example
|
82
|
+
- app_generators/gigantron/templates/initialize.rb
|
83
|
+
- app_generators/gigantron/templates/tasks/import.rake
|
84
|
+
- app_generators/gigantron/templates/test/tasks/test_import.rb
|
85
|
+
- app_generators/gigantron/templates/test/test_helper.rb
|
86
|
+
- bin/gigantron
|
87
|
+
- features/generators.feature
|
88
|
+
- features/object_relational_management.feature
|
89
|
+
- features/project_creation.feature
|
90
|
+
- features/step_definitions/project_steps.rb
|
91
|
+
- features/support/env.rb
|
92
|
+
- features/testing.feature
|
93
|
+
- gigantron.gemspec
|
94
|
+
- gigantron_generators/migration/USAGE
|
95
|
+
- gigantron_generators/migration/migration_generator.rb
|
96
|
+
- gigantron_generators/migration/templates/db/migrate/migration.rb
|
97
|
+
- gigantron_generators/model/USAGE
|
98
|
+
- gigantron_generators/model/model_generator.rb
|
99
|
+
- gigantron_generators/model/templates/models/model.rb
|
100
|
+
- gigantron_generators/model/templates/test/models/test_model.rb
|
101
|
+
- gigantron_generators/task/USAGE
|
102
|
+
- gigantron_generators/task/task_generator.rb
|
103
|
+
- gigantron_generators/task/templates/tasks/task.rake
|
104
|
+
- gigantron_generators/task/templates/test/tasks/test_task.rb
|
105
|
+
- lib/gigantron.rb
|
106
|
+
- lib/gigantron/migrator.rb
|
107
|
+
- lib/gigantron/tasks/db.rb
|
108
|
+
- lib/gigantron/tasks/test.rb
|
109
|
+
- lib/gigantron/version.rb
|
110
|
+
has_rdoc: true
|
111
|
+
homepage: http://github.com/schleyfox/gigantron
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options:
|
114
|
+
- --charset=UTF-8
|
115
|
+
require_paths:
|
116
|
+
- lib
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: "0"
|
122
|
+
version:
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: "0"
|
128
|
+
version:
|
129
|
+
requirements: []
|
130
|
+
|
131
|
+
rubyforge_project:
|
132
|
+
rubygems_version: 1.2.0
|
133
|
+
signing_key:
|
134
|
+
specification_version: 2
|
135
|
+
summary: Ruby Framework for Data Processing
|
136
|
+
test_files: []
|
137
|
+
|