ncore 2.0.0 → 2.0.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: 48412aecbd99b296c719895d2bbd4337d509be4e
4
- data.tar.gz: f0aae8fdd116df4efa17f2796622de842a2d972a
3
+ metadata.gz: 9f3d6a794a49da4166e2b53d68a6d4c0b672c252
4
+ data.tar.gz: afd4fe0120f932d16d1d1695440eb18c252191bd
5
5
  SHA512:
6
- metadata.gz: 016a83badb0134a32217d94da2293d9c80f7de47d31cc8ce16a749d695943b6cd35cce140a16c123dc9053d784d0b35c800b2b13afe4faeaeff486c741677d7f
7
- data.tar.gz: a71630c646664844ddbf54733978fea894a1aa79dfc915574e8acf88538e0dd1551a9d0052e3ae89df3fa851baf95e18a8f69d94085406f5331e84392fe1e70d
6
+ metadata.gz: 9191e55d316d0b1155dac584ce3f2ba46cd85c0f02cb16e982a9d5ed98dbdb3a254b5ab3722e99126bee0f438abbcd0bd773515cfea855f8f4172d204bd64780
7
+ data.tar.gz: ec0beb95fc9f16435ca8f8164514c0bdc4e9d804d9b0007d94cafc7f45ec17f18e6434deb8b423b8ac655672eba6c156c8a690a63fc85dd72e84b7d136100fb2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ #### 2.0.1
2
+ - Add .bulk_delete and bulk_delete!
3
+ - Handle 215 response code
4
+ - Better handle network error
5
+
1
6
  #### 2.0.0
2
7
 
3
8
  - NOTE: This version includes breaking changes.
data/lib/ncore.rb CHANGED
@@ -7,7 +7,7 @@ require 'pp'
7
7
  require "ncore/#{f}"
8
8
  end
9
9
 
10
- %w(all build count create delete delete_single find find_single update).each do |f|
10
+ %w(all build count create delete delete_bulk delete_single find find_single update).each do |f|
11
11
  require "ncore/methods/#{f}"
12
12
  end
13
13
 
data/lib/ncore/base.rb CHANGED
@@ -18,6 +18,7 @@ module NCore
18
18
  include Count if types.include? :count
19
19
  include Create if types.include? :create
20
20
  include Delete if types.include? :delete
21
+ include DeleteBulk if types.include? :delete_bulk
21
22
  include Find if types.include? :find
22
23
  include Update if types.include? :update
23
24
  end
data/lib/ncore/client.rb CHANGED
@@ -194,7 +194,7 @@ module NCore
194
194
  case e.message
195
195
  when /Unable to verify certificate/
196
196
  raise parent::ConnectionError, "Unable to verify certificate for #{host_for_error rest_opts[:url]} : verify URL or disable SSL certificate verification (insecure)."
197
- when /Name or service not known/
197
+ when /Name or service not known/, /No address associated with hostname/
198
198
  raise parent::ConnectionError, "DNS error for #{host_for_error rest_opts[:url]} : check network and DNS or visit #{status_page}."
199
199
  when /Errno::ECONNREFUSED/
200
200
  raise parent::ConnectionError, "Connection error for #{host_for_error rest_opts[:url]} : check network and DNS or visit #{status_page}."
@@ -262,6 +262,9 @@ module NCore
262
262
  metadata = nil
263
263
  end
264
264
  end
265
+ if response.status == 215
266
+ metadata, json = json, {}.with_indifferent_access
267
+ end
265
268
  if [409, 422].include?(response.status) && errors.empty?
266
269
  errors.push 'Validation error'
267
270
  end
@@ -38,6 +38,7 @@ module NCore
38
38
  end
39
39
  end
40
40
 
41
+ class BulkActionError < QueryError ; end
41
42
  class ValidationError < QueryError ; end
42
43
  INCL
43
44
  end
@@ -0,0 +1,26 @@
1
+ module NCore
2
+ module DeleteBulk
3
+ extend ActiveSupport::Concern
4
+
5
+ module ClassMethods
6
+ def bulk_delete!(ids, params={})
7
+ raise(parent::RecordNotFound, "ids must not be empty") if ids.blank?
8
+ params[:ids] = ids
9
+ params = parse_request_params(params)
10
+ parsed, creds = request(:delete, url, params)
11
+ if parsed[:errors].any?
12
+ raise parent::BulkActionError, parsed[:errors]
13
+ else
14
+ parsed[:metadata]
15
+ end
16
+ end
17
+
18
+ def bulk_delete(ids, params={})
19
+ bulk_delete!(ids, params)
20
+ rescue parent::RecordNotFound, parent::BulkActionError
21
+ false
22
+ end
23
+ end
24
+
25
+ end
26
+ end
data/lib/ncore/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module NCore
2
- VERSION = '2.0.0'
2
+ VERSION = '2.0.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ncore
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Notioneer Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-13 00:00:00.000000000 Z
11
+ date: 2016-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -107,6 +107,7 @@ files:
107
107
  - lib/ncore/methods/count.rb
108
108
  - lib/ncore/methods/create.rb
109
109
  - lib/ncore/methods/delete.rb
110
+ - lib/ncore/methods/delete_bulk.rb
110
111
  - lib/ncore/methods/delete_single.rb
111
112
  - lib/ncore/methods/find.rb
112
113
  - lib/ncore/methods/find_single.rb