wires 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe29f3e409b25c86e97fbf9a3fee96713d1cb5a6
4
- data.tar.gz: 579b5558cfd68bc598d58d59ce6244d62f5cdafe
3
+ metadata.gz: 8d9d25b472a5b695894bd0ac5f39d95f637c49f2
4
+ data.tar.gz: 14409acc61b2b8dcfd68a5a69453c96eec78960b
5
5
  SHA512:
6
- metadata.gz: ec044b26ff4fd30985d140c6024aa2065dad8afdd0c600cba2aa9cc2d15c239247b1f2e580f90c34fd549afaf99615b645791a19304f2949b794f85f5686b5e2
7
- data.tar.gz: cbdbf46e3a314b075b404c2536cc9a78866b14f9b4020d5954d07395b271561619117de6949bb77ed751614b159235320e9745f20aae068d82b0cfd9423e8fd1
6
+ metadata.gz: 6b0f002d2346c8c0fe1e91fbedcb4ef4aa3faaef06a479154a893930614f5b7474629bc852b7bd0471ddf427b85889cf7de804a48c891a4254fa03f1304063bd
7
+ data.tar.gz: 8163af3fc07e3d2da2136adbefff6b2523729aeb97ecfec8556a19b88db011fca4d39be4ae65d9ea78abe1ecc47aaabf03cee285c3e8878cd519bf9eb9df2129
data/lib/wires/base.rb CHANGED
@@ -2,13 +2,54 @@
2
2
  require 'thread'
3
3
  require 'threadlock'
4
4
 
5
- require_relative 'base/util/hooks'
6
- require_relative 'base/util/build_alt'
7
-
8
- require_relative 'base/event'
9
- require_relative 'base/hub'
10
- require_relative 'base/router'
11
- require_relative 'base/channel'
12
- require_relative 'base/time_scheduler_item'
13
- require_relative 'base/time_scheduler'
14
- require_relative 'base/convenience'
5
+
6
+ module Wires
7
+ def self.network(id=:main)
8
+ @networks ||= {main:Wires}
9
+
10
+ @networks[id] = Module.new \
11
+ unless @networks.has_key? id
12
+ @networks[id].const_set :Namespace, @networks[id] \
13
+ unless @networks[id].const_defined? :Namespace
14
+
15
+ return @networks[id]
16
+ end
17
+
18
+ def self.set_current_network(*args)
19
+ @current_network = network(*args)
20
+ end
21
+
22
+ def self.current_network_name
23
+ @networks.each_pair.select{ |k,v| v==@current_network }.first.first
24
+ end
25
+
26
+ def self.current_network
27
+ @current_network ||= network
28
+ end
29
+
30
+ def self.replicate
31
+ save_name = Wires.current_network_name
32
+ other = Wires.set_current_network Object.new
33
+
34
+ load __FILE__
35
+
36
+ Wires.set_current_network save_name
37
+ return other
38
+ end
39
+ end
40
+
41
+
42
+ loader = Proc.new do |path|
43
+ load File.expand_path(path+'.rb', File.dirname(__FILE__))
44
+ end
45
+
46
+ loader.call 'base/util/hooks'
47
+ loader.call 'base/util/build_alt'
48
+
49
+ loader.call 'base/event'
50
+ loader.call 'base/hub'
51
+ loader.call 'base/router'
52
+ loader.call 'base/channel'
53
+ loader.call 'base/time_scheduler_item'
54
+ loader.call 'base/time_scheduler'
55
+ loader.call 'base/convenience'
@@ -1,5 +1,5 @@
1
1
 
2
- module Wires
2
+ module Wires.current_network::Namespace
3
3
 
4
4
  #
5
5
  #
@@ -1,5 +1,5 @@
1
1
 
2
- module Wires
2
+ module Wires.current_network::Namespace
3
3
 
4
4
  module Convenience
5
5
 
@@ -1,5 +1,5 @@
1
1
 
2
- module Wires
2
+ module Wires.current_network::Namespace
3
3
 
4
4
  class Event
5
5
  attr_accessor :type
@@ -1,5 +1,5 @@
1
1
 
2
- module Wires
2
+ module Wires.current_network::Namespace
3
3
  # An Event Hub. Event/proc associations come in, and the procs
4
4
  # get called in new threads in the order received
5
5
  class Hub
@@ -1,5 +1,5 @@
1
1
 
2
- module Wires
2
+ module Wires.current_network::Namespace
3
3
  module Router
4
4
 
5
5
  class Default
@@ -1,5 +1,5 @@
1
1
 
2
- module Wires
2
+ module Wires.current_network::Namespace
3
3
 
4
4
  # A singleton class to schedule future firing of events
5
5
  class TimeScheduler
@@ -1,5 +1,5 @@
1
1
 
2
- module Wires
2
+ module Wires.current_network::Namespace
3
3
 
4
4
  class TimeSchedulerItem
5
5
 
@@ -84,6 +84,7 @@ module Wires
84
84
 
85
85
  # Lock some of the methods to try to make them atomic
86
86
  # Must exclude methods that get called from within the TimeScheduler lock
87
+ include Threadlock
87
88
  threadlock :fire,
88
89
  :count=,
89
90
  :count_inc,
@@ -1,5 +1,5 @@
1
1
 
2
- module Wires
2
+ module Wires.current_network::Namespace
3
3
  module Util
4
4
 
5
5
  # Build an alternate version of the Wires module that doesn't
@@ -8,16 +8,10 @@ module Wires
8
8
  # >> module MyModule; end
9
9
  # >> Wires::Util.build_alt "::MyModule::MyWires"
10
10
  def self.build_alt(module_path)
11
- main_file = File.expand_path("../../base.rb", File.dirname(__FILE__))
12
-
13
- File.read(main_file)
14
- .scan(/require_relative[\s\(]+(["'])(.*)\1/)
15
- .map(&:last)
16
- .map { |file| File.expand_path("#{file}.rb", File.dirname(main_file)) }
17
- .map { |file| File.read file }
18
- .each { |code| eval code.gsub("Wires", "#{module_path}") }
19
-
20
- eval "#{module_path}"
11
+ warn "DEPRECATED: Wires::Util.build_alt('::MyModule::MyWires')"\
12
+ " is deprecated, and will be removed in version 0.6."\
13
+ " Please use ::MyModule::MyWires=Wires.replicate"
14
+ eval "#{module_path} = Wires.replicate"
21
15
  end
22
16
 
23
17
  end
@@ -1,5 +1,5 @@
1
1
 
2
- module Wires
2
+ module Wires.current_network::Namespace
3
3
  module Util
4
4
  module Hooks
5
5
 
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wires
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe McIlvain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-09 00:00:00.000000000 Z
11
+ date: 2013-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: threadlock
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '1.2'
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: '1.2'
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +53,7 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: rdoc
56
+ name: rb-readline
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="