rocketstarter 0.0.1

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 ADDED
@@ -0,0 +1,4 @@
1
+ == 0.0.1 2008-06-20
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/License.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Yusuke Ohmichi(maimuzo)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,30 @@
1
+ History.txt
2
+ License.txt
3
+ Manifest.txt
4
+ PostInstall.txt
5
+ README.txt
6
+ Rakefile
7
+ bin/rocketstarter
8
+ config/hoe.rb
9
+ config/requirements.rb
10
+ lib/rocketstarter.rb
11
+ lib/rocketstarter/rocket_starter_core.rb
12
+ lib/rocketstarter/rocket_starter_options.rb
13
+ lib/rocketstarter/version.rb
14
+ script/console
15
+ script/destroy
16
+ script/generate
17
+ script/txt2html
18
+ setup.rb
19
+ spec/rocketstarter_spec.rb
20
+ spec/spec.opts
21
+ spec/spec_helper.rb
22
+ tasks/deployment.rake
23
+ tasks/environment.rake
24
+ tasks/rspec.rake
25
+ tasks/website.rake
26
+ website/index.html
27
+ website/index.txt
28
+ website/javascripts/rounded_corners_lite.inc.js
29
+ website/stylesheets/screen.css
30
+ website/template.html.erb
data/PostInstall.txt ADDED
@@ -0,0 +1,28 @@
1
+
2
+ 1. Set environment valiable.
3
+
4
+ export ROCKET_STARTER_CONF=~/.rocket_starter
5
+
6
+ 2. Create config file.
7
+
8
+ rocketstarter --init
9
+
10
+ 3. Modify default values.
11
+
12
+ vi ~/.rocket_starter
13
+
14
+ 4. Test for setting
15
+
16
+ rocketstarter --check
17
+
18
+ 5. Create project.
19
+
20
+ cd source-dir
21
+ rocketstarter project_name
22
+
23
+
24
+ For more information on rocket-starter, see http://rocket-starter.rubyforge.org
25
+
26
+
27
+
28
+
data/README.txt ADDED
@@ -0,0 +1,54 @@
1
+ = rocketstarter
2
+
3
+ * http://rocketstarter.rubyforge.org
4
+
5
+ == DESCRIPTION:
6
+
7
+ The Rocket-starter is a setup utility of the Rails applications.
8
+ When you want to create new rails applications, the Rocket-starter can set up basic directories and svn/git repositories for your applications.
9
+
10
+ == FEATURES/PROBLEMS:
11
+
12
+ * create basic directories
13
+ * commit to subversion or git repositories
14
+ * install plugins
15
+ * use RaPT gem for managing plugins (Optional)
16
+
17
+ == SYNOPSIS:
18
+
19
+ $ rocketstarter project-name [options]
20
+ $ rocketstarter --init
21
+ $ rocketstarter --check
22
+
23
+ == REQUIREMENTS:
24
+
25
+ * Readline library on your system
26
+
27
+ == INSTALL:
28
+
29
+ $ sudo gem install rocketstarter
30
+
31
+ == LICENSE:
32
+
33
+ The MIT License
34
+
35
+ Copyright (c) 2008 Yusuke Ohmichi(maimuzo)
36
+
37
+ Permission is hereby granted, free of charge, to any person obtaining
38
+ a copy of this software and associated documentation files (the
39
+ 'Software'), to deal in the Software without restriction, including
40
+ without limitation the rights to use, copy, modify, merge, publish,
41
+ distribute, sublicense, and/or sell copies of the Software, and to
42
+ permit persons to whom the Software is furnished to do so, subject to
43
+ the following conditions:
44
+
45
+ The above copyright notice and this permission notice shall be
46
+ included in all copies or substantial portions of the Software.
47
+
48
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
49
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
50
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
51
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
52
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
53
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
54
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require 'config/requirements'
2
+ require 'config/hoe' # setup Hoe + all gem configuration
3
+
4
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
data/bin/rocketstarter ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Created by Yusuke Ohmichi(maimuzo) on 2008-6-20.
4
+ # Copyright (c) 2008. All rights reserved.
5
+
6
+ require 'rubygems'
7
+ require 'rocketstarter'
8
+
9
+ options = Rocket_starter_options.new.parse
10
+ # Create an instance and run it
11
+ Rocket_starter_core.new( options ).run
12
+
13
+
data/config/hoe.rb ADDED
@@ -0,0 +1,73 @@
1
+ require 'rocketstarter/version'
2
+
3
+ AUTHOR = 'Yusuke Ohmichi(maimuzo)' # can also be an array of Authors
4
+ EMAIL = "maimuzo@gmail.com"
5
+ DESCRIPTION = "When you want to create new rails applications, the Rocket-starter can set up basic directories and svn/git repositories for your applications."
6
+ GEM_NAME = 'rocketstarter' # what ppl will type to install your gem
7
+ RUBYFORGE_PROJECT = 'rocketstarter' # The unix name for your project
8
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
+ EXTRA_DEPENDENCIES = [
11
+ # ['activesupport', '>= 1.3.1']
12
+ ] # An array of rubygem dependencies [name, version]
13
+
14
+ @config_file = "~/.rubyforge/user-config.yml"
15
+ @config = nil
16
+ RUBYFORGE_USERNAME = "unknown"
17
+ def rubyforge_username
18
+ unless @config
19
+ begin
20
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
21
+ rescue
22
+ puts <<-EOS
23
+ ERROR: No rubyforge config file found: #{@config_file}
24
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
25
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
26
+ EOS
27
+ exit
28
+ end
29
+ end
30
+ RUBYFORGE_USERNAME.replace @config["username"]
31
+ end
32
+
33
+
34
+ REV = nil
35
+ # UNCOMMENT IF REQUIRED:
36
+ # REV = YAML.load(`svn info`)['Revision']
37
+ VERS = Rocketstarter::VERSION::STRING + (REV ? ".#{REV}" : "")
38
+ RDOC_OPTS = ['--quiet', '--title', 'rocketstarter documentation',
39
+ "--opname", "index.html",
40
+ "--line-numbers",
41
+ "--main", "README",
42
+ "--inline-source"]
43
+
44
+ class Hoe
45
+ def extra_deps
46
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
47
+ @extra_deps
48
+ end
49
+ end
50
+
51
+ # Generate all the Rake tasks
52
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
53
+ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
54
+ p.developer(AUTHOR, EMAIL)
55
+ p.description = DESCRIPTION
56
+ p.summary = DESCRIPTION
57
+ p.url = HOMEPATH
58
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
59
+ p.test_globs = ["test/**/test_*.rb"]
60
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
61
+
62
+ # == Optional
63
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
64
+ #p.extra_deps = EXTRA_DEPENDENCIES
65
+
66
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
67
+ end
68
+
69
+ CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
70
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
71
+ $hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
72
+ $hoe.rsync_args = '-av --delete --ignore-errors'
73
+ $hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
@@ -0,0 +1,15 @@
1
+ require 'fileutils'
2
+ include FileUtils
3
+
4
+ require 'rubygems'
5
+ %w[rake hoe newgem rubigen].each do |req_gem|
6
+ begin
7
+ require req_gem
8
+ rescue LoadError
9
+ puts "This Rakefile requires the '#{req_gem}' RubyGem."
10
+ puts "Installation: gem install #{req_gem} -y"
11
+ exit
12
+ end
13
+ end
14
+
15
+ $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
@@ -0,0 +1,281 @@
1
+ require 'rubygems'
2
+ require File.dirname(__FILE__) + "/rocket_starter_options"
3
+
4
+ class Rocket_starter_core
5
+ # not use this version number in this class
6
+ @@version = [ 0, 0, 1 ]
7
+
8
+ def initialize(frontend)
9
+ @options = frontend
10
+ @logfile = File::new( @options[:log_file], "a" ) if @options[:logging]
11
+ end
12
+
13
+ =begin
14
+ for subversion
15
+
16
+ cd current_dir
17
+ rocket_starter projname scmuri
18
+
19
+ mkdir projname
20
+ cd projname
21
+ mkdir trunk branches tags
22
+ svn import . scmuri [--passowrd=scmpass] -m "create basic directories"
23
+ rmdir trunk branches tags
24
+ svn checkout scmuri/trunk . [--passowrd=scmpass]
25
+
26
+ svn mkdir docs rails
27
+ cd rails
28
+ rails projname -c [--database=name]
29
+ svn commit . [--passowrd=scmpass] -m "generate rails app"
30
+ cd projname
31
+
32
+ trim app
33
+
34
+ set svn::ignore
35
+
36
+
37
+
38
+ for git
39
+
40
+ cd current_dir
41
+ rocket_starter projname scmuri
42
+
43
+ mkdir projname
44
+ cd projname
45
+ git init
46
+ mkdir docs rails
47
+ cd rails
48
+ rails projname -g [--database=name]
49
+ git add .
50
+ git commit -m "generate rails app"
51
+ cd projname
52
+
53
+ trim app
54
+
55
+ put gitignore files
56
+
57
+
58
+ =end
59
+
60
+ def run
61
+ notice "Rocket_starter: Starting at " + Time.now.strftime("%Y/%m/%d %H:%M:%S")
62
+
63
+ get_current_directory
64
+ set_scm_password
65
+
66
+ if "svn" == @options[:scmtype] and not @options[:scmuri].empty?
67
+ subversion_basic_dirs
68
+ subversion_import
69
+ subversion_checkout
70
+ create_basic_dirs_and_project
71
+ subversion_commit "generate rails app"
72
+ trim_project
73
+ subversion_commit "delete not use files"
74
+ subversion_propset
75
+ subversion_propset_for_netbeans unless @options[:skip_netbeans]
76
+ subversion_commit "set svn:ignore"
77
+ unless @options[:skip_plugins] or @options[:pluginlist_path].empty?
78
+ setup_plugins
79
+ subversion_commit "install rails plugins"
80
+ end
81
+ elsif "git" == @options[:scmtype]
82
+ git_project_dirs_and_init
83
+ create_basic_dirs_and_project
84
+ git_commit "generate rails app"
85
+ trim_project
86
+ git_commit "delete not use files"
87
+ git_ignore
88
+ git_ignore_for_netbeans unless @options[:skip_netbeans]
89
+ git_commit "put .gitignore files"
90
+ unless @options[:skip_plugins] or @options[:pluginlist_path].empty?
91
+ setup_plugins
92
+ git_commit "install rails plugins"
93
+ end
94
+ else
95
+ Rocket_starter_options::error_with_show_usage "irigal SCM type or scmuri is empty."
96
+ end
97
+ notice "Rocket_starter: Complete at " + Time.now.strftime("%Y/%m/%d %H:%M:%S")
98
+ @logfile.close if @logfile
99
+ end
100
+
101
+ def git_project_dirs_and_init
102
+ notice "Create project directory and initialize for git"
103
+ exec_shell_command "mkdir #{@options[:project]}"
104
+ managed_chdir("#{@scm_root}")
105
+ exec_shell_command "git init"
106
+ end
107
+
108
+ def git_commit(message)
109
+ notice "Commiting to local-git for " + message
110
+ exec_shell_command "git add ."
111
+ exec_shell_command "git commit -a -m '#{message}'"
112
+ end
113
+
114
+ def git_ignore
115
+ notice "Configuring .gitignore files."
116
+
117
+ exec_shell_command "echo '*.log' >> log/.gitignore"
118
+ exec_shell_command "echo '*.pid' >> log/.gitignore"
119
+ exec_shell_command "echo '*' >> tmp/.gitignore"
120
+ exec_shell_command "echo '*.db' >> db/.gitignore"
121
+ exec_shell_command "echo '*.sqlite' >> db/.gitignore"
122
+ exec_shell_command "echo '*.sqlite3' >> db/.gitignore"
123
+ exec_shell_command "echo 'schema.rb' >> db/.gitignore"
124
+ exec_shell_command "echo 'schema.sql' >> db/.gitignore"
125
+ exec_shell_command "echo 'database.yml' >> config/.gitignore" if @options[:ignoredatabase]
126
+ end
127
+
128
+ def git_ignore_for_netbeans
129
+ notice "Setting .gitignore file for netbeans."
130
+ exec_shell_command "mkdir nbproject"
131
+ exec_shell_command "echo '*' >> nbproject/.gitignore"
132
+ end
133
+
134
+ def subversion_basic_dirs
135
+ notice "Create basic directories."
136
+ exec_shell_command "mkdir #{@options[:project]}"
137
+ managed_chdir("#{@scm_root}")
138
+ exec_shell_command "mkdir trunk branches tags"
139
+ exec_shell_command "pwd"
140
+ end
141
+
142
+ def subversion_import
143
+ notice "Importing project to subvserion."
144
+ exec_shell_command "svn import . #{@options[:scmuri]} #{@scm_password} -m \"Initial import\""
145
+ exec_shell_command "rmdir trunk branches tags"
146
+ end
147
+
148
+ def subversion_checkout
149
+ notice "Checking out trunk of the project from subversion."
150
+ exec_shell_command "svn checkout #{@options[:scmuri]}/trunk . #{@scm_password}"
151
+ end
152
+
153
+ def create_basic_dirs_and_project
154
+ exec_shell_command "pwd"
155
+ case @options[:scmtype]
156
+ when "svn"
157
+ exec_shell_command "svn mkdir rails docs"
158
+ managed_chdir("#{@scm_root}/rails")
159
+ rails_option = " -c"
160
+ when "git"
161
+ exec_shell_command "mkdir rails docs"
162
+ managed_chdir("#{@scm_root}/rails")
163
+ rails_option = " -g"
164
+ else
165
+ exec_shell_command "mkdir rails docs"
166
+ managed_chdir("#{@scm_root}/rails")
167
+ rails_option = ""
168
+ end
169
+ rails_option << " --database=" + @options[:database] unless "" == @options[:database]
170
+ if exec_shell_command "rails #{@options[:project]}" + rails_option
171
+ notice "Rails Project Folder Successfully Created."
172
+ else
173
+ notice "Error creating the Rails project folder: exiting."
174
+ exit
175
+ end
176
+ end
177
+
178
+ def subversion_commit(message)
179
+ notice "Commiting to subversion for " + message
180
+ exec_shell_command "svn commit #{@scm_root} #{@scm_password} -m '#{message}'"
181
+ end
182
+
183
+ def trim_project
184
+ notice "Triming initial project."
185
+ exec_shell_command "pwd"
186
+ managed_chdir("#{@scm_root}/rails/#{@options[:project]}")
187
+ exec_shell_command "svn mv config/database.yml config/database.yml.sample" if @options[:ignoredatabase]
188
+ case @options[:scmtype]
189
+ when "svn"
190
+ exec_shell_command "svn rm doc/README_FOR_APP"
191
+ exec_shell_command "svn rm README"
192
+ exec_shell_command "svn rm -r log/*"
193
+ exec_shell_command "svn rm -r tmp/*"
194
+ when "git"
195
+ exec_shell_command "rm doc/README_FOR_APP"
196
+ exec_shell_command "rm README"
197
+ exec_shell_command "rm -rf log/*"
198
+ exec_shell_command "rm -rf tmp/*"
199
+ end
200
+ end
201
+
202
+ def subversion_propset
203
+ notice "Configuring svn:ignore properties."
204
+ exec_shell_command "svn propset svn:ignore \"*.log\n*.pid\" log/"
205
+ exec_shell_command "svn propset svn:ignore \"*\" tmp/"
206
+ exec_shell_command "svn propset svn:ignore \"*.db\n*.sqlite\n*.sqlite3\nschema.rb\nschema.sql\" db/"
207
+ if @options[:ignoredatabase]
208
+ exec_shell_command "cp config/database.yml.sample config/database.yml"
209
+ exec_shell_command "svn propset svn:ignore \"database.yml\" config/"
210
+ end
211
+ exec_shell_command "svn update . #{@scm_password}"
212
+ end
213
+
214
+ def subversion_propset_for_netbeans
215
+ notice "Setting svn:ignore for netbeans."
216
+ exec_shell_command "mkdir nbproject"
217
+ exec_shell_command "svn propset svn:ignore \"*\" nbproject/"
218
+ exec_shell_command "svn update nbproject/ #{@scm_password}"
219
+ exec_shell_command "rmdir nbproject"
220
+ end
221
+
222
+ def setup_plugins
223
+ begin
224
+ plugin_option = ""
225
+ plugin_option << " -x " if @options[:external]
226
+
227
+ File.open(@options[:pluginlist_path]) do |plugin_file|
228
+ plugin_file.each do |line|
229
+ if @options[:rapt]
230
+ exec_shell_command "rapt install #{plugin_option} #{line}"
231
+ else
232
+ exec_shell_command "script/plugin install #{plugin_option} #{line}"
233
+ end
234
+ end
235
+ end
236
+ rescue
237
+ notice "Can not open #{@options[:pluginlist_path]}"
238
+ Rocket_starter_options::show_usage
239
+ end
240
+ end
241
+
242
+ protected
243
+
244
+ def managed_chdir(path)
245
+ notice("change directory to " + path)
246
+ Dir::chdir(path)
247
+ end
248
+
249
+ def set_scm_password
250
+ @scm_password = ""
251
+ @scm_password = '--password=' + @options[:scmpassword] if @options[:scmpassword]
252
+ end
253
+
254
+ def get_current_directory
255
+ @current_dir = `pwd`.chomp
256
+ notice "current directory is " + @current_dir
257
+ @scm_root = @current_dir + "/" + @options[:project]
258
+ notice "scm_root is " + @scm_root
259
+ Rocket_starter_options::error_with_show_usage "irigal directory name." if (@current_dir + "/") == @scm_root
260
+ end
261
+
262
+ def notice(message)
263
+ puts "* " + message if @options[:verbose]
264
+ @logfile.puts "* " + message if @options[:logging]
265
+ end
266
+
267
+ def exec_shell_command(command)
268
+ command << " > /dev/null" unless @options[:verbose]
269
+ command = "sudo " + command if @options[:sudo]
270
+ puts '->' + command if @options[:verbose]
271
+ @logfile.puts '->' + command if @options[:logging]
272
+ #system command unless @options[:emulate]
273
+ result = `#{command}`.chomp unless @options[:emulate]
274
+ puts '-->' + result if @options[:verbose] and not result.nil? and not result.empty?
275
+ @logfile.puts '-->' + result if @options[:logging] and not result.nil? and not result.empty?
276
+ Rocket_starter_options::error_with_show_usage "receive error from command." unless 0 == $?
277
+ $?
278
+ end
279
+
280
+ end
281
+