right_scraper 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/lib/right_scraper.rb CHANGED
@@ -29,3 +29,4 @@ require File.join(File.dirname(__FILE__), 'right_scraper', 'scrapers', 'git_scra
29
29
  require File.join(File.dirname(__FILE__), 'right_scraper', 'scrapers', 'svn_scraper')
30
30
  require File.join(File.dirname(__FILE__), 'right_scraper', 'repository')
31
31
  require File.join(File.dirname(__FILE__), 'right_scraper', 'scraper')
32
+ require File.join(File.dirname(__FILE__), 'right_scraper', 'watcher')
@@ -84,9 +84,13 @@ module RightScale
84
84
  # Loop until process is done or times out or takes too much space
85
85
  timed_out = repeat(1, @max_seconds) do
86
86
  output += r.readlines.join
87
- size = 0
88
- Find.find(dest_dir) { |f| size += File.stat(f).size unless File.directory?(f) } if File.directory?(dest_dir)
89
- size > @max_bytes || status
87
+ if @max_bytes < 0
88
+ status
89
+ else
90
+ size = 0
91
+ Find.find(dest_dir) { |f| size += File.stat(f).size unless File.directory?(f) } if File.directory?(dest_dir)
92
+ size > @max_bytes || status
93
+ end
90
94
  end
91
95
 
92
96
  # Cleanup and report status
@@ -127,7 +131,7 @@ module RightScale
127
131
  # res(TrueClass|FalseClass):: true if timeout is reached, false otherwise.
128
132
  def repeat(period, timeout)
129
133
  end_at = Time.now + timeout
130
- while res = (Time.now < end_at)
134
+ while res = (timeout < 0 || Time.now < end_at)
131
135
  exit = false
132
136
  elapsed = timed { exit = yield }
133
137
  break if exit
@@ -23,7 +23,7 @@ require 'rubygems'
23
23
 
24
24
  spec = Gem::Specification.new do |spec|
25
25
  spec.name = 'right_scraper'
26
- spec.version = '1.0.5'
26
+ spec.version = '1.0.6'
27
27
  spec.authors = ['Raphael Simon']
28
28
  spec.email = 'raphael@rightscale.com'
29
29
  spec.homepage = 'https://github.com/rightscale/right_scraper'
data/spec/watcher_spec.rb CHANGED
@@ -59,4 +59,12 @@ describe RightScale::Watcher do
59
59
  status.output.should == "42\n"
60
60
  end
61
61
 
62
+ it 'should allow infinite size and timeout' do
63
+ watcher = RightScale::Watcher.new(max_bytes=-1, max_seconds=-1)
64
+ status = watcher.launch_and_watch("ruby -e 'puts 42; File.open(File.join(\"#{@dest_dir}\", \"test\"), \"w\") { |f| f.puts \"MORE THAN 2 CHARS\" };sleep 2'", @dest_dir)
65
+ status.status.should == :success
66
+ status.exit_code.should == 0
67
+ status.output.should == "42\n"
68
+ end
69
+
62
70
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_scraper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raphael Simon
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-08 00:00:00 -08:00
12
+ date: 2010-02-09 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -34,7 +34,6 @@ files:
34
34
  - lib/right_scraper/scrapers/svn_scraper.rb
35
35
  - lib/right_scraper/watcher.rb
36
36
  - right_scraper.gemspec
37
- - spec/__origin/config
38
37
  - spec/download_scraper_spec.rb
39
38
  - spec/git_scraper_spec.rb
40
39
  - spec/rcov.opts
data/spec/__origin/config DELETED
@@ -1,5 +0,0 @@
1
- [core]
2
- repositoryformatversion = 0
3
- filemode = true
4
- bare = true
5
- ignorecase = true