right_scraper 3.2.6 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/right_scraper.rb +16 -34
- data/lib/right_scraper/builders.rb +32 -0
- data/lib/right_scraper/builders/base.rb +19 -20
- data/lib/right_scraper/builders/filesystem.rb +8 -6
- data/lib/right_scraper/builders/union.rb +4 -1
- data/lib/right_scraper/loggers.rb +31 -0
- data/lib/right_scraper/loggers/base.rb +113 -0
- data/lib/right_scraper/loggers/default.rb +98 -0
- data/lib/right_scraper/{scraper.rb → main.rb} +53 -9
- data/lib/right_scraper/processes.rb +33 -0
- data/lib/right_scraper/processes/shell.rb +227 -0
- data/lib/right_scraper/processes/{ssh.rb → ssh_agent.rb} +4 -0
- data/lib/right_scraper/processes/svn_client.rb +117 -0
- data/lib/right_scraper/processes/warden.rb +358 -0
- data/lib/right_scraper/registered_base.rb +154 -0
- data/lib/right_scraper/repositories.rb +33 -0
- data/lib/right_scraper/repositories/base.rb +271 -232
- data/lib/right_scraper/repositories/download.rb +8 -6
- data/lib/right_scraper/repositories/git.rb +8 -9
- data/lib/right_scraper/repositories/svn.rb +8 -8
- data/lib/right_scraper/resources.rb +32 -0
- data/lib/right_scraper/resources/base.rb +5 -1
- data/lib/right_scraper/resources/cookbook.rb +34 -27
- data/lib/right_scraper/resources/workflow.rb +27 -28
- data/lib/right_scraper/retrievers.rb +34 -0
- data/lib/right_scraper/retrievers/base.rb +80 -84
- data/lib/right_scraper/retrievers/checkout_base.rb +178 -0
- data/lib/right_scraper/retrievers/download.rb +125 -117
- data/lib/right_scraper/retrievers/git.rb +377 -223
- data/lib/right_scraper/retrievers/svn.rb +102 -62
- data/lib/right_scraper/scanners.rb +37 -0
- data/lib/right_scraper/scanners/base.rb +77 -80
- data/lib/right_scraper/scanners/cookbook_manifest.rb +31 -30
- data/lib/right_scraper/scanners/cookbook_metadata.rb +380 -35
- data/lib/right_scraper/scanners/cookbook_s3_upload.rb +56 -53
- data/lib/right_scraper/scanners/union.rb +61 -58
- data/lib/right_scraper/scanners/workflow_manifest.rb +55 -54
- data/lib/right_scraper/scanners/workflow_metadata.rb +41 -39
- data/lib/right_scraper/scanners/workflow_s3_upload.rb +59 -55
- data/lib/right_scraper/scrapers.rb +32 -0
- data/lib/right_scraper/scrapers/base.rb +217 -205
- data/lib/right_scraper/scrapers/cookbook.rb +42 -40
- data/lib/right_scraper/scrapers/workflow.rb +57 -58
- data/lib/right_scraper/version.rb +3 -0
- data/right_scraper.gemspec +12 -16
- metadata +57 -163
- data/Gemfile +0 -15
- data/Rakefile +0 -89
- data/lib/right_scraper/logger.rb +0 -107
- data/lib/right_scraper/loggers/noisy.rb +0 -85
- data/lib/right_scraper/repositories/mock.rb +0 -70
- data/lib/right_scraper/retrievers/checkout.rb +0 -79
- data/lib/right_scraper/scraper_logger.rb +0 -66
- data/lib/right_scraper/svn_client.rb +0 -164
- data/right_scraper.rconf +0 -13
- data/spec/builder_spec.rb +0 -50
- data/spec/cookbook_helper.rb +0 -73
- data/spec/cookbook_manifest_spec.rb +0 -93
- data/spec/cookbook_s3_upload_spec.rb +0 -159
- data/spec/download/download_retriever_spec.rb +0 -118
- data/spec/download/download_retriever_spec_helper.rb +0 -72
- data/spec/download/download_spec.rb +0 -128
- data/spec/download/multi_dir_spec.rb +0 -106
- data/spec/download/multi_dir_spec_helper.rb +0 -40
- data/spec/git/cookbook_spec.rb +0 -165
- data/spec/git/demokey +0 -27
- data/spec/git/demokey.pub +0 -1
- data/spec/git/password_key +0 -30
- data/spec/git/password_key.pub +0 -1
- data/spec/git/repository_spec.rb +0 -110
- data/spec/git/retriever_spec.rb +0 -553
- data/spec/git/retriever_spec_helper.rb +0 -112
- data/spec/git/scraper_spec.rb +0 -151
- data/spec/git/ssh_spec.rb +0 -174
- data/spec/git/url_spec.rb +0 -103
- data/spec/logger_spec.rb +0 -185
- data/spec/repository_spec.rb +0 -111
- data/spec/retriever_spec_helper.rb +0 -146
- data/spec/scanner_spec.rb +0 -61
- data/spec/scraper_helper.rb +0 -88
- data/spec/scraper_spec.rb +0 -147
- data/spec/spec_helper.rb +0 -185
- data/spec/svn/cookbook_spec.rb +0 -96
- data/spec/svn/multi_svn_spec.rb +0 -64
- data/spec/svn/multi_svn_spec_helper.rb +0 -40
- data/spec/svn/repository_spec.rb +0 -72
- data/spec/svn/retriever_spec.rb +0 -266
- data/spec/svn/scraper_spec.rb +0 -90
- data/spec/svn/svn_retriever_spec_helper.rb +0 -90
- data/spec/svn/url_spec.rb +0 -47
- data/spec/url_spec.rb +0 -164
data/Gemfile
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gemspec
|
4
|
-
|
5
|
-
gem 'right_popen', :git => 'git@github.com:rightscale/right_popen.git',
|
6
|
-
:branch => "master"
|
7
|
-
|
8
|
-
gem 'right_support', '2.7'
|
9
|
-
|
10
|
-
group :development do
|
11
|
-
gem "rake", "0.8.7"
|
12
|
-
gem "ruby-debug", :platform=>"ruby_18"
|
13
|
-
gem "ruby-debug19", :platform=>"ruby_19"
|
14
|
-
gem "rdoc", "~> 2.4"
|
15
|
-
end
|
data/Rakefile
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
#-- -*-ruby-*-
|
2
|
-
# Copyright: Copyright (c) 2010-2011 RightScale, Inc.
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# 'Software'), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be
|
13
|
-
# included in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
18
|
-
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
19
|
-
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
20
|
-
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
21
|
-
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#++
|
23
|
-
|
24
|
-
require 'rubygems'
|
25
|
-
require 'rubygems/package_task'
|
26
|
-
require 'bundler/setup'
|
27
|
-
|
28
|
-
require 'fileutils'
|
29
|
-
require 'rake'
|
30
|
-
require 'rspec/core/rake_task'
|
31
|
-
require 'rdoc/task'
|
32
|
-
require 'rake/clean'
|
33
|
-
|
34
|
-
task :default => 'spec'
|
35
|
-
|
36
|
-
# == Gem packaging == #
|
37
|
-
|
38
|
-
desc "Build right_scraper gem"
|
39
|
-
Gem::PackageTask.new(Gem::Specification.load("right_scraper.gemspec")) do |package|
|
40
|
-
package.need_zip = true
|
41
|
-
package.need_tar = true
|
42
|
-
end
|
43
|
-
|
44
|
-
CLEAN.include('pkg')
|
45
|
-
|
46
|
-
# == Unit Tests == #
|
47
|
-
|
48
|
-
task :specs => :spec
|
49
|
-
|
50
|
-
# == Unit Tests == #
|
51
|
-
|
52
|
-
desc 'Run unit tests'
|
53
|
-
RSpec::Core::RakeTask.new do |t|
|
54
|
-
t.pattern = 'spec/**/*_spec.rb'
|
55
|
-
t.rspec_opts = ["--color", "--format", "nested"]
|
56
|
-
end
|
57
|
-
|
58
|
-
namespace :spec do
|
59
|
-
desc "Run unit tests with RCov"
|
60
|
-
RSpec::Core::RakeTask.new(:rcov) do |t|
|
61
|
-
t.pattern = '*/spec/**/*_spec.rb'
|
62
|
-
t.rcov = true
|
63
|
-
t.rcov_opts = %q[--exclude "spec"]
|
64
|
-
end
|
65
|
-
|
66
|
-
desc "Print Specdoc for unit tests"
|
67
|
-
RSpec::Core::RakeTask.new(:doc) do |t|
|
68
|
-
t.pattern = '*/spec/**/*_spec.rb'
|
69
|
-
t.rspec_opts = ["--format", "documentation"]
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
# == Documentation == #
|
74
|
-
|
75
|
-
desc "Generate API documentation to doc/rdocs/index.html"
|
76
|
-
RDoc::Task.new do |rd|
|
77
|
-
rd.rdoc_dir = 'doc/rdocs'
|
78
|
-
rd.main = 'README.rdoc'
|
79
|
-
rd.rdoc_files.include 'README.rdoc', 'lib/**/*.rb'
|
80
|
-
|
81
|
-
rd.options << '--all'
|
82
|
-
rd.options << '--diagram'
|
83
|
-
end
|
84
|
-
|
85
|
-
# == Emacs integration == #
|
86
|
-
desc "Rebuild TAGS file"
|
87
|
-
task :tags do
|
88
|
-
sh "rtags -R */{lib,spec}"
|
89
|
-
end
|
data/lib/right_scraper/logger.rb
DELETED
@@ -1,107 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright: Copyright (c) 2010-2011 RightScale, Inc.
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# 'Software'), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be
|
13
|
-
# included in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
18
|
-
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
19
|
-
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
20
|
-
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
21
|
-
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#++
|
23
|
-
|
24
|
-
require 'logger'
|
25
|
-
|
26
|
-
module RightScraper
|
27
|
-
# Very simplistic logger for scraper operations.
|
28
|
-
class Logger < ::Logger
|
29
|
-
# If no arguments, create a Logger that logs to nothing.
|
30
|
-
# Otherwise pass the arguments on to ::Logger.
|
31
|
-
def initialize(*args)
|
32
|
-
if args.empty?
|
33
|
-
is_windows = !!(RUBY_PLATFORM =~ /mswin|win32|dos|mingw|cygwin/)
|
34
|
-
super((is_windows ? 'nul' : '/dev/null'))
|
35
|
-
self.level = ::Logger::ERROR
|
36
|
-
else
|
37
|
-
super
|
38
|
-
end
|
39
|
-
@exceptional = false
|
40
|
-
end
|
41
|
-
|
42
|
-
# (RightScraper::Repositories::Base) Repository currently being examined.
|
43
|
-
attr_writer :repository
|
44
|
-
|
45
|
-
# Begin an operation that merits logging. Will call #note_error
|
46
|
-
# if an exception is raised during the operation.
|
47
|
-
#
|
48
|
-
# === Parameters
|
49
|
-
# type(Symbol):: operation type identifier
|
50
|
-
# explanation(String):: optional explanation
|
51
|
-
def operation(type, explanation="")
|
52
|
-
begin
|
53
|
-
note_phase(:begin, type, explanation)
|
54
|
-
result = yield
|
55
|
-
note_phase(:commit, type, explanation)
|
56
|
-
result
|
57
|
-
rescue Exception => e
|
58
|
-
note_phase(:abort, type, explanation, e)
|
59
|
-
raise
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
# Note an event to the log. In this base class this calls
|
64
|
-
# note_error when an error occurs, but subclasses will presumably
|
65
|
-
# want to override it.
|
66
|
-
#
|
67
|
-
# === Parameters
|
68
|
-
# phase(Symbol):: phase of operation; one of :begin, :commit, :abort
|
69
|
-
# type(Symbol):: operation type identifier
|
70
|
-
# explanation(String):: explanation of operation
|
71
|
-
# exception(Exception):: optional exception (only if +phase+ is :abort)
|
72
|
-
def note_phase(phase, type, explanation, exception=nil)
|
73
|
-
case phase
|
74
|
-
when :begin then @exceptional = false
|
75
|
-
when :abort then
|
76
|
-
unless @exceptional
|
77
|
-
note_error(exception, type, explanation)
|
78
|
-
@exceptional = true
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
# Log an error, with the given exception and explanation of what
|
84
|
-
# was going on.
|
85
|
-
#
|
86
|
-
# === Parameters
|
87
|
-
# exception(Exception):: exception raised
|
88
|
-
# type(Symbol):: operation type identifier
|
89
|
-
# explanation(String):: optional explanation
|
90
|
-
def note_error(exception, type, explanation="")
|
91
|
-
error("Saw #{exception} during #{type}#{maybe_explain(explanation)}")
|
92
|
-
end
|
93
|
-
|
94
|
-
def note_warning(message)
|
95
|
-
warn(message)
|
96
|
-
end
|
97
|
-
|
98
|
-
protected
|
99
|
-
def maybe_explain(explanation)
|
100
|
-
if explanation.nil? || explanation.empty?
|
101
|
-
""
|
102
|
-
else
|
103
|
-
": #{explanation}"
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright: Copyright (c) 2010 RightScale, Inc.
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# 'Software'), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be
|
13
|
-
# included in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
18
|
-
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
19
|
-
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
20
|
-
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
21
|
-
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#++
|
23
|
-
|
24
|
-
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'logger'))
|
25
|
-
|
26
|
-
module RightScraper
|
27
|
-
module Loggers
|
28
|
-
# A very noisy logger, useful for debugging.
|
29
|
-
class NoisyLogger < Logger
|
30
|
-
# Initialize the logger, setting the current operation depth to 1.
|
31
|
-
def initialize(*args)
|
32
|
-
super
|
33
|
-
@pending = []
|
34
|
-
end
|
35
|
-
|
36
|
-
# Note an event to the log, including a visual indicator of how
|
37
|
-
# many nested operations are currently pending.
|
38
|
-
#
|
39
|
-
# === Parameters
|
40
|
-
# phase(Symbol):: phase of operation; one of :begin, :commit, :abort
|
41
|
-
# type(Symbol):: operation type identifier
|
42
|
-
# explanation(String):: explanation of operation
|
43
|
-
# exception(Exception):: optional exception (only if +phase+ is :abort)
|
44
|
-
def note_phase(phase, type, explanation, exception=nil)
|
45
|
-
if phase == :begin
|
46
|
-
@pending.push [type, explanation]
|
47
|
-
end
|
48
|
-
super
|
49
|
-
debug("#{depth_str} #{phase} #{immediate_context}")
|
50
|
-
unless phase == :begin
|
51
|
-
@pending.pop
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def note_error(exception, type, explanation="")
|
56
|
-
recordedtype, recordedexplanation = @pending[-1]
|
57
|
-
if recordedtype != type || recordedexplanation != explanation
|
58
|
-
@pending.push [type, explanation]
|
59
|
-
end
|
60
|
-
error("Saw #{exception} during #{context}")
|
61
|
-
if recordedtype != type || recordedexplanation != explanation
|
62
|
-
@pending.pop
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
private
|
67
|
-
def depth_str
|
68
|
-
'>' * @pending.size
|
69
|
-
end
|
70
|
-
|
71
|
-
def context
|
72
|
-
@pending.reverse.map {|pair| contextify(pair)}.join(" in ")
|
73
|
-
end
|
74
|
-
|
75
|
-
def immediate_context
|
76
|
-
contextify(@pending[-1])
|
77
|
-
end
|
78
|
-
|
79
|
-
def contextify(pair)
|
80
|
-
type, explanation = pair
|
81
|
-
"#{type}#{maybe_explain(explanation)}"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright: Copyright (c) 2010-2011 RightScale, Inc.
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# 'Software'), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be
|
13
|
-
# included in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
18
|
-
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
19
|
-
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
20
|
-
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
21
|
-
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#++
|
23
|
-
require File.expand_path(File.join(File.dirname(__FILE__), 'base'))
|
24
|
-
|
25
|
-
module RightScraper
|
26
|
-
module Repositories
|
27
|
-
# A "repository" that is just there for testing. This class is not
|
28
|
-
# loaded by default.
|
29
|
-
class Mock < Base
|
30
|
-
# Create a new mock repository.
|
31
|
-
def initialize
|
32
|
-
@repo_type = :mock
|
33
|
-
end
|
34
|
-
# (String) Type of the repository, here 'download'.
|
35
|
-
attr_accessor :repo_type
|
36
|
-
|
37
|
-
# (String) Optional, tag or branch of repository that should be downloaded
|
38
|
-
attr_accessor :tag
|
39
|
-
|
40
|
-
# (String) Optional, username
|
41
|
-
attr_accessor :first_credential
|
42
|
-
|
43
|
-
# (String) Optional, password
|
44
|
-
attr_accessor :second_credential
|
45
|
-
|
46
|
-
# Unique representation for this repo, should resolve to the same string
|
47
|
-
# for repos that should be cloned in same directory
|
48
|
-
#
|
49
|
-
# === Returns
|
50
|
-
# res(String):: Unique representation for this repo
|
51
|
-
def to_s
|
52
|
-
res = "mock #{url}:#{tag}"
|
53
|
-
end
|
54
|
-
|
55
|
-
# (Base class) Appropriate class for scraping this sort of
|
56
|
-
# repository.
|
57
|
-
def scraper
|
58
|
-
@@scraper || raise("Scraper for mocks isn't defined yet")
|
59
|
-
end
|
60
|
-
|
61
|
-
# Set the correct sort of scraper to use for mock repositories.
|
62
|
-
def self.scraper=(scraper)
|
63
|
-
@@scraper = scraper
|
64
|
-
end
|
65
|
-
|
66
|
-
# Add this repository to the list of available types.
|
67
|
-
@@types[:mock] = RightScraper::Repositories::Mock
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright: Copyright (c) 2010-2011 RightScale, Inc.
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# 'Software'), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be
|
13
|
-
# included in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
18
|
-
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
19
|
-
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
20
|
-
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
21
|
-
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#++
|
23
|
-
|
24
|
-
module RightScraper
|
25
|
-
module Retrievers
|
26
|
-
|
27
|
-
# Base class for retrievers that want to do version control operations
|
28
|
-
# (CVS, SVN, etc.). Subclasses can get away with implementing only
|
29
|
-
# Retrievers::Base#available? and #do_checkout but to support incremental
|
30
|
-
# operation need to implement #exists? and #do_update, in addition to
|
31
|
-
# Retrievers::Base#ignorable_paths.
|
32
|
-
class CheckoutBasedRetriever < Base
|
33
|
-
|
34
|
-
# Check out repository into the directory. Occurs between
|
35
|
-
# variable initialization and beginning scraping.
|
36
|
-
def retrieve
|
37
|
-
raise RetrieverError.new("retriever is unavailable") unless available?
|
38
|
-
if exists?
|
39
|
-
begin
|
40
|
-
@logger.operation(:updating) do
|
41
|
-
do_update
|
42
|
-
end
|
43
|
-
rescue Exception => e
|
44
|
-
FileUtils.remove_entry_secure @basedir
|
45
|
-
@logger.operation(:checkout, "switching to using checkout") do
|
46
|
-
do_checkout
|
47
|
-
end
|
48
|
-
end
|
49
|
-
else
|
50
|
-
@logger.operation(:checkout) do
|
51
|
-
do_checkout
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
# Return true if a checkout exists.
|
57
|
-
#
|
58
|
-
# === Returns
|
59
|
-
# Boolean:: true if the checkout already exists (and thus
|
60
|
-
# incremental updating can occur).
|
61
|
-
def exists?
|
62
|
-
false
|
63
|
-
end
|
64
|
-
|
65
|
-
# Perform an incremental update of the checkout. Subclasses that
|
66
|
-
# want to handle incremental updating need to override this.
|
67
|
-
def do_update
|
68
|
-
do_checkout
|
69
|
-
end
|
70
|
-
|
71
|
-
# Perform a de novo full checkout of the repository. Subclasses
|
72
|
-
# must override this to do anything useful.
|
73
|
-
def do_checkout
|
74
|
-
FileUtils.mkdir_p(@repo_dir)
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|