Class: RightScraper::Processes::SvnClient
- Inherits:
-
Object
- Object
- RightScraper::Processes::SvnClient
- Defined in:
- lib/right_scraper/processes/svn_client.rb
Overview
Simplified interface to the process of creating SVN client contexts.
SVN client contexts are needed for almost every nontrivial SVN operation, and the authentication procedure is truly baroque. Thus, when you need a client context, do something like this:
client = SvnClient.new(repository)
client.with_context do |ctx|
...
end
Defined Under Namespace
Classes: SvnClientError
Instance Attribute Summary collapse
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
-
#shell ⇒ Object
readonly
Returns the value of attribute shell.
Class Method Summary collapse
Instance Method Summary collapse
-
#execute(*args) ⇒ TrueClass
Executes svn using the given arguments.
-
#initialize(repository, logger, shell) ⇒ SvnClient
constructor
A new instance of SvnClient.
-
#output_for(*args) ⇒ String
Executes and returns output for svn using the given arguments.
Constructor Details
#initialize(repository, logger, shell) ⇒ SvnClient
Returns a new instance of SvnClient.
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/right_scraper/processes/svn_client.rb', line 47 def initialize(repository, logger, shell) unless @repository = repository raise ::ArgumentError, 'repository is required' end unless @logger = logger raise ::ArgumentError, 'logger is required' end unless @shell = shell raise ::ArgumentError, 'shell is required' end end |
Instance Attribute Details
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
43 44 45 |
# File 'lib/right_scraper/processes/svn_client.rb', line 43 def repository @repository end |
#shell ⇒ Object (readonly)
Returns the value of attribute shell.
43 44 45 |
# File 'lib/right_scraper/processes/svn_client.rb', line 43 def shell @shell end |
Class Method Details
.calculate_version ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/right_scraper/processes/svn_client.rb', line 59 def self.calculate_version unless @svn_version begin cmd = 'svn --version --quiet' out = `#{cmd}` if $?.success? @svn_version = out.chomp.split('.').map {|e| e.to_i} else raise SvnClientError, "Unable to determine svn version: #{cmd.inspect} exited with #{$?.exitstatus}" end rescue Errno::ENOENT => e raise SvnClientError, "Unable to determine svn version: #{e.}" end end @svn_version end |
Instance Method Details
#execute(*args) ⇒ TrueClass
Executes svn using the given arguments.
81 82 83 84 |
# File 'lib/right_scraper/processes/svn_client.rb', line 81 def execute(*args) shell.execute(svn_command_for(args), :logger => @logger) true end |
#output_for(*args) ⇒ String
Executes and returns output for svn using the given arguments.
91 92 93 |
# File 'lib/right_scraper/processes/svn_client.rb', line 91 def output_for(*args) shell.output_for(svn_command_for(args), :logger => @logger) end |