ehbrs_ruby_utils 0.31.0 → 0.32.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 +4 -4
- data/lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/base/format_option.rb +22 -0
- data/lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/base/format_player.rb +27 -0
- data/lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/base.rb +68 -0
- data/lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/beginning/format_player.rb +24 -0
- data/lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/beginning.rb +35 -0
- data/lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/ending/format_player.rb +32 -0
- data/lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/ending.rb +45 -0
- data/lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters.rb +13 -0
- data/lib/ehbrs_ruby_utils/gjt1/manager.rb +8 -5
- data/lib/ehbrs_ruby_utils/version.rb +1 -1
- metadata +11 -12
- data/lib/ehbrs_ruby_utils/bga/table_whatsapp_formatter/format_option.rb +0 -18
- data/lib/ehbrs_ruby_utils/bga/table_whatsapp_formatter/format_player.rb +0 -30
- data/lib/ehbrs_ruby_utils/bga/table_whatsapp_formatter.rb +0 -66
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bfa52ff0a0f148ccb210785d37954b3b3e3e991a4fb3517bb78d23bc1a683c9
|
4
|
+
data.tar.gz: cc72969d634c6153c8841507fdc7582d1e004b52af6f6d6d1fc6cce0b5fff113
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf06db90d4000d4a320e1832e1d02700d3c6d6ce302a1a47699dd5744a03aa07d3635389b56f4890ffb74e715842d0d4623143dc36ed01aceb5614a19e845723
|
7
|
+
data.tar.gz: ca8701c99fb083ff76ae8aad14cfd0e94f36f9e414e5a6fd570755dfe0e4feab816eeaf2ff98817f45db1e2a4ba14d8c60aa9ff756ccebf473ce2ebffea19d62
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EhbrsRubyUtils
|
6
|
+
module Bga
|
7
|
+
class Table
|
8
|
+
module WhatsappFormatters
|
9
|
+
class Base
|
10
|
+
class FormatOption
|
11
|
+
acts_as_instance_method
|
12
|
+
common_constructor :table_formatter, :option
|
13
|
+
|
14
|
+
def result
|
15
|
+
"*#{option.label}:* #{option.value}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EhbrsRubyUtils
|
6
|
+
module Bga
|
7
|
+
class Table
|
8
|
+
module WhatsappFormatters
|
9
|
+
class Base
|
10
|
+
class FormatPlayer
|
11
|
+
acts_as_abstract :fields
|
12
|
+
acts_as_instance_method
|
13
|
+
common_constructor :table_formatter, :player
|
14
|
+
|
15
|
+
FIELD_SEPARATOR = ' - '
|
16
|
+
|
17
|
+
delegate :name, to: :player
|
18
|
+
|
19
|
+
def result
|
20
|
+
fields.map { |v| send(v) }.join(FIELD_SEPARATOR)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EhbrsRubyUtils
|
6
|
+
module Bga
|
7
|
+
class Table
|
8
|
+
module WhatsappFormatters
|
9
|
+
class Base
|
10
|
+
acts_as_abstract :players_title, :root_items_title, :title_icon
|
11
|
+
enable_simple_cache
|
12
|
+
common_constructor :table
|
13
|
+
|
14
|
+
PLAYERS_EXTRA = ''
|
15
|
+
ROOT_ITENS = {
|
16
|
+
'Jogo' => :game_name,
|
17
|
+
'Criada em' => :creation_time,
|
18
|
+
'Duração' => :estimated_duration,
|
19
|
+
'Endereço' => :url
|
20
|
+
}.freeze
|
21
|
+
SECTION_SEPARATOR = "\n\n"
|
22
|
+
|
23
|
+
# @return [Pathname]
|
24
|
+
def image_local_path
|
25
|
+
table.game.box_large_image.local_path
|
26
|
+
end
|
27
|
+
|
28
|
+
def to_s
|
29
|
+
[root_items_to_s, players_to_s, options_to_s].map(&:strip).join(SECTION_SEPARATOR)
|
30
|
+
end
|
31
|
+
|
32
|
+
def root_items_to_s
|
33
|
+
title_to_s(root_items_title) + ROOT_ITENS.map { |k, v| "*#{k}*: #{table.send(v)}" }
|
34
|
+
.join("\n")
|
35
|
+
end
|
36
|
+
|
37
|
+
def options_to_s
|
38
|
+
title_to_s('Opções') + options.join("\n")
|
39
|
+
end
|
40
|
+
|
41
|
+
# @return [String]
|
42
|
+
def players_extra
|
43
|
+
PLAYERS_EXTRA
|
44
|
+
end
|
45
|
+
|
46
|
+
# @return [String]
|
47
|
+
def players_to_s
|
48
|
+
title_to_s(players_title) + players_extra + players.join("\n")
|
49
|
+
end
|
50
|
+
|
51
|
+
def title_to_s(title)
|
52
|
+
'*' + [title_icon, title, title_icon].join(' ') + "*\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
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'ehbrs_ruby_utils/bga/table/whatsapp_formatters/base/format_player'
|
5
|
+
|
6
|
+
module EhbrsRubyUtils
|
7
|
+
module Bga
|
8
|
+
class Table
|
9
|
+
module WhatsappFormatters
|
10
|
+
class Beginning < ::EhbrsRubyUtils::Bga::Table::WhatsappFormatters::Base
|
11
|
+
class FormatPlayer < ::EhbrsRubyUtils::Bga::Table::WhatsappFormatters::Base::FormatPlayer
|
12
|
+
acts_as_instance_method
|
13
|
+
|
14
|
+
FIELDS = %w[name].freeze
|
15
|
+
|
16
|
+
def fields
|
17
|
+
FIELDS
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'ehbrs_ruby_utils/bga/table/whatsapp_formatters/base'
|
5
|
+
|
6
|
+
module EhbrsRubyUtils
|
7
|
+
module Bga
|
8
|
+
class Table
|
9
|
+
module WhatsappFormatters
|
10
|
+
class Beginning < ::EhbrsRubyUtils::Bga::Table::WhatsappFormatters::Base
|
11
|
+
PLAYERS_TITLE = 'Jogadores'
|
12
|
+
ROOT_ITEMS_TITLE = 'Mesa iniciada'
|
13
|
+
TITLE_ICON = 0x2694.chr(::Encoding::UTF_8)
|
14
|
+
|
15
|
+
# @return [String]
|
16
|
+
def players_title
|
17
|
+
PLAYERS_TITLE
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [String]
|
21
|
+
def root_items_title
|
22
|
+
ROOT_ITEMS_TITLE
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [String]
|
26
|
+
def title_icon
|
27
|
+
TITLE_ICON
|
28
|
+
end
|
29
|
+
|
30
|
+
require_sub __FILE__, require_mode: :kernel
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'ehbrs_ruby_utils/bga/table/whatsapp_formatters/base/format_player'
|
5
|
+
|
6
|
+
module EhbrsRubyUtils
|
7
|
+
module Bga
|
8
|
+
class Table
|
9
|
+
module WhatsappFormatters
|
10
|
+
class Ending < ::EhbrsRubyUtils::Bga::Table::WhatsappFormatters::Base
|
11
|
+
class FormatPlayer < ::EhbrsRubyUtils::Bga::Table::WhatsappFormatters::Base::FormatPlayer
|
12
|
+
acts_as_instance_method
|
13
|
+
|
14
|
+
FIELDS = %w[table_rank name score].freeze
|
15
|
+
|
16
|
+
def fields
|
17
|
+
FIELDS
|
18
|
+
end
|
19
|
+
|
20
|
+
def table_rank
|
21
|
+
"*#{player.rank}º*"
|
22
|
+
end
|
23
|
+
|
24
|
+
def score
|
25
|
+
"⭐ #{player.score}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'ehbrs_ruby_utils/bga/table/whatsapp_formatters/base'
|
5
|
+
|
6
|
+
module EhbrsRubyUtils
|
7
|
+
module Bga
|
8
|
+
class Table
|
9
|
+
module WhatsappFormatters
|
10
|
+
class Ending < ::EhbrsRubyUtils::Bga::Table::WhatsappFormatters::Base
|
11
|
+
PLAYERS_TITLE = 'Resultado'
|
12
|
+
ROOT_ITEMS_TITLE = 'Mesa terminada'
|
13
|
+
TITLE_ICON = 0x1F3C6.chr(::Encoding::UTF_8)
|
14
|
+
|
15
|
+
# @return [String]
|
16
|
+
def game_conceded_to_s
|
17
|
+
table.game_conceded? ? "*Derrota admitida*\n\n" : ''
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [String]
|
21
|
+
def players_extra
|
22
|
+
game_conceded_to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [String]
|
26
|
+
def players_title
|
27
|
+
PLAYERS_TITLE
|
28
|
+
end
|
29
|
+
|
30
|
+
# @return [String]
|
31
|
+
def root_items_title
|
32
|
+
ROOT_ITEMS_TITLE
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [String]
|
36
|
+
def title_icon
|
37
|
+
TITLE_ICON
|
38
|
+
end
|
39
|
+
|
40
|
+
require_sub __FILE__, require_mode: :kernel
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -11,11 +11,14 @@ module EhbrsRubyUtils
|
|
11
11
|
include ::Singleton
|
12
12
|
acts_as_abstract :bga_usernam, :bga_password, :whatsapp_recipient
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
%w[beginning ending].each do |type|
|
15
|
+
# @param table [EhbrsRubyUtils::Bga::Table]
|
16
|
+
# @return [void]
|
17
|
+
define_method "bga_table_#{type}_notify" do |table|
|
18
|
+
formatter = ::EhbrsRubyUtils::Bga::Table::WhatsappFormatters.const_get(type.camelize)
|
19
|
+
.new(table)
|
20
|
+
whatsapp_send(formatter.to_s, formatter.image_local_path)
|
21
|
+
end
|
19
22
|
end
|
20
23
|
|
21
24
|
def on_bga_logged_session(&block)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.32.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo H. Bogoni
|
@@ -132,20 +132,14 @@ dependencies:
|
|
132
132
|
requirements:
|
133
133
|
- - "~>"
|
134
134
|
- !ruby/object:Gem::Version
|
135
|
-
version: '0.
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: 0.117.1
|
135
|
+
version: '0.118'
|
139
136
|
type: :runtime
|
140
137
|
prerelease: false
|
141
138
|
version_requirements: !ruby/object:Gem::Requirement
|
142
139
|
requirements:
|
143
140
|
- - "~>"
|
144
141
|
- !ruby/object:Gem::Version
|
145
|
-
version: '0.
|
146
|
-
- - ">="
|
147
|
-
- !ruby/object:Gem::Version
|
148
|
-
version: 0.117.1
|
142
|
+
version: '0.118'
|
149
143
|
- !ruby/object:Gem::Dependency
|
150
144
|
name: eac_templates
|
151
145
|
requirement: !ruby/object:Gem::Requirement
|
@@ -258,9 +252,14 @@ files:
|
|
258
252
|
- lib/ehbrs_ruby_utils/bga/table.rb
|
259
253
|
- lib/ehbrs_ruby_utils/bga/table/option.rb
|
260
254
|
- lib/ehbrs_ruby_utils/bga/table/player.rb
|
261
|
-
- lib/ehbrs_ruby_utils/bga/
|
262
|
-
- lib/ehbrs_ruby_utils/bga/
|
263
|
-
- lib/ehbrs_ruby_utils/bga/
|
255
|
+
- lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters.rb
|
256
|
+
- lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/base.rb
|
257
|
+
- lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/base/format_option.rb
|
258
|
+
- lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/base/format_player.rb
|
259
|
+
- lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/beginning.rb
|
260
|
+
- lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/beginning/format_player.rb
|
261
|
+
- lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/ending.rb
|
262
|
+
- lib/ehbrs_ruby_utils/bga/table/whatsapp_formatters/ending/format_player.rb
|
264
263
|
- lib/ehbrs_ruby_utils/bga/urls.rb
|
265
264
|
- lib/ehbrs_ruby_utils/circular_list_spreader.rb
|
266
265
|
- lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb
|
@@ -1,18 +0,0 @@
|
|
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
|
@@ -1,30 +0,0 @@
|
|
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.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
|
@@ -1,66 +0,0 @@
|
|
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
|
-
# @return [Pathname]
|
25
|
-
def image_local_path
|
26
|
-
table.game.box_large_image.local_path
|
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
|