right_scraper 3.2.6 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,66 +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
|
-
|
26
|
-
class ScraperLogger < Logger
|
27
|
-
attr_accessor :callback, :errors, :warnings
|
28
|
-
|
29
|
-
def add(severity, message=nil, progname=nil)
|
30
|
-
if severity >= (self.level || Logger::WARN)
|
31
|
-
if message.nil?
|
32
|
-
if block_given?
|
33
|
-
message = yield
|
34
|
-
else
|
35
|
-
message = progname
|
36
|
-
progname = self.progname
|
37
|
-
end
|
38
|
-
end
|
39
|
-
@errors << [nil, :log,
|
40
|
-
{:severity => severity,
|
41
|
-
:message => message,
|
42
|
-
:progname => progname}]
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def initialize
|
47
|
-
@errors = []
|
48
|
-
@warnings = []
|
49
|
-
end
|
50
|
-
|
51
|
-
def note_phase(phase, type, explanation, exception=nil)
|
52
|
-
@callback.call(phase, type, explanation, exception) unless @callback.nil?
|
53
|
-
super
|
54
|
-
end
|
55
|
-
|
56
|
-
def note_error(exception, type, explanation="")
|
57
|
-
@errors << [exception, type, explanation]
|
58
|
-
end
|
59
|
-
|
60
|
-
def note_warning(message)
|
61
|
-
@warnings << message
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
@@ -1,164 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright: Copyright (c) 2010-2013 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 'right_popen'
|
25
|
-
require 'right_popen/safe_output_buffer'
|
26
|
-
|
27
|
-
module RightScraper
|
28
|
-
# Simplified interface to the process of creating SVN client
|
29
|
-
# contexts.
|
30
|
-
#
|
31
|
-
# SVN client contexts are needed for almost every nontrivial SVN
|
32
|
-
# operation, and the authentication procedure is truly baroque.
|
33
|
-
# Thus, when you need a client context, do something like this:
|
34
|
-
# client = SvnClient.new(repository)
|
35
|
-
# client.with_context do |ctx|
|
36
|
-
# ...
|
37
|
-
# end
|
38
|
-
module SvnClient
|
39
|
-
|
40
|
-
class SvnClientError < Exception; end
|
41
|
-
|
42
|
-
def calculate_version
|
43
|
-
unless @svn_version
|
44
|
-
begin
|
45
|
-
cmd = 'svn --version --quiet'
|
46
|
-
out = `#{cmd}`
|
47
|
-
if $?.success?
|
48
|
-
@svn_version = out.chomp.split('.').map {|e| e.to_i}
|
49
|
-
else
|
50
|
-
raise SvnClientError, "Unable to determine svn version: #{cmd.inspect} exited with #{$?.exitstatus}"
|
51
|
-
end
|
52
|
-
rescue Errno::ENOENT => e
|
53
|
-
raise SvnClientError, "Unable to determine svn version: #{e.message}"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
@svn_version
|
57
|
-
end
|
58
|
-
|
59
|
-
def svn_arguments
|
60
|
-
version = calculate_version
|
61
|
-
case
|
62
|
-
when version[0] != 1
|
63
|
-
raise "SVN major revision is not 1, cannot be sure it will run properly."
|
64
|
-
when version[1] < 4
|
65
|
-
raise "SVN minor revision < 4; cannot be sure it will run properly."
|
66
|
-
when version[1] < 6
|
67
|
-
# --trust-server-cert is a 1.6ism
|
68
|
-
args = ["--no-auth-cache", "--non-interactive"]
|
69
|
-
else
|
70
|
-
args = ["--no-auth-cache", "--non-interactive", "--trust-server-cert"]
|
71
|
-
end
|
72
|
-
if repository.first_credential && repository.second_credential
|
73
|
-
args << "--username"
|
74
|
-
args << repository.first_credential
|
75
|
-
args << "--password"
|
76
|
-
args << repository.second_credential
|
77
|
-
end
|
78
|
-
args
|
79
|
-
end
|
80
|
-
|
81
|
-
def get_tag_argument
|
82
|
-
if repository.tag
|
83
|
-
tag_cmd = ["-r", get_tag.to_s]
|
84
|
-
else
|
85
|
-
tag_cmd = ["-r", "HEAD"]
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def run_svn_no_chdir(*args)
|
90
|
-
run_svn_with(nil, :safe_output_svn_client, *args)
|
91
|
-
end
|
92
|
-
|
93
|
-
def run_svn(*args)
|
94
|
-
run_svn_with(repo_dir, :safe_output_svn_client, *args)
|
95
|
-
end
|
96
|
-
|
97
|
-
def run_svn_with_buffered_output(*args)
|
98
|
-
run_svn_with(repo_dir, :unsafe_output_svn_client, *args)
|
99
|
-
end
|
100
|
-
|
101
|
-
# runs svn client with safe buffering (by default).
|
102
|
-
#
|
103
|
-
# === Parameters
|
104
|
-
# @param [Array] args for svn client command line
|
105
|
-
#
|
106
|
-
# === Return
|
107
|
-
# @return [Array] lines of output or empty
|
108
|
-
def run_svn_with(initial_directory, output_handler, *args)
|
109
|
-
@output = ::RightScale::RightPopen::SafeOutputBuffer.new
|
110
|
-
@output_handler = output_handler
|
111
|
-
cmd = ['svn', args, svn_arguments].flatten
|
112
|
-
::RightScale::RightPopen.popen3_sync(
|
113
|
-
cmd,
|
114
|
-
:target => self,
|
115
|
-
:directory => initial_directory,
|
116
|
-
:timeout_handler => :timeout_svn_client,
|
117
|
-
:size_limit_handler => :size_limit_svn_client,
|
118
|
-
:exit_handler => :exit_svn_client,
|
119
|
-
:stderr_handler => output_handler,
|
120
|
-
:stdout_handler => output_handler,
|
121
|
-
:inherit_io => true, # avoid killing any rails connection
|
122
|
-
:watch_directory => repo_dir,
|
123
|
-
:size_limit_bytes => @max_bytes,
|
124
|
-
:timeout_seconds => @max_seconds)
|
125
|
-
@output.buffer
|
126
|
-
end
|
127
|
-
|
128
|
-
def safe_output_svn_client(data)
|
129
|
-
@output.safe_buffer_data(data)
|
130
|
-
end
|
131
|
-
|
132
|
-
def unsafe_output_svn_client(data)
|
133
|
-
@output.buffer << data.chomp
|
134
|
-
end
|
135
|
-
|
136
|
-
def timeout_svn_client
|
137
|
-
raise SvnClientError, "svn client timed out"
|
138
|
-
end
|
139
|
-
|
140
|
-
def size_limit_svn_client
|
141
|
-
raise SvnClientError, "svn client exceeded size limit"
|
142
|
-
end
|
143
|
-
|
144
|
-
def exit_svn_client(status)
|
145
|
-
unless status.success?
|
146
|
-
self.method(@output_handler).call("Exit code = #{status.exitstatus}")
|
147
|
-
raise SvnClientError, "svn client failed: #{@output.display_text}"
|
148
|
-
end
|
149
|
-
true
|
150
|
-
end
|
151
|
-
|
152
|
-
# Fetch the tag from the repository, or nil if one doesn't
|
153
|
-
# exist. This is a separate method because the repo tag should
|
154
|
-
# be a number but is a string in the database.
|
155
|
-
def get_tag
|
156
|
-
case repository.tag
|
157
|
-
when Fixnum then repository.tag
|
158
|
-
when /^\d+$/ then repository.tag.to_i
|
159
|
-
else
|
160
|
-
repository.tag
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
data/right_scraper.rconf
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# RConf configuration file, usage:
|
2
|
-
# gem install rconf
|
3
|
-
# rconf
|
4
|
-
#
|
5
|
-
ruby do
|
6
|
-
version 'ruby-1.9.2-p290'
|
7
|
-
rubygems '1.8.10'
|
8
|
-
gemset 'right_scraper'
|
9
|
-
end
|
10
|
-
bundler do
|
11
|
-
version '1.2.1'
|
12
|
-
bundle_path File.join(ENV["HOME"], '.rightscale', 'right_scraper')
|
13
|
-
end
|
data/spec/builder_spec.rb
DELETED
@@ -1,50 +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 File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
25
|
-
require File.expand_path(File.join(File.dirname(__FILE__), 'download', 'download_retriever_spec_helper'))
|
26
|
-
|
27
|
-
describe RightScraper::Builders::Builder do
|
28
|
-
|
29
|
-
include RightScraper::SpecHelpers::DevelopmentModeEnvironment
|
30
|
-
|
31
|
-
before(:each) do
|
32
|
-
@helper = RightScraper::DownloadRetrieverSpecHelper.new
|
33
|
-
@repo_dir = @helper.download_repo_path
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'should be called correctly' do
|
37
|
-
builder = flexmock("builder")
|
38
|
-
builder.should_receive(:new).with(Hash).once.and_return(builder)
|
39
|
-
builder.should_receive(:go).with(String, RightScraper::Resources::Cookbook).once
|
40
|
-
builder.should_receive(:finish).with().once
|
41
|
-
|
42
|
-
@scraper = RightScraper::Scrapers::Cookbook.new(:repository => @helper.repo,
|
43
|
-
:repo_dir => @repo_dir,
|
44
|
-
:builders => [builder])
|
45
|
-
@scraper.next_resource.should_not be_nil
|
46
|
-
@scraper.next_resource.should be_nil
|
47
|
-
@scraper.close
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
data/spec/cookbook_helper.rb
DELETED
@@ -1,73 +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 File.expand_path(File.join(File.dirname(__FILE__), 'retriever_spec_helper'))
|
25
|
-
require 'uri'
|
26
|
-
require 'cgi'
|
27
|
-
|
28
|
-
module RightScraper
|
29
|
-
module CookbookHelper
|
30
|
-
|
31
|
-
def example_cookbook(repository, position=nil)
|
32
|
-
@helper = RightScraper::RetrieverSpecHelper.new if @helper.nil?
|
33
|
-
RightScraper::Resources::Cookbook.new(@repository, position)
|
34
|
-
end
|
35
|
-
|
36
|
-
def parse_url(repository)
|
37
|
-
uri = URI.parse(repository.url)
|
38
|
-
userinfo, query, tag = uri.select(:userinfo, :query, :fragment)
|
39
|
-
unless userinfo.nil?
|
40
|
-
username, password = userinfo.split(":", 2).map {|str| URI.unescape str}
|
41
|
-
uri.user = nil
|
42
|
-
uri.password = nil
|
43
|
-
end
|
44
|
-
unless query.nil?
|
45
|
-
hash = CGI::parse(query)
|
46
|
-
position = hash["p"][0]
|
47
|
-
hash.delete("p")
|
48
|
-
result = hash.map do |key, values|
|
49
|
-
values.map {|value| CGI::escape(key) + "=" + CGI::escape(value)}.join(";")
|
50
|
-
end.join(';')
|
51
|
-
|
52
|
-
if result == ""
|
53
|
-
uri.query = nil
|
54
|
-
else
|
55
|
-
uri.query = result
|
56
|
-
end
|
57
|
-
end
|
58
|
-
uri.fragment = nil unless tag.nil?
|
59
|
-
{ :url => uri.to_s,
|
60
|
-
:username => username,
|
61
|
-
:password => password,
|
62
|
-
:position => position,
|
63
|
-
:tag => tag}
|
64
|
-
end
|
65
|
-
|
66
|
-
shared_examples_for 'a generic repository' do
|
67
|
-
it 'should have the same url' do
|
68
|
-
parse_url(@repository)[:url].should == @repository.url
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
73
|
-
end
|
@@ -1,93 +0,0 @@
|
|
1
|
-
#-- -*- mode: ruby; encoding: utf-8 -*-
|
2
|
-
# Copyright: Copyright (c) 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 File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
25
|
-
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'right_scraper'))
|
26
|
-
|
27
|
-
|
28
|
-
module RightScraper::Scanners
|
29
|
-
describe CookbookManifest do
|
30
|
-
it 'should accumulate files' do
|
31
|
-
resource = flexmock(:resource)
|
32
|
-
resource.should_receive(:manifest=).with({"foo" => Digest::MD5.hexdigest("bar"),
|
33
|
-
"baz" => Digest::MD5.hexdigest("quux")
|
34
|
-
}).once
|
35
|
-
manifest = CookbookManifest.new
|
36
|
-
manifest.notice("foo") { "bar" }
|
37
|
-
manifest.notice("baz") { "quux" }
|
38
|
-
manifest.end(resource)
|
39
|
-
end
|
40
|
-
it 'should keep different resources separated' do
|
41
|
-
resource = flexmock(:resource)
|
42
|
-
resource.should_receive(:manifest=).with({"foo" => Digest::MD5.hexdigest("bar"),
|
43
|
-
"baz" => Digest::MD5.hexdigest("quux")
|
44
|
-
}).once
|
45
|
-
resource.should_receive(:manifest=).with({"bar" => Digest::MD5.hexdigest("fred")
|
46
|
-
}).once
|
47
|
-
manifest = CookbookManifest.new
|
48
|
-
manifest.notice("foo") { "bar" }
|
49
|
-
manifest.notice("baz") { "quux" }
|
50
|
-
manifest.end(resource)
|
51
|
-
manifest.notice("bar") { "fred" }
|
52
|
-
manifest.end(resource)
|
53
|
-
end
|
54
|
-
it 'should hash to the same value despite resource order' do
|
55
|
-
cookbook1 = RightScraper::Resources::Cookbook.new('<empty>', '')
|
56
|
-
cookbook2 = RightScraper::Resources::Cookbook.new('<empty>', '')
|
57
|
-
|
58
|
-
manifest = CookbookManifest.new
|
59
|
-
|
60
|
-
manifest.notice("foo") {"bar"}
|
61
|
-
manifest.notice("baz") {"quux"}
|
62
|
-
manifest.notice("bar/none") {"fred"}
|
63
|
-
manifest.notice("bar/all") {"fred"}
|
64
|
-
manifest.notice("a/really/deep/directory/fox") {"stray"}
|
65
|
-
manifest.end(cookbook1)
|
66
|
-
|
67
|
-
manifest.notice("bar/none") {"fred"}
|
68
|
-
manifest.notice("a/really/deep/directory/fox") {"stray"}
|
69
|
-
manifest.notice("foo") {"bar"}
|
70
|
-
manifest.notice("baz") {"quux"}
|
71
|
-
manifest.notice("bar/all") {"fred"}
|
72
|
-
manifest.end(cookbook2)
|
73
|
-
|
74
|
-
cookbook1.resource_hash.should == cookbook2.resource_hash
|
75
|
-
end
|
76
|
-
it 'should hash to the same value despite repository location' do
|
77
|
-
cookbook1 = RightScraper::Resources::Cookbook.new('git://github.com/somerepo', '')
|
78
|
-
cookbook2 = RightScraper::Resources::Cookbook.new('svn://mycompany/rss/myrepo', '')
|
79
|
-
|
80
|
-
manifest = CookbookManifest.new
|
81
|
-
|
82
|
-
manifest.notice("foo") {"bar"}
|
83
|
-
manifest.notice("baz") {"quux"}
|
84
|
-
manifest.end(cookbook1)
|
85
|
-
|
86
|
-
manifest.notice("foo") {"bar"}
|
87
|
-
manifest.notice("baz") {"quux"}
|
88
|
-
manifest.end(cookbook2)
|
89
|
-
|
90
|
-
cookbook1.resource_hash.should == cookbook2.resource_hash
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|