rorsvnprep 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README ADDED
@@ -0,0 +1,50 @@
1
+ Ruby on Rails Subversion Prep Tool
2
+ ===============================================================================
3
+ README rorsvnprep
4
+
5
+ This gem provides some aids for starting new Rails projects that will be
6
+ managed with the subversion SCM system. The command line utility provides will
7
+ create a new project, perform initial modifications and even the initial
8
+ subversion specific actions to get your project under subversion management
9
+ quickly and with a minimum of fuss.
10
+
11
+ This gem provides a simple command-line tool that handles everything:
12
+
13
+ rorsvnprep
14
+
15
+ It is recommended that you create an alias for this command to save you on
16
+ typing. On most systems you can alias rorsvnprep to rsp without interfering
17
+ with anything else, but double-check on your own system before deciding on an
18
+ alias.
19
+
20
+ ================
21
+ Using rorsvnprep
22
+ ================
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.
43
+
44
+ -------------------
45
+ Command-Line Syntax
46
+ -------------------
47
+
48
+ rorsvnprep projectname [--svn svn://example.org/path/to/repos]
49
+ [--password pass]
50
+ [--rpath /custom/trunk]
data/bin/rorsvnprep ADDED
@@ -0,0 +1,142 @@
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 your project stored in <em>projectname</em>/trunk
26
+ # within the repository you provide, eventually this will become adjustable via
27
+ # the command-line.
28
+ #
29
+ # == Effects
30
+ #
31
+ # * Renames <em>config/database.yml</em> to <em>config/database.yml.sample</em>
32
+ # * Deletes extraneous files and directories
33
+ # * <tt><em>doc/README_FOR_APP</em></tt>
34
+ # * <tt><em>README</em></tt>
35
+ # * <tt><em>log/*</em></tt>
36
+ # * <tt><em>tmp/*</em></tt>
37
+ # * Performs an initial import
38
+ # * Performs an initial checkout
39
+ # * Updates svn:ignore properties for project and recommits project
40
+ # * <tt><em>log/*.log</em></tt>
41
+ # * <tt><em>log/*.pid</em></tt>
42
+ # * <tt><em>tmp/*</em></tt>
43
+ # * <tt><em>db/*.db</em></tt>
44
+ # * <tt><em>db/*.sqlite</em></tt>
45
+ # * <tt><em>db/*.sqlite3</em></tt>
46
+ # * <tt><em>db/schema.rb</em></tt>
47
+ # * <tt><em>db/schema.sql</em></tt>
48
+ #
49
+ # == TODO
50
+ #
51
+ # * Rewrite to work with Ruby's subversion bindings if available
52
+ # * 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
+ # * Add some helpful Subversion rake tasks
56
+ #
57
+ # == License
58
+ #
59
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
60
+ # of this software and associated documentation files (the "Software"), to deal
61
+ # in the Software without restriction, including without limitation the rights
62
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
63
+ # copies of the Software, and to permit persons to whom the Software is
64
+ # furnished to do so, subject to the following conditions:
65
+ #
66
+ # The above copyright notice and this permission notice shall be included in
67
+ # all copies or substantial portions of the Software.
68
+ #
69
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
70
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
71
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
72
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
73
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
74
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
75
+ # SOFTWARE.
76
+
77
+ if require('svn/core') && require('svn/client')
78
+ svnbind = true
79
+ end
80
+
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"
86
+
87
+ print "\n"
88
+
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"
95
+
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"
105
+
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"
112
+
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"
118
+
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"
130
+
131
+ # Creating a svn_add_new rake task
132
+ #print "Create a svn_add_new rake task..."
133
+ #
134
+ #print "Done.\n"
135
+
136
+ # Committing updates
137
+ print "Committing updates..."
138
+ system "svn commit -m \"Updated svn:ignore properties\" > /dev/null"
139
+ print "Done.\n"
140
+
141
+ # Return to where we started
142
+ Dir::chdir ".."
data/lib/rorsvnprep.rb ADDED
@@ -0,0 +1,101 @@
1
+ # This file contains the main class definition for the Ruby on Rails Subversion
2
+ # Prep Tool.
3
+ #
4
+ # Author:: James W. Thompson, II
5
+ # Copyright:: Copyright (c) 2007, James W. Thompson, II
6
+
7
+ # This class provides all the heavy lifting methods used by the command-line
8
+ # utility. This class could also be implemented as part of another package to
9
+ # provide further automated utilities.
10
+ class RailsSVNPrep
11
+ @project = nil
12
+ @svn = nil
13
+ @password = nil
14
+ @log = false
15
+
16
+ # The new method expects up to four arguments. Only if the projname argument
17
+ # is missing will the method raise an error for anything other than failed
18
+ # validation.
19
+ def initialize(projname = nil, svnuri = nil, svnpass = nil, svnpath = nil, log = false)
20
+ if projname
21
+ if RailsSVNPrep::validate_name(projname)
22
+ @project = proj_name
23
+ else
24
+ raise ArgumentError, "Invalid Project Name Supplied", caller
25
+ end
26
+ else
27
+ raise ArgumentError, "No Project Name Supplied", caller
28
+ end
29
+
30
+ if svnuri
31
+ if RailsSVNPrep::validate_uri(svnuri)
32
+ @svn = svnuri
33
+ else
34
+ raise ArgumentError, "Invalid Subversion URI Supplied", caller
35
+ end
36
+ end
37
+
38
+ if svnpath
39
+ if RailsSVNPrep::validate_path(svnpath)
40
+ @svn += svnpath
41
+ else
42
+ raise ArgumentError, "Invalid Subversion Path Supplied", caller
43
+ end
44
+ elsif @svn
45
+ @svn += "/#{@project}/trunk"
46
+ end
47
+
48
+ if svnpass
49
+ if RailsSVNPrep::validate_password(svnpass)
50
+ @password = svnpass
51
+ else
52
+ raise ArgumentError, "Invalid Password Supplied", caller
53
+ end
54
+ end
55
+
56
+ @log = log
57
+
58
+ @svn = RailsSVNPrep::normalize_svn(@svn)
59
+ end
60
+
61
+ # This method creates a new project and moves us into the new directory. The
62
+ # method makes direct call to the rails command and dumps the output to
63
+ # /dev/null.
64
+ def create_project
65
+ if Dir::glob(@project)
66
+ raise StandardError, "Directory #{@project} already exists", caller
67
+ end
68
+
69
+ if system "rails #{@project} > /dev/null"
70
+ Dir::chdir @project
71
+ else
72
+ raise StandardError, "Unable to successfully run Rails", caller
73
+ end
74
+ end
75
+
76
+ #
77
+ # Below are a series of utility methods for validation and other internal
78
+ # processing requirements.
79
+ #
80
+ protected
81
+
82
+ # A method to validate project names
83
+ def self.validate_name(projname)
84
+
85
+ end
86
+
87
+ # A method to validate subversion URIs
88
+ def self.validate_uri(svnuri)
89
+
90
+ end
91
+
92
+ # A method to validate a subversion repository path
93
+ def self.validate_path(svnpath)
94
+
95
+ end
96
+
97
+ # A method to normalize the combined subversion URI and repository path
98
+ def self.normalize_svn(svn)
99
+
100
+ end
101
+ end
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class RorsvnprepTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ end
7
+
8
+ def test_truth
9
+ assert true
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.0
3
+ specification_version: 1
4
+ name: rorsvnprep
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.0.1
7
+ date: 2007-02-15 00:00:00 -05:00
8
+ summary: Provides additional automation to make managing Rails project with subversion easier.
9
+ require_paths:
10
+ - lib
11
+ email: jwthompson2@gmail.com
12
+ homepage: http://rorsvnprep.rubyforge.org/
13
+ rubyforge_project: rorsvnprep
14
+ description:
15
+ autorequire: rorsvnprep
16
+ default_executable: rorsvnprep
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
+ - James W. Thompson, II
31
+ files:
32
+ - lib/rorsvnprep.rb
33
+ - README
34
+ test_files:
35
+ - test/rorsvnprep_test.rb
36
+ rdoc_options: []
37
+
38
+ extra_rdoc_files:
39
+ - README
40
+ executables:
41
+ - rorsvnprep
42
+ extensions: []
43
+
44
+ requirements: []
45
+
46
+ dependencies:
47
+ - !ruby/object:Gem::Dependency
48
+ name: cmdparse
49
+ version_requirement:
50
+ version_requirements: !ruby/object:Gem::Version::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 2.0.0
55
+ version:
56
+ - !ruby/object:Gem::Dependency
57
+ name: rails
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Version::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 1.0.0
64
+ version: