Skip to content

jruby: Add StringIO::VERSION #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ext/java/org/jruby/ext/stringio/StringIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ public static RubyClass createStringIOClass(final Ruby runtime) {
RubyClass stringIOClass = runtime.defineClass(
"StringIO", runtime.getObject(), StringIO::new);

RubyString version = RubyString.newString(runtime, "3.0.8");
stringIOClass.defineConstant("VERSION", version);

stringIOClass.defineAnnotatedMethods(StringIO.class);
stringIOClass.includeModule(runtime.getEnumerable());

Expand Down
19 changes: 9 additions & 10 deletions rakelib/version.rake
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
class << (helper = Bundler::GemHelper.instance)
SOURCE_PATH = "ext/stringio/stringio.c"
C_SOURCE_PATH = "ext/stringio/stringio.c"
JAVA_SOURCE_PATH = "ext/java/org/jruby/ext/stringio/StringIO.java"
def update_source_version
path = SOURCE_PATH
File.open(path, "r+b") do |f|
d = f.read
if d.sub!(/^#define\s+STRINGIO_VERSION\s+\K".*"/) {version.to_s.dump}
f.rewind
f.truncate(0)
f.print(d)
end
end
c_source = File.read(C_SOURCE_PATH)
c_source.sub!(/^#define\s+STRINGIO_VERSION\s+\K".*"/) {version.to_s.dump}
File.write(C_SOURCE_PATH, c_source)

java_source = File.read(JAVA_SOURCE_PATH)
java_source.sub!(/version = RubyString\.newString\(runtime, \K".*"/) {version.to_s.dump}
File.write(JAVA_SOURCE_PATH, java_source)
end

def commit_bump
Expand Down
4 changes: 4 additions & 0 deletions test/stringio/test_stringio.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ def open_file(content)

include TestEOF::Seek

def test_version
assert_kind_of(String, StringIO::VERSION)
end

def test_initialize
assert_kind_of StringIO, StringIO.new
assert_kind_of StringIO, StringIO.new('str')
Expand Down