-
Notifications
You must be signed in to change notification settings - Fork 499
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bindings/ruby): Add I/O class for Ruby (#5354)
- Loading branch information
Showing
10 changed files
with
624 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,3 +61,6 @@ indent_size = 2 | |
|
||
[*.{yaml,yml}] | ||
indent_size = 2 | ||
|
||
[*.rb] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]"] | ||
|
||
|
Oops, something went wrong.