rorsvnprep 0.0.1 → 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.
Files changed (4) hide show
  1. data/README +2 -22
  2. data/bin/rorsvnprep +111 -60
  3. data/lib/rorsvnprep.rb +9 -2
  4. metadata +3 -3
data/README CHANGED
@@ -21,30 +21,10 @@ alias.
21
21
  Using rorsvnprep
22
22
  ================
23
23
 
24
- The rorsvnprep command can accept a number of command-line parameters that
25
- determine its behavior. At the very minimum you need to supply it with a
26
- project name, just like you would the rails command. Under the hood rorsvnprep
27
- actually calls the rails command and then performs some basic preparations.
28
-
29
- If all you provide is the project name then rorsvnprep simply generates
30
- .cvsignore files for your project as described later and trims a few extraneous
31
- directories and files. If, however, you also provide a repository URI via the
32
- '--svn [repos]' switch; then rorsvnprep will actually perform an initial import
33
- of your project and perform svn propset calls in place of using .cvsignore
34
- files. You may supply a password to rorsvnprep to further automate things, if
35
- you haven't setup shared-key authentication, via the '--password [pass]'
36
- switch.
37
-
38
- Assuming you supply nothing else, rorsvnprep will attempt to import your
39
- project to '/<projectname>/trunk' within the supplied svn repository. However,
40
- you can change this behavior by supplying an alternate location via the
41
- '--rpath [path]' switch. When finished importing and setting up your project
42
- rorsvnprep will leave you with a good working copy to begin development with.
24
+ Give the command the name of your project and the full URI to your repository.
43
25
 
44
26
  -------------------
45
27
  Command-Line Syntax
46
28
  -------------------
47
29
 
48
- rorsvnprep projectname [--svn svn://example.org/path/to/repos]
49
- [--password pass]
50
- [--rpath /custom/trunk]
30
+ rorsvnprep projectname [--svn=svn://example.org/path/to/repos]
data/bin/rorsvnprep CHANGED
@@ -22,9 +22,13 @@
22
22
  # the project and updates various svn:ignore properties before recommitting the
23
23
  # project and exiting.
24
24
  #
25
- # The script assumes you want your project stored in <em>projectname</em>/trunk
26
- # within the repository you provide, eventually this will become adjustable via
27
- # the command-line.
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.
28
32
  #
29
33
  # == Effects
30
34
  #
@@ -50,8 +54,6 @@
50
54
  #
51
55
  # * Rewrite to work with Ruby's subversion bindings if available
52
56
  # * Make explicitly object oriented
53
- # * Flesh out command-line options a bit and make them smarter
54
- # * Package as a Gem so it can be easily installed
55
57
  # * Add some helpful Subversion rake tasks
56
58
  #
57
59
  # == License
@@ -73,70 +75,119 @@
73
75
  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
74
76
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
75
77
  # SOFTWARE.
78
+ require 'optparse'
79
+ require 'rorsvnprep'
76
80
 
77
- if require('svn/core') && require('svn/client')
78
- svnbind = true
81
+ class RORSVNPREP < Hash
82
+ def initialize
83
+ super()
84
+
85
+ puts ARGV.join(', ')
86
+
87
+ self[:svnuri] = ""
88
+ self[:password] = ""
89
+ self[:verbose] = false
90
+
91
+ opts = OptionParser.new do |opts|
92
+ opts.banner = "Usage: rorsvnprep project [options]"
93
+
94
+ opts.separator ""
95
+ opts.separator "Useful Options:"
96
+ opts.separator ""
97
+
98
+ opts.on( '--svn=URI', 'use provided URI for subversion operations' ) do |p|
99
+ self[:svnuri] = p
100
+ end
101
+
102
+ opts.on( '--password=PASSWORD', 'use supplied password for subversion operations' ) do |p|
103
+ self[:password] = p
104
+ end
105
+
106
+ opts.on( '--verbose', 'provide extra output while running') do
107
+ self[:verbose] = true
108
+ end
109
+
110
+ opts.separator ""
111
+ opts.separator "General Options:"
112
+ opts.separator ""
113
+
114
+ opts.on( '-h', '--help', 'display this information' ) do
115
+ puts opts
116
+ exit
117
+ end
118
+
119
+ opts.on( '-v', '--version', 'display version information' ) do
120
+ puts "Ruby on Rails SVN Prep Tool: rorsvnprep v#{RailsSVNPrep::version.join('.')}"
121
+ exit
122
+ end
123
+ end
124
+
125
+ opts.parse!
126
+ end
79
127
  end
80
128
 
81
- # Initialize our parameters from the command line and raise errors when needed
82
- print "Initializing..."
83
- ARGV[0] ? appname = ARGV[0] : raise
84
- ARGV[1] ? svnrepo = ARGV[1] : raise
85
- print "Done.\n"
129
+ arguments = RORSVNPREP.new
86
130
 
87
- print "\n"
131
+ puts ARGV.join(', ')
88
132
 
89
- # Start by creating our actual project directory and then change into the new
90
- # directory
91
- print "Creating project..."
92
- system "rails #{appname} > /dev/null"
93
- Dir::chdir appname
94
- print "Done.\n"
133
+ # For each project name supplied roll through the preparation cycle
134
+ project = ARGV.first
95
135
 
96
- # Trim out all the stuff we don't want in the initial subversion import and
97
- # move some other stuff around.
98
- print "Triming initial project..."
99
- File::rename "config/database.yml", "config/database.yml.sample"
100
- File::delete "doc/README_FOR_APP"
101
- File::delete "README"
102
- system "rm -rf log/* > /dev/null"
103
- system "rm -rf tmp/* > /dev/null"
104
- print "Done.\n"
136
+ svnuri = arguments[:svnuri]
137
+ password = arguments[:password]
105
138
 
106
- # Perform our initial subversion import
107
- print "Importing project to subvserion..."
108
- system "svn import #{svnrepo}/#{appname}/trunk -m \"Initial import\" > /dev/null"
109
- Dir::chdir ".."
110
- system "rm -rf #{appname} > /dev/null"
111
- print "Done.\n"
139
+ # TODO: Switch over to following code and remove everything beyond it
140
+ #
141
+ #rsp = RailsSVNPrep.new( $project, $svnuri, $password, $svnpath, $logfile )
142
+ #
143
+ #rsp.execute
112
144
 
113
- # Perform a subversion checkout of our project
114
- print "Checking out project from subversion..."
115
- system "svn co #{svnrepo}/#{appname}/trunk #{appname} > /dev/null"
116
- Dir::chdir appname
117
- print "Done.\n"
145
+ # Create our new project
146
+ puts "Creating Rails project: #{project}" if arguments[:verbose]
118
147
 
119
- # Setup svn:ignore properties
120
- print "Congiguring svn:ignore properties..."
121
- system "svn propset svn:ignore \"*.log\n*.pid\" log/ > /dev/null"
122
- system "svn update log/ > /dev/null"
123
- system "svn propset svn:ignore \"*\" tmp/ > /dev/null"
124
- system "svn update tmp/ > /dev/null"
125
- system "svn propset svn:ignore \"*.db\n*.sqlite\n*.sqlite3\nschema.rb\nschema.sql\" db/ > /dev/null"
126
- system "svn update db/ > /dev/null"
127
- system "svn propset svn:ignore \"database.yml\" config/ > /dev/null"
128
- system "svn update config/ > /dev/null"
129
- print "Done.\n"
148
+ if arguments[:verbose]
149
+ system "rails #{project}"
150
+ else
151
+ system "rails #{project} >> /dev/null"
152
+ end
130
153
 
131
- # Creating a svn_add_new rake task
132
- #print "Create a svn_add_new rake task..."
133
- #
134
- #print "Done.\n"
154
+ Dir::chdir project
155
+
156
+ # Trim out all the stuff we don't want in the initial subversion import and
157
+ # move some other stuff around.
158
+ puts "Triming initial project..." if arguments[:verbose]
159
+ File::rename "config/database.yml", "config/database.yml.sample"
160
+ File::delete "doc/README_FOR_APP"
161
+ File::delete "README"
162
+ system "rm -rf log/* > /dev/null"
163
+ system "rm -rf tmp/* > /dev/null"
164
+
165
+ # Perform our initial subversion import
166
+ puts "Importing project to subvserion..." if arguments[:verbose]
167
+ system "svn import #{svnuri} -m \"Initial import\" > /dev/null"
168
+ Dir::chdir ".."
169
+ system "rm -rf #{project} > /dev/null"
170
+
171
+ # Perform a subversion checkout of our project
172
+ puts "Checking out project from subversion..." if arguments[:verbose]
173
+ system "svn co #{svnuri} #{project} > /dev/null"
174
+ Dir::chdir project
175
+
176
+ # Setup svn:ignore properties
177
+ puts "Configuring svn:ignore properties..." if arguments[:verbose]
178
+ system "svn propset svn:ignore \"*.log\n*.pid\" log/ > /dev/null"
179
+ system "svn update log/ > /dev/null"
180
+ system "svn propset svn:ignore \"*\" tmp/ > /dev/null"
181
+ system "svn update tmp/ > /dev/null"
182
+ system "svn propset svn:ignore \"*.db\n*.sqlite\n*.sqlite3\nschema.rb\nschema.sql\" db/ > /dev/null"
183
+ system "svn update db/ > /dev/null"
184
+ system "svn propset svn:ignore \"database.yml\" config/ > /dev/null"
185
+ system "svn update config/ > /dev/null"
135
186
 
136
- # Committing updates
137
- print "Committing updates..."
138
- system "svn commit -m \"Updated svn:ignore properties\" > /dev/null"
139
- print "Done.\n"
187
+ # Committing updates
188
+ puts "Committing updates..." if arguments[:verbose]
189
+ system "svn commit -m \"Updated svn:ignore properties\" > /dev/null"
140
190
 
141
- # Return to where we started
142
- Dir::chdir ".."
191
+ # Return to where we started
192
+ Dir::chdir ".."
193
+ puts "Done with project: #{project}"
data/lib/rorsvnprep.rb CHANGED
@@ -8,15 +8,17 @@
8
8
  # utility. This class could also be implemented as part of another package to
9
9
  # provide further automated utilities.
10
10
  class RailsSVNPrep
11
+ @@version = [ 0, 1, 0 ]
12
+
11
13
  @project = nil
12
14
  @svn = nil
13
15
  @password = nil
14
- @log = false
16
+ @log = nil
15
17
 
16
18
  # The new method expects up to four arguments. Only if the projname argument
17
19
  # is missing will the method raise an error for anything other than failed
18
20
  # validation.
19
- def initialize(projname = nil, svnuri = nil, svnpass = nil, svnpath = nil, log = false)
21
+ def initialize(projname = nil, svnuri = nil, svnpass = nil, svnpath = nil, logfile = nil)
20
22
  if projname
21
23
  if RailsSVNPrep::validate_name(projname)
22
24
  @project = proj_name
@@ -73,6 +75,11 @@ class RailsSVNPrep
73
75
  end
74
76
  end
75
77
 
78
+ # A convenience method to return our version number
79
+ def RailsSVNPrep.version
80
+ @@version
81
+ end
82
+
76
83
  #
77
84
  # Below are a series of utility methods for validation and other internal
78
85
  # processing requirements.
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
2
+ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: rorsvnprep
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.1
7
- date: 2007-02-15 00:00:00 -05:00
6
+ version: 0.1.0
7
+ date: 2007-02-19 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