Class: SC::Repository
- Inherits:
-
Object
- Object
- SC::Repository
- Defined in:
- lib/sc/repository.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
The name the user gave for this repository.
-
#options ⇒ Object
Additional options to send to svn.
-
#url ⇒ Object
The URL to the repository.
-
#workspace ⇒ Object
get the full path for the workspace.
Class Method Summary collapse
-
.ask ⇒ Object
Prompt the user to enter the necessary attributes for a repository.
- .create_local(path) ⇒ Object
- .default_workspace(name) ⇒ Object
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Repository
constructor
setup the details for a repository object.
-
#to_s ⇒ Object
convert the repository to a string.
Constructor Details
#initialize(options = {}) ⇒ Repository
setup the details for a repository object
87 88 89 90 91 92 |
# File 'lib/sc/repository.rb', line 87 def initialize (={}) @url = [:url] @name = [:name] @workspace = [:workspace] @options = [:options] end |
Instance Attribute Details
#name ⇒ Object
The name the user gave for this repository
34 35 36 |
# File 'lib/sc/repository.rb', line 34 def name @name end |
#options ⇒ Object
Additional options to send to svn
42 43 44 |
# File 'lib/sc/repository.rb', line 42 def @options end |
#url ⇒ Object
The URL to the repository
30 31 32 |
# File 'lib/sc/repository.rb', line 30 def url @url end |
#workspace ⇒ Object
get the full path for the workspace
38 39 40 |
# File 'lib/sc/repository.rb', line 38 def workspace @workspace end |
Class Method Details
.ask ⇒ Object
Prompt the user to enter the necessary attributes for a repository
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/sc/repository.rb', line 46 def self.ask = {} [:name] = Constants::TERMINAL.ask("Repository Name (used with sc -r): ") [:url] = Constants::TERMINAL.ask("Repository URL: ") url = URI.parse([:url]) if url.scheme.nil? and Constants::TERMINAL.agree("Repository URL is missing protocol, assume it's local? ") url.scheme = 'file' end if url.scheme.downcase == 'file' url.path = File.(url.path) if !File.exist?(url.path) and Constants::TERMINAL.agree("Local repository does not exist, should I create it? ") create_local(url.path) end [:url] = "file://#{url.path}" end [:workspace] = Constants::TERMINAL.ask("Directory where checkouts go (can be relative to ~/): ") do |q| q.default = default_workspace([:name]) end self.new() end |
.create_local(path) ⇒ Object
75 76 77 78 |
# File 'lib/sc/repository.rb', line 75 def self.create_local (path) Dir.mkdir(path) unless File.exist?(path) system('svnadmin', 'create', path, '--fs-type', 'fsfs') or exit 1 end |
.default_workspace(name) ⇒ Object
81 82 83 |
# File 'lib/sc/repository.rb', line 81 def self.default_workspace (name) "develop/#{name.gsub(/[^\w_-]+/, '_').downcase}" end |
Instance Method Details
#to_s ⇒ Object
convert the repository to a string
102 103 104 |
# File 'lib/sc/repository.rb', line 102 def to_s "#{@name} (#{@url})" end |