traffic_light_controller 0.0.1 → 0.0.3
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/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -4,13 +4,13 @@ module TrafficLightController
|
|
4
4
|
@config = Hashie::Mash.new(YAML.load_file('./config/config.yml'))
|
5
5
|
end
|
6
6
|
|
7
|
-
def method_missing(
|
8
|
-
return config[
|
7
|
+
def method_missing(method_name, *args, &block)
|
8
|
+
return config[method_name.to_s] if config.has_key?(method_name.to_s)
|
9
9
|
super
|
10
10
|
end
|
11
11
|
|
12
|
-
def respond_to?(
|
13
|
-
config.has_key?(
|
12
|
+
def respond_to?(method_name)
|
13
|
+
config.has_key?(method_name.to_s) || super
|
14
14
|
end
|
15
15
|
|
16
16
|
private
|
@@ -2,15 +2,13 @@ module TrafficLightController
|
|
2
2
|
class Server
|
3
3
|
|
4
4
|
def initialize
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
puts "Address not available"
|
13
|
-
end
|
5
|
+
Thread.abort_on_exception = true
|
6
|
+
@config = Config.new
|
7
|
+
@server = TCPServer.new(config.server.address, config.server.port)
|
8
|
+
rescue Errno::EADDRINUSE
|
9
|
+
puts "Address in use"
|
10
|
+
rescue Errno::EADDRNOTAVAIL, SocketError
|
11
|
+
puts "Address not available"
|
14
12
|
end
|
15
13
|
|
16
14
|
def work(run_forever = true)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: traffic_light_controller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|