solvebio 1.7.0 → 1.7.1

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.
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 1.7.0
2
+ current_version = 1.7.1
3
3
  files = lib/solvebio/version.rb
4
4
  commit = True
5
5
  tag = False
data/installer CHANGED
@@ -22,7 +22,10 @@ function fail_exit() {
22
22
  echo " #####################################"
23
23
  echo
24
24
  echo " Failed to install SolveBio."
25
- echo " Contact us at support@solvebio.com"
25
+ echo " Contact us at support@solvebio.com for help."
26
+ echo
27
+ echo " In your email, please copy/paste the output of:"
28
+ echo " cat ${LOG}"
26
29
  echo
27
30
  echo " #####################################"
28
31
  echo
@@ -42,18 +45,24 @@ echo " Installing SolveBio for Ruby..."
42
45
  echo
43
46
  echo " IMPORTANT: Your computer's password may be required. It will NOT be sent to SolveBio."
44
47
 
48
+ # Setup the log
49
+ LOG=/tmp/solvebio-ruby.log
50
+ echo "SolveBio Ruby Guided Installer log" > $LOG
51
+ echo `date` >> $LOG
52
+
45
53
  # Are we installing or upgrading?
46
54
  if [ $(gem list | grep solvebio -c) -ne 0 ]; then
47
- sudo gem update -q solvebio 2>&1 > /dev/null
55
+ sudo gem update solvebio 2>&1 >> $LOG
48
56
  else
49
- sudo gem install -q solvebio 2>&1 > /dev/null
57
+ sudo gem install -q solvebio 2>&1 >> $LOG
50
58
  fi
51
59
 
52
60
  if [ $? -eq 0 ]; then
61
+ VERSION=`ruby -e "require 'solvebio'; print SolveBio::VERSION"`
53
62
  echo
54
63
  echo " ##############################################"
55
64
  echo
56
- echo " Success! SolveBio for Ruby is now installed."
65
+ echo " Success! SolveBio for Ruby ${VERSION} is now installed."
57
66
  echo
58
67
  echo " Please run 'solvebio.rb login' to finish the setup."
59
68
  echo
@@ -3,7 +3,7 @@ module SolveBio
3
3
  module Create
4
4
  module ClassMethods
5
5
  def create(params={})
6
- response = Client.request('post', url, {:payload => params} )
6
+ response = Client.post(url, params)
7
7
  Util.to_solve_object(response)
8
8
  end
9
9
  end
@@ -55,10 +55,7 @@ module SolveBio
55
55
 
56
56
  path = Dir.tmpdir unless path
57
57
  filename = File.join(path, filename)
58
- response = nil
59
-
60
- response = Client.get(download_url, :raw => true,
61
- :default_headers => false)
58
+ response = Client.get(download_url, :raw => true, :auth => false, :default_headers => false)
62
59
 
63
60
  File.open(filename, 'wb') do |fh|
64
61
  fh.write(response.body)
@@ -14,7 +14,7 @@ module SolveBio
14
14
  def ask_for_credentials()
15
15
  print_message('Enter your SolveBio credentials')
16
16
  email = Readline.readline('Email: ', true)
17
- puts 'Password (typing will be hidden): '
17
+ print 'Password (typing will be hidden): '
18
18
  password = STDIN.noecho(&:gets).chomp
19
19
  puts
20
20
  return email, password
@@ -29,7 +29,7 @@ module SolveBio
29
29
  :ruby_implementation => RbConfig::CONFIG['RUBY_SO_NAME'],
30
30
  :architecture => RbConfig::CONFIG['arch'],
31
31
  }
32
- Client.request('post', '/v1/reports/install', {:payload => data}) rescue nil
32
+ Client.post('/v1/reports/install', data) rescue nil
33
33
  end
34
34
 
35
35
  def login
@@ -46,7 +46,7 @@ module SolveBio
46
46
  }
47
47
 
48
48
  begin
49
- response = Client.post('/v1/auth/token', {:payload => data})
49
+ response = Client.post('/v1/auth/token', data)
50
50
  rescue SolveBio::SolveError => e
51
51
  puts "Login failed: #{e.to_s}"
52
52
  return false
@@ -1,7 +1,7 @@
1
1
  module SolveBio
2
2
  class Client
3
- attr_reader :headers, :api_host
4
- attr_accessor :api_key
3
+ attr_reader :headers
4
+ attr_accessor :api_host, :api_key
5
5
 
6
6
  # Add our own kind of Authorization tokens. This has to be
7
7
  # done this way, late, because the rest-client gem looks for
@@ -13,8 +13,8 @@ module SolveBio
13
13
  end
14
14
 
15
15
  def initialize(api_key=nil, api_host=nil)
16
- @api_key = api_key || SolveBio.api_key
17
- @api_host = api_host || SolveBio.api_host
16
+ @api_key = api_key
17
+ @api_host = api_host
18
18
 
19
19
  # Mirroring comments from:
20
20
  # http://ruby-doc.org/stdlib-2.1.2/libdoc/net/http/rdoc/Net/HTTP.html
@@ -32,7 +32,9 @@ module SolveBio
32
32
 
33
33
  DEFAULT_REQUEST_OPTS = {
34
34
  :raw => false,
35
- :default_headers => true
35
+ :default_headers => true,
36
+ :auth => true,
37
+ :json => true
36
38
  }
37
39
 
38
40
  # Issues an HTTP GET across the wire via the Ruby 'rest-client'
@@ -44,14 +46,14 @@ module SolveBio
44
46
  # Issues an HTTP POST across the wire via the Ruby 'rest-client'
45
47
  # library. See *request* for information on opts.
46
48
  def post(url, data, opts={})
47
- opts[:payload] =
48
- if opts.member?(:no_json)
49
- data
50
- else
51
- data.to_json
52
- end
49
+ opts[:payload] = data
53
50
  request('post', url, opts)
54
51
  end
52
+
53
+ def put(url, data, opts={})
54
+ opts[:payload] = data
55
+ request('put', url, opts)
56
+ end
55
57
 
56
58
  # Issues an HTTP Request across the wire via the Ruby 'rest-client'
57
59
  # library.
@@ -59,7 +61,8 @@ module SolveBio
59
61
  opts = DEFAULT_REQUEST_OPTS.merge(opts)
60
62
 
61
63
  # Expand URL with API host if none was given
62
- api_host = @api_host or SolveBio.api_host
64
+ api_host = @api_host || SolveBio.api_host
65
+ api_key = opts[:auth] ? (@api_key || SolveBio.api_key) : nil
63
66
 
64
67
  if not api_host
65
68
  raise SolveError.new('No SolveBio API host is set')
@@ -68,12 +71,12 @@ module SolveBio
68
71
  end
69
72
 
70
73
  # Handle some default options and add authorization header
71
- if opts[:default_headers] and @api_key
72
- headers = @headers.merge(opts[:headers]||{})
73
- authorization = "Token #{@api_key}"
74
- else
75
- headers = nil
76
- authorization = nil
74
+ headers = opts[:default_headers] ? @headers.merge(opts[:headers] || {}) : nil
75
+ authorization = api_key ? "Token #{api_key}" : nil
76
+
77
+ # By default, encode payload as JSON
78
+ if ['post', 'put', 'patch'].include?(method.downcase) and opts[:json]
79
+ opts[:payload] = opts[:payload].to_json
77
80
  end
78
81
 
79
82
  SolveBio::logger.debug('API %s Request: %s' % [method.upcase, url])
@@ -141,6 +144,10 @@ module SolveBio
141
144
  def self.post(url, data, opts={})
142
145
  client.post(url, data, opts)
143
146
  end
147
+
148
+ def self.put(url, data, opts={})
149
+ client.put(url, data, opts)
150
+ end
144
151
 
145
152
  def self.request(method, url, opts={})
146
153
  client.request(method, url, opts)
@@ -35,7 +35,7 @@ module SolveBio
35
35
  :genome_build => genome_build,
36
36
  :vcf_file => File.open(vcf_file, 'rb')
37
37
  }
38
- response = Client.post(url, data, :no_json => true)
38
+ response = Client.post(url, data, :json => false)
39
39
  Util.to_solve_object(response)
40
40
  end
41
41
 
@@ -1,3 +1,3 @@
1
1
  module SolveBio
2
- VERSION = '1.7.0'
2
+ VERSION = '1.7.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solvebio
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.7.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: