owo 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/owo.rb +12 -2
  3. data/lib/owo/api.rb +5 -4
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dadc9074b3638029d6ddcb693d4ba6dccbafaed9
4
- data.tar.gz: 472b5659f8d11ae77500aa0e18afb5f4b7bfc00f
3
+ metadata.gz: b63af0a02ed16c04d80353bf49e517e4ce01d2d1
4
+ data.tar.gz: ef563964130deb47bfd393ad925f708ed55de93d
5
5
  SHA512:
6
- metadata.gz: ab721cb20581d3889a65af077540d1e78db19a88cd571f108664abacd7d4355ec291462082dce896fc4e91b6d8dfab53044c08ec107acbf158a44135b67c7c43
7
- data.tar.gz: 3429c847244cc54558d85843ba16f4fb9477b24bed44b3966e640a41e448aeab3c2b74d3ff29a44e40792ede4ddbba9fe49b4e31d34ac4c4c7dec509c1d47c43
6
+ metadata.gz: ee5fc3b8ffdc3b48c81385f0ab16eb9f5600abf255df7315b5dde46086da97c259563a721743ae7b9ef355afebd504ae264ea0b18a0bbad11b48027514fe8b33
7
+ data.tar.gz: edd786da2727a724ecb9d8638cea67dff4ac1fdf0d3d75e0289caed9a875c5a4f5e2cacefd71f2db46f45fc19b503d75f5faeb430263f72bb60a69719192d908
data/lib/owo.rb CHANGED
@@ -35,9 +35,19 @@ module OwO
35
35
  files = [ files ]
36
36
  was_string = true
37
37
  end
38
- files.map { |x| File.new(x, 'rb') }
38
+ files = files.map do |x|
39
+ if x.is_a?(String)
40
+ File.new(File.absolute_path(x), 'rb')
41
+ else
42
+ x
43
+ end
44
+ end
39
45
  result = OwO::API.upload(opts(), files)
40
- if was_string
46
+ result.shift
47
+ result = result["files"].map.with_index do |x, i|
48
+ "https://#{@upload_url}/#{x['url']}"
49
+ end
50
+ if files.length == 1
41
51
  result = result[0]
42
52
  end
43
53
  return result
@@ -11,7 +11,7 @@ module OwO
11
11
  module_function
12
12
 
13
13
  def request(type, *attributes)
14
- raw = RestClient.send(type, *attributes, :'User-Agent' => "OwO.rb (https://github.com/whats-this/owo.rb)", :'Content-Type' => "multipart/form-data; boundary=XXX")
14
+ raw = RestClient.send(type, *attributes, :'User-Agent' => "OwO.rb (https://github.com/whats-this/owo.rb)")
15
15
  json = parse_json(raw);
16
16
  return json
17
17
  rescue RestClient::RequestEntityTooLarge
@@ -35,10 +35,11 @@ module OwO
35
35
  else
36
36
  raw
37
37
  end
38
+
38
39
  raise err
39
40
  rescue RestClient::InternalServerError
40
- raise OwO::Err::BadToken, "Server Error!"
41
- rescue Exception => e
41
+ raise OwO::Err::ServerFail, "Server Error!"
42
+ rescue RuntimeError => e
42
43
  raise e
43
44
  end
44
45
 
@@ -53,7 +54,7 @@ module OwO
53
54
  request(
54
55
  :post,
55
56
  "#{UPLOAD_URL}?key=#{opts['t']}",
56
- {:'files[]' => files}
57
+ "files".to_sym() => files
57
58
  )
58
59
  end
59
60
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: owo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Snazzah