rorsvnprep 0.1.1 → 0.1.2

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.
Files changed (3) hide show
  1. data/bin/rorsvnprep +1 -132
  2. data/lib/rorsvnprep.rb +113 -6
  3. metadata +2 -2
data/bin/rorsvnprep CHANGED
@@ -1,80 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- #
3
- # = Ruby on Rails Subversion Prep Tool
4
- #
5
- # This script creates a new Rails application and prepares it for import into
6
- # subversion. It takes a number of command line arguments that specify things
7
- # like application name, repository location and other details to make the
8
- # whole process as streamlined as possible. The more you give the script the
9
- # more it will handle for you automatically.
10
- #
11
- # Author:: James W. Thompson, II
12
- # Copyright:: Copyright (c) 2007. James W. Thompson, II
13
- # License:: Licensed under an MIT style license
14
- #
15
- # == Command-Line Syntax
16
- #
17
- # <tt><b>ruby rorsvnprep.rb</b> <em>example svn://server/path/to/repos</em></tt>
18
- #
19
- # The command creates a new rails project called <em>example</em>, performs a
20
- # variety of actions in preparation for an initial subversion import and then
21
- # imports the project to the repository provided. The script then checks out
22
- # the project and updates various svn:ignore properties before recommitting the
23
- # project and exiting.
24
- #
25
- # The script assumes you want you have given it the full subversion repository
26
- # URI, complete with any applicable path details for within the repository. The
27
- # script also will just break if you don't give it any subversion details, so
28
- # don't use the script unless you have something to give it. Also, the
29
- # --password switch is broken, so don't use it. And finally, remember this is
30
- # still a very 'beta' quality product so don't depend on it for anythign really
31
- # important.
32
- #
33
- # == Effects
34
- #
35
- # * Renames <em>config/database.yml</em> to <em>config/database.yml.sample</em>
36
- # * Deletes extraneous files and directories
37
- # * <tt><em>doc/README_FOR_APP</em></tt>
38
- # * <tt><em>README</em></tt>
39
- # * <tt><em>log/*</em></tt>
40
- # * <tt><em>tmp/*</em></tt>
41
- # * Performs an initial import
42
- # * Performs an initial checkout
43
- # * Updates svn:ignore properties for project and recommits project
44
- # * <tt><em>log/*.log</em></tt>
45
- # * <tt><em>log/*.pid</em></tt>
46
- # * <tt><em>tmp/*</em></tt>
47
- # * <tt><em>db/*.db</em></tt>
48
- # * <tt><em>db/*.sqlite</em></tt>
49
- # * <tt><em>db/*.sqlite3</em></tt>
50
- # * <tt><em>db/schema.rb</em></tt>
51
- # * <tt><em>db/schema.sql</em></tt>
52
- #
53
- # == TODO
54
- #
55
- # * Rewrite to work with Ruby's subversion bindings if available
56
- # * Make explicitly object oriented
57
- # * Add some helpful Subversion rake tasks
58
- #
59
- # == License
60
- #
61
- # Permission is hereby granted, free of charge, to any person obtaining a copy
62
- # of this software and associated documentation files (the "Software"), to deal
63
- # in the Software without restriction, including without limitation the rights
64
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
65
- # copies of the Software, and to permit persons to whom the Software is
66
- # furnished to do so, subject to the following conditions:
67
- #
68
- # The above copyright notice and this permission notice shall be included in
69
- # all copies or substantial portions of the Software.
70
- #
71
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
72
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
73
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
74
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
75
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
76
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
77
- # SOFTWARE.
78
2
  require 'optparse'
79
3
  require 'rorsvnprep'
80
4
 
@@ -143,59 +67,4 @@ logfile = File::new( "rorsvnprep.log", "a" ) if arguments[:log]
143
67
  # Create an instance of our prep class with all our options
144
68
  rsp = RailsSVNPrep.new( project, svnuri, password, logfile, verbose )
145
69
 
146
- # TODO: Switch over to following code and remove everything beyond it
147
- #
148
- #rsp.run
149
-
150
- # Create a project
151
- rsp.create_project
152
-
153
- # OLD: Create our new project
154
- #puts "Creating Rails project: #{project}" if arguments[:verbose]
155
- #
156
- #if arguments[:verbose]
157
- # system "rails #{project}"
158
- #else
159
- # system "rails #{project} >> /dev/null"
160
- #end
161
- #
162
- #Dir::chdir project
163
-
164
- # Trim out all the stuff we don't want in the initial subversion import and
165
- # move some other stuff around.
166
- puts "Triming initial project..." if arguments[:verbose]
167
- File::rename "config/database.yml", "config/database.yml.sample"
168
- File::delete "doc/README_FOR_APP"
169
- File::delete "README"
170
- system "rm -rf log/* > /dev/null"
171
- system "rm -rf tmp/* > /dev/null"
172
-
173
- # Perform our initial subversion import
174
- puts "Importing project to subvserion..." if arguments[:verbose]
175
- system "svn import #{svnuri} -m \"Initial import\" > /dev/null"
176
- Dir::chdir ".."
177
- system "rm -rf #{project} > /dev/null"
178
-
179
- # Perform a subversion checkout of our project
180
- puts "Checking out project from subversion..." if arguments[:verbose]
181
- system "svn co #{svnuri} #{project} > /dev/null"
182
- Dir::chdir project
183
-
184
- # Setup svn:ignore properties
185
- puts "Configuring svn:ignore properties..." if arguments[:verbose]
186
- system "svn propset svn:ignore \"*.log\n*.pid\" log/ > /dev/null"
187
- system "svn update log/ > /dev/null"
188
- system "svn propset svn:ignore \"*\" tmp/ > /dev/null"
189
- system "svn update tmp/ > /dev/null"
190
- system "svn propset svn:ignore \"*.db\n*.sqlite\n*.sqlite3\nschema.rb\nschema.sql\" db/ > /dev/null"
191
- system "svn update db/ > /dev/null"
192
- system "svn propset svn:ignore \"database.yml\" config/ > /dev/null"
193
- system "svn update config/ > /dev/null"
194
-
195
- # Committing updates
196
- puts "Committing updates..." if arguments[:verbose]
197
- system "svn commit -m \"Updated svn:ignore properties\" > /dev/null"
198
-
199
- # Return to where we started
200
- Dir::chdir ".."
201
- puts "Done with project: #{project}"
70
+ rsp.run
data/lib/rorsvnprep.rb CHANGED
@@ -1,14 +1,68 @@
1
- # This file contains the main class definition for the Ruby on Rails Subversion
2
- # Prep Tool.
1
+ # = Ruby on Rails Subversion Prep Tool
3
2
  #
4
- # Author:: James W. Thompson, II
5
- # Copyright:: Copyright (c) 2007, James W. Thompson, II
3
+ # This file contains the main class that powers the Ruby on Rails Subversion
4
+ # Prep Tool's script found in bin/rorsvnprep.
5
+ #
6
+ # Author:: James W. Thompson, II
7
+ # Copyright:: Copyright (c) 2007. James W. Thompson, II
8
+ # License:: Licensed under an MIT style license
9
+ #
10
+ # == Command-Line Syntax
11
+ #
12
+ # <tt><b>rorsvnprep</b> <em>example --svn=svn://server/path/to/repos</em></tt>
13
+ #
14
+ # The command creates a new rails project called <em>example</em>, performs a
15
+ # variety of actions in preparation for an initial subversion import and then
16
+ # imports the project to the repository provided. The script then checks out
17
+ # the project and updates various svn:ignore properties before recommitting the
18
+ # project and exiting.
19
+ #
20
+ # == Effects
21
+ #
22
+ # * Renames <em>config/database.yml</em> to <em>config/database.yml.sample</em>
23
+ # * Deletes extraneous files and directories
24
+ # * <tt><em>doc/README_FOR_APP</em></tt>
25
+ # * <tt><em>README</em></tt>
26
+ # * <tt><em>log/*</em></tt>
27
+ # * <tt><em>tmp/*</em></tt>
28
+ # * Performs an initial import
29
+ # * Performs an initial checkout
30
+ # * Updates svn:ignore properties for project and recommits project
31
+ # * <tt><em>log/*.log</em></tt>
32
+ # * <tt><em>log/*.pid</em></tt>
33
+ # * <tt><em>tmp/*</em></tt>
34
+ # * <tt><em>db/*.db</em></tt>
35
+ # * <tt><em>db/*.sqlite</em></tt>
36
+ # * <tt><em>db/*.sqlite3</em></tt>
37
+ # * <tt><em>db/schema.rb</em></tt>
38
+ # * <tt><em>db/schema.sql</em></tt>
39
+ #
40
+ # == License
41
+ #
42
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
43
+ # of this software and associated documentation files (the "Software"), to deal
44
+ # in the Software without restriction, including without limitation the rights
45
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
46
+ # copies of the Software, and to permit persons to whom the Software is
47
+ # furnished to do so, subject to the following conditions:
48
+ #
49
+ # The above copyright notice and this permission notice shall be included in
50
+ # all copies or substantial portions of the Software.
51
+ #
52
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
53
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
54
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
55
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
56
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
57
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
58
+ # SOFTWARE.
59
+
6
60
 
7
61
  # This class provides all the heavy lifting methods used by the command-line
8
62
  # utility. This class could also be implemented as part of another package to
9
63
  # provide further automated utilities.
10
64
  class RailsSVNPrep
11
- @@version = [ 0, 1, 1 ]
65
+ @@version = [ 0, 1, 2 ]
12
66
 
13
67
  @project = nil
14
68
  @svn = nil
@@ -27,6 +81,8 @@ class RailsSVNPrep
27
81
  @verbose = verbose
28
82
  end
29
83
 
84
+ # A simple method that calls all the other individual methods as necessary to
85
+ # create the rails project, prep it and produce a good working copy.
30
86
  def run
31
87
  puts "Rails SVN Prep: Starting." if @verbose
32
88
  @logfile.puts "Rails SVN Prep: Starting." if @logfile
@@ -59,7 +115,7 @@ class RailsSVNPrep
59
115
  # raise StandardError
60
116
  #end
61
117
 
62
- if system "rails #{@project} >> /dev/null"
118
+ if system "rails #{@project} > /dev/null"
63
119
  puts "Rails Project Folder Successfully Created." if @verbose
64
120
  @logfile.puts "Rails Project Folder Successfully Created." if @logfile
65
121
  Dir::chdir @project
@@ -70,22 +126,73 @@ class RailsSVNPrep
70
126
  end
71
127
  end
72
128
 
129
+ # This method prunes the initial project structure by renaming
130
+ # config/database.yml, getting rid of the default README and README_FOR_APP
131
+ # files and clearing our the log/ and tmp/ folders.
73
132
  def trim_project
133
+ puts "Triming initial project." if @verbose
134
+ @logfile.puts "Triming initial project." if @logfile
135
+
136
+ File::rename "config/database.yml", "config/database.yml.sample"
137
+ File::delete "doc/README_FOR_APP"
138
+ File::delete "README"
139
+ system "rm -rf log/* > /dev/null"
140
+ system "rm -rf tmp/* > /dev/null"
74
141
  end
75
142
 
143
+ # This method produces .cvsignore files for those times when you don't want an
144
+ # initial subversion import done.
145
+ #
146
+ # TODO: Actually implement this.
76
147
  def generate_cvsignore
77
148
  end
78
149
 
150
+ # This method performs the initial subversion import and then deletes the
151
+ # project folder in preparation for the initial checkout.
79
152
  def subversion_import
153
+ puts "Importing project to subvserion." if @verbose
154
+ @logfile.puts "Importing project to subvserion." if @logfile
155
+
156
+ system "svn import #{@svn} -m \"Initial import\" > /dev/null"
157
+ Dir::chdir ".."
158
+ system "rm -rf #{@project} > /dev/null"
80
159
  end
81
160
 
161
+ # This method produces the initial working copy via a subversion checkout.
82
162
  def subversion_checkout
163
+ puts "Checking out project from subversion." if @verbose
164
+ @logfile.puts "Checking out project from subversion." if @logfile
165
+
166
+ system "svn co #{@svn} #{@project} > /dev/null"
167
+ Dir::chdir @project
83
168
  end
84
169
 
170
+ # This method sets the svn:ignore property across a number of folders to make
171
+ # sure files that don't belong in version control don't end up in it.
85
172
  def subversion_propset
173
+ puts "Configuring svn:ignore properties." if @verbose
174
+ @logfile.puts "Configuring svn:ignore properties." if @logfile
175
+
176
+ system "svn propset svn:ignore \"*.log\n*.pid\" log/ > /dev/null"
177
+ system "svn update log/ > /dev/null"
178
+ system "svn propset svn:ignore \"*\" tmp/ > /dev/null"
179
+ system "svn update tmp/ > /dev/null"
180
+ system "svn propset svn:ignore \"*.db\n*.sqlite\n*.sqlite3\nschema.rb\nschema.sql\" db/ > /dev/null"
181
+ system "svn update db/ > /dev/null"
182
+ system "svn propset svn:ignore \"database.yml\" config/ > /dev/null"
183
+ system "svn update config/ > /dev/null"
86
184
  end
87
185
 
186
+ # This method finishes up by committing to subversion if needed and
187
+ # performing other house-keeping measures.
88
188
  def finalize
189
+ if @svn
190
+ puts "Committing updates." if @verbose
191
+ @logfile.puts "Committing updates." if @logfile
192
+
193
+ system "svn commit -m \"Updated svn:ignore properties\" > /dev/null"
194
+ Dir::chdir ".."
195
+ end
89
196
  end
90
197
 
91
198
  # A convenience method to return our version number
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: rorsvnprep
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.1
7
- date: 2007-02-20 00:00:00 -05:00
6
+ version: 0.1.2
7
+ date: 2007-02-22 00:00:00 -05:00
8
8
  summary: Provides additional automation to make managing Rails project with subversion easier.
9
9
  require_paths:
10
10
  - lib