libroute 0.1.3 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bafb0113b18998549c1efe458b3f5b735de3b3c4
4
- data.tar.gz: a55703d7e20895ca2d267dee8db8a301eabbc009
3
+ metadata.gz: ad13a88fd242b832ae6578c0e9d22bf980f88605
4
+ data.tar.gz: 57737b8b1bcdb6228ef9efdf5fbaf3d64d9baf6a
5
5
  SHA512:
6
- metadata.gz: ae98d328b4b782f7fdd3e4eabe42d891f98b7bfe47c20e16d69abf4d1c5a905f9e6b5e3f4016ecbae8a98a3746d671e34b0e91d2cc566c94d1a19a00ced560ab
7
- data.tar.gz: d8e1ab31186919ad737c0e2b568bb8f8747438740d28333dca1966338fc0f5177248485424a62f7905e4ba468a3172122fd337e62b395a13cee97c648a10c262
6
+ metadata.gz: 09979b24df53b97125a59dffc306d8a99462bcad70519f5b720028794dc64e5bc9d55f480633ad0f9a7f6e6971c66d6a377ce9863a0cc29cb8ac26b46351bc2d
7
+ data.tar.gz: a2c7aa88c7e24a2e71959a04f2db41e2451e74d5bb827dbde5c1f7a0187f7d1b8fc2bceb2f65093926ac87c92f66a6317492e82f150a18101cd2908772b12868
@@ -4,12 +4,16 @@ module Libroute
4
4
 
5
5
  def build(options)
6
6
  puts "Building #{options.library} from directory #{options.build}"
7
- im = Docker::Image.build_from_dir(options.build) do |v|
8
- if (log = JSON.parse(v)) && log.has_key?("stream")
9
- puts log["stream"]
7
+ begin
8
+ im = Docker::Image.build_from_dir(options.build) do |v|
9
+ if (log = JSON.parse(v)) && log.has_key?("stream")
10
+ puts log["stream"]
11
+ end
10
12
  end
13
+ im.tag('repo' => 'libroute_image-'+options.library)
14
+ rescue
15
+ puts "Libroute: An error occurred during the build process.\n\n"
11
16
  end
12
- im.tag('repo' => 'libroute_image-'+options.library)
13
17
  end
14
18
 
15
19
  def exec(library, params)
@@ -29,7 +33,22 @@ module Libroute
29
33
  if c.length == 0
30
34
 
31
35
  # Launch container from image
32
- image = Docker::Image.all.select{|x| x.info['RepoTags'][0].split(':')[0].include?('libroute_image-' + library)}.first
36
+
37
+ imagemap = Docker::Image.all.flat_map{|x| x.info['RepoTags'].count == 1 ? [[x.info['RepoTags'][0],x]] : x.info['RepoTags'].map{|y| [y,x]} }
38
+ # This command splits multiple tags into a flat vector
39
+ # -> imagemap is a vector of length equal to the number of images
40
+ # => each elements is a vector of length 2: [tag, image]
41
+
42
+ imagesel = imagemap.select{|x| x[0].split(':')[0].include?('libroute_image-' + library)}
43
+
44
+ if imagesel.count == 0
45
+ h = Hash.new
46
+ h['stderr'] = 'Image not found'
47
+ return h
48
+ end
49
+
50
+ image = imagesel[0][1]
51
+
33
52
  c = Docker::Container.create('Image' => image.id, 'name' => 'libroute_instance-' + library, 'Tty' => true)
34
53
  c.start
35
54
 
@@ -1,3 +1,3 @@
1
1
  module Libroute
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libroute
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Lisk (XS Research Ltd)
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-27 00:00:00.000000000 Z
11
+ date: 2016-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docker-api