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.
Files changed (92) hide show
  1. checksums.yaml +7 -0
  2. data/lib/right_scraper.rb +16 -34
  3. data/lib/right_scraper/builders.rb +32 -0
  4. data/lib/right_scraper/builders/base.rb +19 -20
  5. data/lib/right_scraper/builders/filesystem.rb +8 -6
  6. data/lib/right_scraper/builders/union.rb +4 -1
  7. data/lib/right_scraper/loggers.rb +31 -0
  8. data/lib/right_scraper/loggers/base.rb +113 -0
  9. data/lib/right_scraper/loggers/default.rb +98 -0
  10. data/lib/right_scraper/{scraper.rb → main.rb} +53 -9
  11. data/lib/right_scraper/processes.rb +33 -0
  12. data/lib/right_scraper/processes/shell.rb +227 -0
  13. data/lib/right_scraper/processes/{ssh.rb → ssh_agent.rb} +4 -0
  14. data/lib/right_scraper/processes/svn_client.rb +117 -0
  15. data/lib/right_scraper/processes/warden.rb +358 -0
  16. data/lib/right_scraper/registered_base.rb +154 -0
  17. data/lib/right_scraper/repositories.rb +33 -0
  18. data/lib/right_scraper/repositories/base.rb +271 -232
  19. data/lib/right_scraper/repositories/download.rb +8 -6
  20. data/lib/right_scraper/repositories/git.rb +8 -9
  21. data/lib/right_scraper/repositories/svn.rb +8 -8
  22. data/lib/right_scraper/resources.rb +32 -0
  23. data/lib/right_scraper/resources/base.rb +5 -1
  24. data/lib/right_scraper/resources/cookbook.rb +34 -27
  25. data/lib/right_scraper/resources/workflow.rb +27 -28
  26. data/lib/right_scraper/retrievers.rb +34 -0
  27. data/lib/right_scraper/retrievers/base.rb +80 -84
  28. data/lib/right_scraper/retrievers/checkout_base.rb +178 -0
  29. data/lib/right_scraper/retrievers/download.rb +125 -117
  30. data/lib/right_scraper/retrievers/git.rb +377 -223
  31. data/lib/right_scraper/retrievers/svn.rb +102 -62
  32. data/lib/right_scraper/scanners.rb +37 -0
  33. data/lib/right_scraper/scanners/base.rb +77 -80
  34. data/lib/right_scraper/scanners/cookbook_manifest.rb +31 -30
  35. data/lib/right_scraper/scanners/cookbook_metadata.rb +380 -35
  36. data/lib/right_scraper/scanners/cookbook_s3_upload.rb +56 -53
  37. data/lib/right_scraper/scanners/union.rb +61 -58
  38. data/lib/right_scraper/scanners/workflow_manifest.rb +55 -54
  39. data/lib/right_scraper/scanners/workflow_metadata.rb +41 -39
  40. data/lib/right_scraper/scanners/workflow_s3_upload.rb +59 -55
  41. data/lib/right_scraper/scrapers.rb +32 -0
  42. data/lib/right_scraper/scrapers/base.rb +217 -205
  43. data/lib/right_scraper/scrapers/cookbook.rb +42 -40
  44. data/lib/right_scraper/scrapers/workflow.rb +57 -58
  45. data/lib/right_scraper/version.rb +3 -0
  46. data/right_scraper.gemspec +12 -16
  47. metadata +57 -163
  48. data/Gemfile +0 -15
  49. data/Rakefile +0 -89
  50. data/lib/right_scraper/logger.rb +0 -107
  51. data/lib/right_scraper/loggers/noisy.rb +0 -85
  52. data/lib/right_scraper/repositories/mock.rb +0 -70
  53. data/lib/right_scraper/retrievers/checkout.rb +0 -79
  54. data/lib/right_scraper/scraper_logger.rb +0 -66
  55. data/lib/right_scraper/svn_client.rb +0 -164
  56. data/right_scraper.rconf +0 -13
  57. data/spec/builder_spec.rb +0 -50
  58. data/spec/cookbook_helper.rb +0 -73
  59. data/spec/cookbook_manifest_spec.rb +0 -93
  60. data/spec/cookbook_s3_upload_spec.rb +0 -159
  61. data/spec/download/download_retriever_spec.rb +0 -118
  62. data/spec/download/download_retriever_spec_helper.rb +0 -72
  63. data/spec/download/download_spec.rb +0 -128
  64. data/spec/download/multi_dir_spec.rb +0 -106
  65. data/spec/download/multi_dir_spec_helper.rb +0 -40
  66. data/spec/git/cookbook_spec.rb +0 -165
  67. data/spec/git/demokey +0 -27
  68. data/spec/git/demokey.pub +0 -1
  69. data/spec/git/password_key +0 -30
  70. data/spec/git/password_key.pub +0 -1
  71. data/spec/git/repository_spec.rb +0 -110
  72. data/spec/git/retriever_spec.rb +0 -553
  73. data/spec/git/retriever_spec_helper.rb +0 -112
  74. data/spec/git/scraper_spec.rb +0 -151
  75. data/spec/git/ssh_spec.rb +0 -174
  76. data/spec/git/url_spec.rb +0 -103
  77. data/spec/logger_spec.rb +0 -185
  78. data/spec/repository_spec.rb +0 -111
  79. data/spec/retriever_spec_helper.rb +0 -146
  80. data/spec/scanner_spec.rb +0 -61
  81. data/spec/scraper_helper.rb +0 -88
  82. data/spec/scraper_spec.rb +0 -147
  83. data/spec/spec_helper.rb +0 -185
  84. data/spec/svn/cookbook_spec.rb +0 -96
  85. data/spec/svn/multi_svn_spec.rb +0 -64
  86. data/spec/svn/multi_svn_spec_helper.rb +0 -40
  87. data/spec/svn/repository_spec.rb +0 -72
  88. data/spec/svn/retriever_spec.rb +0 -266
  89. data/spec/svn/scraper_spec.rb +0 -90
  90. data/spec/svn/svn_retriever_spec_helper.rb +0 -90
  91. data/spec/svn/url_spec.rb +0 -47
  92. data/spec/url_spec.rb +0 -164
@@ -1,64 +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__), 'multi_svn_spec_helper'))
25
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'scraper_helper'))
26
-
27
- describe RightScraper::Retrievers::Svn do
28
- context 'in a multiple directory situation with a resources_path set' do
29
- include RightScraper::SpecHelpers::DevelopmentModeEnvironment
30
-
31
- include RightScraper::ScraperHelper
32
-
33
- before(:all) do
34
- @retriever_class = RightScraper::Retrievers::Svn
35
- @ignore = ['.svn']
36
- end
37
-
38
- context 'given a SVN repository' do
39
- before(:each) do
40
- @helper = RightScraper::MultiSvnSpecHelper.new
41
- @repo = @helper.repo
42
- end
43
-
44
- after(:each) do
45
- @helper.close unless @helper.nil?
46
- @helper = nil
47
- end
48
-
49
- include RightScraper::SpecHelpers::FromScratchScraping
50
- include RightScraper::SpecHelpers::CookbookScraping
51
-
52
- it 'should see two cookbooks' do
53
- @scraper.next_resource.should_not == nil
54
- @scraper.next_resource.should_not == nil
55
- @scraper.next_resource.should == nil
56
- end
57
-
58
- it 'should set the position correctly' do
59
- check_resource @scraper.next_resource, :position => "subdir1"
60
- check_resource @scraper.next_resource, :position => "subdir2"
61
- end
62
- end
63
- end
64
- end
@@ -1,40 +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__), "svn_retriever_spec_helper"))
25
-
26
- module RightScraper
27
- class MultiSvnSpecHelper < SvnRetrieverSpecHelper
28
- def make_cookbooks
29
- super
30
- create_cookbook(File.join(repo_path, 'subdir1'), repo_content)
31
- create_cookbook(File.join(repo_path, 'subdir2'), repo_content)
32
- end
33
-
34
- def repo
35
- r = super
36
- r.resources_path = ['subdir1', 'subdir2']
37
- r
38
- end
39
- end
40
- end
@@ -1,72 +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
-
26
- describe RightScraper::Repositories::Svn do
27
- include RightScraper::SpecHelpers::DevelopmentModeEnvironment
28
-
29
- before(:each) do
30
- @repo = RightScraper::Repositories::Base.from_hash(:display_name => 'test repo',
31
- :repo_type => :svn,
32
- :url => "http://foo.bar.baz.quux/%20CBLAH",
33
- :tag => 'foo',
34
- :first_credential => "foo:b/ar",
35
- :second_credential => "foo@bar")
36
- end
37
-
38
- it 'should have the same repository hash with or without credentials' do
39
- initial_hash = @repo.repository_hash
40
- @repo.first_credential = nil
41
- @repo.second_credential = nil
42
- @repo.repository_hash.should == initial_hash
43
- end
44
-
45
- it 'should have the same checkout hash with or without credentials' do
46
- initial_hash = @repo.checkout_hash
47
- @repo.first_credential = nil
48
- @repo.second_credential = nil
49
- @repo.checkout_hash.should == initial_hash
50
- end
51
-
52
- it 'should have a checkout hash' do
53
- @repo.checkout_hash.should ==
54
- Digest::SHA1.hexdigest("1\000svn\000http://foo.bar.baz.quux/%20CBLAH\000foo")
55
- end
56
-
57
- it 'should have a different checkout hash from repository hash' do
58
- @repo.repository_hash.should_not == @repo.checkout_hash
59
- end
60
-
61
- it 'should have the same repository hash regardless of tag' do
62
- initial_hash = @repo.repository_hash
63
- @repo.tag = 'bar'
64
- @repo.repository_hash.should == initial_hash
65
- end
66
-
67
- it 'should have different checkout hashes as tags change' do
68
- initial_hash = @repo.checkout_hash
69
- @repo.tag = 'bar'
70
- @repo.checkout_hash.should_not == initial_hash
71
- end
72
- end
@@ -1,266 +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__), 'svn_retriever_spec_helper'))
26
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'scraper_helper'))
27
- require 'set'
28
-
29
- describe RightScraper::Retrievers::Svn do
30
- include RightScraper::SpecHelpers::DevelopmentModeEnvironment
31
-
32
- include RightScraper::ScraperHelper
33
-
34
- before(:all) do
35
- @retriever_class = RightScraper::Retrievers::Svn
36
- @ignore = ['.svn']
37
- end
38
-
39
- context 'given a remote SVN repository' do
40
- before(:each) do
41
- pending "Not run unless REMOTE_USER and REMOTE_PASSWORD set" unless ENV['REMOTE_USER'] && ENV['REMOTE_PASSWORD']
42
- url = 'https://wush.net/svn/rightscale/cookbooks_test/'
43
- @helper = RightScraper::SvnRetrieverSpecHelper.new
44
- @repo = RightScraper::Repositories::Base.from_hash(:display_name => 'wush',
45
- :repo_type => :svn,
46
- :url => url,
47
- :first_credential => ENV['REMOTE_USER'],
48
- :second_credential => ENV['REMOTE_PASSWORD'])
49
- @retriever = @retriever_class.new(@repo, :max_bytes => 1024**2,
50
- :basedir => @helper.scraper_path,
51
- :max_seconds => 20)
52
- end
53
-
54
- it 'should scrape' do
55
- @retriever.retrieve
56
- @scraper = RightScraper::Scrapers::Base.scraper(:kind => :cookbook,
57
- :ignorable_paths => @retriever.ignorable_paths,
58
- :repo_dir => @retriever.repo_dir,
59
- :repository => @retriever.repository)
60
- first = @scraper.next_resource
61
- first.should_not == nil
62
- end
63
-
64
- # quick_start not actually being a cookbook
65
- it 'should scrape 5 repositories' do
66
- @retriever.retrieve
67
- @scraper = RightScraper::Scrapers::Base.scraper(:kind => :cookbook,
68
- :ignorable_paths => @retriever.ignorable_paths,
69
- :repo_dir => @retriever.repo_dir,
70
- :repository => @retriever.repository)
71
- locations = Set.new
72
- (1..5).each {|n|
73
- cookbook = @scraper.next_resource
74
- locations << cookbook.pos
75
- cookbook.should_not == nil
76
- }
77
- @scraper.next_resource.should == nil
78
- locations.should == Set.new(["cookbooks/app_rails",
79
- "cookbooks/db_mysql",
80
- "cookbooks/repo_git",
81
- "cookbooks/rs_utils",
82
- "cookbooks/web_apache"])
83
- end
84
- end
85
-
86
- context 'given a SVN repository' do
87
- before(:each) do
88
- @helper = RightScraper::SvnRetrieverSpecHelper.new
89
- @repo = @helper.repo
90
- end
91
-
92
- after(:each) do
93
- @helper.close unless @helper.nil?
94
- @helper = nil
95
- end
96
-
97
- context 'with one cookbook' do
98
- include RightScraper::SpecHelpers::FromScratchScraping
99
- include RightScraper::SpecHelpers::CookbookScraping
100
-
101
- it 'should scrape the master branch' do
102
- check_resource @scraper.next_resource
103
- end
104
-
105
- it 'should only see one cookbook' do
106
- @scraper.next_resource.should_not == nil
107
- @scraper.next_resource.should == nil
108
- end
109
-
110
- it 'should record the head SHA' do
111
- tag = @scraper.next_resource.repository.tag
112
- tag.should_not == "master"
113
- tag.should =~ /^[0-9]+$/
114
- end
115
- end
116
-
117
- context 'with multiple cookbooks' do
118
- def secondary_cookbook(where)
119
- FileUtils.mkdir_p(where)
120
- @helper.create_cookbook(where, @helper.repo_content)
121
- end
122
-
123
- before(:each) do
124
- @helper.delete(File.join(@helper.repo_path, "metadata.json"))
125
- @cookbook_places = [File.join(@helper.repo_path, "cookbooks", "first"),
126
- File.join(@helper.repo_path, "cookbooks", "second"),
127
- File.join(@helper.repo_path, "other_random_place")]
128
- @cookbook_places.each {|place| secondary_cookbook(place)}
129
- @helper.commit_content("secondary cookbooks added")
130
- end
131
-
132
- include RightScraper::SpecHelpers::FromScratchScraping
133
- include RightScraper::SpecHelpers::CookbookScraping
134
-
135
- it 'should scrape' do
136
- scraped = []
137
- while scrape = @scraper.next_resource
138
- place = (@cookbook_places - scraped).detect {|place| File.join(@helper.repo_path, scrape.pos) == place}
139
- scraped << place
140
- check_resource scrape, :position => place[@helper.repo_path.length+1..-1]
141
- end
142
- scraped.should have(@cookbook_places.size).repositories
143
- end
144
-
145
- end
146
-
147
- context 'and a revision' do
148
- before(:each) do
149
- @oldmetadata = @helper.repo_content
150
- @helper.create_file_layout(@helper.repo_path, @helper.branch_content)
151
- @helper.commit_content('added branch content')
152
- @repo.tag = @helper.commit_id(1).to_s
153
- end
154
-
155
- include RightScraper::SpecHelpers::FromScratchScraping
156
- include RightScraper::SpecHelpers::CookbookScraping
157
-
158
- it 'should scrape a revision' do
159
- check_resource @scraper.next_resource, :metadata => @oldmetadata, :rootdir => @retriever.repo_dir
160
- end
161
- end
162
-
163
- context 'and an incremental scraper' do
164
- before(:each) do
165
- @retriever = @retriever_class.new(@repo,
166
- :max_bytes => 1024**2,
167
- :basedir => @helper.scraper_path,
168
- :max_seconds => 20)
169
- @retriever.retrieve
170
- @scraper = RightScraper::Scrapers::Base.scraper(:kind => :cookbook,
171
- :ignorable_paths => @retriever.ignorable_paths,
172
- :repo_dir => @retriever.repo_dir,
173
- :repository => @retriever.repository)
174
- end
175
-
176
- after(:each) do
177
- @scraper.close
178
- @scraper = nil
179
- end
180
-
181
- it 'the scraper should store intermediate versions where we expect' do
182
- @retriever.repo_dir.should begin_with @helper.scraper_path
183
- end
184
-
185
- it 'the scraper should scrape' do
186
- check_resource @scraper.next_resource
187
- end
188
-
189
- it 'the scraper should only see one cookbook' do
190
- @scraper.next_resource.should_not == nil
191
- @scraper.next_resource.should == nil
192
- end
193
-
194
- context 'when a change is made to the master repo' do
195
- before(:each) do
196
- @helper.create_file_layout(@helper.repo_path, @helper.branch_content)
197
- @helper.commit_content
198
- end
199
-
200
- context 'a new scraper' do
201
- before(:each) do
202
- @olddir = @retriever.repo_dir
203
- @retriever = @retriever_class.new(@repo,
204
- :basedir => @helper.scraper_path,
205
- :max_bytes => 1024**2,
206
- :max_seconds => 20)
207
- @retriever.retrieve
208
- end
209
-
210
- it 'should use the same directory for files' do
211
- @olddir.should == @retriever.repo_dir
212
- end
213
-
214
- it 'should see the new change' do
215
- File.exists?(File.join(@olddir, 'branch_folder', 'bfile1')).should be_true
216
- end
217
- end
218
- end
219
-
220
- context 'when a textual change is made to the master repo' do
221
- before(:each) do
222
- File.open(File.join(@helper.repo_path, "file1"), 'w') do |f|
223
- f.puts "bar"
224
- end
225
- @helper.commit_content("appended bar")
226
- File.open(File.join(@helper.repo_path, "file1"), 'a+') do |f|
227
- f.puts "bar"
228
- end
229
- @helper.commit_content("appended bar again")
230
- File.open(File.join(@helper.repo_path, "file1"), 'a+') do |f|
231
- f.puts "bar"
232
- end
233
- @helper.commit_content("appended bar again^2")
234
- File.open(File.join(@helper.repo_path, "file1"), 'a+') do |f|
235
- f.puts "bar"
236
- end
237
- @helper.commit_content("appended bar again^3")
238
- end
239
-
240
- context 'a new scraper' do
241
- before(:each) do
242
- @olddir = @retriever.repo_dir
243
- @retriever = @retriever_class.new(@repo,
244
- :basedir => @helper.scraper_path,
245
- :max_bytes => 1024**2,
246
- :max_seconds => 20)
247
- @retriever.retrieve
248
- @scraper = RightScraper::Scrapers::Base.scraper(:kind => :cookbook,
249
- :ignorable_paths => @retriever.ignorable_paths,
250
- :repo_dir => @retriever.repo_dir,
251
- :repository => @retriever.repository)
252
- end
253
-
254
- it 'should notice the new revision' do
255
- cookbook = @scraper.next_resource
256
- cookbook.repository.tag.should == "5"
257
- end
258
-
259
- it 'should see the new change' do
260
- File.open(File.join(@olddir, 'file1')).read.should == "bar\n" * 4
261
- end
262
- end
263
- end
264
- end
265
- end
266
- end
@@ -1,90 +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 'stringio'
25
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
26
- require File.expand_path(File.join(File.dirname(__FILE__), 'svn_retriever_spec_helper'))
27
- require 'tmpdir'
28
- require 'flexmock'
29
-
30
- describe RightScraper::Scraper do
31
- include RightScraper::SpecHelpers::DevelopmentModeEnvironment
32
-
33
- include RightScraper::SharedExamples
34
-
35
- before(:each) do
36
- @stream = StringIO.new()
37
- @tmpdir = Dir.mktmpdir
38
- @scraper = RightScraper::Scraper.new(:basedir => @tmpdir, :kind => :cookbook)
39
- end
40
-
41
- after(:each) do
42
- FileUtils.remove_entry_secure @tmpdir
43
- end
44
-
45
- context 'given a SVN repository' do
46
- before(:each) do
47
- @helper = RightScraper::SvnRetrieverSpecHelper.new
48
- @repo = @helper.repo
49
- end
50
-
51
- after(:each) do
52
- @helper.close
53
- end
54
-
55
- it_should_behave_like "a normal repository"
56
-
57
- it 'should log correctly as it scrapes' do
58
- callback = flexmock("callback")
59
- callback.should_receive(:call).with(:begin, :retrieving, "from #{@repo}", nil).once.ordered
60
- callback.should_receive(:call).with(:begin, :initialize, String, nil).once.ordered
61
- callback.should_receive(:call).with(:commit, :initialize, String, nil).once.ordered
62
- callback.should_receive(:call).with(:begin, :checkout, "", nil).once.ordered
63
- callback.should_receive(:call).with(:begin, :checkout_revision, "", nil).once.ordered
64
- callback.should_receive(:call).with(:commit, :checkout_revision, "", nil).once.ordered
65
- callback.should_receive(:call).with(:commit, :checkout, "", nil).once.ordered
66
- callback.should_receive(:call).with(:commit, :retrieving, "from #{@repo}", nil).once.ordered
67
- callback.should_receive(:call).with(:begin, :scraping, String, nil).once.ordered
68
- callback.should_receive(:call).with(:begin, :finding_next_cookbook, String, nil).once.ordered
69
- callback.should_receive(:call).with(:begin, :reading_cookbook, String, nil).once.ordered
70
- callback.should_receive(:call).with(:begin, :scanning_filesystem, String, nil).once.ordered
71
- callback.should_receive(:call).with(:begin, :metadata_parsing, "", nil).once.ordered
72
- callback.should_receive(:call).with(:commit, :metadata_parsing, "", nil).once.ordered
73
- callback.should_receive(:call).with(:commit, :scanning_filesystem, String, nil).once.ordered
74
- callback.should_receive(:call).with(:commit, :reading_cookbook, String, nil).once.ordered
75
- callback.should_receive(:call).with(:commit, :finding_next_cookbook, String, nil).once.ordered
76
- callback.should_receive(:call).with(:begin, :next, "", nil).once.ordered
77
- callback.should_receive(:call).with(:begin, :searching, "", nil).once.ordered
78
- callback.should_receive(:call).with(:commit, :searching, "", nil).once.ordered
79
- callback.should_receive(:call).with(:commit, :next, "", nil).once.ordered
80
- callback.should_receive(:call).with(:begin, :next, "", nil).once.ordered
81
- callback.should_receive(:call).with(:commit, :next, "", nil).once.ordered
82
- callback.should_receive(:call).with(:commit, :scraping, String, nil).once.ordered
83
- @scraper.scrape(@repo) do |phase, operation, explanation, exception|
84
- callback.call(phase, operation, explanation, exception)
85
- end
86
- @scraper.errors.should == []
87
- @scraper.succeeded?.should be_true
88
- end
89
- end
90
- end