barney 0.9.1 → 0.10.0
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 +3 -0
- data/README.md +32 -7
- data/Rakefile +1 -0
- data/lib/barney/share.rb +8 -8
- data/lib/barney.rb +16 -2
- metadata +2 -2
data/ChangeLog
CHANGED
@@ -3,6 +3,9 @@
|
|
3
3
|
* lib/barney/share.rb:
|
4
4
|
Fix a bug where Barney::Share#share could return nil.
|
5
5
|
If there were no duplicates in @variables, `nil` would be returned.
|
6
|
+
|
7
|
+
* lib/barney.rb:
|
8
|
+
The Barney module proxies requests onto a Barney::Share object.
|
6
9
|
|
7
10
|
|
8
11
|
2011-04-21 Robert Gleeson <rob@flowof.info>
|
data/README.md
CHANGED
@@ -3,7 +3,8 @@
|
|
3
3
|
Barney tries to make the sharing of data between processes as easy and **natural** as possible.
|
4
4
|
Barney is developed to run on Ruby 1.9.1 or later, but it may work on earlier versions of Ruby as well.
|
5
5
|
|
6
|
-
|
6
|
+
Limitations
|
7
|
+
-----------
|
7
8
|
|
8
9
|
* Sharable objects
|
9
10
|
Behind the scenes, Barney is using Marshal to send data between processes.
|
@@ -16,12 +17,13 @@ Barney is developed to run on Ruby 1.9.1 or later, but it may work on earlier ve
|
|
16
17
|
There is a mutex lock in place, but it only concerns Barney::Share#synchronize, where data is shared
|
17
18
|
among all instances of Barney::Share.
|
18
19
|
|
19
|
-
|
20
|
+
Examples
|
21
|
+
--------
|
20
22
|
|
21
23
|
Okay, now that we've got that out of the way, let's see what using Barney is like:
|
22
24
|
(The [Samples](https://github.com/robgleeson/barney/tree/develop/samples) directory has more examples …)
|
23
25
|
|
24
|
-
**
|
26
|
+
**Barney::Share**
|
25
27
|
|
26
28
|
#!/usr/bin/env ruby
|
27
29
|
require 'barney'
|
@@ -40,7 +42,28 @@ Okay, now that we've got that out of the way, let's see what using Barney is lik
|
|
40
42
|
puts message # 'Hello, World!'
|
41
43
|
|
42
44
|
|
43
|
-
|
45
|
+
|
46
|
+
**Barney (Module)**
|
47
|
+
|
48
|
+
The Barney module will forward requests onto an instance of Barney::Share:
|
49
|
+
|
50
|
+
#!/usr/bin/env ruby
|
51
|
+
require 'barney'
|
52
|
+
|
53
|
+
Barney.share :name
|
54
|
+
name = 'Robert'
|
55
|
+
|
56
|
+
pid = Barney.fork do
|
57
|
+
name.slice! 0..2
|
58
|
+
end
|
59
|
+
|
60
|
+
Process.wait pid
|
61
|
+
Barney.sync
|
62
|
+
|
63
|
+
puts name # "Rob"
|
64
|
+
|
65
|
+
Install
|
66
|
+
--------
|
44
67
|
|
45
68
|
RubyGems.org
|
46
69
|
|
@@ -55,21 +78,23 @@ Github
|
|
55
78
|
|
56
79
|
I'm following the [Semantic Versioning](http://www.semver.org) policy.
|
57
80
|
|
58
|
-
|
81
|
+
Documentation
|
82
|
+
--------------
|
59
83
|
|
60
84
|
**API**
|
61
85
|
|
62
86
|
* [master (git)](http://rubydoc.info/github/robgleeson/barney/master/)
|
87
|
+
* [0.10.0](http://rubydoc.info/gems/barney/0.10.0/)
|
63
88
|
* [0.9.1](http://rubydoc.info/gems/barney/0.9.1/)
|
64
89
|
* [0.9.0](http://rubydoc.info/gems/barney/0.9.0/)
|
65
90
|
* [0.8.1](http://rubydoc.info/gems/barney/0.8.1/)
|
66
91
|
* [0.8.0](http://rubydoc.info/gems/barney/0.8.0/)
|
67
92
|
* [0.7.0](http://rubydoc.info/gems/barney/0.7.0)
|
68
|
-
* [0.6.0](http://rubydoc.info/gems/barney/0.6.0)
|
69
93
|
* …
|
70
94
|
|
71
95
|
|
72
|
-
|
96
|
+
License
|
97
|
+
--------
|
73
98
|
|
74
99
|
Barney is released under the Lesser GPL(LGPL).
|
75
100
|
|
data/Rakefile
CHANGED
data/lib/barney/share.rb
CHANGED
@@ -26,7 +26,7 @@ module Barney
|
|
26
26
|
attr_reader :mutex
|
27
27
|
end
|
28
28
|
|
29
|
-
# Returns a list of all variables or constants being shared for
|
29
|
+
# Returns a list of all variables or constants being shared for an instance of {Barney::Share}.
|
30
30
|
# @return [Array<Symbol>]
|
31
31
|
attr_reader :variables
|
32
32
|
|
@@ -50,8 +50,8 @@ module Barney
|
|
50
50
|
end
|
51
51
|
|
52
52
|
# Marks a variable or constant to be shared between two processes.
|
53
|
-
# @param [Symbol]
|
54
|
-
# @return [Array<Symbol>]
|
53
|
+
# @param [Symbol, #to_sym] Variable Accepts the name(s) of the variables or constants you want to share.
|
54
|
+
# @return [Array<Symbol>] Returns a list of all variables that are being shared.
|
55
55
|
def share *variables
|
56
56
|
@variables.push *variables.map(&:to_sym)
|
57
57
|
@variables.uniq!
|
@@ -59,8 +59,8 @@ module Barney
|
|
59
59
|
end
|
60
60
|
|
61
61
|
# Removes a variable or constant from being shared between two processes.
|
62
|
-
# @param [Symbol] Variable
|
63
|
-
# @return [Array<Symbol>]
|
62
|
+
# @param [Symbol, #to_sym] Variable Accepts the name(s) of the variables or constants you want to stop sharing.
|
63
|
+
# @return [Array<Symbol>] Returns a list of the variables that are still being shared.
|
64
64
|
def unshare *variables
|
65
65
|
variables.map(&:to_sym).each do |variable|
|
66
66
|
@streams.delete_if { |stream| stream.variable == variable }
|
@@ -104,9 +104,9 @@ module Barney
|
|
104
104
|
value = eval "#{stream.variable} = Barney::Share.value", @context
|
105
105
|
@history.push HistoryItem.new(stream.variable, value)
|
106
106
|
end
|
107
|
-
|
108
|
-
|
109
|
-
|
107
|
+
|
108
|
+
@streams.clear
|
109
|
+
end
|
110
110
|
end
|
111
111
|
alias_method :sync, :synchronize
|
112
112
|
|
data/lib/barney.rb
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
require 'barney/share'
|
2
2
|
|
3
3
|
module Barney
|
4
|
-
VERSION = '0.9.1'
|
5
|
-
end
|
6
4
|
|
5
|
+
VERSION = '0.10.0'
|
6
|
+
@proxy = Barney::Share.new
|
7
|
+
|
8
|
+
class << self
|
9
|
+
|
10
|
+
def method_missing meth, *args, &blk
|
11
|
+
if @proxy.respond_to? meth
|
12
|
+
@proxy.send meth, *args, &blk
|
13
|
+
else
|
14
|
+
super
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: barney
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.10.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Robert Gleeson
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-04-
|
13
|
+
date: 2011-04-25 00:00:00 +01:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|