parallel 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  task :default => :spec
2
2
  require 'spec/rake/spectask'
3
- Spec::Rake::SpecTask.new {|t| t.spec_opts = ['--color']}
3
+ Spec::Rake::SpecTask.new {|t| t.spec_opts = ['--color'] }
4
4
 
5
5
  begin
6
6
  require 'jeweler'
@@ -15,5 +15,5 @@ begin
15
15
 
16
16
  Jeweler::GemcutterTasks.new
17
17
  rescue LoadError
18
- puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
19
- end
18
+ puts "Jeweler, or one of its dependencies, is not available. Install it with: gem install jeweler"
19
+ end
data/Readme.md CHANGED
@@ -44,10 +44,11 @@ TODO
44
44
  Authors
45
45
  =======
46
46
 
47
- ###Contributors
47
+ ### [Contributors](http://github.com/grosser/parallel/contributors)
48
48
  - [Przemyslaw Wroblewski](http://github.com/lowang)
49
49
  - [TJ Holowaychuk](http://vision-media.ca/)
50
50
  - [Masatomo Nakano](http://twitter.com/masatomo2)
51
+ - [Fred Wu](http://fredwu.me)
51
52
 
52
53
  [Michael Grosser](http://pragmatig.wordpress.com)
53
54
  grosser.michael@gmail.com
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.3
1
+ 0.4.4
data/lib/parallel.rb CHANGED
@@ -2,6 +2,7 @@ require 'thread' # to get Thread.exclusive
2
2
 
3
3
  class Parallel
4
4
  VERSION = File.read( File.join(File.dirname(__FILE__),'..','VERSION') ).strip
5
+ SPLAT_BUG = *[] # fix for bug/feature http://redmine.ruby-lang.org/issues/show/2422
5
6
 
6
7
  def self.in_threads(options={:count => 2})
7
8
  count, options = extract_count_from_options(options)
@@ -67,6 +68,7 @@ class Parallel
67
68
  end
68
69
  end
69
70
 
71
+ results = results.flatten(1) if SPLAT_BUG
70
72
  results
71
73
  end
72
74
 
data/parallel.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{parallel}
8
- s.version = "0.4.3"
8
+ s.version = "0.4.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Grosser"]
12
- s.date = %q{2010-08-24}
12
+ s.date = %q{2010-09-24}
13
13
  s.email = %q{grosser.michael@gmail.com}
14
14
  s.files = [
15
15
  "Rakefile",
@@ -1,4 +1,4 @@
1
- require 'spec/spec_helper.rb'
1
+ require File.expand_path('spec/spec_helper')
2
2
  cmd = "ps uaxw|grep ruby|wc -l"
3
3
 
4
4
  processes_before = `#{cmd}`.to_i
data/spec/cases/each.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'spec/spec_helper.rb'
1
+ require File.expand_path('spec/spec_helper')
2
2
  STDOUT.sync = true # otherwise results can go weird...
3
3
 
4
4
  x = ['a','b','c','d']
@@ -1,4 +1,4 @@
1
- require 'spec/spec_helper.rb'
1
+ require File.expand_path('spec/spec_helper')
2
2
 
3
3
  Parallel.each_with_index(['a','b'], :in_threads => 2) do |x, i|
4
4
  print "#{x}#{i}"
@@ -1,4 +1,4 @@
1
- require 'spec/spec_helper.rb'
1
+ require File.expand_path('spec/spec_helper')
2
2
 
3
3
  result = Parallel.map_with_index(['a','b']) do |x, i|
4
4
  "#{x}#{i}"
@@ -1,4 +1,4 @@
1
- require 'spec/spec_helper.rb'
1
+ require File.expand_path('spec/spec_helper')
2
2
 
3
3
  result = Parallel.map_with_index([]) do |x, i|
4
4
  "#{x}#{i}"
@@ -1,4 +1,4 @@
1
- require 'spec/spec_helper.rb'
1
+ require File.expand_path('spec/spec_helper')
2
2
 
3
3
  class NotDumpable
4
4
  def marshal_dump
@@ -1,4 +1,5 @@
1
- require 'spec/spec_helper.rb'
1
+ require File.expand_path('spec/spec_helper')
2
+
2
3
  Parallel.each((0..200).to_a, :in_processes=>200) do |x|
3
4
  sleep 1
4
5
  end
@@ -1,4 +1,4 @@
1
- require 'spec/spec_helper.rb'
1
+ require File.expand_path('spec/spec_helper')
2
2
 
3
3
  x = 'yes'
4
4
 
@@ -1,4 +1,4 @@
1
- require 'spec/spec_helper.rb'
1
+ require File.expand_path('spec/spec_helper')
2
2
 
3
3
  result = Parallel.map(['a','b','c','d']) do |x|
4
4
  "-#{x}-"
@@ -1,6 +1,6 @@
1
- require 'spec/spec_helper.rb'
1
+ require File.expand_path('spec/spec_helper')
2
2
 
3
3
  result = Parallel.map(1..5) do |x|
4
4
  x
5
5
  end
6
- print result
6
+ print result.inspect
@@ -1,4 +1,4 @@
1
- require 'spec/spec_helper.rb'
1
+ require File.expand_path('spec/spec_helper')
2
2
 
3
3
  Parallel.map(['a','b','c','d']) do |x|
4
4
  sleep 1
@@ -1,4 +1,4 @@
1
- require 'spec/spec_helper.rb'
1
+ require File.expand_path('spec/spec_helper')
2
2
 
3
3
  Parallel.map([1,2,1,2]) do |x|
4
4
  sleep 2 if x == 1
@@ -1,4 +1,4 @@
1
- require 'spec/spec_helper.rb'
1
+ require File.expand_path('spec/spec_helper')
2
2
 
3
3
  begin
4
4
  Parallel.in_processes(2) do
@@ -1,4 +1,4 @@
1
- require 'spec/spec_helper.rb'
1
+ require File.expand_path('spec/spec_helper')
2
2
 
3
3
  Parallel.in_processes(5) do
4
4
  sleep 2
@@ -1,4 +1,4 @@
1
- require 'spec/spec_helper.rb'
1
+ require File.expand_path('spec/spec_helper')
2
2
 
3
3
  Parallel.in_processes(2) do
4
4
  sleep 10
@@ -1,4 +1,4 @@
1
- require 'spec/spec_helper.rb'
1
+ require File.expand_path('spec/spec_helper')
2
2
 
3
3
  x = Parallel.in_processes do
4
4
  "HELLO"
@@ -1,4 +1,4 @@
1
- require 'spec/spec_helper.rb'
1
+ require File.expand_path('spec/spec_helper')
2
2
 
3
3
  x = Parallel.in_processes(nil) do
4
4
  "HELLO"
@@ -1,4 +1,4 @@
1
- require 'spec/spec_helper.rb'
1
+ require File.expand_path('spec/spec_helper')
2
2
 
3
3
  x = Parallel.in_processes(5) do
4
4
  "HELLO"
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
1
+ require File.expand_path('spec/spec_helper')
2
2
 
3
3
  describe Parallel do
4
4
  describe :in_processes do
@@ -14,7 +14,7 @@ describe Parallel do
14
14
  `ruby spec/cases/parallel_with_nil_uses_detected_cpus.rb`.should == "HELLO\n" * @cpus
15
15
  end
16
16
 
17
- it "set ammount of parallel processes" do
17
+ it "set amount of parallel processes" do
18
18
  `ruby spec/cases/parallel_with_set_processes.rb`.should == "HELLO\n" * 5
19
19
  end
20
20
 
@@ -29,8 +29,9 @@ describe Parallel do
29
29
  `ruby spec/cases/parallel_start_and_kill.rb`
30
30
  end
31
31
  sleep 1
32
- running_processes = `ps -f`.split("\n").map{|line| line.split(/\s+/)}
33
- parent = running_processes.detect{|line| line.include?("00:00:00") and line.include?("ruby") }[1]
32
+ running_processes = `ps -f`.split("\n").map{ |line| line.split(/\s+/) }
33
+ uid_index = running_processes.detect{ |line| line.include?("UID") }.index("UID") + 1
34
+ parent = running_processes.detect{ |line| line.grep(/(0|)0:00(:|.)00/).any? and line.include?("ruby") }[uid_index]
34
35
  `kill -2 #{parent}` #simulates Ctrl+c
35
36
  }.should_not change{`ps`.split("\n").size}
36
37
  Time.now.should be_close(t, 3)
@@ -102,7 +103,7 @@ describe Parallel do
102
103
  end
103
104
 
104
105
  it 'supports ranges' do
105
- `ruby spec/cases/parallel_map_range.rb`.should == '12345'
106
+ `ruby spec/cases/parallel_map_range.rb`.should == '[1, 2, 3, 4, 5]'
106
107
  end
107
108
  end
108
109
 
@@ -149,4 +150,4 @@ describe Parallel do
149
150
  Parallel.send(:in_groups_of, [1,2,3,4], 3).should == [[1,2,3],[4]]
150
151
  end
151
152
  end
152
- end
153
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,2 +1,2 @@
1
- $LOAD_PATH << 'lib'
1
+ $LOAD_PATH.unshift 'lib'
2
2
  require 'parallel'
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 3
9
- version: 0.4.3
8
+ - 4
9
+ version: 0.4.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Michael Grosser
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-08-24 00:00:00 +02:00
17
+ date: 2010-09-24 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies: []
20
20