diff --git a/.travis.yml b/.travis.yml index 0e1526b2..797ab53e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,40 +1,14 @@ sudo: false -os: - - linux - -dist: - - trusty - language: rust - -matrix: - include: - - rust: 1.13.0 - env: IMAG_RUBY_VERSION=2.3.3 - - rust: beta - env: IMAG_RUBY_VERSION=2.3.3 - - rust: stable - env: IMAG_RUBY_VERSION=2.3.3 - -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 - +rust: +- 1.13.0 +- beta +- stable +cache: cargo before_script: - | pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH - script: - | make all test @@ -51,14 +25,12 @@ addons: - tree sources: - kalakris-cmake - after_success: - | pushd .imag-documentation && travis-cargo --only stable doc && travis-cargo --only stable doc-upload popd - notifications: email: on_success: never @@ -67,11 +39,7 @@ notifications: - chat.freenode.net#imag template: - "%{repository_name} (%{branch} @ %{commit} by %{author}): %{result}" - env: global: - - THERMITE_DEBUG_FILENAME=/tmp/thermite-debug.log - - secure: D+3exBnbvzFvk7fvLOxkF7UotCc4gBbvvOW4xGr9u6dDjEjV5y6CdDy/OQAkhfKhvSou+lIC22g5MuCBQXFEf/ua7A1XzwBAFeVLK4cWZSa7+ql6LdHKqOg3oF6pQlh095WeWr8S2PYJFFJFg8RGUPnbjqdu1J4KSXqe/7GoZ3lYS69mx7D5Hb93KEN084/KGfBuvyJtMjO1fK3spltL2zV8oqegFpv0gLG5GY4LsJ/7ij4Mc6wepXSyyQbaiA1eKMMwQZDvoi4V1mCulo/jeC3pucGxvgnMV5DZs8aa8R7votltGvSpHCgU78LW19dg8oZqwShQQ+XUYw27H+QK5V1lz1l1MaJLbwS3ySyZBPGH8qUuOzQ3bLp9x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csPZ2uH4= diff --git a/Makefile b/Makefile index 42f629f8..e47c0c1d 100644 --- a/Makefile +++ b/Makefile @@ -68,9 +68,9 @@ lib: $(LIB_TARGETS) lib-test: $(LIB_TARGETS_TEST) lib-imag-ruby-test: - @$(MAKE) -C libimagruby test + @$(MAKE) -C libimagruby -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..c0dfb890 100644 --- a/default.nix +++ b/default.nix @@ -7,8 +7,6 @@ let ]; dependencies = with pkgs; [ - ruby - bundler cmake curl gcc diff --git a/libimagruby/.gitignore b/libimagruby/.gitignore index d76ba1ac..2f7c731a 100644 --- a/libimagruby/.gitignore +++ b/libimagruby/.gitignore @@ -1,5 +1,3 @@ .bundle Gemfile.lock -lib/liblibimagruby.so vendor/bundle -libimagruby*.tar.gz diff --git a/libimagruby/Makefile b/libimagruby/Makefile index f597909a..f7ed82d6 100644 --- a/libimagruby/Makefile +++ b/libimagruby/Makefile @@ -1,22 +1,20 @@ ECHO=$(shell which echo) -e RUBY=$(shell which ruby) -BUNDLE=$(shell which bundle) +RUBY_TESTS=$(shell find ./test -maxdepth 1 -name "*.rb" -type f) +RUBY_TEST_TARGETS=$(foreach x,$(subst ,,$(RUBY_TESTS)),$(x)) -all: - @$(ECHO) "There is no default target here" +all: lib -bundle: - @$(ECHO) "[BUNDLE]" - @$(BUNDLE) install --path vendor/bundle +lib: + $(MAKE) -C .. libimagruby -bundle-rake-thermite-test: - @$(ECHO) "[RAKE ][thermite]" - @CARGO_TARGET=debug $(BUNDLE) exec rake thermite:tarball +lib-release: + $(MAKE) -C .. libimagruby-release -test: lib bundle-rake-thermite-test - @$(ECHO) "[TEST ]" +test: lib $(RUBY_TEST_TARGETS) + +$(RUBY_TEST_TARGETS): %: lib .FORCE + @$(ECHO) "\t[TEST ]:\t$@" + @$(RUBY) $(subst -test,,$@) .FORCE: - -.PHONY: all - diff --git a/libimagruby/Rakefile b/libimagruby/Rakefile index a1397441..43022f71 100644 --- a/libimagruby/Rakefile +++ b/libimagruby/Rakefile @@ -1,5 +1,2 @@ require "bundler/gem_tasks" -require 'thermite/tasks' - -Thermite::Tasks.new(cargo_project_path: "..", cargo_workspace_member: "libimagruby") - +task :default => :spec 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 index 5ffa7a62..c6066912 100644 --- a/libimagruby/imag.gemspec +++ b/libimagruby/imag.gemspec @@ -23,7 +23,4 @@ Gem::Specification.new do |spec| 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 index d0db0d53..b8c91115 100644 --- a/libimagruby/lib/imag.rb +++ b/libimagruby/lib/imag.rb @@ -1,12 +1,5 @@ #!/usr/bin/env ruby -require 'thermite/fiddle' - -toplevel_dir = File.dirname(File.dirname(__FILE__)) -Thermite::Fiddle.load_module('init_imag', - cargo_project_path: toplevel_dir, - ruby_project_path: toplevel_dir) - module Imag IMAG_INIT_FN_NAME = 'imag_ruby_initialize' diff --git a/libimagruby/test/test_entries.rb b/libimagruby/test/test_entries.rb new file mode 100644 index 00000000..f10dc643 --- /dev/null +++ b/libimagruby/test/test_entries.rb @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby + +require "../target/debug/liblibimagruby.so" + +color = true +verbose = true +debug = false + +RImag.init_logger debug, verbose, color + +store_handle = RStoreHandle::new(false, "/tmp/store") +id = RStoreId::new_baseless("test") +test_handle = store_handle.retrieve(id) +puts "Header: #{test_handle.header.to_s}" +puts "Content: '#{test_handle.content}'" + +test_handle.content = "Foo" +test_handle.header = { + "imag" => { + "links" => [], + "version" => "0.2.0" + }, + "example" => { + "test" => "foo" + } +} + diff --git a/libimagruby/test/test_ruby.rb b/libimagruby/test/test_ruby.rb new file mode 100644 index 00000000..9b088594 --- /dev/null +++ b/libimagruby/test/test_ruby.rb @@ -0,0 +1,58 @@ +#!/usr/bin/env ruby + +require "../target/debug/liblibimagruby.so" + +color = true +verbose = true +debug = true + +RImag.init_logger debug, verbose, color + +RImag.trace "Trace-Hello from Ruby" +RImag.dbg "Debug-Hello from Ruby" +RImag.debug "Debug-Hello from Ruby" +RImag.info "Info-Hello from Ruby" +RImag.warn "Warn-Hello from Ruby" +RImag.error "Error-Hello from Ruby" + +def works name, b + if b + RImag.info "Works: #{name}" + else + RImag.error "Fails: #{name}" + end +end + +def has_instance_method klass, meth + works "#{klass}.instance_methods.include? #{meth}", + (klass.instance_methods.include? meth) +end + +puts "---" + +works "RStoreId.new_baseless", (not RStoreId.new_baseless("test").nil?) + +works "RStoreHandle.respond_to? :new", (RStoreHandle.respond_to? :new) + +has_instance_method RStoreHandle, :create +has_instance_method RStoreHandle, :get +has_instance_method RStoreHandle, :retrieve +has_instance_method RStoreHandle, :delete +has_instance_method RStoreHandle, :update +has_instance_method RStoreHandle, :move_by_id +has_instance_method RStoreHandle, :save_as +has_instance_method RStoreHandle, :save_to + +has_instance_method RFileLockEntryHandle, :content +has_instance_method RFileLockEntryHandle, :content= +has_instance_method RFileLockEntryHandle, :header +has_instance_method RFileLockEntryHandle, :header= + +has_instance_method REntryHeader, :read +has_instance_method REntryHeader, :[] +has_instance_method REntryHeader, :set +has_instance_method REntryHeader, :[]= +has_instance_method REntryHeader, :insert + +works "REntryContent.superclass == String", (REntryContent.superclass == String) + diff --git a/libimagruby/test/test_store.rb b/libimagruby/test/test_store.rb new file mode 100644 index 00000000..aed00177 --- /dev/null +++ b/libimagruby/test/test_store.rb @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby + +require "../target/debug/liblibimagruby.so" + +color = true +verbose = true +debug = true + +RImag.init_logger debug, verbose, color + +store_handle = RStoreHandle::new(false, "/tmp/store") +id = RStoreId::new_baseless("test") +test_handle = store_handle.create(id) + +RImag.info "Created #{test_handle.location.to_str} from Ruby" +