camping_generator 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +0 -0
- data/Manifest.txt +9 -0
- data/README.txt +54 -0
- data/Rakefile +50 -0
- data/USAGE +10 -0
- data/camping_generator.rb +40 -0
- data/setup.rb +1585 -0
- data/templates/app.rb +158 -0
- metadata +71 -0
data/History.txt
ADDED
File without changes
|
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
Parasite: Turning Rails into Camping Generator
|
2
|
+
==============================================
|
3
|
+
|
4
|
+
Parasite turns Rails into a Camping creator. Use generators, config files, and rake tasks to build Camping apps faster and better.
|
5
|
+
|
6
|
+
Components
|
7
|
+
==========
|
8
|
+
|
9
|
+
Parasite is composed of two components: a generator to make new camping apps and a rake task to launch your camping apps using your rails environment (i.e. development, production, testing).
|
10
|
+
|
11
|
+
Usage is straightforward:
|
12
|
+
|
13
|
+
$ script/generate camping
|
14
|
+
Usage: script/generate camping CampingName [options] [ModelOne ModelTwo ...]
|
15
|
+
|
16
|
+
Options:
|
17
|
+
--scaffold Generate controllers and views
|
18
|
+
--session Add session support
|
19
|
+
--stylesheet Include a dynamic style sheet
|
20
|
+
|
21
|
+
General Options:
|
22
|
+
-p, --pretend Run but do not make any changes.
|
23
|
+
-f, --force Overwrite files that already exist.
|
24
|
+
-s, --skip Skip files that already exist.
|
25
|
+
-q, --quiet Suppress normal output.
|
26
|
+
-t, --backtrace Debugging: show backtrace on errors.
|
27
|
+
-h, --help Show this help message.
|
28
|
+
-c, --svn Modify files with subversion. (Note: svn must be in path)
|
29
|
+
|
30
|
+
Description:
|
31
|
+
The camping generator creates a new camping app in a single file in the /app
|
32
|
+
directory.
|
33
|
+
|
34
|
+
Example:
|
35
|
+
./script/generate camping Blog
|
36
|
+
|
37
|
+
This will create a Blog app with models, views, controllers, and the
|
38
|
+
appropriate pre-amble and post-amble.
|
39
|
+
|
40
|
+
For the rake task,
|
41
|
+
|
42
|
+
$ rake camping
|
43
|
+
|
44
|
+
will run all your .rb files in the /app directory. It uses the configuration found in /config/database.yml, so make sure to update this prior use using the rake task. You can also load only specific files using
|
45
|
+
|
46
|
+
$ rake camping app/my_file.rb app/my_other_app.rb ...
|
47
|
+
|
48
|
+
For now, this task can only serve the camping apps using WEBrick. Future versions will support Mongrel as well.
|
49
|
+
|
50
|
+
Future Development
|
51
|
+
==================
|
52
|
+
|
53
|
+
Right now, the camping generator works off of one giant template file. In future versions, this file will be split into the relevant parts (e.g. pre_amble.rb, views.rb, controllers.rb, etc). This will allow creation of specific component files for larger camping apps (e.g. myapp/controllers/controller1.rb, myapp/controllers/controller2.rb, etc). A rake task will also be created to locally install these generators over the usual rails generators, thus more fully turning the rails environment into a camping creator.
|
54
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/clean'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'rake/packagetask'
|
6
|
+
require 'rake/gempackagetask'
|
7
|
+
require 'rake/rdoctask'
|
8
|
+
require 'rake/contrib/rubyforgepublisher'
|
9
|
+
require 'fileutils'
|
10
|
+
require 'hoe'
|
11
|
+
include FileUtils
|
12
|
+
require File.join(File.dirname(__FILE__), '..', 'version')
|
13
|
+
|
14
|
+
AUTHOR = "Mark Fredrickson" # can also be an array of Authors
|
15
|
+
EMAIL = "mark.m.fredrickson@gmail.com"
|
16
|
+
DESCRIPTION = "The Camping Generator, a leg of Parasite"
|
17
|
+
GEM_NAME = "camping_generator" # what ppl will type to install your gem
|
18
|
+
RUBYFORGE_PROJECT = "parasite" # The unix name for your project
|
19
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
20
|
+
RELEASE_TYPES = %w( gem ) # can use: gem, tar, zip
|
21
|
+
|
22
|
+
|
23
|
+
NAME = "camping_generator"
|
24
|
+
REV = nil # UNCOMMENT IF REQUIRED: File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
|
25
|
+
VERS = ENV['VERSION'] || (Parasite::VERSION::STRING + (REV ? ".#{REV}" : ""))
|
26
|
+
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
27
|
+
RDOC_OPTS = ['--quiet', '--title', "camping_generator documentation",
|
28
|
+
"--opname", "index.html",
|
29
|
+
"--line-numbers",
|
30
|
+
"--main", "README",
|
31
|
+
"--inline-source"]
|
32
|
+
|
33
|
+
# Generate all the Rake tasks
|
34
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
35
|
+
hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
36
|
+
p.author = AUTHOR
|
37
|
+
p.description = DESCRIPTION
|
38
|
+
p.email = EMAIL
|
39
|
+
p.summary = DESCRIPTION
|
40
|
+
p.url = HOMEPATH
|
41
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
42
|
+
p.test_globs = ["test/**/*_test.rb"]
|
43
|
+
p.clean_globs = CLEAN #An array of file patterns to delete on clean.
|
44
|
+
|
45
|
+
# == Optional
|
46
|
+
#p.changes - A description of the release's latest changes.
|
47
|
+
p.extra_deps = { 'rails' => '>=1.1.6', 'camping' => '>=1.5' }
|
48
|
+
p.spec_extras = { 'has_rdoc' => false }
|
49
|
+
end
|
50
|
+
|
data/USAGE
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
Description:
|
2
|
+
The camping generator creates a new camping app in a single file in the /app
|
3
|
+
directory.
|
4
|
+
|
5
|
+
Example:
|
6
|
+
./script/generate camping --scaffold Blog Post User
|
7
|
+
|
8
|
+
This will create a Blog app with models (Posts and Users), views,
|
9
|
+
controllers, and the appropriate pre-amble and post-amble.
|
10
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
class CampingGenerator < Rails::Generator::NamedBase
|
2
|
+
attr_reader :class_db_name, :models, :model_tables,
|
3
|
+
:scaffold, :session, :stylesheet
|
4
|
+
|
5
|
+
def manifest
|
6
|
+
@class_db_name = class_name.downcase
|
7
|
+
@models = args
|
8
|
+
@model_tables = args.map { |m| '' << class_db_name << '_' << m.downcase.pluralize }
|
9
|
+
|
10
|
+
# options variables
|
11
|
+
@scaffold = options[:scaffold]
|
12
|
+
@session = options[:session]
|
13
|
+
@stylesheet = options[:stylesheet]
|
14
|
+
|
15
|
+
# TODO create an option called "split to put the pieces in multiple
|
16
|
+
# directories.
|
17
|
+
|
18
|
+
record do |m|
|
19
|
+
|
20
|
+
# The directory
|
21
|
+
m.directory File.join('app', class_path)
|
22
|
+
|
23
|
+
# For now, we just create a single app file
|
24
|
+
m.template 'app.rb', File.join('app', class_path, "#{file_name}.rb")
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
protected
|
30
|
+
def add_options!(opt)
|
31
|
+
opt.separator ''
|
32
|
+
opt.separator 'Options:'
|
33
|
+
opt.on("--scaffold",
|
34
|
+
"Generate controllers and views") { |v| options[:scaffold] = v }
|
35
|
+
opt.on("--session",
|
36
|
+
"Add session support") { |v| options[:session] = v }
|
37
|
+
opt.on("--stylesheet",
|
38
|
+
"Include a dynamic style sheet") { |v| options[:stylesheet] = v }
|
39
|
+
end
|
40
|
+
end
|