Skip to content

Commit

Permalink
Merge branch 'main' into add-upgrade-for-core
Browse files Browse the repository at this point in the history
  • Loading branch information
Xuanwo authored Dec 11, 2024
2 parents 09fce21 + 566a789 commit cce3e08
Show file tree
Hide file tree
Showing 24 changed files with 778 additions and 56 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,6 @@ indent_size = 2

[*.{yaml,yml}]
indent_size = 2

[*.rb]
indent_size = 2
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# IDE and editor
.vscode
.idea

.vscode
!.vscode/settings.json
**/target
**/vendor
dist/
Expand Down
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"rust-analyzer.cargo.allTargets": true,
"rust-analyzer.cargo.features": "all",
"rust-analyzer.linkedProjects": [
"${workspaceFolder}/core/Cargo.toml",
"${workspaceFolder}/bindings/python/Cargo.toml",
"${workspaceFolder}/bindings/java/Cargo.toml",
"${workspaceFolder}/bindings/nodejs/Cargo.toml",
],
"java.compile.nullAnalysis.mode": "automatic"
}
2 changes: 1 addition & 1 deletion bindings/ruby/lib/opendal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@

# frozen_string_literal: true

require_relative "opendal_ruby/version"
require_relative "opendal_ruby/opendal_ruby"
require_relative "opendal_ruby/io"
66 changes: 66 additions & 0 deletions bindings/ruby/lib/opendal_ruby/io.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# frozen_string_literal: true

module OpenDAL
class IO
# Reads all lines from the stream into an array.
# Raises `EOFError` when the end of the file is reached.
def readlines
results = []

loop do
results << readline
rescue EOFError
break
end

results
end

# Rewinds the stream to the beginning.
def rewind
seek(0, ::IO::SEEK_SET)
end

# Sets the file position to `new_position`.
def pos=(new_position)
seek(new_position, ::IO::SEEK_SET)
end

alias_method :pos, :tell

# Checks if the stream is at the end of the file.
def eof
position = tell
seek(0, ::IO::SEEK_END)
tell == position
end

alias_method :eof?, :eof

# Returns the total length of the stream.
def length
current_position = tell
seek(0, ::IO::SEEK_END)
tell.tap { self.pos = current_position }
end

alias_method :size, :length
end
end
22 changes: 0 additions & 22 deletions bindings/ruby/lib/opendal_ruby/version.rb

This file was deleted.

13 changes: 11 additions & 2 deletions bindings/ruby/opendal.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,20 @@

# frozen_string_literal: true

require_relative "lib/opendal_ruby/version"
require "json"

Gem::Specification.new do |spec|
spec.name = "opendal"
spec.version = OpenDAL::VERSION
# RubyGems integrates and expects `cargo`.
# Read more about [Gem::Ext::CargoBuilder](https://github.com/rubygems/rubygems/blob/v3.5.23/lib/rubygems/ext/cargo_builder.rb)
#
# OpenDAL relies on "version" in `Cargo.toml` for the release process. You can read this gem spec with:
# `bundle exec ruby -e 'puts Gem::Specification.load("opendal.gemspec")'`
#
# keep in sync the key "opendal-ruby" with `Rakefile`.
#
# uses `cargo` to extract the version.
spec.version = JSON.parse(`cargo metadata --format-version 1`.strip)["packages"].find { |p| p["name"] == "opendal-ruby" }["version"]
spec.authors = ["OpenDAL Contributors"]
spec.email = ["[email protected]"]

Expand Down
Loading

0 comments on commit cce3e08

Please sign in to comment.