Class: RailsSVNPrep

Inherits:
Object
  • Object
show all
Defined in:
lib/rorsvnprep.rb

Overview

This class provides all the heavy lifting methods used by the command-line utility. This class could also be implemented as part of another package to provide further automated utilities.

Instance Method Summary collapse

Constructor Details

#initialize(projname = nil, svnuri = nil, svnpass = nil, svnpath = nil, log = false) ⇒ RailsSVNPrep

The new method expects up to four arguments. Only if the projname argument is missing will the method raise an error for anything other than failed validation.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/rorsvnprep.rb', line 19

def initialize(projname = nil, svnuri = nil, svnpass = nil, svnpath = nil, log = false)
  if projname
    if RailsSVNPrep::validate_name(projname)
      @project = proj_name
    else
      raise ArgumentError,  "Invalid Project Name Supplied", caller
    end
  else
    raise ArgumentError, "No Project Name Supplied", caller
  end
  
  if svnuri
    if RailsSVNPrep::validate_uri(svnuri)
      @svn = svnuri
    else
      raise ArgumentError, "Invalid Subversion URI Supplied", caller
    end
  end
  
  if svnpath
    if RailsSVNPrep::validate_path(svnpath)
      @svn += svnpath
    else  
      raise ArgumentError, "Invalid Subversion Path Supplied", caller
    end
  elsif @svn
    @svn += "/#{@project}/trunk"
  end
  
  if svnpass
    if RailsSVNPrep::validate_password(svnpass)
      @password = svnpass
    else
      raise ArgumentError, "Invalid Password Supplied", caller
    end
  end
  
  @log = log
  
  @svn = RailsSVNPrep::normalize_svn(@svn)
end

Instance Method Details

#create_projectObject

This method creates a new project and moves us into the new directory. The method makes direct call to the rails command and dumps the output to /dev/null.



64
65
66
67
68
69
70
71
72
73
74
# File 'lib/rorsvnprep.rb', line 64

def create_project
  if Dir::glob(@project)
    raise StandardError, "Directory #{@project} already exists", caller
  end
  
  if system "rails #{@project} > /dev/null"
    Dir::chdir @project
  else
    raise StandardError, "Unable to successfully run Rails", caller
  end
end