summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2017-05-02 16:00:14 +0200
committerMatthias Beyer <mail@beyermatthias.de>2017-05-02 17:14:48 +0200
commit2b2ef72b696287037a0fba3eaf364ec654f2c60c (patch)
tree44de5d99f593fcb564d455b58d18cdeea2bb193a
parent7e3c9467e7b95324f1bc34dc05fb8b33e2a26e90 (diff)
Remove libimagruby
To quick-fix the master branch.
-rw-r--r--.travis.yml18
-rw-r--r--Cargo.toml1
-rw-r--r--Makefile10
-rw-r--r--default.nix1
-rw-r--r--libimagruby/.gitignore5
-rw-r--r--libimagruby/Cargo.toml41
-rw-r--r--libimagruby/Gemfile4
-rw-r--r--libimagruby/Makefile22
-rw-r--r--libimagruby/README.md85
-rw-r--r--libimagruby/Rakefile5
-rw-r--r--libimagruby/ext/Rakefile5
-rw-r--r--libimagruby/imag.gemspec29
-rw-r--r--libimagruby/lib/imag.rb140
-rw-r--r--libimagruby/lib/imag/version.rb3
-rw-r--r--libimagruby/src/cache.rs42
-rw-r--r--libimagruby/src/entry.rs276
-rw-r--r--libimagruby/src/error.rs52
-rw-r--r--libimagruby/src/imag.rs148
-rw-r--r--libimagruby/src/lib.rs55
-rw-r--r--libimagruby/src/ruby_utils.rs210
-rw-r--r--libimagruby/src/store.rs578
-rw-r--r--libimagruby/src/storeid.rs164
-rw-r--r--libimagruby/src/toml_utils.rs65
-rw-r--r--libimagruby/src/util.rs102
24 files changed, 2 insertions, 2059 deletions
diff --git a/.travis.yml b/.travis.yml
index ce909c6b..d3fd9427 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -10,23 +10,9 @@ language: rust
matrix:
include:
- rust: 1.13.0
- env: IMAG_RUBY_VERSION=2.3.3
- - rust: 1.13.0
- env: IMAG_RUBY_VERSION=2.4.0
cache:
cargo: true
- directories:
- - $TRAVIS_BUILD_DIR/libimagruby/vendor/bundle
-
-before_install:
-- |
- rvm install "$IMAG_RUBY_VERSION"
- rvm use "$IMAG_RUBY_VERSION"
- ruby --version
- pushd libimagruby
- bundle install --jobs=3 --retry=3 --path=$TRAVIS_BUILD_DIR/libimagruby/vendor/bundle
- popd
before_script:
- |
@@ -44,7 +30,6 @@ addons:
- libcurl4-openssl-dev
- libdw-dev
- libelf-dev
- - libruby
- libzzip-dev
- make
- tree
@@ -71,6 +56,3 @@ env:
global:
- THERMITE_DEBUG_FILENAME=/tmp/thermite-debug.log
- secure: D+3exBnbvzFvk7fvLOxkF7UotCc4gBbvvOW4xGr9u6dDjEjV5y6CdDy/OQAkhfKhvSou+lIC22g5MuCBQXFEf/ua7A1XzwBAFeVLK4cWZSa7+ql6LdHKqOg3oF6pQlh095WeWr8S2PYJFFJFg8RGUPnbjqdu1J4KSXqe/7GoZ3lYS69mx7D5Hb93KEN084/KGfBuvyJtMjO1fK3spltL2zV8oqegFpv0gLG5GY4LsJ/7ij4Mc6wepXSyyQbaiA1eKMMwQZDvoi4V1mCulo/jeC3pucGxvgnMV5DZs8aa8R7votltGvSpHCgU78LW19dg8oZqwShQQ+XUYw27H+QK5V1lz1l1MaJLbwS3ySyZBPGH8qUuOzQ3bLp9xhAIRgCui3kX/UDhmeME7nJI6k3UZydh+/ydNB1BZHTKn76XS/yFj0Gcibxg7f5fcAYA6Ge5Sg+YPozuwbcKnKe6IpN2M7qNgWa+6MCSXJ1v4BgPb7kN74EynJUM8+yWEFN7MZtWEUQ4ZsHdCs8Pub4C/zHpYGV8qGenZwQzosAFq56YwoGCvJezz35yg4BDd3IMKenOzNnXLBrdxxqX8ySgwt5B3zBqwve/64Lx6OXjae2m8wZKlsmeqad/s6K7nx0zG15/qqRIzyvgcLXq3jwBaHkteq49FRFWvHQFpBQcsPZ2uH4=
- matrix:
- - IMAG_RUBY_VERSION=2.3.3
- - IMAG_RUBY_VERSION=2.4.0
diff --git a/Cargo.toml b/Cargo.toml
index e2033577..dee38680 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,7 +21,6 @@ members = [
"libimagnotes",
"libimagref",
"libimagrt",
- "libimagruby",
"libimagstore",
"libimagstorestdhook",
"libimagtimeui",
diff --git a/Makefile b/Makefile
index 838ba1cf..afc3e17a 100644
--- a/Makefile
+++ b/Makefile
@@ -47,18 +47,12 @@ bin: $(BIN_TARGETS) imag-bin
bin-test: $(BIN_TARGET_TESTS) imag-bin
-lib: $(LIB_TARGETS) lib-imag-ruby-tarball
+lib: $(LIB_TARGETS)
@$(ECHO) "\t[ALLLIB ]"
lib-test: $(LIB_TARGETS_TEST)
-lib-imag-ruby-tarball:
- @$(MAKE) -C libimagruby tarball
-
-lib-imag-ruby-test:
- @$(MAKE) -C libimagruby test
-
-test: bin-test lib-test lib-imag-ruby-test
+test: bin-test lib-test
install: $(INSTALL_TARGETS) imag-bin-install
@$(ECHO) "\t[INSTALL]"
diff --git a/default.nix b/default.nix
index 5d8e76d5..70f6cb78 100644
--- a/default.nix
+++ b/default.nix
@@ -7,7 +7,6 @@ let
];
dependencies = with pkgs; [
- ruby
bundler
cmake
curl
diff --git a/libimagruby/.gitignore b/libimagruby/.gitignore
deleted file mode 100644
index d76ba1ac..00000000
--- a/libimagruby/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-.bundle
-Gemfile.lock
-lib/liblibimagruby.so
-vendor/bundle
-libimagruby*.tar.gz
diff --git a/libimagruby/Cargo.toml b/libimagruby/Cargo.toml
deleted file mode 100644
index 2d98a086..00000000
--- a/libimagruby/Cargo.toml
+++ /dev/null
@@ -1,41 +0,0 @@
-[package]
-name = "libimagruby"
-version = "0.1.0"
-authors = ["Matthias Beyer <mail@beyermatthias.de>"]
-
-description = "Library for the imag core distribution"
-
-keywords = ["imag", "PIM", "personal", "information", "management"]
-readme = "../README.md"
-license = "LGPL-2.1"
-
-documentation = "https://matthiasbeyer.github.io/imag/imag_documentation/index.html"
-repository = "https://github.com/matthiasbeyer/imag"
-homepage = "http://imag-pim.org"
-
-[lib]
-crate-type = ["dylib"]
-
-[dependencies]
-ruru = "0.9"
-lazy_static = "0.2"
-log = "0.3"
-env_logger = "0.3"
-toml = "0.2"
-uuid = { version = "0.3", features = ["v4"] }
-
-[dependencies.libimagerror]
-path = "../libimagerror"
-
-[dependencies.libimagrt]
-path = "../libimagrt"
-
-[dependencies.libimagstore]
-path = "../libimagstore"
-
-[dependencies.libimagstorestdhook]
-path = "../libimagstorestdhook"
-
-[dependencies.libimagutil]
-path = "../libimagutil"
-
diff --git a/libimagruby/Gemfile b/libimagruby/Gemfile
deleted file mode 100644
index aadb3470..00000000
--- a/libimagruby/Gemfile
+++ /dev/null
@@ -1,4 +0,0 @@
-# frozen_string_literal: true
-source "https://rubygems.org"
-
-gemspec
diff --git a/libimagruby/Makefile b/libimagruby/Makefile
deleted file mode 100644
index bf023b98..00000000
--- a/libimagruby/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
-ECHO=$(shell which echo) -e
-RUBY=$(shell which ruby)
-BUNDLE=$(shell which bundle)
-
-all:
- @$(ECHO) "There is no default target here"
-
-bundle:
- @$(ECHO) "[BUNDLE]"
- @$(BUNDLE) install --path vendor/bundle
-
-tarball: bundle
- @$(ECHO) "[RAKE ][thermite]"
- @CARGO_TARGET=debug $(BUNDLE) exec rake thermite:tarball
-
-test: tarball
- @$(ECHO) "[TEST ] Not yet implemented. :-("
-
-.FORCE:
-
-.PHONY: all
-
diff --git a/libimagruby/README.md b/libimagruby/README.md
deleted file mode 100644
index b11cc5cb..00000000
--- a/libimagruby/README.md
+++ /dev/null
@@ -1,85 +0,0 @@
-# imag-ruby
-
-A Ruby gem for scripting imag modules.
-
-## How does this work?
-
-Well, as we have some problems with lifetimes here, we have a fairly complex
-codebase in this crate.
-
-### The Problem
-
-The Problem is, that `libimagstore::store::FileLockEntry<'a>` has a lifetime. If
-we would wrap this object into a ruru wrapper and pass to the Ruby code, we
-couldn't guarantee anymore that the lifetime holds.
-
-The problem is simple, you see...
-
-### The solution?
-
-Never pass anything to the Ruby code.
-
-Yes, exactly. The Ruby code only sees 'handles'. It never actually gets the
-`Store` object either.
-We move the `Store` Object into a `Cache` object (actually, the Ruby code could
-have multiple `Store` objects to work with this way) and return a `StoreHandle`
-to the Ruby code (which is a UUID underneath).
-
-Also, the Ruby code never actually touches a `FileLockEntry` - it only gets a
-Handle for each `FileLockEntry` - which is a tuple of the `StoreHandle` and the
-`libimagstore::storeid::StoreId` for the Entry.
-
-Each operation on a `FileLockEntry` is then wrapped by this very library. Each
-time `FileLockEntry` is touched, this library fetches the appropriate `Store`
-object from the static `Cache`, then fetches the `FileLockEntry` object from it,
-does the operation and then drops the object (which implies that the actual
-`FileLockEntry` is `update()`d!).
-
-### The Hell?
-
-Yes, I know this is a lot of overhead. But what are we talking about here? This
-is Ruby code we're talking about here, so speed is not our concern.
-
-You could argue this is a hell of complexity introduced in this library and yes
-it is.
-If there are bugs (and I bet there are) they would be complex as hell.
-But that's it... if you have a better approach, please file a PR.
-
-## Tests?
-
-We have tests Ruby scripts in `./test`, they are not executed by travis-ci, as
-we need Ruby `2.3.0` for this and travis has `2.2.0` as latest version.
-But I hope we get it in travis soonish.
-
-## Ruby gem?
-
-This crate will contain both the Rust bindings for imag using `ruru` and a bunch
-of wrapper code for the actual `imag` gem.
-
-### Why another layer of indirection?
-
-As "ruru" does not yet support modules (which is sad btw) we would end up with
-functions for all the things.
-
-E.G.: `imag_runtime_setup()` instead of `Imag::Runtime::setup()`
-
-I want to add a Ruby gem to wrap these things.
-
-So basically a piece of Ruby which uses the Rust code to build
-`imag` as a gem which then exports a fine module system.
-
-### The module system:
-
-```text
-Imag (Module)
- EntryContent (Class (inherits from String))
- EntryHeader (Class)
- FileLockEntryHandle (Class)
- StoreHandle (Class)
- StoreId (Class)
-```
-
-`libimagentrytag` and the other `libimagentry*` libraries will be pulled into
-this library to support more advanced operations with the `FileLockEntryHandle`
-type.
-
diff --git a/libimagruby/Rakefile b/libimagruby/Rakefile
deleted file mode 100644
index a1397441..00000000
--- a/libimagruby/Rakefile
+++ /dev/null
@@ -1,5 +0,0 @@
-require "bundler/gem_tasks"
-require 'thermite/tasks'
-
-Thermite::Tasks.new(cargo_project_path: "..", cargo_workspace_member: "libimagruby")
-
diff --git a/libimagruby/ext/Rakefile b/libimagruby/ext/Rakefile
deleted file mode 100644
index 4e097360..00000000
--- a/libimagruby/ext/Rakefile
+++ /dev/null
@@ -1,5 +0,0 @@
-require 'thermite/tasks'
-
-Thermite::Tasks.new(cargo_project_path: "..", cargo_workspace_member: "libimagruby")
-task default: %w(thermite:build)
-
diff --git a/libimagruby/imag.gemspec b/libimagruby/imag.gemspec
deleted file mode 100644
index 5ffa7a62..00000000
--- a/libimagruby/imag.gemspec
+++ /dev/null
@@ -1,29 +0,0 @@
-# coding: utf-8
-lib = File.expand_path('../lib', __FILE__)
-$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
-require 'imag/version'
-
-Gem::Specification.new do |spec|
- spec.name = "imag"
- spec.version = Imag::VERSION
- spec.authors = ["Matthias Beyer"]
- spec.email = ["mail@beyermatthias.de"]
-
- spec.summary = %q{A Ruby gem to script imag.}
- spec.description = %q{A Ruby gem to script imag, the personal information management suite for the commandline}
- spec.homepage = "http://imag-pim.org"
-
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
- f.match(%r{^(test|spec|features)/})
- end
-
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-
- spec.add_development_dependency "bundler", "~> 1.13"
- spec.add_development_dependency "rake", "~> 10.0"
- spec.add_development_dependency 'thermite', "~> 0.11", ">= 0.11.1"
-
- spec.extensions << 'ext/Rakefile'
-end
diff --git a/libimagruby/lib/imag.rb b/libimagruby/lib/imag.rb
deleted file mode 100644
index 0938c50b..00000000
--- a/libimagruby/lib/imag.rb
+++ /dev/null
@@ -1,140 +0,0 @@
-#!/usr/bin/env ruby
-
-# imag ruby interface module
-#
-# This module is created because the library which is used to write the Ruby
-# bindings in Rust does not support modules.
-#
-# This is a wrapper to have nice Ruby-like things in the Ruby codebase and for
-# beeing backwards compatible as soon as the Rust library gets module support.
-#
-# There will probably always be a wrapper for the Rust library, to be more
-# flexible with the API, though.
-module Imag
-
- # Function name of the function to call to initialize the Rust backend part.
- # Do not use.
- IMAG_INIT_FN_NAME = 'imag_ruby_initialize'
-
- # Setup method
- #
- # Call this method for initializing the library.
- # It dynamically creates the classes for the imag library.
- def self.setup binary_path
- require binary_path
-
- self.core_setup
- self.classes_setup
- end
-
- # Abstraction over the logger frontend of the binary
- #
- # This is just a translation to nice Ruby code
- module Logger
-
- def self.init cfg
- debug = !!cfg[:debug]
- verbose = !!cfg[:verbose]
- color = !!cfg[:color]
- ::RImag.init_logger debug, verbose, color
- end
-
- # Log text with "trace" level in imag
- def self.trace msg
- ::RImag.trace msg
- end
-
- # Log text with "debug" level in imag
- def self.dbg msg
- ::RImag.dbg msg
- end
-
- # Log text with "debug" level in imag (alias for Imag::Logger::dbg)
- def self.debug msg
- ::RImag.debug msg
- end
-
- # Log text with "info" level in imag
- def self.info msg
- ::RImag.info msg
- end
-
- # Log text with "warning" level in imag
- def self.warn msg
- ::RImag.warn msg
- end
-
- # Log text with "error" level in imag
- def self.error msg
- ::RImag.error msg
- end
-
- end
-
- private
-
- # Class names of the Classes in the Ruby scope
- #
- # These classes are created by the Rust backend with an "R" prefix, and are
- # here mapped to Ruby classes by inheriting from them.
- #
- # Addidional functionality and convenience methods can then be set up upon
- # these pure Ruby classes.
- def self.class_names
- [
- :StoreId ,
- :StoreHandle ,
- :FileLockEntryHandle ,
- :EntryHeader ,
- :EntryContent ,
- ]
- end
-
- # Do the core setup
- #
- # Maps the Rust classes to Ruby classes by inheriting from them
- def self.core_setup
- self.class_names.map {|n| [n, "R#{n}".to_sym ] }.each do |elem|
- Imag.const_set elem.first, Kernel.const_get(elem.last)
- end
- end
-
- # Class setup
- #
- # Summarizing method for calling all the class-setup methods.
- def self.classes_setup
- self.class_storeid_setup
- end
-
- # Class setup for the StoreId class
- #
- # Sets up additional methods for the Imag::StoreId class.
- def self.class_storeid_setup
- Imag::StoreId.class_exec do
- def to_s
- self.to_str
- end
- end
- end
-
-end
-
-if __FILE__ == $0
- puts "Running some tests..."
- puts "I hope you passed the library object as first argument..."
- begin
- Imag.setup ARGV.first
- rescue Exception => e
- puts "Seems not to be the case... or something else went wrong..."
- puts e
- exit 1
- end
-
- Imag::Logger.init debug: true, verbose: true, color: true
- Imag::Logger.info "The Logger should work now"
-
- Imag::Logger.info "Lets see whether we have properly setup StoreId"
- Imag::Logger.info Imag::StoreId::new_baseless("baselessId").to_s
- Imag::Logger.info "Seems good."
-end
-
diff --git a/libimagruby/lib/imag/version.rb b/libimagruby/lib/imag/version.rb
deleted file mode 100644
index c2a2473f..00000000
--- a/libimagruby/lib/imag/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-module Imag
- VERSION = "0.1.0"
-end
diff --git a/libimagruby/src/cache.rs b/libimagruby/src/cache.rs
deleted file mode 100644
index 94c2b869..00000000
--- a/libimagruby/src/cache.rs
+++ /dev/null
@@ -1,42 +0,0 @@
-//
-// imag - the personal information management suite for the commandline
-// Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; version
-// 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-//
-
-use std::collections::BTreeMap;
-use std::sync::Arc;
-use std::sync::Mutex;
-
-use uuid::Uuid;
-
-use libimagstore::store::Store;
-
-#[derive(Clone, Debug, Ord, Hash, Eq, PartialOrd, PartialEq)]
-pub struct StoreHandle(Uuid);
-
-impl StoreHandle {
- pub fn new() -> StoreHandle {
- StoreHandle(Uuid::new_v4())
- }
-}
-
-lazy_static! {
- pub static ref RUBY_STORE_CACHE: Arc<Mutex<BTreeMap<StoreHandle, Store>>> = {
- Arc::new(Mutex::new(BTreeMap::new()))
- };
-}
-
diff --git a/libimagruby/src/entry.rs b/libimagruby/src/entry.rs
deleted file mode 100644
index 9c55e72d..00000000
--- a/libimagruby/src/entry.rs
+++ /dev/null
@@ -1,276 +0,0 @@
-//
-// imag - the personal information management suite for the commandline
-// Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; version
-// 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-//
-
-#[allow(unused_variables)]
-
-use std::error::Error;
-
-use ruru::{Class, Object, AnyObject, Boolean, RString, VM, Hash, NilClass, VerifiedObject};
-use toml::Value;
-
-use libimagstore::store::EntryContent;
-use libimagstore::store::Entry;
-use libimagstore::storeid::StoreId;
-use libimagstore::toml_ext::TomlValueExt;
-
-use ruby_utils::IntoToml;
-use toml_utils::IntoRuby;
-use util::Wrap;
-use util::Unwrap;
-use cache::StoreHandle;
-
-pub struct FileLockEntryHandle(StoreHandle, StoreId);
-
-impl FileLockEntryHandle {
- pub fn new(sh: StoreHandle, id: StoreId) -> FileLockEntryHandle {
- FileLockEntryHandle(sh, id)
- }
-
- pub fn store_handle(&self) -> &StoreHandle {
- &self.0
- }
-
- pub fn fle_handle(&self) -> &StoreId {
- &self.1
- }
-}
-
-wrappable_struct!(FileLockEntryHandle, FileLockEntryWrapper, FLE_WRAPPER);
-class!(RFileLockEntryHandle);
-impl_wrap!(FileLockEntryHandle => FLE_WRAPPER);
-impl_unwrap!(RFileLockEntryHandle => FileLockEntryHandle => FLE_WRAPPER);
-impl_verified_object!(RFileLockEntryHandle);
-
-/// Helper macro for operating on RUBY_STORE_CACHE object
-///
-/// This helps us calling operations on FileLockEntry objects.
-///
-/// What I do here: Fetch the Store object from the cache, fetch the appropriate FileLockEntry and
-/// call the operation on it.
-///
-/// This could be improved with another cache, so not the store is cached but the FileLockEntry
-/// only, but then we run into lifetime problems with the Store and its FileLockEntry objects.
-/// Feel free to fix this, but for now, this is a workable solution.
-///
-#[macro_export]
-macro_rules! call_on_fle_from_store {
- ($itself:ident ($wrapper:ident) -> $name:ident -> $operation:block) => {{
- let handle = $itself.get_data(&*$wrapper);
- let store_handle = handle.store_handle();
- call_on_store_by_handle! {
- store_handle named store inside {
- match store.get(handle.fle_handle().clone()) {
- Ok(Some(mut $name)) => {
- $operation
- },
- Ok(None) => {
- VM::raise(Class::from_existing("RImagStoreReadError"), "Obj does not exist");
- NilClass::new().to_any_object()
- },
- Err(e) => {
- VM::raise(Class::from_existing("RImagStoreReadError"), e.description());
- NilClass::new().to_any_object()
- },
- }
- }
- }
- }};
- ($itself:ident ($wrapper:ident) -> $name:ident -> $operation: block on fail return $ex:expr) => {{
- let handle = $itself.get_data(&*$wrapper);
- let store_handle = handle.store_handle();
- call_on_store_by_handle! {
- store_handle named store inside {
- match store.get(handle.fle_handle().clone()) {
- Ok(Some(mut $name)) => {
- $operation
- },
- Ok(None) => {
- VM::raise(Class::from_existing("RImagStoreReadError"), "Obj does not exist");
- $ex
- },
- Err(e) => {
- VM::raise(Class::from_existing("RImagStoreReadError"), e.description());
- $ex
- },
- }
- } on fail return $ex
- }
- }};
-}
-
-
-methods!(
- RFileLockEntryHandle,
- itself,
-
- fn r_get_location() -> AnyObject {
- call_on_fle_from_store!(itself (FLE_WRAPPER) -> fle -> { fle.get_location().clone().wrap() })
- }
-
- fn r_get_header() -> AnyObject {
- call_on_fle_from_store!(itself (FLE_WRAPPER) -> fle -> { fle.get_header().clone().wrap() })
- }
-
- fn r_set_header(hdr: Hash) -> NilClass {
- use ruby_utils::IntoToml;
- use toml::Value;
-
- let entryheader = match typecheck!(hdr or return NilClass::new()).into_toml() {
- Value::Table(t) => Value::Table(t),
- _ => {
- let ec = Class::from_existing("RImagEntryHeaderWriteError");
- VM::raise(ec, "Something weird happened. Hash seems to be not a Hash");
- return NilClass::new();
- },
- };
-
- call_on_fle_from_store!(itself (FLE_WRAPPER) -> fle -> {
- *fle.get_header_mut() = entryheader;
- NilClass::new().to_any_object()
- });
-
- NilClass::new()
- }
-
- fn r_get_content() -> AnyObject {
- call_on_fle_from_store!(itself (FLE_WRAPPER) -> fle -> {
- fle.get_content().clone().wrap()
- } on fail return NilClass::new().to_any_object())
- }
-
- fn r_set_content(ctt: RString) -> NilClass {
- use ruby_utils::IntoToml;
- use toml::Value;
-
- let content = match typecheck!(ctt).into_toml() {
- Value::String(s) => s,
- _ => {
- let ec = Class::from_existing("RImagEntryError");
- VM::raise(ec, "Something weird happened. String seems to be not a String");
- return NilClass::new();
- },
- };
-
- call_on_fle_from_store!(itself (FLE_WRAPPER) -> fle -> {
- *fle.get_content_mut() = content;
- NilClass::new().to_any_object()
- });
-
- NilClass::new()
- }
-
-);
-
-wrappable_struct!(Value, EntryHeaderWrapper, ENTRY_HEADER_WRAPPER);
-class!(REntryHeader);
-impl_wrap!(Value => ENTRY_HEADER_WRAPPER);
-impl_unwrap!(REntryHeader => Value => ENTRY_HEADER_WRAPPER);
-impl_verified_object!(REntryHeader);
-
-methods!(
- REntryHeader,
- itself,
-
- fn r_entry_header_new() -> AnyObject {
- Entry::default_header().wrap()
- }
-
- fn r_entry_header_insert(spec: RString, obj: AnyObject) -> Boolean {
- let spec = typecheck!(spec or return Boolean::new(false)).to_string();
- let obj = obj.unwrap(); // possibly not safe... TODO
-
- match itself.get_data(&*ENTRY_HEADER_WRAPPER).insert(&spec, obj.into_toml()) {
- Ok(b) => Boolean::new(b),
- Err(e) => {
- VM::raise(Class::from_existing("RImagEntryHeaderWriteError"), e.description());
- Boolean::new(false)
- }
- }
- }
-
- fn r_entry_header_set(spec: RString, obj: AnyObject) -> AnyObject {
- use ruru::NilClass;
-
- let spec = typecheck!(spec or return any Boolean::new(false)).to_string();
- let obj = obj.unwrap(); // possibly not safe... TODO
-
- match itself.get_data(&*ENTRY_HEADER_WRAPPER).set(&spec, obj.into_toml()) {
- Ok(Some(v)) => v.into_ruby(),
- Ok(None) => NilClass::new().to_any_object(),
- Err(e) => {
- VM::raise(Class::from_existing("RImagEntryHeaderWriteError"), e.description());
- return Boolean::new(false).to_any_object();
- }
- }
- }
-
- fn r_entry_header_get(spec: RString) -> AnyObject {
- use ruru::NilClass;
-
- let spec = typecheck!(spec or return any Boolean::new(false)).to_string();
-
- match itself.get_data(&*ENTRY_HEADER_WRAPPER).read(&spec) {
- Ok(Some(v)) => v.into_ruby(),
- Ok(None) => NilClass::new().to_any_object(),
- Err(e) => {
- VM::raise(Class::from_existing("RImagEntryHeaderReadError"), e.description());
- return Boolean::new(false).to_any_object();
- }
- }
- }
-
-);
-
-wrappable_struct!(EntryContent, EntryContentWrapper, ENTRY_CONTENT_WRAPPER);
-class!(REntryContent);
-impl_wrap!(EntryContent => ENTRY_CONTENT_WRAPPER);
-impl_unwrap!(REntryContent => EntryContent => ENTRY_CONTENT_WRAPPER);
-
-wrappable_struct!(Entry, EntryWrapper, ENTRY_WRAPPER);
-class!(REntry);
-impl_unwrap!(REntry => Entry => ENTRY_WRAPPER);
-
-pub fn setup_filelockentry() -> Class {
- let mut class = Class::new("RFileLockEntryHandle", None);
- class.define(|itself| {
- itself.def("location", r_get_location);
- itself.def("header" , r_get_header);
- itself.def("header=" , r_set_header);
- itself.def("content" , r_get_content);
- itself.def("content=", r_set_content);
- });
- class
-}
-
-pub fn setup_entryheader() -> Class {
- let mut class = Class::new("REntryHeader", None);
- class.define(|itself| {
- itself.def("insert", r_entry_header_insert);
- itself.def("set" , r_entry_header_set);
- itself.def("[]=" , r_entry_header_set);
- itself.def("read" , r_entry_header_get);
- itself.def("[]" , r_entry_header_get);
- });
- class
-}
-
-pub fn setup_entrycontent() -> Class {
- let string = Class::from_existing("String");
- Class::new("REntryContent", Some(&string))
-}
diff --git a/libimagruby/src/error.rs b/libimagruby/src/error.rs
deleted file mode 100644
index acd01d4e..00000000
--- a/libimagruby/src/error.rs
+++ /dev/null
@@ -1,52 +0,0 @@
-//
-// imag - the personal information management suite for the commandline
-// Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; version
-// 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-//
-
-use ruru::Class;
-
-class!(RImagError);
-class!(RImagObjDoesNotExistError);
-class!(RImagStoreError);
-class!(RImagStoreWriteError);
-class!(RImagStoreReadError);
-class!(RImagEntryError);
-class!(RImagEntryHeaderError);
-class!(RImagEntryHeaderReadError);
-class!(RImagEntryHeaderWriteError);
-class!(RImagTypeError);
-
-pub fn setup() {
- let imag_error = Class::new("RImagError", Some(&Class::from_existing("RuntimeError")));
- Class::new("RImagObjDoesNotExistError" , Some(&imag_error));
-
- {
- let imag_store_error = Class::new("RImagStoreError", Some(&imag_error));
- Class::new("RImagStoreWriteError", Some(&imag_store_error));
- Class::new("RImagStoreReadError" , Some(&imag_store_error));
- }
-
- {
- let imag_entry_error = Class::new("RImagEntryError" , Some(&imag_error));
- let imag_entry_header_error = Class::new("RImagEntryHeaderError", Some(&imag_entry_error));
- Class::new("RImagEntryHeaderReadError" , Some(&imag_entry_header_error));
- Class::new("RImagEntryHeaderWriteError", Some(&imag_entry_header_error));
- }
-
- Class::new("RImagTypeError", Some(&imag_error));
-}
-
diff --git a/libimagruby/src/imag.rs b/libimagruby/src/imag.rs
deleted file mode 100644
index 8cec75ba..00000000
--- a/libimagruby/src/imag.rs
+++ /dev/null
@@ -1,148 +0,0 @@
-//
-// imag - the personal information management suite for the commandline
-// Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; version
-// 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-//
-
-#[allow(unused_variables)]
-
-use std::error::Error;
-
-use ruru::{Class, Boolean, RString, NilClass, VM, Object};
-
-use libimagrt::logger::ImagLogger;
-
-class!(RImag);
-
-methods!(
- RImag,
- itself,
-