bin/sisu juggle multiple install & run options
authorRalph Amissah <ralph@amissah.com>
Mon, 18 May 2015 00:22:55 +0000 (20:22 -0400)
committerRalph Amissah <ralph@amissah.com>
Mon, 18 May 2015 00:26:03 +0000 (20:26 -0400)
bin/sisu

index 011c1f4f3df8b1b708b345200b983d212beca270..7a69dc5daf854f7e46518daed1dcffacba885d4a 100755 (executable)
--- a/bin/sisu
+++ b/bin/sisu
@@ -20,7 +20,7 @@ class Orient
       :full_path_to_sisu_bin_in_sisu_dir_tree
     elsif processing.sisu_runtime_path =~/\/gems\// \
     and processing.sisu_runtime_path \
-    =~ processing.gem_regex
+    =~ /\/#{processing.gem_regex}\//
       :gem_install
     else
       :system_install
@@ -43,7 +43,7 @@ class Orient
       %r{\bsisu$}
     end
     def gem_regex
-      %r{\/sisu-[0-9]+\.[0-9]+\.[0-9]+(?:\.r[0-9]+\.g[0-9a-f]{7})?\/}
+      %r{sisu-[0-9]+\.[0-9]+\.[0-9]+(?:\.r[0-9]+\.g[0-9a-f]{7})?}
     end
     self
   end
@@ -109,12 +109,21 @@ class Orient
       File.expand_path(processing.called_as).
         sub(/\/bin\/sisu$/,'/data/sisu')
     when :set_path_gem
-      Gem::Specification.find_by_name("sisu").gem_dir + '/data/sisu'
+      Gem::Specification.find_by_name("sisu").gem_dir \
+      + '/data/sisu'
     else nil
     end
   end
   def sisu_this_lib
-    if (processing.called_as \
+    if not Gem::Specification.find_by_name("sisu").nil? \
+    and processing.sisu_runtime_path =~/\/gems\// \
+    and processing.sisu_runtime_path \
+    =~ /\/#{processing.gem_regex}\//
+      # gem sought
+      processing.sisu_runtime_path.
+        gsub(/\/bin\/sisu[a-z0-9._-]*$/,
+          '/lib/sisu')
+    elsif (processing.called_as \
     !~ /^#{RbConfig::CONFIG['bindir']}\/sisu$/)
       # called off file system, project directory tree
       File.expand_path(processing.called_as).