memoir 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 684b447befdf0b8cdaf05389e5e0dc60e6e803d2
4
- data.tar.gz: 1a1b49ac8e00ed1a69f848f007dc95bfbf49bd0b
3
+ metadata.gz: 796a35d84795be6d68fd0fb93f6334d9e3580b99
4
+ data.tar.gz: 480ad5612349c69a5ccb6f62636d6f7f2084a900
5
5
  SHA512:
6
- metadata.gz: 0c18b10cea866bc3f156698e1ae97a60d3450f17537c41abe1c7dabe182e7e4448c7a8cace2c8e9c60f9d33c9005aa9df79121d3eb5bbf8c979d0b0c650e002d
7
- data.tar.gz: 8e457a5b1625ed73d13bb6794da504c5ffce7f02773ca827fc9fcd2e9b430df40f4205aa20886a66b61933da03eaedab277e5eb9f75bacb416c898fef9eae85c
6
+ metadata.gz: f1a701e9c6d77d733f4a0ee30076ecfce59e10fad41111edc86c588fe88b3045624c42d7e7aed52ac98a0549d3eaeeb0855a844b9c19359f41869e53ad494fc5
7
+ data.tar.gz: b738cead5216b952f2fb883a6999a7bac6c2c34eb9a314ddde5410ab61ddaeab8e553bd4a870a17c584fd3e773d7897ad9696bc959f22e5db0404c4595460bfc
@@ -16,6 +16,7 @@ module Memoir
16
16
  require File.join(File.dirname(__FILE__), 'memoir', 'query')
17
17
  require File.join(File.dirname(__FILE__), 'memoir', 'request')
18
18
  require File.join(File.dirname(__FILE__), 'memoir', 'data_set')
19
+ require File.join(File.dirname(__FILE__), 'memoir', 'error')
19
20
  require File.join(File.dirname(__FILE__), 'memoir', 'response')
20
21
  require File.join(File.dirname(__FILE__), 'memoir', 'client')
21
22
  end
@@ -21,7 +21,11 @@ class Memoir::Client
21
21
  end
22
22
 
23
23
  def run(request)
24
- Memoir::Response.new(connection.post API_QUERY_URL, request.to_h)
24
+ response = connection.post API_QUERY_URL, request.to_h do |req|
25
+ req.params['arrays'] = true if request.arrays
26
+ end
27
+
28
+ Memoir::Response.new response
25
29
  end
26
30
 
27
31
  def dry_run(request)
@@ -10,10 +10,6 @@ class Memoir::DataSet
10
10
  @global_annotations = data_set['globalAnnotations'] || []
11
11
  @tsuids = data_set['tsuids'] || []
12
12
  @query = query || {}
13
- self.dps = data_set['dps'] || {}
14
- end
15
-
16
- def dps=(dps_object)
17
- @dps = dps_object.instance_of?(Array) ? dps_object.to_h : dps_object
13
+ @dps = data_set['dps']
18
14
  end
19
15
  end
@@ -0,0 +1,10 @@
1
+ class Memoir::Error
2
+ attr_accessor :code, :message, :details, :trace
3
+
4
+ def initialize(error)
5
+ @code = error['code']
6
+ @message = error['message']
7
+ @details = error['details']
8
+ @trace = error['trace']
9
+ end
10
+ end
@@ -1,5 +1,5 @@
1
1
  class Memoir::Request
2
- attr_accessor :start_time, :end_time, :queries, :options
2
+ attr_accessor :start_time, :end_time, :queries, :options, :arrays
3
3
 
4
4
  VALID_OPTIONS = {
5
5
  no_annotations: 'noAnnotations',
@@ -18,6 +18,7 @@ class Memoir::Request
18
18
  @end_time = end_time
19
19
  @queries = []
20
20
  @options = options
21
+ @arrays = false
21
22
  end
22
23
 
23
24
  def <<(query)
@@ -1,11 +1,18 @@
1
1
  class Memoir::Response
2
- attr_accessor :data_sets, :stats_summary, :status, :raw
2
+ attr_accessor :data_sets, :stats_summary, :status, :raw, :error
3
+
4
+ STATUS_OK = 200
3
5
 
4
6
  def initialize(faraday_response)
5
7
  @data_sets = []
6
8
  @status = faraday_response.status
7
9
  @raw = faraday_response.body
8
- parse_response(raw)
10
+
11
+ if status == STATUS_OK
12
+ parse_response(raw)
13
+ else
14
+ @error = Memoir::Error.new(raw['error'])
15
+ end
9
16
  end
10
17
 
11
18
  private
@@ -1,3 +1,3 @@
1
1
  module Memoir
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memoir
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Kimle
@@ -155,6 +155,7 @@ files:
155
155
  - lib/memoir/client.rb
156
156
  - lib/memoir/data_set.rb
157
157
  - lib/memoir/downsample.rb
158
+ - lib/memoir/error.rb
158
159
  - lib/memoir/errors.rb
159
160
  - lib/memoir/errors/argument_error.rb
160
161
  - lib/memoir/errors/request_error.rb