creator 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ == 0.5.0 / 2007-06-16
2
+
3
+ * Initial Release
@@ -0,0 +1,7 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ bin/creator
6
+ lib/creator.rb
7
+ test/test_creator.rb
@@ -0,0 +1,49 @@
1
+ creator
2
+ by Robert R Evans
3
+ http://robertrevans.com
4
+ http://rubysnips.com
5
+
6
+ == DESCRIPTION:
7
+
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.
11
+
12
+ Subversion is optional, and it asks you if you'd like to use it.
13
+
14
+ == SYNOPSIS:
15
+
16
+ At the command line, type: creator
17
+ That command will start the process.
18
+
19
+ == TODO:
20
+ Refactor the code base and add additional utility functions such as recursively removing subversion
21
+ directories.
22
+
23
+ == INSTALL:
24
+
25
+ * sudo gem install creator
26
+
27
+ == LICENSE:
28
+
29
+
30
+ Copyright (c) 2007 Robert R Evans
31
+
32
+ Permission is hereby granted, free of charge, to any person obtaining
33
+ a copy of this software and associated documentation files (the
34
+ 'Software'), to deal in the Software without restriction, including
35
+ without limitation the rights to use, copy, modify, merge, publish,
36
+ distribute, sublicense, and/or sell copies of the Software, and to
37
+ permit persons to whom the Software is furnished to do so, subject to
38
+ the following conditions:
39
+
40
+ The above copyright notice and this permission notice shall be
41
+ included in all copies or substantial portions of the Software.
42
+
43
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
44
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
45
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
46
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
47
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
48
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
49
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require './lib/creator.rb'
6
+
7
+ Hoe.new('creator', Creator::VERSION) do |p|
8
+ p.rubyforge_name = 'creator'
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
+ p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
11
+ p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
12
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
13
+ # p.remote_rdoc_dir = '' # Release to root
14
+ end
15
+
16
+ # vim: syntax=Ruby
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'creator'
5
+
6
+ Creator.create
@@ -0,0 +1,160 @@
1
+ %w[open-uri fileutils].each { |f| require f }
2
+
3
+ include FileUtils
4
+
5
+ module Creator
6
+ extend self
7
+ VERSION = '0.5.0'
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
+ puts `clear`
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
+ puts `clear`
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`
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
156
+
157
+ def create_database_yml
158
+ touch "config/database.yml.sample"
159
+ end
160
+ end
File without changes
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.4
3
+ specification_version: 1
4
+ name: creator
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.5.0
7
+ date: 2007-06-17 00:00:00 -07:00
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
+ require_paths:
10
+ - lib
11
+ email: ryand-ruby@zenspider.com
12
+ homepage: " by Robert R Evans"
13
+ rubyforge_project: creator
14
+ description: "Subversion is optional, and it asks you if you'd like to use it. == SYNOPSIS: At the command line, type: creator That command will start the process. == TODO: Refactor the code base and add additional utility functions such as recursively removing subversion directories."
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Ryan Davis
31
+ files:
32
+ - History.txt
33
+ - Manifest.txt
34
+ - README.txt
35
+ - Rakefile
36
+ - bin/creator
37
+ - lib/creator.rb
38
+ - test/test_creator.rb
39
+ test_files:
40
+ - test/test_creator.rb
41
+ rdoc_options: []
42
+
43
+ extra_rdoc_files: []
44
+
45
+ executables:
46
+ - creator
47
+ extensions: []
48
+
49
+ requirements: []
50
+
51
+ dependencies:
52
+ - !ruby/object:Gem::Dependency
53
+ name: hoe
54
+ version_requirement:
55
+ version_requirements: !ruby/object:Gem::Version::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 1.2.0
60
+ version: