ehbrs_ruby_utils 0.24.1 → 0.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ehbrs_ruby_utils/bga/table_whatsapp_formatter/format_option.rb +18 -0
- data/lib/ehbrs_ruby_utils/bga/table_whatsapp_formatter/format_player.rb +30 -0
- data/lib/ehbrs_ruby_utils/bga/table_whatsapp_formatter.rb +66 -0
- data/lib/ehbrs_ruby_utils/version.rb +1 -1
- metadata +13 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bf7c3e4429f41191524b18b9d208696ff51c8758af361ed718e3234ebcdc74a
|
4
|
+
data.tar.gz: 5f15d68339789d7a1d3a101763f3509d425e484b185b93aba23675962abcd99e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43a6c2d7ef864aad1c3a0876e6a1d2a8ea7a710c33d93a424f10a3f995b2a470c10750bc553a954cb3fc2168e6aca08b41b9abd6497d07a33db97c99f95a0676
|
7
|
+
data.tar.gz: 6b0f6f13cdca5b13938068eb9d9c2d2def16e2e7f0f79c74eae5c6c9c5d8a827303258db7b2b1c183db1cdba0e947f25aaf9a8f2a705d3ab96ed70162e95b57a
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EhbrsRubyUtils
|
6
|
+
module Bga
|
7
|
+
class TableWhatsappFormatter
|
8
|
+
class FormatOption
|
9
|
+
enable_method_class
|
10
|
+
common_constructor :table_formatter, :option
|
11
|
+
|
12
|
+
def result
|
13
|
+
"*#{option.label}:* #{option.value}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EhbrsRubyUtils
|
6
|
+
module Bga
|
7
|
+
class TableWhatsappFormatter
|
8
|
+
class FormatPlayer
|
9
|
+
enable_method_class
|
10
|
+
common_constructor :table_formatter, :player
|
11
|
+
|
12
|
+
FIELD_SEPARATOR = ' - '
|
13
|
+
|
14
|
+
def result
|
15
|
+
%w[table_rank name score].map { |v| send(v) }.join(FIELD_SEPARATOR)
|
16
|
+
end
|
17
|
+
|
18
|
+
def table_rank
|
19
|
+
"*#{player.table_rank}º*"
|
20
|
+
end
|
21
|
+
|
22
|
+
delegate :name, to: :player
|
23
|
+
|
24
|
+
def score
|
25
|
+
"⭐ #{player.score}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ehbrs_ruby_utils/bga/session'
|
4
|
+
require 'ehbrs_ruby_utils/executables'
|
5
|
+
require 'eac_ruby_utils/core_ext'
|
6
|
+
|
7
|
+
module EhbrsRubyUtils
|
8
|
+
module Bga
|
9
|
+
class TableWhatsappFormatter
|
10
|
+
enable_simple_cache
|
11
|
+
common_constructor :table
|
12
|
+
|
13
|
+
TITLE_BEFORE = 0x22D8.chr(::Encoding::UTF_8) + ' '
|
14
|
+
TITLE_AFTER = ' ' + 0x22D9.chr(::Encoding::UTF_8)
|
15
|
+
|
16
|
+
ROOT_ITENS = {
|
17
|
+
'Jogo' => :game_name,
|
18
|
+
'Criada em' => :creation_time,
|
19
|
+
'Duração' => :estimated_duration,
|
20
|
+
'Endereço' => :url
|
21
|
+
}.freeze
|
22
|
+
SECTION_SEPARATOR = "\n\n"
|
23
|
+
|
24
|
+
def perform
|
25
|
+
infov 'Fetching table', table_id
|
26
|
+
infov 'Message', "<<<EOS\n#{to_message}\nEOS\n"
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_s
|
30
|
+
[root_items_to_s, players_to_s, options_to_s].map(&:strip).join(SECTION_SEPARATOR)
|
31
|
+
end
|
32
|
+
|
33
|
+
def root_items_to_s
|
34
|
+
title_to_s('Mesa terminada') + ROOT_ITENS.map { |k, v| "*#{k}*: #{table.send(v)}" }
|
35
|
+
.join("\n")
|
36
|
+
end
|
37
|
+
|
38
|
+
# @return [String]
|
39
|
+
def game_conceded_to_s
|
40
|
+
table.game_conceded? ? "*Derrota admitida*\n\n" : ''
|
41
|
+
end
|
42
|
+
|
43
|
+
def players_to_s
|
44
|
+
title_to_s('Resultado') + game_conceded_to_s + players.join("\n")
|
45
|
+
end
|
46
|
+
|
47
|
+
def options_to_s
|
48
|
+
title_to_s('Opções') + options.join("\n")
|
49
|
+
end
|
50
|
+
|
51
|
+
def title_to_s(title)
|
52
|
+
"*#{TITLE_BEFORE}#{title}#{TITLE_AFTER}*\n\n"
|
53
|
+
end
|
54
|
+
|
55
|
+
def players
|
56
|
+
table.players.map { |player| format_player(player) }
|
57
|
+
end
|
58
|
+
|
59
|
+
def options
|
60
|
+
table.options.map { |player| format_option(player) }
|
61
|
+
end
|
62
|
+
|
63
|
+
require_sub __FILE__, require_mode: :kernel
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ehbrs_ruby_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.25.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo H. Bogoni
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aranha
|
@@ -37,6 +37,9 @@ dependencies:
|
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '0.19'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.19.1
|
40
43
|
type: :runtime
|
41
44
|
prerelease: false
|
42
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -44,20 +47,23 @@ dependencies:
|
|
44
47
|
- - "~>"
|
45
48
|
- !ruby/object:Gem::Version
|
46
49
|
version: '0.19'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.19.1
|
47
53
|
- !ruby/object:Gem::Dependency
|
48
54
|
name: avm
|
49
55
|
requirement: !ruby/object:Gem::Requirement
|
50
56
|
requirements:
|
51
57
|
- - "~>"
|
52
58
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0.
|
59
|
+
version: '0.76'
|
54
60
|
type: :runtime
|
55
61
|
prerelease: false
|
56
62
|
version_requirements: !ruby/object:Gem::Requirement
|
57
63
|
requirements:
|
58
64
|
- - "~>"
|
59
65
|
- !ruby/object:Gem::Version
|
60
|
-
version: '0.
|
66
|
+
version: '0.76'
|
61
67
|
- !ruby/object:Gem::Dependency
|
62
68
|
name: eac_fs
|
63
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -210,6 +216,9 @@ files:
|
|
210
216
|
- lib/ehbrs_ruby_utils/bga/table.rb
|
211
217
|
- lib/ehbrs_ruby_utils/bga/table/option.rb
|
212
218
|
- lib/ehbrs_ruby_utils/bga/table/player.rb
|
219
|
+
- lib/ehbrs_ruby_utils/bga/table_whatsapp_formatter.rb
|
220
|
+
- lib/ehbrs_ruby_utils/bga/table_whatsapp_formatter/format_option.rb
|
221
|
+
- lib/ehbrs_ruby_utils/bga/table_whatsapp_formatter/format_player.rb
|
213
222
|
- lib/ehbrs_ruby_utils/bga/urls.rb
|
214
223
|
- lib/ehbrs_ruby_utils/circular_list_spreader.rb
|
215
224
|
- lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb
|