rorsvnprep 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/rorsvnprep +28 -20
  2. data/lib/rorsvnprep.rb +55 -42
  3. metadata +2 -2
data/bin/rorsvnprep CHANGED
@@ -82,11 +82,10 @@ class RORSVNPREP < Hash
82
82
  def initialize
83
83
  super()
84
84
 
85
- puts ARGV.join(', ')
86
-
87
85
  self[:svnuri] = ""
88
86
  self[:password] = ""
89
87
  self[:verbose] = false
88
+ self[:log] = false
90
89
 
91
90
  opts = OptionParser.new do |opts|
92
91
  opts.banner = "Usage: rorsvnprep project [options]"
@@ -107,6 +106,10 @@ class RORSVNPREP < Hash
107
106
  self[:verbose] = true
108
107
  end
109
108
 
109
+ opts.on( '--log', 'create a log of command activity' ) do
110
+ self[:log] = true
111
+ end
112
+
110
113
  opts.separator ""
111
114
  opts.separator "General Options:"
112
115
  opts.separator ""
@@ -128,30 +131,35 @@ end
128
131
 
129
132
  arguments = RORSVNPREP.new
130
133
 
131
- puts ARGV.join(', ')
132
-
133
- # For each project name supplied roll through the preparation cycle
134
+ # Grab the project name to use
134
135
  project = ARGV.first
135
136
 
136
- svnuri = arguments[:svnuri]
137
- password = arguments[:password]
137
+ # Create some useful variables to pass around
138
+ svnuri = arguments[:svnuri]
139
+ password = arguments[:password]
140
+ verbose = arguments[:verbose]
141
+ logfile = File::new( "rorsvnprep.log", "a" ) if arguments[:log]
138
142
 
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
143
+ # Create an instance of our prep class with all our options
144
+ rsp = RailsSVNPrep.new( project, svnuri, password, logfile, verbose )
144
145
 
145
- # Create our new project
146
- puts "Creating Rails project: #{project}" if arguments[:verbose]
146
+ # TODO: Switch over to following code and remove everything beyond it
147
+ #
148
+ #rsp.run
147
149
 
148
- if arguments[:verbose]
149
- system "rails #{project}"
150
- else
151
- system "rails #{project} >> /dev/null"
152
- end
150
+ # Create a project
151
+ rsp.create_project
153
152
 
154
- Dir::chdir project
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
155
163
 
156
164
  # Trim out all the stuff we don't want in the initial subversion import and
157
165
  # move some other stuff around.
data/lib/rorsvnprep.rb CHANGED
@@ -8,73 +8,86 @@
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 ]
11
+ @@version = [ 0, 1, 1 ]
12
12
 
13
13
  @project = nil
14
14
  @svn = nil
15
15
  @password = nil
16
- @log = nil
16
+ @logfile = nil
17
+ @verbose = false
17
18
 
18
19
  # The new method expects up to four arguments. Only if the projname argument
19
20
  # is missing will the method raise an error for anything other than failed
20
21
  # validation.
21
- def initialize(projname = nil, svnuri = nil, svnpass = nil, svnpath = nil, logfile = nil)
22
- if projname
23
- if RailsSVNPrep::validate_name(projname)
24
- @project = proj_name
25
- else
26
- raise ArgumentError, "Invalid Project Name Supplied", caller
27
- end
28
- else
29
- raise ArgumentError, "No Project Name Supplied", caller
30
- end
22
+ def initialize(projname = nil, svnuri = nil, svnpass = nil, logfile = nil, verbose = false)
23
+ @project = projname
24
+ @svn = svnuri
25
+ @password = svnpass
26
+ @log = logfile
27
+ @verbose = verbose
28
+ end
29
+
30
+ def run
31
+ puts "Rails SVN Prep: Starting." if @verbose
32
+ @logfile.puts "Rails SVN Prep: Starting." if @logfile
31
33
 
32
- if svnuri
33
- if RailsSVNPrep::validate_uri(svnuri)
34
- @svn = svnuri
35
- else
36
- raise ArgumentError, "Invalid Subversion URI Supplied", caller
37
- end
38
- end
34
+ create_project
39
35
 
40
- if svnpath
41
- if RailsSVNPrep::validate_path(svnpath)
42
- @svn += svnpath
43
- else
44
- raise ArgumentError, "Invalid Subversion Path Supplied", caller
45
- end
46
- elsif @svn
47
- @svn += "/#{@project}/trunk"
48
- end
36
+ trim_project
49
37
 
50
- if svnpass
51
- if RailsSVNPrep::validate_password(svnpass)
52
- @password = svnpass
53
- else
54
- raise ArgumentError, "Invalid Password Supplied", caller
55
- end
56
- end
38
+ generate_cvsignore unless @svn
39
+
40
+ subversion_import if @svn
41
+
42
+ subversion_checkout if @svn
43
+
44
+ subversion_propset if @svn
57
45
 
58
- @log = log
46
+ finalize
59
47
 
60
- @svn = RailsSVNPrep::normalize_svn(@svn)
48
+ puts "Rails SVN Prep: Complete." if @verbose
49
+ @logfile.puts "Rails SVN Prep: Complete." if @logfile
61
50
  end
62
51
 
63
52
  # This method creates a new project and moves us into the new directory. The
64
53
  # method makes direct call to the rails command and dumps the output to
65
54
  # /dev/null.
66
55
  def create_project
67
- if Dir::glob(@project)
68
- raise StandardError, "Directory #{@project} already exists", caller
69
- end
56
+ #if Dir::glob(@project)
57
+ # puts "A folder named #{@project} already exists: exiting." if @verbose
58
+ # @logfile.puts "A folder named #{@project} already exists: exiting." if @logfile
59
+ # raise StandardError
60
+ #end
70
61
 
71
- if system "rails #{@project} > /dev/null"
62
+ if system "rails #{@project} >> /dev/null"
63
+ puts "Rails Project Folder Successfully Created." if @verbose
64
+ @logfile.puts "Rails Project Folder Successfully Created." if @logfile
72
65
  Dir::chdir @project
73
66
  else
74
- raise StandardError, "Unable to successfully run Rails", caller
67
+ puts "Error creating the Rails project folder: exiting." if @verbose
68
+ @logfile.puts "Error creating the Rails project folder: exiting." if @logfile
69
+ raise StandardError
75
70
  end
76
71
  end
77
72
 
73
+ def trim_project
74
+ end
75
+
76
+ def generate_cvsignore
77
+ end
78
+
79
+ def subversion_import
80
+ end
81
+
82
+ def subversion_checkout
83
+ end
84
+
85
+ def subversion_propset
86
+ end
87
+
88
+ def finalize
89
+ end
90
+
78
91
  # A convenience method to return our version number
79
92
  def RailsSVNPrep.version
80
93
  @@version
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.0
7
- date: 2007-02-19 00:00:00 -05:00
6
+ version: 0.1.1
7
+ date: 2007-02-20 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