domotics-core 0.1.10 → 0.2.0

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: 3a9249aba43383d48f079b2dff64a1bdf7803239
4
- data.tar.gz: e20bb0ea0ad164ee103333986f8011b583de25d8
3
+ metadata.gz: 0a8ed63671e10315d7088954915555a65e06f584
4
+ data.tar.gz: 0236feacef77fb06929960aef64ffe8ad76f420d
5
5
  SHA512:
6
- metadata.gz: d6e3337f02dc48e2590626dded52590fca8458f1c1d7463373dac6c49b3f649f0ed930d1429736a1f80a481b8b402f19d739b253865e5184adf91b13a3ea4001
7
- data.tar.gz: a2e1b441bc9da43fc6d7b56e5cf57f03e278daeda0c0c86ec6931292bae93d86146e232835bbf02d61c10b6e38e11042583c8061e703335dd35cb5924a681018
6
+ metadata.gz: c2bba5ade068a12ef7dab4397f98179034629fbd4f4f6941a9855ccd7ccca3d7b34ae9be38ea7d19010a1a6048b0308625a5ab9531e860d3085a1672357c191f
7
+ data.tar.gz: e803b482603d93d6b0a37f410165f6dbd36ba241d980c0dc9588cc70a2b52c14c64b236db118a0b7ed643c63bf7f5af6f462a5f4ef1789bb6621e8fd7d9ef032
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.add_runtime_dependency "bson_ext"
26
26
  spec.add_runtime_dependency "rack"
27
27
  spec.add_runtime_dependency "rb-inotify"
28
+ spec.add_runtime_dependency "em-websocket"
28
29
 
29
30
  spec.add_development_dependency "bundler"
30
31
  spec.add_development_dependency "rake"
@@ -13,6 +13,8 @@ require 'securerandom'
13
13
  require 'rb-inotify'
14
14
  # From server
15
15
  require 'json'
16
+ # From ws_server
17
+ require 'em-websocket'
16
18
 
17
19
  module Domotics
18
20
  module Core
@@ -6,9 +6,9 @@ Thread.class_eval do
6
6
  begin
7
7
  block.call
8
8
  rescue Exception => e
9
- $logger.error { e.message }
10
- $logger.debug { e.inspect }
11
- raise e
9
+ Domotics::Core::Setup.logger.error { e.message }
10
+ Domotics::Core::Setup.logger.debug { e }
11
+ nil
12
12
  end
13
13
  end
14
14
  end
@@ -1,7 +1,7 @@
1
1
  module Domotics::Core
2
2
  class Server
3
3
  def initialize(args = {})
4
- @logger = $logger || Logger.new(STDERR)
4
+ @logger = Domotics::Core::Setup.logger || Logger.new(STDERR)
5
5
  end
6
6
  def call(env)
7
7
  # [object]/[action]/[params]
@@ -4,15 +4,13 @@ module Domotics::Core
4
4
  class Setup < BasicObject
5
5
  @@logger = ::Logger.new(::STDERR)
6
6
  @@logger.level = ::Logger::FATAL
7
- $logger = @@logger
8
7
  def self.logger
9
8
  @@logger
10
9
  end
11
10
  def self.logger=(logger)
12
11
  @@logger = logger
13
- $logger = @@logger
14
12
  end
15
-
13
+
16
14
  def initialize(conf)
17
15
  @current_room = {}
18
16
  @current_device = {}
@@ -1,5 +1,6 @@
1
1
  module Domotics
2
2
  module Core
3
- VERSION = "0.1.10"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
6
+
@@ -0,0 +1,21 @@
1
+ module Domotics::Core
2
+ class WsServer
3
+ def initialize(args = {})
4
+ @args = args
5
+ @channel = EM::Channel.new
6
+ end
7
+ def run
8
+ EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 8080) do |ws|
9
+ ws.onopen do
10
+ sid = @channel.subscribe { |msg| ws.send msg }
11
+ ws.onmessage do |msg|
12
+
13
+ end
14
+ ws.onclose do
15
+ @channel.unsubscribe(sid)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,6 +1,10 @@
1
1
  module Domotics
2
2
  module FileCamera
3
3
  class CameraElement < Domotics::Core::Element
4
+ def initialize(args = {})
5
+ super
6
+ set_state @device.mode
7
+ end
4
8
  def image
5
9
  @device.current_link
6
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: domotics-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - goredar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-01 00:00:00.000000000 Z
11
+ date: 2014-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: domotics-arduino
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: em-websocket
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: bundler
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -197,6 +211,7 @@ files:
197
211
  - lib/domotics/core/server.rb
198
212
  - lib/domotics/core/setup.rb
199
213
  - lib/domotics/core/version.rb
214
+ - lib/domotics/core/ws_server.rb
200
215
  - lib/domotics/file_camera/camera_element.rb
201
216
  - lib/domotics/file_camera/digital_sensor.rb
202
217
  - test/config.test.rb