openbabel-ruby 3.1.1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4b041ce12f6f124d860ad7280ec2ce5aeaf36df897405b2b9a2819f703dc734c
4
+ data.tar.gz: 5236c280c3186d3406dda3009e277a30748f042371c9f91e583609006e3f0c51
5
+ SHA512:
6
+ metadata.gz: 9f69a57091083cad77100223068b413221e803a883d7521f203866c049d5f8b7af6f12e7c13172b7ceca515a95eeb9036ae01d2853ef875908f7297094ea8d64
7
+ data.tar.gz: a6b24eaa24f2ea9fef22e993a4298d24e08337891cf12d2469ded36bee31344d82c99ae3d74501183daeef4cecf424f87df695772d6b08a1ee28bdc659848c63
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'test'
6
+ end
7
+
8
+ desc "Run tests"
9
+ task :default => :test
@@ -0,0 +1,61 @@
1
+ require 'fileutils'
2
+ require 'rbconfig'
3
+ require 'mkmf'
4
+
5
+ main_dir = File.expand_path(File.join(File.dirname(__FILE__),"..",".."))
6
+
7
+ # install OpenBabel
8
+
9
+ openbabel_dir = File.join main_dir, "openbabel_src"
10
+ src_dir = openbabel_dir
11
+ build_dir = File.join src_dir, "build"
12
+ install_dir = File.join main_dir, "openbabel"
13
+ install_lib_dir = File.join install_dir, "lib"
14
+ ruby_src_dir = File.join src_dir, "scripts", "ruby"
15
+
16
+ begin
17
+ nr_processors = `getconf _NPROCESSORS_ONLN`.to_i # should be POSIX compatible
18
+ rescue
19
+ nr_processors = 1
20
+ end
21
+
22
+ OPENBABEL_COMMIT = '889c350'
23
+
24
+ FileUtils.mkdir_p openbabel_dir
25
+ Dir.chdir main_dir do
26
+ FileUtils.rm_rf src_dir
27
+ puts "Downloading OpenBabel sources"
28
+ system "git clone https://github.com/openbabel/openbabel.git #{src_dir}"
29
+ Dir.chdir(src_dir) do
30
+ system "git checkout #{OPENBABEL_COMMIT}"
31
+ end
32
+ end
33
+
34
+ FileUtils.mkdir_p build_dir
35
+ FileUtils.mkdir_p install_dir
36
+ Dir.chdir build_dir do
37
+ puts "Configuring OpenBabel"
38
+ cmake = "cmake #{src_dir} -DCMAKE_INSTALL_PREFIX=#{install_dir} -DBUILD_GUI=OFF -DENABLE_TESTS=OFF -DRUN_SWIG=ON -DRUBY_BINDINGS=ON"
39
+ # set rpath for local installations
40
+ # http://www.cmake.org/Wiki/CMake_RPATH_handling
41
+ # http://vtk.1045678.n5.nabble.com/How-to-force-cmake-not-to-remove-install-rpath-td5721193.html
42
+ cmake += " -DCMAKE_INSTALL_RPATH:STRING=\"#{install_lib_dir}\""
43
+ system cmake
44
+ end
45
+
46
+ # local installation in gem directory
47
+ Dir.chdir build_dir do
48
+ puts "Compiling OpenBabel sources."
49
+ system "make -j#{nr_processors}"
50
+ system "make install"
51
+ ENV["PKG_CONFIG_PATH"] = File.dirname(File.expand_path(Dir["#{install_dir}/**/openbabel*pc"].first))
52
+ end
53
+
54
+ FileUtils.remove_dir(openbabel_dir)
55
+
56
+ # create a fake Makefile
57
+ File.open(File.join(File.dirname(__FILE__),"Makefile"),"w+") do |makefile|
58
+ makefile.puts "all:\n\ttrue\n\ninstall:\n\ttrue\n"
59
+ end
60
+
61
+ $makefile_created = true
@@ -0,0 +1,4 @@
1
+ module OpenBabel
2
+ VERSION = '3.1.1'
3
+ GEMVERSION = VERSION + '.0'
4
+ end
data/lib/openbabel.rb ADDED
@@ -0,0 +1,4 @@
1
+ require_relative '../openbabel/lib/openbabel'
2
+ require 'openbabel/version'
3
+ # http://sourceforge.net/mailarchive/message.php?msg_id=31065700
4
+ OpenBabel::OBConversion.new # required to load plugins
@@ -0,0 +1,22 @@
1
+ require 'test/unit'
2
+
3
+ require 'openbabel'
4
+ include OpenBabel
5
+
6
+ class OBTest < Test::Unit::TestCase
7
+ def test_obmol
8
+ # Code from http://goo.gl/9H1LZ
9
+
10
+ smi2mol = OBConversion.new
11
+ smi2mol.set_in_format("smi")
12
+
13
+ mol = OBMol.new
14
+ smi2mol.read_string(mol, 'CC(C)CCCC(C)C1CCC2C1(CCC3C2CC=C4C3(CCC(C4)O)C)C') # cholesterol, no chirality
15
+ mol.add_hydrogens
16
+
17
+ assert_equal(mol.num_atoms, 74)
18
+ assert_in_delta(mol.get_mol_wt, 386.65, 0.1)
19
+ assert_equal(mol.get_formula, "C27H46O")
20
+
21
+ end
22
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: openbabel-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.1.1.0
5
+ platform: ruby
6
+ authors:
7
+ - An Nguyen
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 2025-12-12 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: OpenBabel as a GEM
13
+ email:
14
+ - caman.nguyenthanh@gmail.com
15
+ executables: []
16
+ extensions:
17
+ - ext/openbabel/extconf.rb
18
+ extra_rdoc_files: []
19
+ files:
20
+ - Rakefile
21
+ - ext/openbabel/extconf.rb
22
+ - lib/openbabel.rb
23
+ - lib/openbabel/version.rb
24
+ - test/test_openbabel.rb
25
+ homepage: https://github.com/CamAnNguyen/openbabel-gem
26
+ licenses:
27
+ - GPL-3.0
28
+ metadata: {}
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubygems_version: 4.0.1
44
+ specification_version: 4
45
+ summary: OpenBabel!
46
+ test_files:
47
+ - test/test_openbabel.rb