panda_doc 0.2.1 → 0.3.0

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: 20c64601c28630002024bfddd0bfd521393c50a2
4
- data.tar.gz: f43b22cfec4d8963034a6c246a3392433b3b6090
3
+ metadata.gz: d46e1363f6a1b416eb2f04311fe60934c973faa3
4
+ data.tar.gz: 43e4790a1cf556272115627686f3af5975a076a8
5
5
  SHA512:
6
- metadata.gz: f25b077c20e44861891e9f5b01b8353be37a9f97a497d7951733b62a618ac89a7ba15fa0d0fa0be528bc587eeab1e9e62d7bc015376401a1bd3342f1ed8b4961
7
- data.tar.gz: e134cfbcddb257fb57831ef95f30664af7ac538d795431c4da580dc8a2b630cc43260bc17534a8be43f65dd72913d769477bdc276fa49066c0b7fb7f8535ac32
6
+ metadata.gz: e812108468ec7cf00312452b9d84b53fb6802e10335193c1b038885f37fbf47d8388654802dbda4af1aa451ddc47819ecdcd4a2fe4cf8aa605e9af5a6a70ede3
7
+ data.tar.gz: 7f4f4463daa0c61ae96220847fb272b182851c13afb9c656f37926a6538c208923fb341cba3a8d35fd2ffad3d9bc4a39a26c13f3cf7ff7506b7e2471059f5d71
data/CHANGELOG.md CHANGED
@@ -4,6 +4,21 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.3.0][] (2016-02-20)
8
+
9
+ ### API change:
10
+
11
+ - Raise error on failed response.
12
+
13
+ ```ruby
14
+ begin
15
+ PandaDoc::Document.create(name: "Sample")
16
+ rescue PandaDoc::FailureResult => e
17
+ puts e.detail
18
+ puts e.response
19
+ end
20
+ ```
21
+
7
22
  ## [0.2.0][] (2016-02-18)
8
23
 
9
24
  New:
@@ -43,7 +58,8 @@ Fixes:
43
58
 
44
59
  - Initial release
45
60
 
46
- [Unreleased]: https://github.com/opti/panda_doc/compare/v0.2.0...HEAD
61
+ [Unreleased]: https://github.com/opti/panda_doc/compare/v0.3.0...HEAD
62
+ [0.3.0]: https://github.com/opti/panda_doc/compare/v0.2.0...v0.3.0
47
63
  [0.2.0]: https://github.com/opti/panda_doc/compare/v0.1.0...v0.2.0
48
64
  [0.1.0]: https://github.com/opti/panda_doc/compare/v0.0.2...v0.1.0
49
65
  [0.0.2]: https://github.com/opti/panda_doc/compare/v0.0.1...v0.0.2
data/README.md CHANGED
@@ -114,12 +114,11 @@ If an error occurs during an API request it will be wrapped into a plain ruby
114
114
  object as well.
115
115
 
116
116
  ```ruby
117
- response = PandaDoc::Document.create(name: "Sample Document")
118
-
119
- if response.success?
120
- uuid = response.uuid
121
- else
122
- puts response.error.detail
117
+ begin
118
+ PandaDoc::Document.create(name: "Sample Document")
119
+ rescue PandaDoc::FailureResult => e
120
+ puts e.detail
121
+ puts e.response
123
122
  end
124
123
  ```
125
124
 
@@ -20,7 +20,7 @@ module PandaDoc
20
20
  private
21
21
 
22
22
  def respond(response, type: :document)
23
- return FailureResult.new(response) unless response.success?
23
+ fail FailureResult.new(response) unless response.success?
24
24
 
25
25
  SuccessResult.new(
26
26
  ResponseFactory.new(type).build.from_hash(response.body)
@@ -1,7 +1,8 @@
1
1
  module PandaDoc
2
- class FailureResult
2
+ class FailureResult < StandardError
3
3
  extend Forwardable
4
4
  def_delegators :response, :status, :success?
5
+ def_delegators :error, :type, :detail
5
6
 
6
7
  attr_reader :error
7
8
 
@@ -12,5 +13,9 @@ module PandaDoc
12
13
  @response = response
13
14
  @error = Responses::Error.new(Objects::Error.new).from_hash(response.body)
14
15
  end
16
+
17
+ def to_s
18
+ "#{status} #{type}: #{detail}"
19
+ end
15
20
  end
16
21
  end
@@ -1,3 +1,3 @@
1
1
  module PandaDoc
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panda_doc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Pstyga
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-19 00:00:00.000000000 Z
11
+ date: 2016-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -88,7 +88,6 @@ files:
88
88
  - README.md
89
89
  - Rakefile
90
90
  - bin/console
91
- - bin/rspec
92
91
  - bin/setup
93
92
  - lib/panda_doc.rb
94
93
  - lib/panda_doc/api_client.rb
data/bin/rspec DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'rspec' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require "pathname"
10
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require "rubygems"
14
- require "bundler/setup"
15
-
16
- load Gem.bin_path("rspec-core", "rspec")