opendal 0.1.6.pre.rc.1-arm64-darwin-23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. checksums.yaml +7 -0
  2. data/.standard.yml +20 -0
  3. data/.tool-versions +1 -0
  4. data/.yardopts +1 -0
  5. data/DEPENDENCIES.md +9 -0
  6. data/DEPENDENCIES.rust.tsv +277 -0
  7. data/Gemfile +35 -0
  8. data/README.md +159 -0
  9. data/Rakefile +149 -0
  10. data/core/CHANGELOG.md +4929 -0
  11. data/core/CONTRIBUTING.md +61 -0
  12. data/core/DEPENDENCIES.md +3 -0
  13. data/core/DEPENDENCIES.rust.tsv +185 -0
  14. data/core/LICENSE +201 -0
  15. data/core/README.md +228 -0
  16. data/core/benches/README.md +18 -0
  17. data/core/benches/ops/README.md +26 -0
  18. data/core/benches/types/README.md +9 -0
  19. data/core/benches/vs_fs/README.md +35 -0
  20. data/core/benches/vs_s3/README.md +55 -0
  21. data/core/edge/README.md +3 -0
  22. data/core/edge/file_write_on_full_disk/README.md +14 -0
  23. data/core/edge/s3_aws_assume_role_with_web_identity/README.md +18 -0
  24. data/core/edge/s3_read_on_wasm/.gitignore +3 -0
  25. data/core/edge/s3_read_on_wasm/README.md +42 -0
  26. data/core/edge/s3_read_on_wasm/webdriver.json +15 -0
  27. data/core/examples/README.md +23 -0
  28. data/core/examples/basic/README.md +15 -0
  29. data/core/examples/concurrent-upload/README.md +15 -0
  30. data/core/examples/multipart-upload/README.md +15 -0
  31. data/core/fuzz/.gitignore +5 -0
  32. data/core/fuzz/README.md +68 -0
  33. data/core/src/docs/comparisons/vs_object_store.md +183 -0
  34. data/core/src/docs/performance/concurrent_write.md +101 -0
  35. data/core/src/docs/performance/http_optimization.md +124 -0
  36. data/core/src/docs/rfcs/0000_example.md +74 -0
  37. data/core/src/docs/rfcs/0000_foyer_integration.md +111 -0
  38. data/core/src/docs/rfcs/0041_object_native_api.md +185 -0
  39. data/core/src/docs/rfcs/0044_error_handle.md +198 -0
  40. data/core/src/docs/rfcs/0057_auto_region.md +160 -0
  41. data/core/src/docs/rfcs/0069_object_stream.md +145 -0
  42. data/core/src/docs/rfcs/0090_limited_reader.md +155 -0
  43. data/core/src/docs/rfcs/0112_path_normalization.md +79 -0
  44. data/core/src/docs/rfcs/0191_async_streaming_io.md +328 -0
  45. data/core/src/docs/rfcs/0203_remove_credential.md +96 -0
  46. data/core/src/docs/rfcs/0221_create_dir.md +89 -0
  47. data/core/src/docs/rfcs/0247_retryable_error.md +87 -0
  48. data/core/src/docs/rfcs/0293_object_id.md +67 -0
  49. data/core/src/docs/rfcs/0337_dir_entry.md +191 -0
  50. data/core/src/docs/rfcs/0409_accessor_capabilities.md +67 -0
  51. data/core/src/docs/rfcs/0413_presign.md +154 -0
  52. data/core/src/docs/rfcs/0423_command_line_interface.md +268 -0
  53. data/core/src/docs/rfcs/0429_init_from_iter.md +107 -0
  54. data/core/src/docs/rfcs/0438_multipart.md +163 -0
  55. data/core/src/docs/rfcs/0443_gateway.md +73 -0
  56. data/core/src/docs/rfcs/0501_new_builder.md +111 -0
  57. data/core/src/docs/rfcs/0554_write_refactor.md +96 -0
  58. data/core/src/docs/rfcs/0561_list_metadata_reuse.md +210 -0
  59. data/core/src/docs/rfcs/0599_blocking_api.md +157 -0
  60. data/core/src/docs/rfcs/0623_redis_service.md +300 -0
  61. data/core/src/docs/rfcs/0627_split_capabilities.md +89 -0
  62. data/core/src/docs/rfcs/0661_path_in_accessor.md +126 -0
  63. data/core/src/docs/rfcs/0793_generic_kv_services.md +209 -0
  64. data/core/src/docs/rfcs/0926_object_reader.md +93 -0
  65. data/core/src/docs/rfcs/0977_refactor_error.md +151 -0
  66. data/core/src/docs/rfcs/1085_object_handler.md +73 -0
  67. data/core/src/docs/rfcs/1391_object_metadataer.md +110 -0
  68. data/core/src/docs/rfcs/1398_query_based_metadata.md +125 -0
  69. data/core/src/docs/rfcs/1420_object_writer.md +147 -0
  70. data/core/src/docs/rfcs/1477_remove_object_concept.md +159 -0
  71. data/core/src/docs/rfcs/1735_operation_extension.md +117 -0
  72. data/core/src/docs/rfcs/2083_writer_sink_api.md +106 -0
  73. data/core/src/docs/rfcs/2133_append_api.md +88 -0
  74. data/core/src/docs/rfcs/2299_chain_based_operator_api.md +99 -0
  75. data/core/src/docs/rfcs/2602_object_versioning.md +138 -0
  76. data/core/src/docs/rfcs/2758_merge_append_into_write.md +79 -0
  77. data/core/src/docs/rfcs/2774_lister_api.md +66 -0
  78. data/core/src/docs/rfcs/2779_list_with_metakey.md +143 -0
  79. data/core/src/docs/rfcs/2852_native_capability.md +58 -0
  80. data/core/src/docs/rfcs/2884_merge_range_read_into_read.md +80 -0
  81. data/core/src/docs/rfcs/3017_remove_write_copy_from.md +94 -0
  82. data/core/src/docs/rfcs/3197_config.md +237 -0
  83. data/core/src/docs/rfcs/3232_align_list_api.md +69 -0
  84. data/core/src/docs/rfcs/3243_list_prefix.md +128 -0
  85. data/core/src/docs/rfcs/3356_lazy_reader.md +111 -0
  86. data/core/src/docs/rfcs/3526_list_recursive.md +59 -0
  87. data/core/src/docs/rfcs/3574_concurrent_stat_in_list.md +80 -0
  88. data/core/src/docs/rfcs/3734_buffered_reader.md +64 -0
  89. data/core/src/docs/rfcs/3898_concurrent_writer.md +66 -0
  90. data/core/src/docs/rfcs/3911_deleter_api.md +165 -0
  91. data/core/src/docs/rfcs/4382_range_based_read.md +213 -0
  92. data/core/src/docs/rfcs/4638_executor.md +215 -0
  93. data/core/src/docs/rfcs/5314_remove_metakey.md +120 -0
  94. data/core/src/docs/rfcs/5444_operator_from_uri.md +162 -0
  95. data/core/src/docs/rfcs/5479_context.md +140 -0
  96. data/core/src/docs/rfcs/5485_conditional_reader.md +112 -0
  97. data/core/src/docs/rfcs/5495_list_with_deleted.md +81 -0
  98. data/core/src/docs/rfcs/5556_write_returns_metadata.md +121 -0
  99. data/core/src/docs/rfcs/5871_read_returns_metadata.md +112 -0
  100. data/core/src/docs/rfcs/6189_remove_native_blocking.md +106 -0
  101. data/core/src/docs/rfcs/6209_glob_support.md +132 -0
  102. data/core/src/docs/rfcs/6213_options_api.md +142 -0
  103. data/core/src/docs/rfcs/README.md +62 -0
  104. data/core/src/docs/upgrade.md +1556 -0
  105. data/core/src/services/aliyun_drive/docs.md +61 -0
  106. data/core/src/services/alluxio/docs.md +45 -0
  107. data/core/src/services/azblob/docs.md +77 -0
  108. data/core/src/services/azdls/docs.md +73 -0
  109. data/core/src/services/azfile/docs.md +65 -0
  110. data/core/src/services/b2/docs.md +54 -0
  111. data/core/src/services/cacache/docs.md +38 -0
  112. data/core/src/services/cloudflare_kv/docs.md +21 -0
  113. data/core/src/services/cos/docs.md +55 -0
  114. data/core/src/services/d1/docs.md +48 -0
  115. data/core/src/services/dashmap/docs.md +38 -0
  116. data/core/src/services/dbfs/docs.md +57 -0
  117. data/core/src/services/dropbox/docs.md +64 -0
  118. data/core/src/services/etcd/docs.md +45 -0
  119. data/core/src/services/foundationdb/docs.md +42 -0
  120. data/core/src/services/fs/docs.md +49 -0
  121. data/core/src/services/ftp/docs.md +42 -0
  122. data/core/src/services/gcs/docs.md +76 -0
  123. data/core/src/services/gdrive/docs.md +65 -0
  124. data/core/src/services/ghac/docs.md +84 -0
  125. data/core/src/services/github/docs.md +52 -0
  126. data/core/src/services/gridfs/docs.md +46 -0
  127. data/core/src/services/hdfs/docs.md +140 -0
  128. data/core/src/services/hdfs_native/docs.md +35 -0
  129. data/core/src/services/http/docs.md +45 -0
  130. data/core/src/services/huggingface/docs.md +61 -0
  131. data/core/src/services/ipfs/docs.md +45 -0
  132. data/core/src/services/ipmfs/docs.md +14 -0
  133. data/core/src/services/koofr/docs.md +51 -0
  134. data/core/src/services/lakefs/docs.md +62 -0
  135. data/core/src/services/memcached/docs.md +47 -0
  136. data/core/src/services/memory/docs.md +36 -0
  137. data/core/src/services/mini_moka/docs.md +19 -0
  138. data/core/src/services/moka/docs.md +42 -0
  139. data/core/src/services/mongodb/docs.md +49 -0
  140. data/core/src/services/monoiofs/docs.md +46 -0
  141. data/core/src/services/mysql/docs.md +47 -0
  142. data/core/src/services/obs/docs.md +54 -0
  143. data/core/src/services/onedrive/docs.md +115 -0
  144. data/core/src/services/opfs/docs.md +18 -0
  145. data/core/src/services/oss/docs.md +74 -0
  146. data/core/src/services/pcloud/docs.md +51 -0
  147. data/core/src/services/persy/docs.md +43 -0
  148. data/core/src/services/postgresql/docs.md +47 -0
  149. data/core/src/services/redb/docs.md +41 -0
  150. data/core/src/services/redis/docs.md +43 -0
  151. data/core/src/services/rocksdb/docs.md +54 -0
  152. data/core/src/services/s3/compatible_services.md +126 -0
  153. data/core/src/services/s3/docs.md +244 -0
  154. data/core/src/services/seafile/docs.md +54 -0
  155. data/core/src/services/sftp/docs.md +49 -0
  156. data/core/src/services/sled/docs.md +39 -0
  157. data/core/src/services/sqlite/docs.md +46 -0
  158. data/core/src/services/surrealdb/docs.md +54 -0
  159. data/core/src/services/swift/compatible_services.md +53 -0
  160. data/core/src/services/swift/docs.md +52 -0
  161. data/core/src/services/tikv/docs.md +43 -0
  162. data/core/src/services/upyun/docs.md +51 -0
  163. data/core/src/services/vercel_artifacts/docs.md +40 -0
  164. data/core/src/services/vercel_blob/docs.md +45 -0
  165. data/core/src/services/webdav/docs.md +49 -0
  166. data/core/src/services/webhdfs/docs.md +90 -0
  167. data/core/src/services/yandex_disk/docs.md +45 -0
  168. data/core/tests/behavior/README.md +77 -0
  169. data/core/tests/data/normal_dir/.gitkeep +0 -0
  170. data/core/tests/data/normal_file.txt +1041 -0
  171. data/core/tests/data/special_dir !@#$%^&()_+-=;',/.gitkeep +0 -0
  172. data/core/tests/data/special_file !@#$%^&()_+-=;',.txt +1041 -0
  173. data/core/users.md +13 -0
  174. data/extconf.rb +24 -0
  175. data/lib/opendal.rb +25 -0
  176. data/lib/opendal_ruby/entry.rb +35 -0
  177. data/lib/opendal_ruby/io.rb +70 -0
  178. data/lib/opendal_ruby/metadata.rb +44 -0
  179. data/lib/opendal_ruby/opendal_ruby.bundle +0 -0
  180. data/lib/opendal_ruby/operator.rb +29 -0
  181. data/lib/opendal_ruby/operator_info.rb +26 -0
  182. data/opendal.gemspec +91 -0
  183. data/test/blocking_op_test.rb +112 -0
  184. data/test/capability_test.rb +42 -0
  185. data/test/io_test.rb +172 -0
  186. data/test/lister_test.rb +77 -0
  187. data/test/metadata_test.rb +78 -0
  188. data/test/middlewares_test.rb +46 -0
  189. data/test/operator_info_test.rb +35 -0
  190. data/test/test_helper.rb +36 -0
  191. metadata +240 -0
data/core/users.md ADDED
@@ -0,0 +1,13 @@
1
+ # Users
2
+
3
+ - [apache/iceberg-rust](https://github.com/apache/iceberg-rust/): Native Rust implementation of [Apache Iceberg](https://iceberg.apache.org/), the open table format for analytic datasets.
4
+ - [Databend](https://github.com/datafuselabs/databend/): A modern Elasticity and Performance cloud data warehouse.
5
+ - [deepeth/mars](https://github.com/deepeth/mars): The powerful analysis platform to explore and visualize data from blockchain.
6
+ - [GreptimeDB](https://github.com/GreptimeTeam/greptimedb): An open-source, cloud-native, distributed time-series database.
7
+ - [mozilla/sccache](https://github.com/mozilla/sccache/): `sccache` is [`ccache`](https://github.com/ccache/ccache) with cloud storage
8
+ - [OctoBase](https://github.com/toeverything/OctoBase): the open-source database behind [AFFiNE](https://github.com/toeverything/affine), local-first, yet collaborative.
9
+ - [Pants](https://github.com/pantsbuild/pants): A fast, scalable, user-friendly build system for codebases of all sizes.
10
+ - [QuestDB](https://github.com/questdb/questdb): An open-source time-series database for high throughput ingestion and fast SQL queries with operational simplicity.
11
+ - [RisingWave](https://github.com/risingwavelabs/risingwave): A Distributed SQL Database for Stream Processing
12
+ - [Vector](https://github.com/vectordotdev/vector): A high-performance observability data pipeline.
13
+ - [rustic](https://github.com/rustic-rs/rustic): Fast, encrypted, and deduplicated backups powered by Rust
data/extconf.rb ADDED
@@ -0,0 +1,24 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ require "mkmf"
19
+ # We use rb_sys for makefile generation only.
20
+ # We can use `RB_SYS_CARGO_PROFILE` to choose Cargo profile
21
+ # Read more https://github.com/oxidize-rb/rb-sys/blob/main/gem/README.md
22
+ require "rb_sys/mkmf"
23
+
24
+ create_rust_makefile("opendal_ruby/opendal_ruby")
data/lib/opendal.rb ADDED
@@ -0,0 +1,25 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ # frozen_string_literal: true
19
+
20
+ require_relative "opendal_ruby/opendal_ruby"
21
+ require_relative "opendal_ruby/io"
22
+ require_relative "opendal_ruby/entry"
23
+ require_relative "opendal_ruby/metadata"
24
+ require_relative "opendal_ruby/operator"
25
+ require_relative "opendal_ruby/operator_info"
@@ -0,0 +1,35 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ # frozen_string_literal: true
19
+
20
+ module OpenDal
21
+ class Entry
22
+ # Returns the canonical data about an entry
23
+ # @return [Hash]
24
+ def to_h
25
+ {
26
+ path: path,
27
+ metadata: metadata
28
+ }
29
+ end
30
+
31
+ def inspect
32
+ "#<#{self.class.name} path: \"#{path}\", metadata: #{metadata.inspect}>"
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,70 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ # frozen_string_literal: true
19
+
20
+ module OpenDal
21
+ class IO
22
+ # Reads all lines from the stream into an array.
23
+ # @raise [EOFError] when the end of the file is reached.
24
+ # @return [Array<String>]
25
+ def readlines
26
+ results = []
27
+
28
+ loop do
29
+ results << readline
30
+ rescue EOFError
31
+ break
32
+ end
33
+
34
+ results
35
+ end
36
+
37
+ # Rewinds the stream to the beginning.
38
+ def rewind
39
+ seek(0, ::IO::SEEK_SET)
40
+ end
41
+
42
+ # Sets the file position to `new_position`.
43
+ # @param new_position [Integer]
44
+ def pos=(new_position)
45
+ seek(new_position, ::IO::SEEK_SET)
46
+ end
47
+
48
+ alias_method :pos, :tell
49
+
50
+ # Checks if the stream is at the end of the file.
51
+ # @return [Boolean]
52
+ def eof
53
+ position = tell
54
+ seek(0, ::IO::SEEK_END)
55
+ tell == position
56
+ end
57
+
58
+ alias_method :eof?, :eof
59
+
60
+ # Returns the total length of the stream.
61
+ # @return [Integer]
62
+ def length
63
+ current_position = tell
64
+ seek(0, ::IO::SEEK_END)
65
+ tell.tap { self.pos = current_position }
66
+ end
67
+
68
+ alias_method :size, :length
69
+ end
70
+ end
@@ -0,0 +1,44 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ # frozen_string_literal: true
19
+
20
+ module OpenDal
21
+ class Metadata
22
+ FILE = "File"
23
+ DIRECTORY = "Directory"
24
+
25
+ # Returns `True` if this is a file.
26
+ # @return [Boolean]
27
+ def file?
28
+ mode == FILE
29
+ end
30
+
31
+ # Returns `True` if this is a directory.
32
+ # @return [Boolean]
33
+ def dir?
34
+ mode == DIRECTORY
35
+ end
36
+
37
+ def inspect
38
+ # Be concise to keep a few attributes
39
+ "#<#{self.class.name} mode: #{mode}, \
40
+ content_type: #{content_type}, \
41
+ content_length: #{content_length}>"
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,29 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ # frozen_string_literal: true
19
+
20
+ module OpenDal
21
+ class Operator
22
+ # Applies a middleware to the operator.
23
+ # @param middleware [Middleware]
24
+ # @return [Operator]
25
+ def middleware(middleware)
26
+ middleware.apply_to(self) # duck typing, expects a middleware to implement `#apply_to`
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,26 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ # frozen_string_literal: true
19
+
20
+ module OpenDal
21
+ class OperatorInfo
22
+ def inspect
23
+ "#<#{self.class.name} scheme: \"#{scheme}\", root: \"#{root}\">"
24
+ end
25
+ end
26
+ end
data/opendal.gemspec ADDED
@@ -0,0 +1,91 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ # frozen_string_literal: true
19
+
20
+ require "json"
21
+
22
+ Gem::Specification.new do |spec|
23
+ spec.name = "opendal"
24
+ # RubyGems integrates and expects `cargo`.
25
+ # Read more about [Gem::Ext::CargoBuilder](https://github.com/rubygems/rubygems/blob/v3.5.23/lib/rubygems/ext/cargo_builder.rb)
26
+ #
27
+ # OpenDAL relies on "version" in `Cargo.toml` for the release process. You can read this gem spec with:
28
+ # `bundle exec ruby -e 'puts Gem::Specification.load("opendal.gemspec")'`
29
+ #
30
+ # keep in sync the key "opendal-ruby" with `Rakefile`.
31
+ #
32
+ # uses `cargo` to extract the version.
33
+ spec.version = JSON.parse(`cargo metadata --format-version 1`.strip)
34
+ .fetch("packages")
35
+ .find { |p| p["name"] == "opendal-ruby" }
36
+ .fetch("version")
37
+ spec.authors = ["OpenDAL Contributors"]
38
+ spec.email = ["dev@opendal.apache.org"]
39
+
40
+ spec.summary = "OpenDAL Ruby Binding"
41
+ spec.homepage = "https://opendal.apache.org/"
42
+ spec.license = "Apache-2.0"
43
+
44
+ spec.metadata["homepage_uri"] = spec.homepage
45
+ spec.metadata["source_code_uri"] = "https://github.com/apache/opendal"
46
+ spec.metadata["changelog_uri"] = "https://github.com/apache/opendal/releases"
47
+ spec.metadata["rubygems_mfa_required"] = "true"
48
+
49
+ # Specify which files should be added to a source release gem when we release OpenDAL Ruby gem.
50
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
51
+ spec.files = Dir.chdir(__dir__) do
52
+ git_files = `git ls-files -z`.split("\x0").reject do |f|
53
+ (File.expand_path(f) == __FILE__) || f.start_with?(*%w[gems/ pkg/ target/ tmp/ .git]) || f == "core"
54
+ end
55
+
56
+ # Include core directory files, excluding symlinks
57
+ core_files = Dir.chdir("./core") do
58
+ `git ls-files -z`.split("\x0").reject do |f|
59
+ File.symlink?(File.join("./core", f))
60
+ end.map { |f| "core/#{f}" }
61
+ end
62
+
63
+ # Resolve symlinks: copy actual files from their target locations
64
+ # This handles recursive symbol link cases. e.g., core/CHANGELOG.md -> ../CHANGELOG.md
65
+ symlink_targets = Dir.chdir("./core") do
66
+ `git ls-files -z`.split("\x0").select do |f|
67
+ File.symlink?(File.join("./core", f))
68
+ end.filter_map do |f|
69
+ link_target = File.readlink(File.join("./core", f))
70
+ resolved_path = File.expand_path(link_target, File.join(__dir__, "core"))
71
+ File.exist?(resolved_path) ? "core/#{f}" : nil
72
+ end
73
+ end
74
+
75
+ git_files + core_files + symlink_targets
76
+ end
77
+
78
+ spec.require_paths = ["lib"]
79
+
80
+ spec.extensions = ["./extconf.rb"]
81
+
82
+ spec.requirements = ["Rust >= 1.82"]
83
+ # use a Ruby version which:
84
+ # - supports Rubygems with the ability of compilation of Rust gem
85
+ # - not end of life
86
+ #
87
+ # keep in sync with `Rakefile`.
88
+ spec.required_ruby_version = ">= 3.2"
89
+
90
+ # intentionally skipping rb_sys gem because newer Rubygems will be present
91
+ end
@@ -0,0 +1,112 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ # frozen_string_literal: true
19
+
20
+ require "test_helper"
21
+ require "tmpdir"
22
+
23
+ class OpenDalTest < ActiveSupport::TestCase
24
+ setup do
25
+ @root = Dir.mktmpdir
26
+ File.write("#{@root}/sample", "Sample data for testing")
27
+ @op = OpenDal::Operator.new("fs", {"root" => @root})
28
+ end
29
+
30
+ teardown do
31
+ FileUtils.remove_entry(@root) if File.exist?(@root)
32
+ end
33
+
34
+ test "write writes to a file" do
35
+ @op.write("/file", "OpenDAL Ruby is ready.")
36
+
37
+ assert_equal "OpenDAL Ruby is ready.", File.read("/#{@root}/file")
38
+ end
39
+
40
+ test "write writes binary" do
41
+ # writes 32-bit signed integers
42
+ @op.write("/file", [67305985, -50462977].pack("l*"))
43
+
44
+ assert_equal [67305985, -50462977], File.binread("/#{@root}/file").unpack("l*")
45
+ end
46
+
47
+ test "read reads file data" do
48
+ data = @op.read("/sample")
49
+
50
+ assert_equal "Sample data for testing", data
51
+ end
52
+
53
+ test "stat returns file metadata" do
54
+ stat = @op.stat("sample")
55
+
56
+ assert stat.is_a?(OpenDal::Metadata)
57
+ assert_equal 23, stat.content_length
58
+ assert stat.file?
59
+ end
60
+
61
+ test "create_dir creates directory" do
62
+ @op.create_dir("/new/directory/")
63
+ assert File.directory?("#{@root}/new/directory/")
64
+ end
65
+
66
+ test "exists returns existence" do
67
+ assert @op.exist?("sample")
68
+ end
69
+
70
+ test "delete removes file" do
71
+ @op.delete("/sample")
72
+
73
+ assert_not File.exist?("#{@root}/sample")
74
+ end
75
+
76
+ test "rename renames file" do
77
+ @op.rename("/sample", "/new_name")
78
+
79
+ assert_not File.exist?("#{@root}/sample")
80
+ assert File.exist?("#{@root}/new_name")
81
+ end
82
+
83
+ test "remove_all removes files" do
84
+ @op.create_dir("/nested/directory/")
85
+ @op.write("/nested/directory/text", "content")
86
+
87
+ @op.remove_all("/")
88
+
89
+ assert_not File.exist?(@root)
90
+ end
91
+
92
+ test "copy copies file" do
93
+ @op.copy("/sample", "/new_name")
94
+
95
+ assert File.exist?("#{@root}/sample")
96
+ assert File.exist?("#{@root}/new_name")
97
+ end
98
+
99
+ test "opens an IO" do
100
+ io = @op.open("/sample", "rb")
101
+
102
+ assert_not io.closed?
103
+
104
+ io.close
105
+ end
106
+
107
+ test "middleware applies a middleware" do
108
+ @op.middleware(OpenDal::Middleware::Retry.new)
109
+
110
+ assert @op.is_a?(OpenDal::Operator)
111
+ end
112
+ end
@@ -0,0 +1,42 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ # frozen_string_literal: true
19
+
20
+ require "test_helper"
21
+
22
+ class CapabilityTest < ActiveSupport::TestCase
23
+ setup do
24
+ @op = OpenDal::Operator.new("memory", nil)
25
+ end
26
+
27
+ test "has read capability" do
28
+ capability = @op.capability
29
+
30
+ assert_not capability.nil?
31
+ assert capability.read
32
+ end
33
+
34
+ test "doesn't respond to undefined capability" do
35
+ capability = @op.capability
36
+
37
+ assert_not capability.nil?
38
+ assert_raises(NoMethodError) do
39
+ capability.not_exist
40
+ end
41
+ end
42
+ end