discorb 0.12.3 → 0.12.4

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.
data/lib/discorb/http.rb CHANGED
@@ -144,7 +144,7 @@ module Discorb
144
144
  end
145
145
 
146
146
  #
147
- # A helper method to send multipart/form-data requests.
147
+ # A helper method to send multipart/form-data requests for creating messages.
148
148
  #
149
149
  # @param [Hash] payload The payload to send.
150
150
  # @param [Array<Discorb::File>] files The files to send.
@@ -159,15 +159,22 @@ module Discorb
159
159
 
160
160
  #{payload.to_json}
161
161
  HTTP
162
- files.each do |single_file|
162
+ files.each_with_index do |single_file, i|
163
163
  str_payloads << <<~HTTP
164
- Content-Disposition: form-data; name="file"; filename="#{single_file.filename}"
164
+ Content-Disposition: form-data; name="files[#{i}]"; filename="#{single_file.filename}"
165
165
  Content-Type: #{single_file.content_type}
166
166
 
167
167
  #{single_file.io.read}
168
168
  HTTP
169
169
  end
170
- [boundary, "--#{boundary}\n#{str_payloads.join("\n--#{boundary}\n")}\n--#{boundary}--"]
170
+ payload = +"--#{boundary}".encode(Encoding::ASCII_8BIT)
171
+ str_payloads.each do |str_payload|
172
+ payload << "\r\n".encode(Encoding::ASCII_8BIT)
173
+ payload << str_payload.force_encoding(Encoding::ASCII_8BIT)
174
+ payload << "\r\n--#{boundary}".encode(Encoding::ASCII_8BIT)
175
+ end
176
+ payload += +"--".encode(Encoding::ASCII_8BIT)
177
+ [boundary, payload]
171
178
  end
172
179
 
173
180
  private
@@ -22,6 +22,12 @@ def yard_replace(dir, version)
22
22
  <h1 class="noborder title">Documentation by YARD 0.9.26</h1>
23
23
  HTML3
24
24
  HTML4
25
+ if version == "main"
26
+ display_version = "(main)"
27
+ else
28
+ display_version = "v" + version
29
+ end
30
+ contents.gsub!(/Documentation by YARD \d+\.\d+\.\d+/, "discorb #{display_version} documentation")
25
31
  File.write(file, contents)
26
32
  end
27
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discorb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.3
4
+ version: 0.12.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - sevenc-nanashi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-25 00:00:00.000000000 Z
11
+ date: 2021-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async
@@ -221,5 +221,5 @@ requirements: []
221
221
  rubygems_version: 3.2.22
222
222
  signing_key:
223
223
  specification_version: 4
224
- summary: discorb is a Discord API wrapper for Ruby.
224
+ summary: A discord API wrapper written in Ruby
225
225
  test_files: []