libroute 0.1.4 → 0.1.5

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: ad13a88fd242b832ae6578c0e9d22bf980f88605
4
- data.tar.gz: 57737b8b1bcdb6228ef9efdf5fbaf3d64d9baf6a
3
+ metadata.gz: d4a0c471f132928b944fdd4066cc1028b6ba253a
4
+ data.tar.gz: c117ec64d1ad11b257b7c3e83161957928143f27
5
5
  SHA512:
6
- metadata.gz: 09979b24df53b97125a59dffc306d8a99462bcad70519f5b720028794dc64e5bc9d55f480633ad0f9a7f6e6971c66d6a377ce9863a0cc29cb8ac26b46351bc2d
7
- data.tar.gz: a2c7aa88c7e24a2e71959a04f2db41e2451e74d5bb827dbde5c1f7a0187f7d1b8fc2bceb2f65093926ac87c92f66a6317492e82f150a18101cd2908772b12868
6
+ metadata.gz: cad0517a721dd489df5ec509b614a17d3c82b60cf169f185cad39e268b468c50fdf07e0abbfb6223f0402df8ddd0fc11e448fbcac85517c4c6bd73d7e365efaf
7
+ data.tar.gz: 9721df9a9e336b25357941f2f4ac1f368f73420ccc39e963dcf6867c3de1d31c4db52fc3db287e9b1dceaecb6b7a5f059b3c5ca053e2a4ee86d0695049bcb230
data/exe/libroute CHANGED
@@ -18,28 +18,40 @@ require 'bson'
18
18
 
19
19
  # Populate params
20
20
  paramshash = Hash.new
21
- if !options.params.empty?
22
- params = options.params.split(",")
23
- params.each do |p|
21
+ if !options.param.empty?
22
+ options.param.each do |p|
24
23
  key,val = p.split("=",2)
25
24
  paramshash[key]=val
26
25
  end
27
26
  end
28
27
 
29
- # Populate stdin
30
- if !$stdin.tty?
31
- data = $stdin.read
32
- if !data.nil?
33
- paramshash['stdin'] = BSON::Binary.new(data)
28
+ # Populate files
29
+ if !options.file.empty?
30
+ options.file.each do |p|
31
+ key,val = p.split("=",2)
32
+ if val.eql?('-')
33
+ fileval = $stdin.read
34
+ else
35
+ begin
36
+ fileval = File.read(val)
37
+ rescue
38
+ fileval = nil
39
+ end
40
+ end
41
+ if fileval.nil?
42
+ puts "Failed to read file: #{val}"
43
+ exit 1
44
+ end
45
+ paramshash[key] = BSON::Binary.new(fileval)
34
46
  end
35
47
  end
36
48
 
37
49
  result = Libroute.exec(options.library, paramshash)
38
- if !result['stdout'].nil?
39
- if result['stdout'].is_a?(String)
40
- puts result['stdout']
50
+ if !result['output'].nil?
51
+ if result['output'].is_a?(String)
52
+ puts result['output']
41
53
  else
42
- bb = result['stdout'].data
54
+ bb = result['output'].data
43
55
  puts bb.to_s
44
56
  end
45
57
  else
@@ -16,7 +16,7 @@ module Libroute
16
16
  end
17
17
  end
18
18
 
19
- def exec(library, params)
19
+ def exec(library, params, opts={})
20
20
 
21
21
  # Check if existing container running
22
22
  c = Docker::Container.all(all: true).select{|c| c.info['Names'][0].eql?('/libroute_instance-' + library)}
@@ -49,7 +49,7 @@ module Libroute
49
49
 
50
50
  image = imagesel[0][1]
51
51
 
52
- c = Docker::Container.create('Image' => image.id, 'name' => 'libroute_instance-' + library, 'Tty' => true)
52
+ c = Docker::Container.create({'Image' => image.id, 'name' => 'libroute_instance-' + library, 'Tty' => true}.merge(opts))
53
53
  c.start
54
54
 
55
55
  # Wait for container to start
@@ -14,7 +14,8 @@ module Libroute
14
14
  options = OpenStruct.new
15
15
  options.library = []
16
16
  options.build = []
17
- options.params = []
17
+ options.param = []
18
+ options.file = []
18
19
  options.showhelp = false
19
20
 
20
21
  opt_parser = OptionParser.new do |opts|
@@ -40,8 +41,12 @@ module Libroute
40
41
  options.build = o
41
42
  end
42
43
 
43
- opts.on("-p","--params PARAMETERS","Parameters","Comma separated list of parameters") do |p|
44
- options.params = p
44
+ opts.on("-p","--param PARAMETER","Specify parameter in the form -p param=value") do |p|
45
+ options.param.push p
46
+ end
47
+
48
+ opts.on("-f","--file FILE","Specify parameter in the form -f param=file"," Use - for file to read from stdin") do |f|
49
+ options.file.push f
45
50
  end
46
51
 
47
52
  opts.on_tail("-h", "--help", "Show command options","Show library options (-l LIBRARY)") do |h|
@@ -1,3 +1,3 @@
1
1
  module Libroute
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
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.4
4
+ version: 0.1.5
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-09-04 00:00:00.000000000 Z
11
+ date: 2016-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docker-api