da_funk 0.4.18 → 0.4.19

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a5fab758ef2648e1788ea84950b7bf6cf831b14
4
- data.tar.gz: 832c818da5391f1ba9be48227d43cac80866bae9
3
+ metadata.gz: 581959a05ca363df037b218fb049a1337a05458e
4
+ data.tar.gz: bc09d913c2a3d7d25607ff173951d267c319f6f5
5
5
  SHA512:
6
- metadata.gz: 20827c1f82448753380b6cefe12ebf9485bc67a53cc1f00067ba4f16beba581725772bd302a25109f740a803a8aec286102dc3e7fa20c09ff815f83910ead73a
7
- data.tar.gz: 1bdeeff9b3c250cc6ec7aa7875fb7b5873cf75652a9016c2e01dcc1b6df091ea0e4c32dcf3697b50d1b8e8cb2e3ca000df6d6e956ac4ea107dbdbd7cf081dc9e
6
+ metadata.gz: 3b7ca6e71008e7dd5962e83d59179246381ada0c227c56334cab6ea449226c8f4adb8784d9d7035a7dd4a470781d7785529207dbe0230d47e446b375b3d72b84
7
+ data.tar.gz: daea05521a99d66a8a3143941f1be5e7707447999003c4fe5d576bbd7cb9a2ee2db3e9883973481499c4976800ccc5ba3343d060e0afd6bcd13e676ccf2e0ccf
@@ -7,7 +7,7 @@ GIT
7
7
  PATH
8
8
  remote: .
9
9
  specs:
10
- da_funk (0.4.18)
10
+ da_funk (0.4.19)
11
11
  bundler (~> 1.7)
12
12
  cloudwalk_handshake (~> 0.4)
13
13
  rake (~> 10.4)
@@ -16,7 +16,7 @@ PATH
16
16
  GEM
17
17
  remote: https://rubygems.org/
18
18
  specs:
19
- cloudwalk_handshake (0.4.6)
19
+ cloudwalk_handshake (0.4.7)
20
20
  rake (10.4.2)
21
21
  yard (0.8.7.6)
22
22
 
@@ -1,5 +1,11 @@
1
1
  # DaFunk
2
2
 
3
+ ### 0.4.19 - 2015-12-04 - Refactoring Device::Setting.to_production!/.to_staging!
4
+ - Implement FileDb#update_attributes to update more than one key in a unique save.
5
+ - Refactoring Device::Setting.to_production!/.to_staging! to clean company_name if the last environment is different.
6
+ - Update cloudwalk_handshake version to 0.4.7.
7
+ - Fix debug flag setup to check if is_a? FalseClass class to define true/false.
8
+
3
9
  ### 0.4.18 - 2015-12-03 - Automatically configure Application running
4
10
  - Automatically configure Application running.
5
11
 
@@ -15,7 +15,7 @@ module DaFunk
15
15
  def initialize
16
16
  yield self if block_given?
17
17
 
18
- @debug ||= true
18
+ @debug = @debug.is_a?(FalseClass) ? false : true
19
19
  @libs ||= FileList['lib/**/*.rb']
20
20
  @tests ||= FileList['test/**/*test.rb']
21
21
  @tests_integration ||= FileList['test/integration/**/*test.rb']
@@ -109,11 +109,15 @@ class Device
109
109
 
110
110
  def create_fiber
111
111
  Fiber.new do
112
- auth = CloudwalkTOTP.at
113
- Serfx.connect(authkey: auth, socket_block: Device::Network.socket, timeout: timeout, stream_timeout: stream_timeout) do |conn|
114
- conn.stream(subscription) { |ev| reply(conn, ev) }
112
+ begin
113
+ auth = CloudwalkTOTP.at
114
+ Serfx.connect(authkey: auth, socket_block: Device::Network.socket, timeout: timeout, stream_timeout: stream_timeout) do |conn|
115
+ conn.stream(subscription) { |ev| reply(conn, ev) }
116
+ end
117
+ true
118
+ rescue => RPCError
119
+ false
115
120
  end
116
- true
117
121
  end
118
122
  end
119
123
 
@@ -124,20 +128,6 @@ class Device
124
128
  def event_name
125
129
  "#{Device::Setting.company_name};#{Device::Setting.logical_number}"
126
130
  end
127
-
128
- def socket_callback
129
- Proc.new do
130
- socket_tcp = Device::Network.create_socket
131
- socket_tcp.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true)
132
-
133
- if Device::Setting.ssl == "1"
134
- socket = Device::Network.handshake_ssl(socket_tcp)
135
- else
136
- socket = socket_tcp
137
- end
138
- [socket, socket_tcp]
139
- end
140
- end
141
131
  end
142
132
  end
143
133
 
@@ -61,12 +61,20 @@ class Device
61
61
  self.environment == "staging"
62
62
  end
63
63
 
64
- def self.to_production!
65
- self.host = HOST_PRODUCTION
64
+ def self.to_production!
65
+ if self.environment != "production"
66
+ @file.update_attributes("company_name" => "", "environment" => "production", "host" => HOST_PRODUCTION)
67
+ return true
68
+ end
69
+ false
66
70
  end
67
71
 
68
72
  def self.to_staging!
69
- self.host = HOST_STAGING
73
+ if self.environment != "staging"
74
+ @file.update_attributes("company_name" => "", "environment" => "staging", "host" => HOST_STAGING)
75
+ return true
76
+ end
77
+ false
70
78
  end
71
79
 
72
80
  def self.method_missing(method, *args, &block)
@@ -1,6 +1,6 @@
1
1
 
2
2
  class Device
3
- API_VERSION="0.4.18"
3
+ API_VERSION="0.4.19"
4
4
 
5
5
  def self.api_version
6
6
  Device::API_VERSION
@@ -45,6 +45,13 @@ class FileDb
45
45
  @hash[key]
46
46
  end
47
47
 
48
+ def update_attributes(values = Hash.new)
49
+ values.each do |key, value|
50
+ @hash[key] = value
51
+ end
52
+ save
53
+ end
54
+
48
55
  private
49
56
  def sanitize(string)
50
57
  new_string = string.to_s.strip
@@ -65,13 +65,16 @@ module Serfx
65
65
  def read_data(read_timeout = self.timeout)
66
66
  buf = read_buffer(read_timeout)
67
67
  return if buf.nil?
68
+ parse_package(buf)
69
+ end
68
70
 
69
- # TODO Check first and second(header and body) packet size
70
- first_packet, second_packet = buf[0..12], buf[13..-1]
71
- if second_packet.nil? || second_packet.empty?
72
- [MessagePack.unpack(first_packet), nil]
71
+ def parse_package(buf)
72
+ object = MessagePack.unpack(buf)
73
+ check = MessagePack.pack(object)
74
+ if check.size == buf.size
75
+ [object, nil]
73
76
  else
74
- [MessagePack.unpack(first_packet), MessagePack.unpack(second_packet)]
77
+ [object, MessagePack.unpack(buf[check.size..-1])]
75
78
  end
76
79
  end
77
80
 
@@ -7,10 +7,8 @@ require 'da_funk'
7
7
 
8
8
  DaFunk::Test.configure do |t|
9
9
  t.root_path = ROOT_PATH
10
- t.serial = "0000000001"
11
- t.logical_number = "001"
10
+ t.serial = "0000011700025246"
11
+ t.logical_number = "002"
12
12
  t.name = APP_NAME
13
13
  end
14
14
 
15
- Device::Setting.to_staging!
16
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: da_funk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.18
4
+ version: 0.4.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thiago Scalone
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-03 00:00:00.000000000 Z
11
+ date: 2015-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake