barney 0.2.0 → 0.3.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.
data/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ 2011-01-16 Robert Gleeson <rob@flowof.info> v0.3.1
2
+
3
+ * Bug Fix(See GH-Issue 1)
4
+ * Process ID is available at Barney::Share#pid.
5
+
1
6
  2011-01-04 Robert Gleeson <rob@flowof.info> v0.2.0
2
7
 
3
8
  * Alias #synchronize as #sync.
data/README.md CHANGED
@@ -38,14 +38,15 @@ Okay, now that we've got that out of the way, let's see what using Barney is lik
38
38
 
39
39
  puts message * $times # output is 'boobooboo'.
40
40
 
41
- ### Documentation
41
+ ## Documentation
42
42
 
43
43
  **API**
44
44
 
45
+ * [master (git)](http://rubydoc.info/github/robgleeson/Barney/master/)
45
46
  * [0.2.0](http://rubydoc.info/gems/barney/0.2.0)
46
47
  * [0.1.0](http://rubydoc.info/gems/barney/0.1.0)
47
48
 
48
- ### Install
49
+ ## Install
49
50
 
50
51
  gem install barney
51
52
 
data/lib/barney/share.rb CHANGED
@@ -5,9 +5,9 @@ module Barney
5
5
  @mutex = Mutex.new
6
6
 
7
7
  class << self
8
- # Serves as a temporary holder for the latest value read from the child process.
9
- # @api private
10
- # @return [void]
8
+ # Serves as a temporary holder for the latest value read from the child process.
9
+ # @api private
10
+ # @return [Object] Returns Object or subclass of.
11
11
  attr_accessor :value
12
12
 
13
13
  # Serves as a lock when {Barney::Share.value Barney::Share.value} is being accessed by {Barney::Share#synchronize}
@@ -20,6 +20,10 @@ module Barney
20
20
  # @return [Array<Symbol>]
21
21
  attr_reader :shared
22
22
  def shared; @shared.keys; end
23
+
24
+ # Serves as a method that tells you the Process ID of the last forked child process.
25
+ # @return [Fixnum] Returns the Process ID as a Fixnum.
26
+ attr_reader :pid
23
27
 
24
28
  # @return [Barney::Share] Returns an instance of Barney::Share.
25
29
  def initialize
@@ -32,7 +36,7 @@ module Barney
32
36
  # @return [Array<Symbol>] Returns a list of all variables that are being shared.
33
37
  def share *variables
34
38
  variables.map(&:to_sym).each do |variable|
35
- @shared.store variable, IO.pipe
39
+ @shared.store variable, IO.pipe
36
40
  end
37
41
  @shared.keys
38
42
  end
@@ -59,16 +63,19 @@ module Barney
59
63
  def fork &blk
60
64
  raise ArgumentError, "A block or Proc object is expected" unless block_given?
61
65
 
62
- @context = blk.binding
63
- process_id = Kernel.fork do
66
+ share *@shared.keys if @pid
67
+
68
+ @context = blk.binding
69
+ @pid = Kernel.fork do
64
70
  blk.call
65
- @shared.each do |variable, pipes|
71
+ @shared.each do |variable, pipes|
66
72
  pipes[0].close
67
73
  pipes[1].write Marshal.dump(eval("#{variable}", @context))
68
74
  pipes[1].close
69
75
  end
70
76
  end
71
- process_id
77
+
78
+ @pid
72
79
  end
73
80
 
74
81
  # Serves as a method that synchronizes data between the parent and child process.
data/lib/barney.rb CHANGED
@@ -2,7 +2,7 @@ require('barney/share')
2
2
 
3
3
  module Barney
4
4
 
5
- VERSION = '0.2.0'
5
+ VERSION = '0.3.1'
6
6
 
7
7
  end
8
8
 
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
8
- - 0
9
- version: 0.2.0
7
+ - 3
8
+ - 1
9
+ version: 0.3.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Robert Gleeson
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-04 00:00:00 +00:00
17
+ date: 2011-01-16 00:00:00 +00:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -67,8 +67,8 @@ extra_rdoc_files: []
67
67
  files:
68
68
  - README.md
69
69
  - ChangeLog
70
- - lib/barney.rb
71
70
  - lib/barney/share.rb
71
+ - lib/barney.rb
72
72
  has_rdoc: true
73
73
  homepage: http://github.com/robgleeson/barney
74
74
  licenses: []