libroute 0.1.5 → 0.1.6

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: d4a0c471f132928b944fdd4066cc1028b6ba253a
4
- data.tar.gz: c117ec64d1ad11b257b7c3e83161957928143f27
3
+ metadata.gz: b610d0c0208fb32d26b6418a21bd178e4420f05b
4
+ data.tar.gz: ba057013fcb6c5ee4fdf0d3b5b7008cb31decd3f
5
5
  SHA512:
6
- metadata.gz: cad0517a721dd489df5ec509b614a17d3c82b60cf169f185cad39e268b468c50fdf07e0abbfb6223f0402df8ddd0fc11e448fbcac85517c4c6bd73d7e365efaf
7
- data.tar.gz: 9721df9a9e336b25357941f2f4ac1f368f73420ccc39e963dcf6867c3de1d31c4db52fc3db287e9b1dceaecb6b7a5f059b3c5ca053e2a4ee86d0695049bcb230
6
+ metadata.gz: 4fa3e4a90e8b6d7b26d881a0f67f4aae6b3d5a3ba4d478cc597231484aacb07fdf97a2f86738f3c515df55e45b3ff38643b9d1aefed1e4e42eda4bbae4e7ec00
7
+ data.tar.gz: e3145a6bb470e7433b9f45e2b153059da015938b4a2a1336cb46a63f364a436589ead585480407966a703008aca80f07e8cd95bb7d48b6d081a8212ce3faf37c
data/exe/libroute CHANGED
@@ -46,6 +46,27 @@ require 'bson'
46
46
  end
47
47
  end
48
48
 
49
+ # Upload only
50
+ if options.upload == true
51
+ puts "Uploading #{options.library} library..."
52
+ Libroute.upload(options, paramshash)
53
+ exit 0
54
+ end
55
+
56
+ # Execute locally
57
+ if options.library.eql?('RACK')
58
+ require 'rack'
59
+ r = Rack::Builder.parse_file('config.ru')
60
+ app = r[0]
61
+ if paramshash.values.length == 1
62
+ h = Hash.from_bson(BSON::ByteBuffer.new(paramshash.values[0].data))
63
+ resp = app.call(h)
64
+ puts resp.to_bson
65
+ end
66
+ exit 0
67
+ end
68
+
69
+ # Otherwise build
49
70
  result = Libroute.exec(options.library, paramshash)
50
71
  if !result['output'].nil?
51
72
  if result['output'].is_a?(String)
data/lib/libroute.rb CHANGED
@@ -4,6 +4,8 @@ require 'optparse/time'
4
4
  require 'ostruct'
5
5
  require 'pp'
6
6
  require 'bson'
7
+ require 'uri'
8
+ require 'net/http'
7
9
 
8
10
  require 'libroute/librouteexec'
9
11
  require 'libroute/librouteparse'
@@ -2,6 +2,28 @@ module Libroute
2
2
 
3
3
  class << self
4
4
 
5
+ def upload(options, params)
6
+ if params['tarfile'].nil?
7
+ puts "Parameter 'tarfile' not specified"
8
+ exit 1
9
+ end
10
+
11
+ user = ENV['LIBROUTE_USER']
12
+ host = ENV['LIBROUTE_HOST']
13
+ port = ENV['LIBROUTE_PORT']
14
+
15
+ if user.nil? then puts "Environment variable LIBROUTE_USER not defined" ; exit 1 end
16
+ if host.nil? then host = "libroute.io" end
17
+ if port.nil? then port = 80 end
18
+
19
+ uri = URI.parse("http://#{host}:#{port}/#{user}/libraries/#{options.library}/upload")
20
+ header = {'Content-Type': 'application/octet-stream'}
21
+ http = Net::HTTP.new(uri.host, uri.port)
22
+ request = Net::HTTP::Post.new(uri.request_uri, header)
23
+ request.body = params['tarfile'].data
24
+ response = http.request(request)
25
+ end
26
+
5
27
  def build(options)
6
28
  puts "Building #{options.library} from directory #{options.build}"
7
29
  begin
@@ -14,6 +14,7 @@ module Libroute
14
14
  options = OpenStruct.new
15
15
  options.library = []
16
16
  options.build = []
17
+ options.upload = false
17
18
  options.param = []
18
19
  options.file = []
19
20
  options.showhelp = false
@@ -41,6 +42,10 @@ module Libroute
41
42
  options.build = o
42
43
  end
43
44
 
45
+ opts.on("-u","--upload","Uploads the specified tarfile. Specify the location using the 'tarfile' parameter.") do |o|
46
+ options.upload = true
47
+ end
48
+
44
49
  opts.on("-p","--param PARAMETER","Specify parameter in the form -p param=value") do |p|
45
50
  options.param.push p
46
51
  end
@@ -1,3 +1,3 @@
1
1
  module Libroute
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
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.5
4
+ version: 0.1.6
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-10-22 00:00:00.000000000 Z
11
+ date: 2017-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docker-api
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  version: '0'
123
123
  requirements: []
124
124
  rubyforge_project:
125
- rubygems_version: 2.6.6
125
+ rubygems_version: 2.6.8
126
126
  signing_key:
127
127
  specification_version: 4
128
128
  summary: Libroute standardises and simplifies the process of running third party libraries