File tree Expand file tree Collapse file tree 3 files changed +16
-10
lines changed
ext/java/org/jruby/ext/stringio Expand file tree Collapse file tree 3 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,9 @@ public static RubyClass createStringIOClass(final Ruby runtime) {
83
83
RubyClass stringIOClass = runtime .defineClass (
84
84
"StringIO" , runtime .getObject (), StringIO ::new );
85
85
86
+ RubyString version = RubyString .newString (runtime , "3.0.8" );
87
+ stringIOClass .defineConstant ("VERSION" , version );
88
+
86
89
stringIOClass .defineAnnotatedMethods (StringIO .class );
87
90
stringIOClass .includeModule (runtime .getEnumerable ());
88
91
Original file line number Diff line number Diff line change 1
1
class << ( helper = Bundler ::GemHelper . instance )
2
- SOURCE_PATH = "ext/stringio/stringio.c"
2
+ C_SOURCE_PATH = "ext/stringio/stringio.c"
3
+ JAVA_SOURCE_PATH = "ext/java/org/jruby/ext/stringio/StringIO.java"
3
4
def update_source_version
4
- path = SOURCE_PATH
5
- File . open ( path , "r+b" ) do |f |
6
- d = f . read
7
- if d . sub! ( /^#define\s +STRINGIO_VERSION\s +\K ".*"/ ) { version . to_s . dump }
8
- f . rewind
9
- f . truncate ( 0 )
10
- f . print ( d )
11
- end
12
- end
5
+ c_source = File . read ( C_SOURCE_PATH )
6
+ c_source . sub! ( /^#define\s +STRINGIO_VERSION\s +\K ".*"/ ) { version . to_s . dump }
7
+ File . write ( C_SOURCE_PATH , c_source )
8
+
9
+ java_source = File . read ( JAVA_SOURCE_PATH )
10
+ java_source . sub! ( /version = RubyString\. newString\( runtime, \K ".*"/ ) { version . to_s . dump }
11
+ File . write ( JAVA_SOURCE_PATH , java_source )
13
12
end
14
13
15
14
def commit_bump
Original file line number Diff line number Diff line change @@ -14,6 +14,10 @@ def open_file(content)
14
14
15
15
include TestEOF ::Seek
16
16
17
+ def test_version
18
+ assert_kind_of ( String , StringIO ::VERSION )
19
+ end
20
+
17
21
def test_initialize
18
22
assert_kind_of StringIO , StringIO . new
19
23
assert_kind_of StringIO , StringIO . new ( 'str' )
You can’t perform that action at this time.
0 commit comments