Skip to content

Commit f4bade2

Browse files
committed
Make DATA work better with prism
1 parent 66b9e06 commit f4bade2

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

core/src/main/java/org/jruby/RubyFile.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
import java.net.URL;
6868
import java.nio.channels.Channels;
6969
import java.nio.channels.FileChannel;
70+
import java.nio.channels.SeekableByteChannel;
7071
import java.nio.charset.StandardCharsets;
7172
import java.nio.file.*;
7273
import java.nio.file.attribute.FileTime;
@@ -237,6 +238,23 @@ public RubyFile(Ruby runtime, String path, InputStream in) {
237238
this.setPath(path);
238239
}
239240

241+
242+
private RubyFile(Ruby runtime, String path, SeekableByteChannel in) {
243+
super(runtime, runtime.getFile(), in);
244+
this.setPath(path);
245+
}
246+
247+
/**
248+
* Only used by parser (prism) so that we can get a File
249+
* @param runtime the runtime
250+
* @param path the path of DATA
251+
* @param in the channel to use
252+
* @return a Ruby file
253+
*/
254+
public static RubyFile DATAFile(Ruby runtime, String path, SeekableByteChannel in) {
255+
return new RubyFile(runtime, path, in);
256+
}
257+
240258
public RubyFile(Ruby runtime, String path, FileChannel channel) {
241259
super(runtime, runtime.getFile(), channel);
242260
this.setPath(path);

0 commit comments

Comments
 (0)