diff --git a/libimagruby/.gitignore b/libimagruby/.gitignore new file mode 100644 index 00000000..627b10ec --- /dev/null +++ b/libimagruby/.gitignore @@ -0,0 +1 @@ +vendor/bundle diff --git a/libimagruby/Gemfile b/libimagruby/Gemfile new file mode 100644 index 00000000..aadb3470 --- /dev/null +++ b/libimagruby/Gemfile @@ -0,0 +1,4 @@ +# frozen_string_literal: true +source "https://rubygems.org" + +gemspec diff --git a/libimagruby/Rakefile b/libimagruby/Rakefile new file mode 100644 index 00000000..43022f71 --- /dev/null +++ b/libimagruby/Rakefile @@ -0,0 +1,2 @@ +require "bundler/gem_tasks" +task :default => :spec diff --git a/libimagruby/imag.gemspec b/libimagruby/imag.gemspec new file mode 100644 index 00000000..c6066912 --- /dev/null +++ b/libimagruby/imag.gemspec @@ -0,0 +1,26 @@ +# 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" +end diff --git a/libimagruby/gem/imag.rb b/libimagruby/lib/imag.rb similarity index 65% rename from libimagruby/gem/imag.rb rename to libimagruby/lib/imag.rb index ab276856..b8c91115 100644 --- a/libimagruby/gem/imag.rb +++ b/libimagruby/lib/imag.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -module RubyImag +module Imag IMAG_INIT_FN_NAME = 'imag_ruby_initialize' @@ -14,31 +14,31 @@ module RubyImag module Logger def self.init debug, verbose, color - Imag.init_logger debug, verbose, color + RImag.init_logger debug, verbose, color end def self.trace msg - Imag.trace msg + RImag.trace msg end def self.dbg msg - Imag.dbg msg + RImag.dbg msg end def self.debug msg - Imag.debug msg + RImag.debug msg end def self.info msg - Imag.info msg + RImag.info msg end def self.warn msg - Imag.warn msg + RImag.warn msg end def self.error msg - Imag.error msg + RImag.error msg end end @@ -57,7 +57,7 @@ module RubyImag def self.core_setup self.class_names.map {|n| [n, "R#{n}".to_sym ] }.each do |elem| - RubyImag.const_set elem.first, Kernel.const_get(elem.last) + Imag.const_set elem.first, Kernel.const_get(elem.last) end end @@ -66,7 +66,7 @@ module RubyImag end def self.class_storeid_setup - RubyImag::StoreId.class_exec do + Imag::StoreId.class_exec do def to_s self.to_str end @@ -79,18 +79,18 @@ if __FILE__ == $0 puts "Running some tests..." puts "I hope you passed the library object as first argument..." begin - RubyImag.setup ARGV.first + Imag.setup ARGV.first rescue Exception => e puts "Seems not to be the case... or something else went wrong..." puts e exit 1 end - RubyImag::Logger.init true, true, true - RubyImag::Logger.info "The Logger should work now" + Imag::Logger.init true, true, true + Imag::Logger.info "The Logger should work now" - RubyImag::Logger.info "Lets see whether we have properly setup StoreId" - RubyImag::Logger.info RubyImag::StoreId::new_baseless("baselessId").to_s - RubyImag::Logger.info "Seems good." + 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 new file mode 100644 index 00000000..c2a2473f --- /dev/null +++ b/libimagruby/lib/imag/version.rb @@ -0,0 +1,3 @@ +module Imag + VERSION = "0.1.0" +end diff --git a/libimagruby/src/imag.rs b/libimagruby/src/imag.rs index eb538899..a59610b2 100644 --- a/libimagruby/src/imag.rs +++ b/libimagruby/src/imag.rs @@ -24,10 +24,10 @@ use ruru::{Class, Boolean, RString, NilClass, VM, Object}; use libimagrt::logger::ImagLogger; -class!(Imag); +class!(RImag); methods!( - Imag, + RImag, itself, fn r_initialize_logger(debug: Boolean, verbose: Boolean, colored: Boolean) -> NilClass { @@ -133,7 +133,7 @@ methods!( ); pub fn setup() -> Class { - let mut class = Class::new("Imag", None); + let mut class = Class::new("RImag", None); class.define(|itself| { itself.def_self("init_logger", r_initialize_logger); itself.def_self("trace", r_log_trace); diff --git a/libimagruby/test/test_ruby.rb b/libimagruby/test/test_ruby.rb index d4ef9cf0..a6dcec93 100644 --- a/libimagruby/test/test_ruby.rb +++ b/libimagruby/test/test_ruby.rb @@ -6,20 +6,20 @@ color = true verbose = true debug = true -Imag.init_logger debug, verbose, color +RImag.init_logger debug, verbose, color -Imag.trace "Trace-Hello from Ruby" -Imag.dbg "Debug-Hello from Ruby" -Imag.debug "Debug-Hello from Ruby" -Imag.info "Info-Hello from Ruby" -Imag.warn "Warn-Hello from Ruby" -Imag.error "Error-Hello from Ruby" +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 - Imag.info "Works: #{name}" + RImag.info "Works: #{name}" else - Imag.error "Fails: #{name}" + RImag.error "Fails: #{name}" end end diff --git a/libimagruby/test/test_store.rb b/libimagruby/test/test_store.rb index 1f0e034d..aed00177 100644 --- a/libimagruby/test/test_store.rb +++ b/libimagruby/test/test_store.rb @@ -6,11 +6,11 @@ color = true verbose = true debug = true -Imag.init_logger debug, verbose, color +RImag.init_logger debug, verbose, color store_handle = RStoreHandle::new(false, "/tmp/store") id = RStoreId::new_baseless("test") test_handle = store_handle.create(id) -Imag.info "Created #{test_handle.location.to_str} from Ruby" +RImag.info "Created #{test_handle.location.to_str} from Ruby"