freefeed 0.5.1 → 0.5.2

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: d2cbf58e8a6119613f877fa15a189432bba93ef71c1d3cc3cb3e604c8a6c1ead
4
- data.tar.gz: f59c245c6b21526751d694aa92943560748123f24b17c18331e6bca7ab69b3bd
3
+ metadata.gz: df70eb7a4e877e4fa7cf8693855850444e72f85a7409c5e74485c558c024522e
4
+ data.tar.gz: 4a3a8b81ae9fedb18f009e90ef2c8e75256ada5b306fe55efb3040329cb21b8a
5
5
  SHA512:
6
- metadata.gz: 7edce7fd36093a5256c9de84498cf43ffa58761d9cb831b902a07a3c94a7c1d54bd792e7abe704905fadf797bf6166d71f051afc831fa83ecd2921b835322e8e
7
- data.tar.gz: 794244daa46d07be457bdb9238bb6a5cb22ef400125fa355b172c13856785818be7f336178c46e5053d05a5178d95dced410251065938e4de601f9b28290ad2f
6
+ metadata.gz: 945fda332433b9bc8037812d566b647ee64cf4d885158d967f7d648439114c18d026be4a09d9c3af60198df98058972e4fe3d02450f4ffa84341fe83ce64e886
7
+ data.tar.gz: 127f2016c0891cad053fd91a14611384e6d0805735a4abccfc56dc13af2bb460100a1ecaed6bd36c423a967ac6c2658450653fc920980e67223bebe30dc8f106
@@ -8,18 +8,19 @@ module Freefeed
8
8
  module Attachments
9
9
  # @param [String, Pathname, IO] source could by a file path
10
10
  # or an IO object
11
- def create_attachment(source)
12
- options = { form: { file: file(source) } }
11
+ def create_attachment(source, content_type: nil)
12
+ options = { form: { file: file(source, content_type) } }
13
13
  authenticated_request(:post, "/v1/attachments", options)
14
14
  end
15
15
 
16
16
  private
17
17
 
18
- def file(source)
19
- HTTP::FormData::File.new(source, content_type: content_type(source))
18
+ def file(source, content_type)
19
+ content_type ||= detect_content_type(source)
20
+ HTTP::FormData::File.new(source, content_type: content_type)
20
21
  end
21
22
 
22
- def content_type(source)
23
+ def detect_content_type(source)
23
24
  return MimeMagic.by_magic(source) if source.is_a?(IO)
24
25
  MimeMagic.by_path(source.to_s)
25
26
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Freefeed
4
- VERSION = "0.5.1"
4
+ VERSION = "0.5.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freefeed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Musayev