motion-parallel 0.1

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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2f340500415ced99cc309619cc0feaa052a11fc5
4
+ data.tar.gz: 3f4dd4d81863aab48bc3340547dc66a88108c4e1
5
+ SHA512:
6
+ metadata.gz: ce8a0282bcfb71b9ab1f747c72454419bcff5ca9aadfa73250264fc95aa8473119281db45d59c1302e53dd8f52dddcb56eff0da5d6b91f2c018159d8fbc25593
7
+ data.tar.gz: 1ea6c1cf13c9c60f960cc52fb3e5684582d4bc565f7bb296deb68de76b7b34fee64a63001db5021d52173947dabec2fba790ee33c20e0a68a65811ca0077dd91
@@ -0,0 +1,68 @@
1
+ # motion-parallel
2
+
3
+ motion-parallel is parallel iterations for RubyMotion
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'motion-parallel'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install motion-parallel
18
+
19
+ ## Usage
20
+
21
+ ### #p_times
22
+
23
+ ```ruby
24
+ 10.p_times do |i|
25
+ i ** 2
26
+ end
27
+ ```
28
+
29
+ ### #p_each
30
+
31
+ ```ruby
32
+ ['foo', 'bar', 'baz'].p_each do |obj|
33
+ "Hello #{obj}"
34
+ end
35
+ ```
36
+
37
+ ### #p_each_index
38
+
39
+ ```ruby
40
+ ['foo', 'bar', 'baz'].p_each_index do |index|
41
+ puts index
42
+ end
43
+ ```
44
+
45
+ ### #p_each_with_index
46
+
47
+ ```ruby
48
+ ['foo', 'bar', 'baz'].p_each_index do |obj, index|
49
+ puts "#{obj} at #{index}"
50
+ end
51
+ ```
52
+
53
+ ### #p_map
54
+
55
+ ```ruby
56
+ ['foo', 'bar', 'baz'].p_map do |obj|
57
+ "Hello #{obj}"
58
+ end
59
+ ```
60
+
61
+
62
+ ## Contributing
63
+
64
+ 1. Fork it
65
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
66
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
67
+ 4. Push to the branch (`git push origin my-new-feature`)
68
+ 5. Create new Pull Request
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+
3
+ unless defined?(Motion::Project::Config)
4
+ raise "This file must be required within a RubyMotion project Rakefile."
5
+ end
6
+
7
+ lib_dir_path = File.dirname(File.expand_path(__FILE__))
8
+ Motion::Project::App.setup do |app|
9
+ app.files.unshift(Dir.glob(File.join(lib_dir_path, "project/**/*.rb")))
10
+ end
@@ -0,0 +1,46 @@
1
+ class Integer
2
+
3
+ def p_times(priority=:default, &block)
4
+ queue = Dispatch::Queue.concurrent(priority)
5
+ queue.apply(self, &block)
6
+ end
7
+
8
+ end
9
+
10
+ module Enumerable
11
+
12
+ def p_each(priority=nil, &block)
13
+ ary = self.to_a
14
+ ary.size.p_times(priority) do |i|
15
+ block.call(ary[i])
16
+ end
17
+ self
18
+ end
19
+
20
+ def p_each_index(priority=nil, &block)
21
+ ary = self.to_a
22
+ ary.size.p_times(priority) do |i|
23
+ block.call(i)
24
+ end
25
+ self
26
+ end
27
+
28
+ def p_each_with_index(priority=nil, &block)
29
+ ary = self.to_a
30
+ ary.size.p_times(priority) do |i|
31
+ block.call(ary[i], i)
32
+ end
33
+ self
34
+ end
35
+
36
+ def p_map(priority=nil, &block)
37
+ ary = self.to_a
38
+ result = Array.new(ary.size)
39
+ ary.p_each_with_index(priority) do |obj, i|
40
+ result[i] = block.call(obj)
41
+ end
42
+ result
43
+ end
44
+ alias :p_collect :p_map
45
+
46
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: motion-parallel
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Watson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: motion-parallel is parallel iterations for RubyMotion
28
+ email:
29
+ - watson1978@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - README.md
35
+ - lib/motion-parallel.rb
36
+ - lib/project/enumerable.rb
37
+ homepage: ''
38
+ licenses:
39
+ - MIT
40
+ metadata: {}
41
+ post_install_message:
42
+ rdoc_options: []
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ requirements: []
56
+ rubyforge_project:
57
+ rubygems_version: 2.2.2
58
+ signing_key:
59
+ specification_version: 4
60
+ summary: motion-parallel is parallel iterations for RubyMotion
61
+ test_files: []