Class: RightScraper::Retrievers::Svn
- Inherits:
-
CheckoutBase
- Object
- Base
- CheckoutBase
- RightScraper::Retrievers::Svn
- Defined in:
- lib/right_scraper/retrievers/svn.rb
Overview
Retriever for svn repositories
Constant Summary collapse
- SVN_CLIENT =
::RightScraper::Processes::SvnClient
- @@available =
false
Instance Attribute Summary
Attributes inherited from Base
#logger, #max_bytes, #max_seconds, #repo_dir, #repository
Instance Method Summary collapse
-
#available? ⇒ Boolean
Determines if svn is available.
-
#do_checkout ⇒ Object
Implements CheckoutBase#do_checkout.
-
#do_update ⇒ Object
Implements CheckoutBase#do_update.
-
#do_update_tag ⇒ Object
Implements CheckoutBase#do_update_tag.
-
#exists? ⇒ Boolean
Return true if a checkout exists.
-
#ignorable_paths ⇒ Object
Ignore .svn directories.
Methods inherited from CheckoutBase
#remote_differs?, #retrieve, #size_limit_exceeded?
Methods inherited from Base
#initialize, repo_dir, #retrieve
Constructor Details
This class inherits a constructor from RightScraper::Retrievers::Base
Instance Method Details
#available? ⇒ Boolean
Determines if svn is available.
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/right_scraper/retrievers/svn.rb', line 37 def available? unless @@available begin SVN_CLIENT.calculate_version @@available = true rescue SVN_CLIENT::SvnClientError => e @logger.note_error(e, :available, 'svn retriever is unavailable') end end @@available end |
#do_checkout ⇒ Object
Implements CheckoutBase#do_checkout
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/right_scraper/retrievers/svn.rb', line 65 def do_checkout @logger.operation(:checkout_revision) do revision = resolve_revision svn_args = ['checkout', @repository.url, @repo_dir] svn_args += ['--revision', revision] if revision svn_args << '--force' svn_client.execute(svn_args) do_update_tag end end |
#do_update ⇒ Object
Implements CheckoutBase#do_update
77 78 79 80 81 82 83 |
# File 'lib/right_scraper/retrievers/svn.rb', line 77 def do_update @logger.operation(:update) do revision = resolve_revision svn_client.execute('update', '--revision', revision, '--force') do_update_tag end end |
#do_update_tag ⇒ Object
Implements CheckoutBase#do_update_tag
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/right_scraper/retrievers/svn.rb', line 86 def do_update_tag # query latest count=1 log entry for latest revision; don't attempt to # specify revision on the assumption that the requested revision is # already checked out. the --revision argument appears to expect a # revision from-to range or else a start date or date range or else a # specific revision number. it prints nothing when HEAD is specified by # itself. @repository = @repository.clone svn_args = ['log', '--limit', '1'] svn_client.output_for(svn_args).lines.each do |line| if matched = SVN_LOG_REGEX.match(line) @repository.tag = matched[1] break end end end |
#exists? ⇒ Boolean
Return true if a checkout exists. Currently tests for .svn in the checkout.
Returns
- Boolean
-
true if the checkout already exists (and thus incremental updating can occur).
55 56 57 |
# File 'lib/right_scraper/retrievers/svn.rb', line 55 def exists? ::File.exists?(::File.join(@repo_dir, '.svn')) end |
#ignorable_paths ⇒ Object
Ignore .svn directories.
60 61 62 |
# File 'lib/right_scraper/retrievers/svn.rb', line 60 def ignorable_paths ['.svn'] end |