da_funk 1.4.1 → 1.4.2

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: 0d44ae33e7fa0e7a6d6c78ef44fc2312988f0edf
4
- data.tar.gz: a5779923dc64ff7c18877d591208399b58b7531b
3
+ metadata.gz: e2deca81b9c82dbcffb3f707550ad3cd63784362
4
+ data.tar.gz: aba07fa8b4ec242317d7c31efb73bdf6f80651c7
5
5
  SHA512:
6
- metadata.gz: 70bb506683c6f05418f9ef60ca01e53873596927ed8586721987847f8fb435dd68b35bae35bf5590f34926b4108d11b20602486c6db89a423e323c7747724bc8
7
- data.tar.gz: 2c83a78af55d08bc6b0045ac7a69e2d0f9651b6fdd6c9789ff14e70ad637f294bbcaa4363d92596d4c3573bce7b82b2631c762764eb16eb2d20171afceb07fdc
6
+ metadata.gz: f6f9b06820c97c1a4814c9fee6a8d423de1cdfe0099c725f44c1fcca83a3153e619eac4642017fc05b36d3235b3975463688cee70235f145feabc606ee3e1f82
7
+ data.tar.gz: 181cacd28882a28283227d4cc4a5c5d3d0b5f15d2c0d80ae743116ae5632b511d15ec80ab6d24f007da33e517b5c329eb26c6da0825e704e9831e06079a786b1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- da_funk (1.4.1)
4
+ da_funk (1.4.2)
5
5
  archive-zip (~> 0.5)
6
6
  bundler
7
7
  cloudwalk_handshake
@@ -27,7 +27,7 @@ GEM
27
27
  parallel (1.12.1)
28
28
  parser (2.4.0.2)
29
29
  ast (~> 2.3)
30
- posxml_parser (1.2.0)
30
+ posxml_parser (1.2.1)
31
31
  funky-emv (~> 0.3)
32
32
  powerpack (0.1.1)
33
33
  rainbow (3.0.0)
data/RELEASE_NOTES.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # DaFunk
2
2
 
3
+ ### 1.4.2 - 2018-01-17
4
+
5
+ - Extract background pagination helper.
6
+ - Refactoring menu helper to support footer, header
7
+ and background customization.
8
+
3
9
  ### 1.4.1 - 2018-01-17
4
10
 
5
11
  - Fix Notification parse to make communication management works.
@@ -170,14 +170,14 @@ module DaFunk
170
170
 
171
171
  # TODO Scalone: Refactor.
172
172
  def pagination(title, options, collection, &block)
173
- start_line, options[:limit] = pagination_limit(title, options[:limit])
173
+ start_line, options[:limit] = pagination_limit(title, options)
174
174
  if collection.size > (options[:limit] - 1) # minus pagination header
175
175
  key = Device::IO.back_key
176
176
  pages = pagination_page(collection, options[:limit] - 1) # minus pagination header
177
177
  page = 1
178
178
  while(key == Device::IO.back_key || key == Device::IO.forward_key)
179
179
  Device::Display.clear
180
- pagination_header(title, page, pages.size, start_line, options[:default])
180
+ pagination_header(title, page, pages.size, start_line, options[:default], options[:header])
181
181
  values = pages[page].to_a
182
182
  block.call(values, start_line+1)
183
183
  key = try_key(pagination_keys(values.size))
@@ -198,11 +198,13 @@ module DaFunk
198
198
  end
199
199
  end
200
200
 
201
- def pagination_header(title, page, pages, line, default)
201
+ def pagination_header(title, page, pages, line, default = nil, header = nil)
202
202
  print_title(title, default) if title
203
203
  back = Device::IO.back_key_label
204
204
  forward = Device::IO.forward_key_label
205
- Device::Display.print("< #{back} __ #{page}/#{pages} __ #{forward} >", line, 0)
205
+ if header || header.nil?
206
+ Device::Display.print("< #{back} __ #{page}/#{pages} __ #{forward} >", line, 0)
207
+ end
206
208
  end
207
209
 
208
210
  def pagination_key_page(page, key, size)
@@ -231,22 +233,25 @@ module DaFunk
231
233
  Device::IO::CANCEL, Device::IO.back_key, Device::IO.forward_key]
232
234
  end
233
235
 
234
- def pagination_limit(title, number = nil)
235
- start = title.nil? ? 0 : 1 # start in next line if title
236
+ def pagination_limit(title, options = {})
237
+ number = options[:limit]
238
+ unless (start = options[:start])
239
+ start = title.nil? ? 0 : 1 # start in next line if title
240
+ end
241
+
236
242
  if number
237
243
  limit = number
238
244
  else
239
- if STDOUT.max_y > 9
245
+ if STDOUT.max_y > (9 + start)
240
246
  limit = 9
241
247
  else
242
- if title.nil?
243
- limit = STDOUT.max_y
244
- else
245
- limit = STDOUT.max_y - 1 # minus title
246
- end
248
+ limit = STDOUT.max_y - start # minus title
247
249
  end
248
250
  end
249
- [start, limit]
251
+
252
+ footer = options[:footer] ? options[:footer] : 0
253
+
254
+ [start, limit - footer]
250
255
  end
251
256
 
252
257
  def number_to_currency(value, options = {})
@@ -305,8 +310,12 @@ module DaFunk
305
310
  options
306
311
  end
307
312
 
313
+ def pagination_bg_image(string)
314
+ string.to_s.downcase.include?(".bmp") && (path = "./shared/#{string}") && File.file?(path) && path
315
+ end
316
+
308
317
  def print_title(string, default)
309
- if string.to_s.downcase.include?(".bmp") && (path = "./shared/#{string}") && File.file?(path)
318
+ if path = pagination_bg_image(string)
310
319
  Device::Display.print_bitmap(path)
311
320
  else
312
321
  if default
@@ -1,4 +1,4 @@
1
1
  module DaFunk
2
- VERSION="1.4.1"
2
+ VERSION="1.4.2"
3
3
  end
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: da_funk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thiago Scalone