Skip to content

Commit 583b9d7

Browse files
committed
First commit
0 parents  commit 583b9d7

File tree

15 files changed

+8415
-0
lines changed

15 files changed

+8415
-0
lines changed

.github/workflows/main.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Ruby
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
pull_request:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
name: Ruby ${{ matrix.ruby }}
14+
strategy:
15+
matrix:
16+
ruby:
17+
- '3.2.0'
18+
19+
steps:
20+
- uses: actions/checkout@v3
21+
- name: Set up Ruby
22+
uses: ruby/setup-ruby@v1
23+
with:
24+
ruby-version: ${{ matrix.ruby }}
25+
bundler-cache: true
26+
- name: Install hdf5
27+
run: sudo apt-get install libhdf5-dev
28+
- name: Run the default task
29+
run: bundle exec rake

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/.bundle/
2+
/.yardoc
3+
/_yardoc/
4+
/coverage/
5+
/doc/
6+
/pkg/
7+
/spec/reports/
8+
/tmp/
9+
10+
*.lock

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "hdf5"]
2+
path = hdf5
3+
url = https://github.com/HDFGroup/hdf5

.rubocop.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
AllCops:
2+
TargetRubyVersion: 2.6
3+
4+
Style/StringLiterals:
5+
Enabled: true
6+
EnforcedStyle: double_quotes
7+
8+
Style/StringLiteralsInInterpolation:
9+
Enabled: true
10+
EnforcedStyle: double_quotes
11+
12+
Layout/LineLength:
13+
Max: 120

Gemfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
# Specify your gem's dependencies in ruby-hdf5.gemspec
6+
gemspec
7+
8+
gem "rake"
9+
10+
gem "test-unit", "~> 3.0"
11+
12+
gem "rubocop"
13+
14+
gem "irb"

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2023 kojix2
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# ruby-hdf5
2+
3+
experimental Ruby bindings for the HDF5 library
4+
5+
## Development
6+
7+
- c2ffi
8+
- c2ffi4rb
9+
10+
## License
11+
12+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

Rakefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# frozen_string_literal: true
2+
3+
require "bundler/gem_tasks"
4+
require "rake/testtask"
5+
6+
Rake::TestTask.new(:test) do |t|
7+
t.libs << "test"
8+
t.libs << "lib"
9+
t.test_files = FileList["test/**/*_test.rb"]
10+
end
11+
12+
require "rubocop/rake_task"
13+
14+
RuboCop::RakeTask.new
15+
16+
task default: %i[test rubocop]

hdf5.json

Lines changed: 1848 additions & 0 deletions
Large diffs are not rendered by default.

lib/hdf5.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# frozen_string_literal: true
2+
3+
require "ffi"
4+
require_relative "hdf5/version"
5+
6+
module HDF5
7+
class Error < StandardError; end
8+
9+
class << self
10+
attr_accessor :lib_path
11+
12+
def search_hdf5lib(name = nil)
13+
return File.expand_path(name, ENV["HDF5_LIB_PATH"]) if ENV["HDF5_LIB_PATH"]
14+
15+
name = "libhdf5.#{FFI::Platform::LIBSUFFIX}"
16+
17+
begin
18+
require "pkg-config"
19+
libs = PKGConfig.libs("hdf5")
20+
pattern = %r{(?<=-L)/[^ ]+}
21+
p lib_dir = libs.scan(pattern).first
22+
lib_path = File.expand_path(name, lib_dir)
23+
rescue PackageConfig::NotFoundError
24+
warn "hdf5.pc not found."
25+
end
26+
return lib_path if File.exist?(lib_path)
27+
28+
warn "htslib shared library '#{name}' not found."
29+
end
30+
end
31+
32+
self.lib_path = search_hdf5lib
33+
end
34+
35+
require_relative "hdf5/ffi3"

0 commit comments

Comments
 (0)