rails_creator 0.5.2 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +18 -0
- data/Manifest.txt +8 -1
- data/README.txt +23 -13
- data/Rakefile +2 -4
- data/bin/rails_creator +105 -3
- data/lib/rails_creator.rb +13 -161
- data/lib/rails_creator/constants.rb +9 -0
- data/lib/rails_creator/generate.rb +94 -0
- data/lib/rails_creator/subversion.rb +115 -0
- data/lib/rails_creator/utilities.rb +94 -0
- data/lib/rails_creator/version.rb +8 -0
- data/lib/tasks/rails_creator.rake +55 -0
- data/test/test_all.rb +0 -0
- metadata +14 -7
data/History.txt
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
== 0.6.2 / 2007-11-26
|
2
|
+
* Added subversion checkin method
|
3
|
+
* Rewrote the README file
|
4
|
+
|
5
|
+
== 0.6.1 / 2007-11-25
|
6
|
+
* Added a utilities mixin for various helpers methods
|
7
|
+
* such as removing subversion files, checking out edge rails
|
8
|
+
* adding plugins, and cleaning up already checked out (subversion)
|
9
|
+
* applications
|
10
|
+
|
11
|
+
* Added a yml config file for allow people to choose their own default list
|
12
|
+
of plugins they'd like to install
|
13
|
+
* Renamed all *.txt files to remove the extension
|
14
|
+
* Updated all files that had the extension hard coded in
|
15
|
+
|
16
|
+
== 0.6.0 / 2007-11-25
|
17
|
+
* Rewrote gem to work more like a gem
|
18
|
+
|
1
19
|
== 0.5.2 / 2007-07-20
|
2
20
|
* Renamed gem to rails_creator (Dr. Nic Williams suggestion)
|
3
21
|
* updated files accordingly
|
data/Manifest.txt
CHANGED
@@ -4,4 +4,11 @@ README.txt
|
|
4
4
|
Rakefile
|
5
5
|
bin/rails_creator
|
6
6
|
lib/rails_creator.rb
|
7
|
-
|
7
|
+
lib/rails_creator/version.rb
|
8
|
+
lib/rails_creator/generate.rb
|
9
|
+
lib/rails_creator/utilities.rb
|
10
|
+
lib/rails_creator/constants.rb
|
11
|
+
lib/rails_creator/subversion.rb
|
12
|
+
lib/tasks/rails_creator.rake
|
13
|
+
test/test_creator.rb
|
14
|
+
test/test_all.rb
|
data/README.txt
CHANGED
@@ -1,24 +1,34 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
http://rubysnips.com
|
1
|
+
creator
|
2
|
+
by Robert R Evans
|
3
|
+
http://robertrevans.com
|
5
4
|
|
6
5
|
== DESCRIPTION:
|
7
6
|
|
8
|
-
This will create a new Rails project for you, either from Edge Rails or whatever version you have
|
9
|
-
installed on your system. It will also check your project into Subversion and check it out to the
|
10
|
-
location you specify, removing common files.
|
7
|
+
This will create a new Rails project for you, either from Edge Rails or whatever version you have installed on your system. It will also check your project into Subversion and check it out to the location you specify, removing common files.
|
11
8
|
|
12
9
|
Subversion is optional, and it asks you if you'd like to use it.
|
13
10
|
|
14
11
|
== SYNOPSIS:
|
15
12
|
|
16
|
-
At the command line, type:
|
17
|
-
That
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
13
|
+
At the command line, type: rails_creator -h
|
14
|
+
That will give you a list of options that you can choose from, for example:
|
15
|
+
|
16
|
+
rails_creator -m my_app
|
17
|
+
|
18
|
+
This will create your new rails project, with the name 'my_app', using mysql, on edge Rails.
|
19
|
+
|
20
|
+
rails_creator -M my_app
|
21
|
+
|
22
|
+
This will create your rails project on the current version of Rails, on your system, using
|
23
|
+
mysql, with the application name: "my_app"
|
24
|
+
|
25
|
+
rails_creator -p my_app
|
26
|
+
|
27
|
+
For postgresql on edge Rails
|
28
|
+
|
29
|
+
rails_creator -P my_app
|
30
|
+
|
31
|
+
For postgresql not on edge Rails
|
22
32
|
|
23
33
|
== INSTALL:
|
24
34
|
|
data/Rakefile
CHANGED
@@ -4,13 +4,11 @@ require 'rubygems'
|
|
4
4
|
require 'hoe'
|
5
5
|
require './lib/rails_creator.rb'
|
6
6
|
|
7
|
-
Hoe.new('rails_creator', RailsCreator::
|
7
|
+
Hoe.new('rails_creator', RailsCreator::Version::String) do |p|
|
8
8
|
p.rubyforge_name = 'rails_creator'
|
9
9
|
p.summary = 'Creates a new Rails project from either Edge Rails or your currently installed version. It will also check your project into Subversion and check it out to the location you specify, removing common files.'
|
10
10
|
p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
|
11
11
|
p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
|
12
12
|
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
13
13
|
p.remote_rdoc_dir = '' # Release to root
|
14
|
-
end
|
15
|
-
|
16
|
-
# vim: syntax=Ruby
|
14
|
+
end
|
data/bin/rails_creator
CHANGED
@@ -1,6 +1,108 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
##
|
4
|
+
# Created on 2007-06-16
|
5
|
+
# Rewrote on 2007-11-20
|
6
|
+
# Copyright (c) 2007 Robert R Evans
|
7
|
+
#
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
9
|
+
# a copy of this software and associated documentation files (the
|
10
|
+
# "Software"), to deal in the Software without restriction, including
|
11
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
12
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
13
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
14
|
+
# the following conditions:
|
15
|
+
#
|
16
|
+
# The above copyright notice and this permission notice shall be
|
17
|
+
# included in all copies or substantial portions of the Software.
|
18
|
+
#
|
19
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
20
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
22
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
23
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
24
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
25
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
5
26
|
|
6
|
-
|
27
|
+
begin
|
28
|
+
require 'rubygems'
|
29
|
+
require 'rails_creator'
|
30
|
+
rescue LoadError
|
31
|
+
require File.dirname(__FILE__) + "/../lib/rails_creator"
|
32
|
+
end
|
33
|
+
|
34
|
+
require 'optparse'
|
35
|
+
OPTIONS = Hash.new
|
36
|
+
|
37
|
+
|
38
|
+
parser = OptionParser.new do |opts|
|
39
|
+
|
40
|
+
opts.banner = <<-BANNER
|
41
|
+
|
42
|
+
#{File.basename($0)}
|
43
|
+
|
44
|
+
An automated way to create your rails applications. It will create your app according to
|
45
|
+
your specs (mysql/postgres) using a more OOP approach of YAML, it will remove some cruft,
|
46
|
+
and setup some files for keeping notes on your application. (located in the doc/ folder)
|
47
|
+
|
48
|
+
Usage: #{File.basename($0)} [options] [application_name]
|
49
|
+
|
50
|
+
options is for setting mysql (-M), postgres (-P)
|
51
|
+
|
52
|
+
If you'd like to create your new application on Edge Rails then the
|
53
|
+
options are (-m) for mysql and edge, or (-p) for postgres and edge
|
54
|
+
|
55
|
+
BANNER
|
56
|
+
|
57
|
+
opts.separator ""
|
58
|
+
|
59
|
+
# use mysql
|
60
|
+
opts.on('-M', '--mysql', String, "Use MySQL as your Database") do |d|
|
61
|
+
OPTIONS[:database] = 'mysql'
|
62
|
+
OPTIONS[:edge] = false
|
63
|
+
end
|
64
|
+
|
65
|
+
# use postgres
|
66
|
+
opts.on('-P', '--postgresql', String, 'Use PostgreSQL as your Database') do |d|
|
67
|
+
OPTIONS[:database] = 'postgresql'
|
68
|
+
OPTIONS[:edge] = false
|
69
|
+
end
|
70
|
+
|
71
|
+
# mysql and edge rails
|
72
|
+
opts.on('-m', '--mysql-edge', String, 'Create your project on edge using mysql') do |me|
|
73
|
+
OPTIONS[:database] = 'mysql'
|
74
|
+
OPTIONS[:edge] = true
|
75
|
+
end
|
76
|
+
|
77
|
+
# postgres and edge rails
|
78
|
+
opts.on('-p', '--postgresql-edge', String, 'Create your project on edge using postgresql') do |pe|
|
79
|
+
OPTIONS[:database] = 'postgresql'
|
80
|
+
OPTIONS[:edge] = true
|
81
|
+
end
|
82
|
+
|
83
|
+
# display the help message
|
84
|
+
opts.on('-h', '--help', 'View the various options that can be used.') do
|
85
|
+
puts "#{opts}\n"
|
86
|
+
exit
|
87
|
+
end
|
88
|
+
|
89
|
+
# get the version number
|
90
|
+
opts.on('-v', '--version', 'Shows the current version number.') do
|
91
|
+
puts "Rails Creator Version #{RailsCreator::Version::String}\n"
|
92
|
+
exit
|
93
|
+
end
|
94
|
+
|
95
|
+
# get the application name and then parse the arguments
|
96
|
+
@app_name = ARGV.last || "i_didnt_name_my_app"
|
97
|
+
opts.parse!(ARGV)
|
98
|
+
|
99
|
+
# check if the options hash is empty (nothing was sent to the script)
|
100
|
+
if OPTIONS.empty?
|
101
|
+
puts "#{opts}\n"; exit
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
# run the rails creator
|
107
|
+
creator = RailsCreator::Generate.new(OPTIONS, @app_name)
|
108
|
+
creator.run
|
data/lib/rails_creator.rb
CHANGED
@@ -1,164 +1,16 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# dependencies
|
2
|
+
require 'open-uri'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'optparse'
|
5
|
+
require 'ostruct'
|
3
6
|
include FileUtils
|
4
7
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
def create
|
10
|
-
@@options = Hash.new
|
11
|
-
greetings
|
12
|
-
ask_questions
|
13
|
-
check_responses
|
14
|
-
if @@options[:svn_answer] == 'y' || @@options[:svn_answer] == 'Y'
|
15
|
-
checkin_subversion
|
16
|
-
end
|
17
|
-
create_database_yml
|
18
|
-
puts 'All Done!'
|
19
|
-
end
|
20
|
-
|
21
|
-
def greetings
|
22
|
-
clear_screen
|
23
|
-
puts "--------------------------------------------------------------------------------------"
|
24
|
-
puts "Greetings."
|
25
|
-
puts "I've been deployed to help you setup your new shiny web application."
|
26
|
-
puts "I've grown up from many versions and although I'm quite powerful, I cannot be held"
|
27
|
-
puts "responsible for any damage that I may or may not do.\n\n"
|
28
|
-
puts "We are now ready to proceed with Rapid Edge Rails Creation."
|
29
|
-
puts "We need a byte of information before we can begin."
|
30
|
-
puts "--------------------------------------------------------------------------------------\n\n"
|
31
|
-
end
|
32
|
-
|
33
|
-
#
|
34
|
-
# Gather Information
|
35
|
-
#
|
36
|
-
def ask_questions
|
37
|
-
printf "Would you like this Application to be on Edge Rails? (y/n) "
|
38
|
-
@@options[:edge_rails] = gets.chomp
|
39
|
-
|
40
|
-
printf "Enter the name of your Rails Application: "
|
41
|
-
@@options[:rails_app] = gets.chomp
|
42
|
-
|
43
|
-
printf "What Database are you going to use: "
|
44
|
-
@@options[:database] = gets.chomp
|
45
|
-
|
46
|
-
printf "Do you want to import this into your Subversion Repository? (y/n) "
|
47
|
-
@@options[:svn_answer] = gets.chomp
|
48
|
-
|
49
|
-
|
50
|
-
if @@options[:svn_answer] == "y" || @@options[:svn_answer] == "Y"
|
51
|
-
printf "Enter the location of your Subversion Repository so we can check in your application (eg: http://svn.robertrevans.com): "
|
52
|
-
@@options[:svn_repo] = gets.chomp
|
53
|
-
|
54
|
-
printf "Enter your Subversion account username: "
|
55
|
-
@@options[:svn_name] = gets.chomp
|
56
|
-
|
57
|
-
printf "What is the path for your Subversion Checkout Location (eg: /home/revans/Ruby/repo): "
|
58
|
-
@@options[:svn_checkout] = gets.chomp
|
59
|
-
else
|
60
|
-
puts "Ok, I won't import your project."
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def check_responses
|
65
|
-
clear_screen
|
66
|
-
puts "OK. I've gathered enough information."
|
67
|
-
puts "----------------------------------------------------------------------"
|
68
|
-
puts "Edge Rails Application: #{@@options[:edge_rails]}"
|
69
|
-
puts "Rails Application Name: #{@@options[:rails_app]}"
|
70
|
-
puts "Database: #{@@options[:database]}"
|
71
|
-
|
72
|
-
if @@options[:svn_answer] == "y" || @@options[:svn_answer] == "Y"
|
73
|
-
puts "Subversion Repository for Importing: #{@@options[:svn_repo]}"
|
74
|
-
puts "Subversion checkout location: #{@@options[:svn_checkout]}"
|
75
|
-
puts "Your Subversion Username: #{@@options[:svn_name]}"
|
76
|
-
end
|
77
|
-
puts "----------------------------------------------------------------------\n\n"
|
78
|
-
|
79
|
-
printf "Shall I create your application for you now? (y/n) "
|
80
|
-
@@options[:answer] = gets.chomp
|
81
|
-
|
82
|
-
if @@options[:answer] == 'n' or @@options[:answer] == 'N'
|
83
|
-
puts "Alrighty then, seeya!"
|
84
|
-
# exit
|
85
|
-
elsif @@options[:answer] == 'y' or @@options[:answer] == 'Y'
|
86
|
-
install_rails
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def install_rails
|
91
|
-
if @@options[:edge_rails] == 'y' or @@options[:edge_rails] == 'Y'
|
92
|
-
puts "Creating a folder for #{@@options[:rails_app]}..."
|
93
|
-
mkdir_p "#{@@options[:rails_app]}/vendor"
|
94
|
-
cd @@options[:rails_app]
|
95
|
-
|
96
|
-
puts "Downloading Edge Rails and setting up your project..."
|
97
|
-
`svn export http://svn.rubyonrails.org/rails/trunk/ vendor/rails`
|
98
|
-
`ruby vendor/rails/railties/bin/rails .`
|
99
|
-
else
|
100
|
-
`rails #{@@options[:rails_app]}`
|
101
|
-
cd @@options[:rails_app]
|
102
|
-
end
|
103
|
-
|
104
|
-
# ADD CHANGELOG AND REMOVE INDEX.RHTML FILE
|
105
|
-
puts "Adding the CHANGELOG file and removing the index.html..."
|
106
|
-
touch "CHANGELOG"
|
107
|
-
rm "public/index.html"
|
108
|
-
|
109
|
-
puts "Creating an application CSS files..."
|
110
|
-
touch "public/stylesheets/application.css"
|
111
|
-
end
|
112
|
-
|
113
|
-
def checkin_subversion
|
114
|
-
# REMOVE EDGE RAILS FROM VENDOR
|
115
|
-
if @@options[:edge_rails] == 'y' or @@options[:edge_rails] == 'Y'
|
116
|
-
`rm -R vendor/rails`
|
117
|
-
end
|
118
|
-
|
119
|
-
clear_screen
|
120
|
-
puts "Now to import your application into your Subversion Repository."
|
121
|
-
`svn import #{@@options[:svn_repo]} -m "Initial Check-In" --username #{@@options[:svn_name]}`
|
122
|
-
|
123
|
-
`cd ..`
|
124
|
-
`rm -R #{@@options[:rails_app]}`
|
125
|
-
cd @@options[:svn_checkout]
|
126
|
-
|
127
|
-
puts "Checking out your application from Subversion..."
|
128
|
-
`svn co #{@@options[:svn_repo]} #{@@options[:rails_app]}`
|
129
|
-
cd @@options[:rails_app]
|
130
|
-
|
131
|
-
puts "Setting Rails to svn:externals..."
|
132
|
-
`svn propset svn:externals "rails http://svn.rubyonrails.org/rails/trunk/" vendor`
|
133
|
-
`svn commit -m "Set Rails to use externals"`
|
134
|
-
|
135
|
-
puts "Removing log files from Subversion..."
|
136
|
-
`svn remove log/*`
|
137
|
-
`svn commit -m "Removed log files."`
|
138
|
-
`svn propset svn:ignore "*.log" log/`
|
139
|
-
`svn update log/`
|
140
|
-
`svn commit -m "Ignoring all files within the log file that have the .log extension."`
|
141
|
-
|
142
|
-
puts "Removing the tmp directory from Subversion..."
|
143
|
-
`svn remove tmp/`
|
144
|
-
`svn commit -m "Removed the tmp file."`
|
145
|
-
`svn propset svn:ignore "*" tmp/`
|
146
|
-
`svn update tmp/`
|
147
|
-
`svn commit -m "Removed the tmp file."`
|
148
|
-
|
149
|
-
puts "Creating database.sample file..."
|
150
|
-
`svn move config/database.yml config/database.yml.sample`
|
151
|
-
`svn commit -m "Moved database.yml to database.yml.sample"`
|
152
|
-
`svn propset svn:ignore "database.yml" config/`
|
153
|
-
`svn update config/`
|
154
|
-
`svn commit -m "Ignoring database.yml file."`
|
155
|
-
end
|
8
|
+
# Add load path
|
9
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
10
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
156
11
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
system('cls') unless system('clear')
|
163
|
-
end
|
164
|
-
end
|
12
|
+
require 'rails_creator/version'
|
13
|
+
require 'rails_creator/generate'
|
14
|
+
require 'rails_creator/utilities'
|
15
|
+
require 'rails_creator/subversion'
|
16
|
+
require 'rails_creator/constants'
|
@@ -0,0 +1,94 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__))
|
2
|
+
require 'utilities'
|
3
|
+
require 'subversion'
|
4
|
+
|
5
|
+
module RailsCreator
|
6
|
+
class Generate
|
7
|
+
|
8
|
+
###
|
9
|
+
# initialize
|
10
|
+
# take a hash and string (options, app_name, respectively)
|
11
|
+
#
|
12
|
+
# example: rails_creator -m my_app_name
|
13
|
+
#
|
14
|
+
|
15
|
+
def initialize(options, app_name)
|
16
|
+
@options = options
|
17
|
+
@application = app_name
|
18
|
+
end
|
19
|
+
|
20
|
+
###
|
21
|
+
# run
|
22
|
+
# this will take our options hash, go through it, and call the
|
23
|
+
# appropriate methods to create a our brand spankin' new, and shiny
|
24
|
+
# rails application
|
25
|
+
#
|
26
|
+
|
27
|
+
def run
|
28
|
+
@options[:edge] ? create_on_edge : create_on_internal_rails
|
29
|
+
cleanup
|
30
|
+
# write_database_yaml(@options[:database])
|
31
|
+
|
32
|
+
puts("Your Application, #{@application}, has been created.\n")
|
33
|
+
printf "Would you like to check this into a Subversion Repository? (y or n) "
|
34
|
+
answer = $stdin.gets.chomp
|
35
|
+
|
36
|
+
import_into_svn if answer == 'y' || answer == 'Y'
|
37
|
+
end
|
38
|
+
|
39
|
+
# mixin behavior
|
40
|
+
include Utilities, Subversion
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
###
|
45
|
+
# create_on_edge
|
46
|
+
# creates a new project using edge rails
|
47
|
+
# it first downloads edge, then creates the project
|
48
|
+
# from edge itself
|
49
|
+
#
|
50
|
+
|
51
|
+
def create_on_edge
|
52
|
+
puts "Creating #{@application} on the edge. This may take a few minutes to check-out the latest Rails and create your application."
|
53
|
+
mkdir_p "#{@application}/vendor"
|
54
|
+
cd_into_app
|
55
|
+
checkout_edge_rails
|
56
|
+
create_rails(@options[:database])
|
57
|
+
end
|
58
|
+
|
59
|
+
###
|
60
|
+
# create_on_internal_rails
|
61
|
+
# creates a new project using the install version
|
62
|
+
# of rails that exists on your system
|
63
|
+
#
|
64
|
+
|
65
|
+
def create_on_internal_rails
|
66
|
+
puts "Creating #{@application} using your installed version of rails. This should be really quick."
|
67
|
+
`rails -d #{@options[:database]} #{@application}`
|
68
|
+
cd_into_app
|
69
|
+
end
|
70
|
+
|
71
|
+
###
|
72
|
+
# cd_into_app
|
73
|
+
#
|
74
|
+
|
75
|
+
def cd_into_app
|
76
|
+
cd "#{@application}"
|
77
|
+
end
|
78
|
+
|
79
|
+
###
|
80
|
+
# cleanup
|
81
|
+
# removes public/index.html and adds:
|
82
|
+
# doc/CHANGELOG
|
83
|
+
# doc/TODO
|
84
|
+
#
|
85
|
+
|
86
|
+
def cleanup
|
87
|
+
`sudo rm public/index.html`
|
88
|
+
touch "doc/CHANGELOG"
|
89
|
+
touch "doc/TODO"
|
90
|
+
`mv config/database.yml config/database.yml.sample`
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__))
|
2
|
+
require 'constants'
|
3
|
+
|
4
|
+
|
5
|
+
module RailsCreator
|
6
|
+
module Subversion
|
7
|
+
include Constants
|
8
|
+
|
9
|
+
###
|
10
|
+
# set_extern_rails
|
11
|
+
# sets your appliaction to use rails as an external
|
12
|
+
#
|
13
|
+
|
14
|
+
def set_extern_rails
|
15
|
+
`svn propset svn:externals #{@@rails} vendor`
|
16
|
+
`svn update`
|
17
|
+
end
|
18
|
+
|
19
|
+
###
|
20
|
+
# rm_svn
|
21
|
+
# removes subversion files from the files specified (must be the word of the day, specified)
|
22
|
+
#
|
23
|
+
|
24
|
+
def rm_svn(location='.')
|
25
|
+
`find #{location} -name .svn -print0 | xargs -0 rm -rf`
|
26
|
+
end
|
27
|
+
|
28
|
+
###
|
29
|
+
# import_into_svn
|
30
|
+
# checks the project into subversion
|
31
|
+
#
|
32
|
+
|
33
|
+
def import_into_svn(location=nil)
|
34
|
+
`cd #{location}` unless location.nil?
|
35
|
+
|
36
|
+
printf "Where do you want to import your project to? (e.g. http://svn.mydomain.com) "
|
37
|
+
@svn_http = $stdin.gets.chomp
|
38
|
+
|
39
|
+
printf "What is your username for this subversion repository? "
|
40
|
+
@username = $stdin.gets.chomp
|
41
|
+
|
42
|
+
if File.exists?("vendor/rails")
|
43
|
+
printf "Would you like to remove rails from the vendor directory before checkin? (y or n) "
|
44
|
+
answer = $stdin.gets.chomp
|
45
|
+
`rm -R vendor/rails` if answer == 'y' || answer == 'Y'
|
46
|
+
end
|
47
|
+
|
48
|
+
`svn import #{@svn_http} -m "Initial Check-in." --username #{@username}`
|
49
|
+
puts("Your project was successfully imported into your subversion repository.")
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
###
|
54
|
+
# clean_app
|
55
|
+
# this is for after you have checked out your project from subversion
|
56
|
+
# and you want to remove various files, such as:
|
57
|
+
# *.log, tmp/*, database.yml files
|
58
|
+
# it will also create a database.yml.sample file for you and then
|
59
|
+
# commit this all back into your subversion repository
|
60
|
+
#
|
61
|
+
|
62
|
+
def clean_app(location=nil)
|
63
|
+
`cd #{location}` unless location.nil?
|
64
|
+
|
65
|
+
remove_ignore_logs
|
66
|
+
remove_ignore_tmp
|
67
|
+
ignore_database_yml
|
68
|
+
|
69
|
+
`svn commit -m "Setup ignores and removed unneccessary logs and tmp files."`
|
70
|
+
end
|
71
|
+
|
72
|
+
###
|
73
|
+
# remove_ignore_logs
|
74
|
+
# removes logs from subversion and then sets them to be ignored
|
75
|
+
# by subversion
|
76
|
+
# updates log/
|
77
|
+
#
|
78
|
+
|
79
|
+
def remove_ignore_logs
|
80
|
+
`svn remove log/*`
|
81
|
+
`svn propset svn:ignore "*.log" log/`
|
82
|
+
`svn update log/`
|
83
|
+
end
|
84
|
+
|
85
|
+
###
|
86
|
+
# remove_ignore_tmp
|
87
|
+
# removes the tmp files from subversion and then sets them
|
88
|
+
# to be ignored by subversion
|
89
|
+
# updates tmp/
|
90
|
+
#
|
91
|
+
|
92
|
+
def remove_ignore_tmp
|
93
|
+
`svn remove tmp/*`
|
94
|
+
`svn propset svn:ignore "*" tmp/`
|
95
|
+
`svn update tmp/`
|
96
|
+
end
|
97
|
+
|
98
|
+
###
|
99
|
+
# ignore_database_yml
|
100
|
+
# moves database.yml to database.yml.sample (renames)
|
101
|
+
# adds the new file to our svn repo and removes the old one
|
102
|
+
# sets subversion to ignore a new database.yml file
|
103
|
+
# updates config/
|
104
|
+
#
|
105
|
+
|
106
|
+
def ignore_database_yml
|
107
|
+
`svn move config/database.yml config/database.yml.sample`
|
108
|
+
`svn add config/database.yml.sample`
|
109
|
+
`svn remove config/database.yml --force`
|
110
|
+
`svn propset svn:ignore "database.yml" config/`
|
111
|
+
`svn update config/`
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__))
|
2
|
+
require 'constants'
|
3
|
+
|
4
|
+
module RailsCreator
|
5
|
+
module Utilities
|
6
|
+
include Constants
|
7
|
+
|
8
|
+
###
|
9
|
+
# checkout_edge_rails
|
10
|
+
# checks out the latest version of rails into the location
|
11
|
+
# specified or the default one already chosen for you
|
12
|
+
#
|
13
|
+
|
14
|
+
def checkout_edge_rails(location=@@vendor)
|
15
|
+
`svn export #{@@rails} #{location}`
|
16
|
+
end
|
17
|
+
|
18
|
+
###
|
19
|
+
# create_rails
|
20
|
+
# create a rails app from a specified version of rails
|
21
|
+
# the 'rails' is assumed here to be what was created using RailsCreator
|
22
|
+
# the user can set this her/himself, e.g.
|
23
|
+
# `ruby vendor/rails/railties/bin/rails -d #{@options[:database]} .`
|
24
|
+
|
25
|
+
def create_rails(db=@@default_database, rails=@@default_rails_location, location='.')
|
26
|
+
`ruby #{rails} -d #{db} #{location}`
|
27
|
+
end
|
28
|
+
|
29
|
+
###
|
30
|
+
# add_plugins
|
31
|
+
# These are some plugins that I typically use for most of my applications
|
32
|
+
# reads a yml file for the plugins to install
|
33
|
+
#
|
34
|
+
# REQUIRED: rapt
|
35
|
+
# TODO: allow rapt plugins
|
36
|
+
#
|
37
|
+
|
38
|
+
def add_plugins
|
39
|
+
# pending - either on edge or not
|
40
|
+
end
|
41
|
+
|
42
|
+
###
|
43
|
+
# write_database_yaml
|
44
|
+
# default type is mysql
|
45
|
+
# writes out our database.yml file
|
46
|
+
#
|
47
|
+
|
48
|
+
def write_database_yaml(type='mysql')
|
49
|
+
db = File.new("config/database.yml", 'w')
|
50
|
+
db.write database_yaml(type)
|
51
|
+
db.close
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
###
|
57
|
+
# mysql_database_yaml
|
58
|
+
# a better way of handling your database connection via YAML
|
59
|
+
#
|
60
|
+
|
61
|
+
def database_yaml(type='mysql')
|
62
|
+
if type == 'postgresql'
|
63
|
+
encoding = "unicode"
|
64
|
+
adapter = 'postgresql'
|
65
|
+
else
|
66
|
+
encoding = "utf8"
|
67
|
+
adapter = 'mysql'
|
68
|
+
end
|
69
|
+
|
70
|
+
<<-YAML
|
71
|
+
|
72
|
+
login: &login
|
73
|
+
adapter: #{adapter}
|
74
|
+
encoding: #{encoding}
|
75
|
+
username: root
|
76
|
+
password:
|
77
|
+
|
78
|
+
development:
|
79
|
+
database: #{@application}_development
|
80
|
+
<<: *login
|
81
|
+
|
82
|
+
test:
|
83
|
+
database: #{@application}_test
|
84
|
+
<<: *login
|
85
|
+
|
86
|
+
production:
|
87
|
+
database: #{@application}_production
|
88
|
+
<<: *login
|
89
|
+
|
90
|
+
YAML
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
namespace :sessions do
|
2
|
+
desc "Outputs the total sessions within the database"
|
3
|
+
task :count => :environment do
|
4
|
+
count = CGI::Session::ActiveRecordStore::Session.count
|
5
|
+
puts "Total Sessions stored: #{count}."
|
6
|
+
end
|
7
|
+
|
8
|
+
desc "Clear all sessions that are 1 week old, within the database"
|
9
|
+
task :remove => :environment do
|
10
|
+
CGI::Session::ActiveRecordStore::Session.delete_all [ "updated_at < ?", 1.week.ago ]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
namespace :update do
|
15
|
+
desc "Do a db migrate, clone the test database and annotate our models"
|
16
|
+
task :db => :environment do
|
17
|
+
`rake db:migrate && rake db:test:clone && rake annotate_models`
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
namespace :data do
|
22
|
+
namespace :auth do
|
23
|
+
desc "Dump the Rights and Roles their join tables to a yaml file inside test/fixtures file."
|
24
|
+
task :dump => :environment do
|
25
|
+
return unless %[development test staging].include? RAILS_ENV
|
26
|
+
["Role", "Right"].each { |a| `rake db:fixtures:dump MODEL=#{a}`}
|
27
|
+
|
28
|
+
puts "\n***********************************************"
|
29
|
+
puts "Completed the Dump of the Authorization System."
|
30
|
+
puts "***********************************************\n"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
namespace :db do
|
36
|
+
desc "Rebuild the development database (or any RAILS_ENV by passing it: RAILS_ENV=test) from migrations. Requires Annotate Models."
|
37
|
+
task :rebuild => :environment do
|
38
|
+
puts "Dropping the database..."
|
39
|
+
Rake::Task["db:drop"].invoke
|
40
|
+
puts "Creating the database..."
|
41
|
+
Rake::Task["db:create"].invoke
|
42
|
+
Rake::Task["db:migrate"].invoke
|
43
|
+
`rake annotate_models`
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
namespace :test do
|
48
|
+
desc "Run rcov for unit and functional tests."
|
49
|
+
task :rcov => :environment do
|
50
|
+
return unless %w[development test staging].include? RAILS_ENV
|
51
|
+
`rcov test/unit/*`
|
52
|
+
`rcov test/functional/*`
|
53
|
+
`open -a safari #{RAILS_ROOT}/coverage/index.html` # this is OS dependent (currently for OSX)
|
54
|
+
end
|
55
|
+
end
|
data/test/test_all.rb
ADDED
File without changes
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.4
|
3
3
|
specification_version: 1
|
4
4
|
name: rails_creator
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.6.2
|
7
|
+
date: 2007-11-29 00:00:00 -08:00
|
8
8
|
summary: Creates a new Rails project from either Edge Rails or your currently installed version. It will also check your project into Subversion and check it out to the location you specify, removing common files.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
11
|
email: ryand-ruby@zenspider.com
|
12
|
-
homepage: "
|
12
|
+
homepage: "\tby Robert R Evans"
|
13
13
|
rubyforge_project: rails_creator
|
14
|
-
description: "Subversion is optional, and it asks you if you'd like to use it. == SYNOPSIS: At the command line, type:
|
14
|
+
description: "Subversion is optional, and it asks you if you'd like to use it. == SYNOPSIS: At the command line, type: rails_creator -h That will give you a list of options that you can choose from, for example: rails_creator -m my_app This will create your new rails project, with the name 'my_app', using mysql, on edge Rails. rails_creator -M my_app This will create your rails project on the current version of Rails, on your system, using mysql, with the application name: \"my_app\" rails_creator -p my_app For postgresql on edge Rails rails_creator -P my_app For postgresql not on edge Rails == INSTALL:"
|
15
15
|
autorequire:
|
16
16
|
default_executable:
|
17
17
|
bindir: bin
|
@@ -35,9 +35,16 @@ files:
|
|
35
35
|
- Rakefile
|
36
36
|
- bin/rails_creator
|
37
37
|
- lib/rails_creator.rb
|
38
|
+
- lib/rails_creator/version.rb
|
39
|
+
- lib/rails_creator/generate.rb
|
40
|
+
- lib/rails_creator/utilities.rb
|
41
|
+
- lib/rails_creator/constants.rb
|
42
|
+
- lib/rails_creator/subversion.rb
|
43
|
+
- lib/tasks/rails_creator.rake
|
38
44
|
- test/test_creator.rb
|
45
|
+
- test/test_all.rb
|
39
46
|
test_files:
|
40
|
-
- test/
|
47
|
+
- test/test_all.rb
|
41
48
|
rdoc_options:
|
42
49
|
- --main
|
43
50
|
- README.txt
|
@@ -59,5 +66,5 @@ dependencies:
|
|
59
66
|
requirements:
|
60
67
|
- - ">="
|
61
68
|
- !ruby/object:Gem::Version
|
62
|
-
version: 1.
|
69
|
+
version: 1.3.0
|
63
70
|
version:
|