right_scraper 1.0.0

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.
@@ -0,0 +1,104 @@
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.join(File.dirname(__FILE__), 'spec_helper')
25
+ require 'scraper_base'
26
+ require 'repository'
27
+ require File.join('scrapers', 'svn_scraper')
28
+
29
+ describe RightScale::SvnScraper do
30
+
31
+ include RightScale::SpecHelpers
32
+
33
+ # Create svn repository following given layout
34
+ # Update @repo_path with path to repository
35
+ # Delete any previously created repo
36
+ def setup_svn_repo
37
+ @svn_repo_path = File.expand_path(File.join(File.dirname(__FILE__), '__svn_repo'))
38
+ @repo_path = File.join(File.dirname(__FILE__), '__repo')
39
+ @repo_content = [ 'file1', { 'folder1' => [ 'file2', 'file3' ] }, { 'folder2' => [ { 'folder3' => [ 'file4' ] } ] } ]
40
+ FileUtils.rm_rf(@svn_repo_path)
41
+ res, status = exec("svnadmin create #{@svn_repo_path}")
42
+ raise "Failed to initialize SVN repository: #{res}" unless status.success?
43
+ FileUtils.rm_rf(@repo_path)
44
+ res, status = exec("svn checkout file://#{@svn_repo_path} #{@repo_path}")
45
+ raise "Failed to checkout repository: #{res}" unless status.success?
46
+ create_file_layout(@repo_path, @repo_content)
47
+ Dir.chdir(@repo_path) do
48
+ res, status = exec("svn add *")
49
+ res, status = exec("svn commit --quiet -m 'Initial Commit'") if status.success?
50
+ raise "Failed to setup repository: #{res}" unless status.success?
51
+ end
52
+ end
53
+
54
+ # Cleanup after ourselves
55
+ def delete_svn_repo
56
+ FileUtils.rm_rf(@svn_repo_path) if @svn_repo_path
57
+ @svn_repo_path = nil
58
+ FileUtils.rm_rf(@repo_path) if @repo_path
59
+ @repo_path = nil
60
+ end
61
+
62
+ context 'given a SVN repository' do
63
+
64
+ before(:all) do
65
+ setup_svn_repo
66
+ end
67
+
68
+ before(:each) do
69
+ @scraper = RightScale::SvnScraper.new(@repo_path)
70
+ @repo = RightScale::Repository.from_hash(:display_name => 'test repo',
71
+ :repo_type => :svn,
72
+ :url => "file://#{@svn_repo_path}")
73
+ end
74
+
75
+ after(:all) do
76
+ delete_svn_repo
77
+ end
78
+
79
+ it 'should scrape' do
80
+ messages = []
81
+ @scraper.scrape(@repo) { |m, progress| messages << m if progress }
82
+ puts "\n **ERRORS: #{@scraper.error_message}\n" unless @scraper.succeeded?
83
+ @scraper.succeeded?.should be_true
84
+ messages.size.should == 1
85
+ File.directory?(@scraper.repo_dir.should be_true)
86
+ extract_file_layout(@scraper.repo_dir, [ '.svn' ]).should == @repo_content
87
+ end
88
+
89
+ it 'should scrape incrementally' do
90
+ @scraper.scrape(@repo)
91
+ puts "\n **ERRORS: #{@scraper.error_message}\n" unless @scraper.succeeded?
92
+ @scraper.incremental_update?.should be_true
93
+ messages = []
94
+ @scraper.scrape(@repo) { |m, progress| messages << m if progress }
95
+ puts "\n **ERRORS: #{@scraper.error_message}\n" unless @scraper.succeeded?
96
+ @scraper.succeeded?.should be_true
97
+ messages.size.should == 1
98
+ File.directory?(@scraper.repo_dir.should be_true)
99
+ extract_file_layout(@scraper.repo_dir, [ '.svn' ]).should == @repo_content
100
+ end
101
+
102
+ end
103
+
104
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: right_scraper
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Raphael Simon
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-01-25 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: " RightScraper provides a simple interface to download and keep local copies of remote\n repositories up-to-date using the following protocols:\n * git: RightScraper will clone then pull repos from git\n * SVN: RightScraper will checkout then update SVN repositories\n * tarballs: RightScraper will download, optionally uncompress and expand a given tar file\n"
17
+ email: raphael@rightscale.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.rdoc
24
+ files:
25
+ - LICENSE
26
+ - README.rdoc
27
+ - Rakefile
28
+ - lib/right_scraper.rb
29
+ - lib/right_scraper/repository.rb
30
+ - lib/right_scraper/scraper.rb
31
+ - lib/right_scraper/scraper_base.rb
32
+ - lib/right_scraper/scrapers/download_scraper.rb
33
+ - lib/right_scraper/scrapers/git_scraper.rb
34
+ - lib/right_scraper/scrapers/svn_scraper.rb
35
+ - right_scraper.gemspec
36
+ - spec/download_scraper_spec.rb
37
+ - spec/git_scraper_spec.rb
38
+ - spec/rcov.opts
39
+ - spec/repository_spec.rb
40
+ - spec/scraper_base_spec.rb
41
+ - spec/scraper_spec.rb
42
+ - spec/spec_helper.rb
43
+ - spec/svn_scraper_spec.rb
44
+ has_rdoc: true
45
+ homepage: https://github.com/rightscale/right_scraper
46
+ licenses: []
47
+
48
+ post_install_message:
49
+ rdoc_options:
50
+ - --main
51
+ - README.rdoc
52
+ - --title
53
+ - RightScraper
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 1.8.6
61
+ version:
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ version:
68
+ requirements: []
69
+
70
+ rubyforge_project: right_scraper
71
+ rubygems_version: 1.3.5
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: Download and update remote repositories
75
+ test_files: []
76
+