michaelbarton-gigantron 0.1.4 → 0.1.6
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/Rakefile +1 -1
- data/VERSION.yml +2 -2
- data/bin/gigantron +18 -11
- data/lib/gigantron/generators/helper.rb +20 -0
- data/lib/gigantron/generators/migration_generator.rb +15 -0
- data/lib/gigantron/generators/model_generator.rb +25 -0
- data/lib/gigantron/generators/new_project_generator.rb +29 -0
- data/lib/gigantron/generators/task_generator.rb +21 -0
- metadata +10 -32
- data/.gitignore +0 -5
- data/app_generators/gigantron/USAGE +0 -7
- data/app_generators/gigantron/gigantron_generator.rb +0 -80
- data/app_generators/gigantron/templates/Rakefile +0 -12
- data/app_generators/gigantron/templates/database.yml.example +0 -9
- data/app_generators/gigantron/templates/initialize.rb +0 -31
- data/app_generators/gigantron/templates/tasks/import.rake +0 -10
- data/app_generators/gigantron/templates/test/tasks/test_import.rb +0 -23
- data/app_generators/gigantron/templates/test/test_helper.rb +0 -8
- data/features/generators.feature +0 -25
- data/features/object_relational_management.feature +0 -15
- data/features/project_creation.feature +0 -28
- data/features/step_definitions/project_steps.rb +0 -106
- data/features/support/env.rb +0 -9
- data/features/testing.feature +0 -10
- data/gigantron.gemspec +0 -85
- data/gigantron_generators/migration/USAGE +0 -5
- data/gigantron_generators/migration/migration_generator.rb +0 -61
- data/gigantron_generators/migration/templates/db/migrate/migration.rb +0 -7
- data/gigantron_generators/model/USAGE +0 -11
- data/gigantron_generators/model/model_generator.rb +0 -54
- data/gigantron_generators/model/templates/models/model.rb +0 -3
- data/gigantron_generators/model/templates/test/models/test_model.rb +0 -13
- data/gigantron_generators/task/USAGE +0 -10
- data/gigantron_generators/task/task_generator.rb +0 -51
- data/gigantron_generators/task/templates/tasks/task.rake +0 -4
- data/gigantron_generators/task/templates/test/tasks/test_task.rb +0 -22
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ begin
|
|
11
11
|
s.email = "ben@pixelmachine.org"
|
12
12
|
|
13
13
|
s.add_dependency('activesupport', '>= 2.0.2')
|
14
|
-
s.add_dependency('
|
14
|
+
s.add_dependency('templater', '>= 0.5.0')
|
15
15
|
s.add_dependency('rake', '>= 0.8.1')
|
16
16
|
s.add_dependency('Shoulda', '>= 1.1.1')
|
17
17
|
s.add_dependency('activerecord', '>= 2.0.2')
|
data/VERSION.yml
CHANGED
data/bin/gigantron
CHANGED
@@ -1,17 +1,24 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
|
-
require '
|
4
|
+
require 'templater'
|
5
|
+
|
6
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
7
|
+
|
8
|
+
require 'gigantron/generators/helper'
|
9
|
+
require 'gigantron/generators/task_generator'
|
10
|
+
require 'gigantron/generators/model_generator'
|
11
|
+
require 'gigantron/generators/migration_generator'
|
12
|
+
require 'gigantron/generators/new_project_generator'
|
13
|
+
|
14
|
+
module GigantronGenerators
|
15
|
+
extend Templater::Manifold
|
16
|
+
|
17
|
+
add :project, NewProjectGenerator
|
18
|
+
add :model, ModelGenerator
|
19
|
+
add :migration, MigrationGenerator
|
20
|
+
add :task, TaskGenerator
|
5
21
|
|
6
|
-
if %w(-v --version).include? ARGV.first
|
7
|
-
require 'gigantron/version'
|
8
|
-
puts "#{File.basename($0)} #{Gigantron::VERSION::STRING}"
|
9
|
-
exit(0)
|
10
22
|
end
|
11
23
|
|
12
|
-
|
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')
|
24
|
+
GigantronGenerators.run_cli Dir.pwd, 'gigantron', '0.1.5', ARGV
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'activesupport'
|
2
|
+
|
3
|
+
class Templater::Generator
|
4
|
+
def camel_case
|
5
|
+
self.name.camel_case
|
6
|
+
end
|
7
|
+
def underscore
|
8
|
+
self.name.underscore
|
9
|
+
end
|
10
|
+
def next_migration_num
|
11
|
+
migrations = File.join(%W|#{self.destination_root} db migrate [0-9][0-9][0-9]_*.rb|)
|
12
|
+
current = Dir.glob(migrations).map{|x| /(\d{3})_.*\.rb/.match(x)[1].to_i }.max
|
13
|
+
current ||= 0
|
14
|
+
"%03d" % current.succ
|
15
|
+
end
|
16
|
+
def migration_name
|
17
|
+
"create_#{self.name}s"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class MigrationGenerator < Templater::Generator
|
2
|
+
|
3
|
+
def self.source_root
|
4
|
+
File.join %W| #{File.dirname(__FILE__)} .. .. .. templates migration |
|
5
|
+
end
|
6
|
+
|
7
|
+
first_argument :name, :required => true
|
8
|
+
|
9
|
+
directory :migrations, File.join(%w|db migrate|)
|
10
|
+
template :migration do |t|
|
11
|
+
t.source = File.join(%w|db migrate migration.rb|)
|
12
|
+
t.destination = File.join(%w|db migrate %next_migration_num%_%underscore%.rb|)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class ModelGenerator < Templater::Generator
|
2
|
+
|
3
|
+
def self.source_root
|
4
|
+
File.join %W| #{File.dirname(__FILE__)} .. .. .. templates model |
|
5
|
+
end
|
6
|
+
|
7
|
+
first_argument :name, :required => true
|
8
|
+
|
9
|
+
empty_directory :models, 'models'
|
10
|
+
template :model do |t|
|
11
|
+
t.source = File.join %W| models model.rb|
|
12
|
+
t.destination = File.join %W| models %underscore%.rb |
|
13
|
+
end
|
14
|
+
|
15
|
+
empty_directory :tests, File.join('test','models')
|
16
|
+
template :test do |t|
|
17
|
+
t.source = File.join %W| test models test_model.rb |
|
18
|
+
t.destination = File.join %W| test models test_%underscore%.rb |
|
19
|
+
end
|
20
|
+
|
21
|
+
invoke :migration do |generator|
|
22
|
+
generator.new(destination_root, options.merge(:name => true), migration_name )
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class NewProjectGenerator < Templater::Generator
|
2
|
+
|
3
|
+
def self.source_root
|
4
|
+
File.join %W| #{File.dirname(__FILE__)} .. .. .. templates project |
|
5
|
+
end
|
6
|
+
|
7
|
+
first_argument :root, :required => true
|
8
|
+
|
9
|
+
empty_directory :root, '%root%'
|
10
|
+
empty_directory :log, File.join('%root%','log')
|
11
|
+
empty_directory :tasks, File.join('%root%','tasks')
|
12
|
+
empty_directory :test, File.join('%root%','test')
|
13
|
+
empty_directory :'test/models', File.join('%root%','test','models')
|
14
|
+
|
15
|
+
files = [
|
16
|
+
['Rakefile'],
|
17
|
+
['initialize.rb'],
|
18
|
+
['database.yml.example'],
|
19
|
+
|
20
|
+
['tasks' ,'import.rake' ],
|
21
|
+
['test' ,'test_helper.rb' ],
|
22
|
+
['test' ,'tasks', 'test_import.rb'],
|
23
|
+
]
|
24
|
+
|
25
|
+
files.each do |file_array|
|
26
|
+
file file_array.last.to_sym, File.join(*file_array), File.join('%root%',*file_array)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class TaskGenerator < Templater::Generator
|
2
|
+
|
3
|
+
def self.source_root
|
4
|
+
File.join %W| #{File.dirname(__FILE__)} .. .. .. templates task |
|
5
|
+
end
|
6
|
+
|
7
|
+
first_argument :name, :required => true
|
8
|
+
|
9
|
+
directory :tasks, File.join(%w|tasks|)
|
10
|
+
template :task do |t|
|
11
|
+
t.source = File.join(%w|tasks task.rake|)
|
12
|
+
t.destination = File.join(%w|tasks %underscore%.rake|)
|
13
|
+
end
|
14
|
+
|
15
|
+
directory :test_tasks, File.join(%w|test tasks|)
|
16
|
+
template :test_task do |t|
|
17
|
+
t.source = File.join(%w|test tasks test_task.rb|)
|
18
|
+
t.destination = File.join(%w|test tasks test_%underscore%.rb|)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: michaelbarton-gigantron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Hughes
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-17 00:00:00 -07:00
|
13
13
|
default_executable: gigantron
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -23,14 +23,14 @@ dependencies:
|
|
23
23
|
version: 2.0.2
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
26
|
+
name: templater
|
27
27
|
type: :runtime
|
28
28
|
version_requirement:
|
29
29
|
version_requirements: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.5.0
|
34
34
|
version:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: rake
|
@@ -71,38 +71,16 @@ extensions: []
|
|
71
71
|
extra_rdoc_files:
|
72
72
|
- README.markdown
|
73
73
|
files:
|
74
|
-
- .gitignore
|
75
74
|
- README.markdown
|
76
75
|
- Rakefile
|
77
76
|
- 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
77
|
- 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
78
|
- lib/gigantron.rb
|
79
|
+
- lib/gigantron/generators/helper.rb
|
80
|
+
- lib/gigantron/generators/migration_generator.rb
|
81
|
+
- lib/gigantron/generators/model_generator.rb
|
82
|
+
- lib/gigantron/generators/new_project_generator.rb
|
83
|
+
- lib/gigantron/generators/task_generator.rb
|
106
84
|
- lib/gigantron/migrator.rb
|
107
85
|
- lib/gigantron/tasks/db.rb
|
108
86
|
- lib/gigantron/tasks/test.rb
|
@@ -131,7 +109,7 @@ requirements: []
|
|
131
109
|
rubyforge_project:
|
132
110
|
rubygems_version: 1.2.0
|
133
111
|
signing_key:
|
134
|
-
specification_version:
|
112
|
+
specification_version: 3
|
135
113
|
summary: Ruby Framework for Data Processing
|
136
114
|
test_files: []
|
137
115
|
|
data/.gitignore
DELETED
@@ -1,80 +0,0 @@
|
|
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
|
@@ -1,31 +0,0 @@
|
|
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
|
@@ -1,10 +0,0 @@
|
|
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
|
@@ -1,23 +0,0 @@
|
|
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/features/generators.feature
DELETED
@@ -1,25 +0,0 @@
|
|
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
|
@@ -1,15 +0,0 @@
|
|
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
|
@@ -1,28 +0,0 @@
|
|
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
|
@@ -1,106 +0,0 @@
|
|
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
|
data/features/support/env.rb
DELETED
data/features/testing.feature
DELETED
@@ -1,10 +0,0 @@
|
|
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
DELETED
@@ -1,85 +0,0 @@
|
|
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
|
@@ -1,61 +0,0 @@
|
|
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
|
@@ -1,11 +0,0 @@
|
|
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
|
-
|
@@ -1,54 +0,0 @@
|
|
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
|
@@ -1,13 +0,0 @@
|
|
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
|
@@ -1,51 +0,0 @@
|
|
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
|
@@ -1,22 +0,0 @@
|
|
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
|