da_funk 2.6.0 → 2.7.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dc30826554a11dfaf3bbb100d86d787684418e0c
4
- data.tar.gz: 0fbdfdd49b382a5e542c6020f9cd9d05f06451eb
3
+ metadata.gz: 1a9b18a63ef6156f2c772c44cf926521b453cd1e
4
+ data.tar.gz: 55670ae7ca118b9d79b93ccfa8a1d6979b508bfa
5
5
  SHA512:
6
- metadata.gz: 1a73f1e049079c3df3969534c161777701857e62db34baab0ff1aead39335617a11c0e178f17e611337daf225eeeb588b476756cf5c13eea1a07a64cc68c431a
7
- data.tar.gz: 9259b39ec57cb2e4a41f87e16a5a1e38fae4d3849cfa886eb69380df4e2bea21c999386b324685fba0e15502ea8a58caec7c426e93f6e27e0fb21e2c50464462
6
+ metadata.gz: '091b2c8dde539fd1cb97fd003e5f1e1cf95e63df0c11b90d514379b035e2d23140c49b5aac03a293af865daf30fce329bf57b3325e6448722d4ff2f0555fe246'
7
+ data.tar.gz: fa45b38e6cd37cfd121d021863237f16b52baa24c7c8d9735a4459c0931be63cd9da9ef7b3f0a401da367a373360d82039ef45a71e93fed6d4bc5e13e5c19af0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- da_funk (2.6.0)
4
+ da_funk (2.7.0)
5
5
  archive-zip (~> 0.5)
6
6
  bundler
7
7
  cloudwalk_handshake
@@ -28,7 +28,7 @@ GEM
28
28
  parallel (1.13.0)
29
29
  parser (2.6.0.0)
30
30
  ast (~> 2.4.0)
31
- posxml_parser (2.13.1)
31
+ posxml_parser (2.14.0)
32
32
  funky-emv (~> 0.3)
33
33
  powerpack (0.1.2)
34
34
  rainbow (3.0.0)
data/RELEASE_NOTES.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # DaFunk
2
2
 
3
+ ### 2.7.0 - 2019-02-16
4
+
5
+ - Execute ThreadScheduler::keep_alive every engine check
6
+ - Refresh every file on every FileDb set method if key is boot, this is a temporary fix to avoid edit problem between threads;
7
+ - Add Device::Setting attributes, payment_channel_attempts - To count channels in a day; payment_channel_date - Connection day;
8
+ - Implement Device::Setting::payment_channel_set_attempts, it’s a simple helper to set both payment_channel_date and payment_channel_attempts;
9
+ - Implement channel connection limit configuration.
10
+
3
11
  ### 2.6.0 - 2019-02-14
4
12
 
5
13
  - Support to Device::Runtime::reload on Engine stop.
@@ -2,6 +2,7 @@ module DaFunk
2
2
  class Engine
3
3
  def self.check
4
4
  DaFunk::EventListener.check
5
+ ThreadScheduler.keep_alive
5
6
  end
6
7
 
7
8
  def self.app_loop(&block)
@@ -52,19 +52,41 @@ module DaFunk
52
52
  end
53
53
  end
54
54
 
55
+ def self.payment_channel_limit?
56
+ DaFunk::ParamsDat.exists? && DaFunk::ParamsDat.file["payment_channel_check_limit"] != "0"
57
+ end
58
+
59
+ def self.payment_channel_limit
60
+ if DaFunk::ParamsDat.exists?
61
+ DaFunk::ParamsDat.file["payment_channel_limit"].to_i
62
+ else
63
+ 0
64
+ end
65
+ end
66
+
67
+ def self.channel_limit_exceed?
68
+ if payment_channel_limit?
69
+ payment_channel_limit <= Device::Setting.payment_channel_attempts.to_i
70
+ else
71
+ false
72
+ end
73
+ end
74
+
55
75
  def self.check(display_message = true)
56
- if self.dead?
57
- PaymentChannel.connect(display_message)
58
- if @client
59
- self.print_info(I18n.t(:attach_waiting), display_message)
60
- if message = @client.check || @client.handshake?
61
- self.print_info(I18n.t(:attach_connected), display_message)
62
- message
76
+ if self.dead?
77
+ unless self.channel_limit_exceed?
78
+ PaymentChannel.connect(display_message)
79
+ if @client
80
+ self.print_info(I18n.t(:attach_waiting), display_message)
81
+ if message = @client.check || @client.handshake?
82
+ self.print_info(I18n.t(:attach_connected), display_message)
83
+ message
84
+ else
85
+ self.error
86
+ end
63
87
  else
64
88
  self.error
65
89
  end
66
- else
67
- self.error
68
90
  end
69
91
  else
70
92
  if @client
@@ -91,11 +113,27 @@ module DaFunk
91
113
  print_last(message) if display
92
114
  end
93
115
 
94
- def self.create
95
- if @client == Context::CommunicationChannel
96
- @client = Context::CommunicationChannel
116
+ def self.payment_channel_increment_attempts
117
+ number = Device::Setting.payment_channel_attempts.to_i
118
+ date = Device::Setting.payment_channel_date
119
+ if date.to_s.empty?
120
+ Device::Setting.payment_channel_set_attempts(Time.now)
97
121
  else
122
+ year, mon, day = date.split("-")
123
+ if day.to_i == Time.now.day
124
+ Device::Setting.payment_channel_set_attempts(nil, number + 1)
125
+ else
126
+ Device::Setting.payment_channel_set_attempts(Time.now)
127
+ end
128
+ end
129
+ end
130
+
131
+ def self.create
132
+ if @client != Context::CommunicationChannel
133
+ payment_channel_increment_attempts
98
134
  @client = PaymentChannel.new
135
+ else
136
+ @client.connect
99
137
  end
100
138
  end
101
139
 
@@ -1,4 +1,4 @@
1
1
  module DaFunk
2
- VERSION="2.6.0"
2
+ VERSION="2.7.0"
3
3
  end
4
4
 
@@ -18,7 +18,7 @@ class Device
18
18
  "sim_pin" => "", #GPRS
19
19
  "sim_slot" => "0", #GPRS
20
20
  "sim_dual" => "0", #GPRS
21
- "wifi_password" => "", #WIFI
21
+ "wifi_password" => "", #WIFI
22
22
  "authentication" => "", #WIFI
23
23
  "essid" => "", #WIFI
24
24
  "bssid" => "", #WIFI
@@ -54,7 +54,9 @@ class Device
54
54
  "heartbeat" => "", #SYS
55
55
  "boot" => "1", #SYS
56
56
  "company_name" => "", #SYS
57
- "metadata_timestamp" => ""
57
+ "metadata_timestamp" => "",
58
+ "payment_channel_attempts" => "0",
59
+ "payment_channel_date" => ""
58
60
  }
59
61
 
60
62
  class << self
@@ -120,6 +122,21 @@ class Device
120
122
  end
121
123
  end
122
124
 
125
+ # helper
126
+ def self.payment_channel_set_attempts(time = nil, attempts = nil)
127
+ if time
128
+ str = "%d-%02d-%02d"
129
+ update_attributes({
130
+ "payment_channel_date" => (str % [time.year, time.mon, time.day]),
131
+ "payment_channel_attempts" => (attempts || 1)
132
+ })
133
+ else
134
+ update_attributes({
135
+ "payment_channel_attempts" => (attempts || 1)
136
+ })
137
+ end
138
+ end
139
+
123
140
  # Custom Attributes
124
141
  def self.tcp_recv_timeout
125
142
  DaFunk::ParamsDat.file["tcp_recv_timeout"] || method_missing(:tcp_recv_timeout)
data/lib/file_db.rb CHANGED
@@ -41,6 +41,9 @@ class FileDb
41
41
 
42
42
  def []=(key, value)
43
43
  value = value.to_s
44
+ # reload if boot is key to avoid initial change problem between threads
45
+ # TODO: Refactoring config.dat handling between threads
46
+ open if key == "boot"
44
47
  old = @hash[key.to_s]
45
48
  ret = @hash[key.to_s] = value
46
49
  save if old != value
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: 2.6.0
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thiago Scalone
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-15 00:00:00.000000000 Z
11
+ date: 2019-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake