Skip to content

Commit d2f2f07

Browse files
committed
Update ruby input file
1 parent dfe67ab commit d2f2f07

File tree

3 files changed

+34
-21
lines changed

3 files changed

+34
-21
lines changed

src/SDK/Language/Ruby.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ public function getFiles()
147147
],
148148
[
149149
'scope' => 'default',
150-
'destination' => 'lib/{{ spec.title | caseDash }}/file.rb',
151-
'template' => 'ruby/lib/container/file.rb.twig',
150+
'destination' => 'lib/{{ spec.title | caseDash }}/input_file.rb',
151+
'template' => 'ruby/lib/container/input_file.rb.twig',
152152
'minify' => false,
153153
],
154154
[
@@ -281,7 +281,7 @@ public function getParamExample(array $param)
281281
$output .= '{}';
282282
break;
283283
case self::TYPE_FILE:
284-
$output .= "'dir/file.png'";
284+
$output .= "InputFile.fromPath('dir/file.png')";
285285
break;
286286
}
287287
}
@@ -302,7 +302,7 @@ public function getParamExample(array $param)
302302
$output .= "'{$example}'";
303303
break;
304304
case self::TYPE_FILE:
305-
$output .= "'file.png'";
305+
$output .= "InputFile.fromPath('dir/file.png')";
306306
break;
307307
}
308308
}

templates/ruby/lib/container/file.rb.twig

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
require 'mime/types'
2+
3+
module {{spec.title | caseUcfirst}}
4+
class InputFile
5+
attr_accessor :path
6+
attr_accessor :filename
7+
attr_accessor :mime_type
8+
attr_accessor :source_type
9+
10+
attr_accessor :data
11+
12+
def self.fromPath(path)
13+
instance = InputFile.new
14+
instance.path = path
15+
instance.filename = ::File.basename(path)
16+
instance.mime_type = MIME::Types.type_for(path)
17+
instance.source_type = 'path'
18+
instance
19+
end
20+
21+
def self.fromBytes(bytes, filename: nil, mime_type: nil)
22+
instance = InputFile.new
23+
instance.data = bytes
24+
instance.filename = filename
25+
instance.mime_type = mime_type
26+
instance.source_type = 'bytes'
27+
instance
28+
end
29+
end
30+
end

0 commit comments

Comments
 (0)