in_threads 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.tmignore +1 -0
- data/LICENSE.txt +20 -0
- data/README.markdown +42 -0
- data/Rakefile +19 -28
- data/VERSION +1 -1
- data/in_threads.gemspec +26 -16
- data/spec/spec_helper.rb +2 -9
- metadata +59 -15
- data/.gitignore +0 -5
- data/Manifest +0 -7
- data/README.rdoc +0 -63
data/.tmignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
/*.gemspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Ivan Kuchin
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# progress
|
2
|
+
|
3
|
+
http://github.com/toy/in_threads
|
4
|
+
|
5
|
+
## DESCRIPTION:
|
6
|
+
|
7
|
+
Easily execute ruby code in parallel
|
8
|
+
|
9
|
+
## SYNOPSIS:
|
10
|
+
|
11
|
+
By default there is maximum of 10 simultaneous threads
|
12
|
+
|
13
|
+
urls.in_threads.each do |url|
|
14
|
+
url.save_to_disk
|
15
|
+
end
|
16
|
+
|
17
|
+
urls.in_threads.map do |url|
|
18
|
+
url.fetch
|
19
|
+
end
|
20
|
+
|
21
|
+
numbers.in_threads(2).map do |number|
|
22
|
+
…
|
23
|
+
# whery long and complicated formula
|
24
|
+
# using only 2 threads
|
25
|
+
end
|
26
|
+
|
27
|
+
You can use any Enumerable method but it is up to you if this is good
|
28
|
+
|
29
|
+
urls.in_threads.any?(&:ok?)
|
30
|
+
urls.in_threads.all?(&:ok?)
|
31
|
+
|
32
|
+
## REQUIREMENTS:
|
33
|
+
|
34
|
+
ruby )))
|
35
|
+
|
36
|
+
## INSTALL:
|
37
|
+
|
38
|
+
sudo gem install in_threads
|
39
|
+
|
40
|
+
## Copyright
|
41
|
+
|
42
|
+
Copyright (c) 2010 Ivan Kuchin. See LICENSE.txt for details.
|
data/Rakefile
CHANGED
@@ -1,34 +1,25 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'rake'
|
2
|
+
require 'jeweler'
|
3
|
+
require 'rake/gem_ghost_task'
|
4
|
+
require 'rspec/core/rake_task'
|
3
5
|
|
4
|
-
|
5
|
-
summary = 'Execute ruby blocks in parallel'
|
6
|
+
name = 'in_threads'
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
require 'pathname'
|
17
|
-
desc "Replace system gem with symlink to this folder"
|
18
|
-
task 'ghost' do
|
19
|
-
gem_path = Pathname(Gem.searcher.find(name).full_gem_path)
|
20
|
-
current_path = Pathname('.').expand_path
|
21
|
-
system('rm', '-r', gem_path)
|
22
|
-
system('ln', '-s', current_path, gem_path)
|
23
|
-
end
|
24
|
-
|
25
|
-
rescue LoadError
|
26
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
8
|
+
Jeweler::Tasks.new do |gem|
|
9
|
+
gem.name = name
|
10
|
+
gem.summary = %Q{Execute ruby blocks in parallel}
|
11
|
+
gem.homepage = "http://github.com/toy/#{name}"
|
12
|
+
gem.license = 'MIT'
|
13
|
+
gem.authors = ['Ivan Kuchin']
|
14
|
+
gem.add_development_dependency 'jeweler', '~> 1.5.1'
|
15
|
+
gem.add_development_dependency 'rake-gem-ghost'
|
16
|
+
gem.add_development_dependency 'rspec'
|
27
17
|
end
|
18
|
+
Jeweler::RubygemsDotOrgTasks.new
|
19
|
+
Rake::GemGhostTask.new
|
28
20
|
|
29
|
-
|
30
|
-
|
31
|
-
spec.
|
32
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
22
|
+
spec.rspec_opts = ['--colour --format progress']
|
23
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
33
24
|
end
|
34
25
|
task :default => :spec
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/in_threads.gemspec
CHANGED
@@ -1,37 +1,38 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{in_threads}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["
|
12
|
-
s.date = %q{2010-
|
11
|
+
s.authors = ["Ivan Kuchin"]
|
12
|
+
s.date = %q{2010-12-15}
|
13
13
|
s.extra_rdoc_files = [
|
14
|
-
"
|
14
|
+
"LICENSE.txt",
|
15
|
+
"README.markdown"
|
15
16
|
]
|
16
17
|
s.files = [
|
17
|
-
".
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
18
|
+
".tmignore",
|
19
|
+
"LICENSE.txt",
|
20
|
+
"README.markdown",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION",
|
23
|
+
"in_threads.gemspec",
|
24
|
+
"lib/in_threads.rb",
|
25
|
+
"spec/in_threads_spec.rb",
|
26
|
+
"spec/spec_helper.rb"
|
26
27
|
]
|
27
28
|
s.homepage = %q{http://github.com/toy/in_threads}
|
28
|
-
s.
|
29
|
+
s.licenses = ["MIT"]
|
29
30
|
s.require_paths = ["lib"]
|
30
31
|
s.rubygems_version = %q{1.3.7}
|
31
32
|
s.summary = %q{Execute ruby blocks in parallel}
|
32
33
|
s.test_files = [
|
33
34
|
"spec/in_threads_spec.rb",
|
34
|
-
|
35
|
+
"spec/spec_helper.rb"
|
35
36
|
]
|
36
37
|
|
37
38
|
if s.respond_to? :specification_version then
|
@@ -39,9 +40,18 @@ Gem::Specification.new do |s|
|
|
39
40
|
s.specification_version = 3
|
40
41
|
|
41
42
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
43
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
|
44
|
+
s.add_development_dependency(%q<rake-gem-ghost>, [">= 0"])
|
45
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
42
46
|
else
|
47
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
|
48
|
+
s.add_dependency(%q<rake-gem-ghost>, [">= 0"])
|
49
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
43
50
|
end
|
44
51
|
else
|
52
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
|
53
|
+
s.add_dependency(%q<rake-gem-ghost>, [">= 0"])
|
54
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
45
55
|
end
|
46
56
|
end
|
47
57
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,24 +1,67 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: in_threads
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
|
-
-
|
13
|
+
- Ivan Kuchin
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-12-15 00:00:00 +03:00
|
19
19
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: jeweler
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 1
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 5
|
33
|
+
- 1
|
34
|
+
version: 1.5.1
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rake-gem-ghost
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
version: "0"
|
49
|
+
type: :development
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: rspec
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
63
|
+
type: :development
|
64
|
+
version_requirements: *id003
|
22
65
|
description:
|
23
66
|
email:
|
24
67
|
executables: []
|
@@ -26,11 +69,12 @@ executables: []
|
|
26
69
|
extensions: []
|
27
70
|
|
28
71
|
extra_rdoc_files:
|
29
|
-
-
|
72
|
+
- LICENSE.txt
|
73
|
+
- README.markdown
|
30
74
|
files:
|
31
|
-
- .
|
32
|
-
-
|
33
|
-
- README.
|
75
|
+
- .tmignore
|
76
|
+
- LICENSE.txt
|
77
|
+
- README.markdown
|
34
78
|
- Rakefile
|
35
79
|
- VERSION
|
36
80
|
- in_threads.gemspec
|
@@ -39,11 +83,11 @@ files:
|
|
39
83
|
- spec/spec_helper.rb
|
40
84
|
has_rdoc: true
|
41
85
|
homepage: http://github.com/toy/in_threads
|
42
|
-
licenses:
|
43
|
-
|
86
|
+
licenses:
|
87
|
+
- MIT
|
44
88
|
post_install_message:
|
45
|
-
rdoc_options:
|
46
|
-
|
89
|
+
rdoc_options: []
|
90
|
+
|
47
91
|
require_paths:
|
48
92
|
- lib
|
49
93
|
required_ruby_version: !ruby/object:Gem::Requirement
|
data/Manifest
DELETED
data/README.rdoc
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
= progress
|
2
|
-
|
3
|
-
* http://github.com/toy/in_threads
|
4
|
-
|
5
|
-
== DESCRIPTION:
|
6
|
-
|
7
|
-
Easily execute ruby code in parallel
|
8
|
-
|
9
|
-
== SYNOPSIS:
|
10
|
-
|
11
|
-
By default there is maximum of 10 simultaneous threads
|
12
|
-
|
13
|
-
urls.in_threads.each do |url|
|
14
|
-
url.save_to_disk
|
15
|
-
end
|
16
|
-
|
17
|
-
urls.in_threads.map do |url|
|
18
|
-
url.fetch
|
19
|
-
end
|
20
|
-
|
21
|
-
numbers.in_threads(2).map do |number|
|
22
|
-
…
|
23
|
-
# whery long and complicated formula
|
24
|
-
# using only 2 threads
|
25
|
-
end
|
26
|
-
|
27
|
-
You can use any Enumerable method but it is up to you if this is good
|
28
|
-
|
29
|
-
urls.in_threads.any?(&:ok?)
|
30
|
-
urls.in_threads.all?(&:ok?)
|
31
|
-
|
32
|
-
== REQUIREMENTS:
|
33
|
-
|
34
|
-
* ruby )))
|
35
|
-
|
36
|
-
== INSTALL:
|
37
|
-
|
38
|
-
* sudo gem install in_threads
|
39
|
-
|
40
|
-
== LICENSE:
|
41
|
-
|
42
|
-
(The MIT License)
|
43
|
-
|
44
|
-
Copyright (c) 2008 toy
|
45
|
-
|
46
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
47
|
-
a copy of this software and associated documentation files (the
|
48
|
-
'Software'), to deal in the Software without restriction, including
|
49
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
50
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
51
|
-
permit persons to whom the Software is furnished to do so, subject to
|
52
|
-
the following conditions:
|
53
|
-
|
54
|
-
The above copyright notice and this permission notice shall be
|
55
|
-
included in all copies or substantial portions of the Software.
|
56
|
-
|
57
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
58
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
59
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
60
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
61
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
62
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
63
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|