telegram-bot-ruby 2.8.0 → 2.8.1

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
  SHA256:
3
- metadata.gz: 305b7281c7f2f3d51656d5556d9435d3b6267ae4f275fc9a04b430cb275eabb2
4
- data.tar.gz: cc6af3a9f74e56a9eb70d4b32cceeaddffb5a4c20cb0e8577b2abdb3ba5ccfb0
3
+ metadata.gz: e5b5d66a75d365647e9866d4ee8b5d624a65e6033b5ca6db9d6131d434876ef2
4
+ data.tar.gz: bccb870d24d0b0a46834cd5b02d171872782febc59a69b30a9bd8d2920176fdd
5
5
  SHA512:
6
- metadata.gz: b72f319422e8943a43fb2128e0553a4bf8518c28ed01489724b2a277797cceb60122302d1127aa14f55938f6d063e10226dd3d72e1fade237975e2648925d7a3
7
- data.tar.gz: 17365086472228247b0e51cfba2d5f3661df32264267c9a2643f7372c39d315255626360dc5cc59341619ded5cf1c6e7528a0e368049b9b8740f9973eb5c8ba0
6
+ metadata.gz: 4156a631585d04798131196b5d50220dffbd221e253b445056216c0fbdcdd415b668266a260a41dc5e021dd3ad1697de24858b6d90387e21164fa2496d373ce1
7
+ data.tar.gz: fe25f0dacbc6beaca8fdb6ae6a8e56841cfd64f017d2c95db982b520c4872acedcc48315ccfa9dbbd33d192bf5efae40b706090e63e7bc7dcdedf16f859adc65
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.8.1
4
+
5
+ ### Fixed
6
+
7
+ - JSON-encode `Hash` params in API calls and parse `RichText` correctly [#340](https://github.com/atipugin/telegram-bot-ruby/pull/340) (thx [@vsevolod](https://github.com/vsevolod))
8
+
3
9
  ## 2.8.0
4
10
 
5
11
  ### Added
data/README.md CHANGED
@@ -11,7 +11,7 @@ Ruby wrapper for [Telegram's Bot API](https://core.telegram.org/bots/api).
11
11
  Add following line to your Gemfile:
12
12
 
13
13
  ```ruby
14
- gem 'telegram-bot-ruby', '~> 2.7'
14
+ gem 'telegram-bot-ruby', '~> 2.8'
15
15
  ```
16
16
 
17
17
  And then execute:
@@ -85,7 +85,7 @@ module Telegram
85
85
  end
86
86
 
87
87
  def jsonify_value?(value)
88
- value.respond_to?(:to_compact_hash) || value.is_a?(Array)
88
+ value.respond_to?(:to_compact_hash) || value.is_a?(Array) || value.is_a?(Hash)
89
89
  end
90
90
 
91
91
  def camelize(method_name)
@@ -6,6 +6,8 @@ module Telegram
6
6
  ## Just for classes consistency
7
7
  # rubocop:disable Naming/ConstantName
8
8
  RichText = (
9
+ Types::String |
10
+ Types::Array.of(Types.deferred(:RichText)) |
9
11
  RichTextBold |
10
12
  RichTextItalic |
11
13
  RichTextUnderline |
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Telegram
4
4
  module Bot
5
- VERSION = '2.8.0'
5
+ VERSION = '2.8.1'
6
6
  end
7
7
  end
@@ -38,10 +38,17 @@ module Builders
38
38
  end
39
39
 
40
40
  def build_empty_type
41
- attrs = attributes[:type].join(" |\n ")
41
+ attrs = attributes[:type].map { |member| empty_type_member(member.to_s) }
42
+ .join(" |\n ")
42
43
  render_template('empty_type.erb', name: name, attributes: attrs)
43
44
  end
44
45
 
46
+ def empty_type_member(member)
47
+ return "Types::Array.of(#{add_module_types(member.delete_prefix('array:'))})" if member.start_with?('array:')
48
+
49
+ add_module_types(member)
50
+ end
51
+
45
52
  def build_full_type
46
53
  process_attributes!
47
54
  render_template('type.erb', name: name, attributes: attributes)
@@ -51,17 +51,23 @@ module Parsers
51
51
  name
52
52
  end
53
53
 
54
- def parse_type(header, _type_name)
54
+ def parse_type(header, type_name)
55
55
  # Check if this is a union type (list of types without a table)
56
+ description = first_description_paragraph(header)
56
57
  next_sibling = find_next_significant_sibling(header)
57
58
 
58
59
  if union_type?(next_sibling)
59
- parse_union_type(next_sibling)
60
+ parse_union_type(next_sibling, description, type_name)
60
61
  else
61
62
  parse_table_type(header)
62
63
  end
63
64
  end
64
65
 
66
+ def first_description_paragraph(header)
67
+ sibling = header.next_element
68
+ sibling if sibling&.name == 'p'
69
+ end
70
+
65
71
  def find_next_significant_sibling(header)
66
72
  sibling = header.next_element
67
73
  # Skip description paragraphs
@@ -73,9 +79,13 @@ module Parsers
73
79
  element&.name == 'ul'
74
80
  end
75
81
 
76
- def parse_union_type(ul_element)
77
- types = ul_element.css('li a').map { |a| a.text.strip }
78
- { 'type' => types }
82
+ def parse_union_type(ul_element, description, type_name)
83
+ types = []
84
+ desc_text = description&.text.to_s
85
+ types << 'string' if desc_text.match?(/String for plain text/i)
86
+ types << "array:#{type_name}" if desc_text.match?(/an Array of #{type_name}/i)
87
+ types.concat(ul_element.css('li a').map { |a| a.text.strip })
88
+ { 'type' => types.uniq }
79
89
  end
80
90
 
81
91
  def parse_table_type(header)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telegram-bot-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.0
4
+ version: 2.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Tipugin