docmago_client 0.4.1 → 0.4.2

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: c3b8e87948991aeedc13a1e469ef9c6bd069f20d
4
- data.tar.gz: 958e06fb3e31656aaa607636a7dfbecea3096df1
3
+ metadata.gz: 5df904a82dddce585c9927218db5a45226b97629
4
+ data.tar.gz: 7c008e9db440b2f55cfe81f38c7d0144bc62ad50
5
5
  SHA512:
6
- metadata.gz: f27651f4830280a893631bcdcd329ec647658cc89ea9c91219d17354b7ac92a6d2c6b09a6f352c9243642937fe534eba2ac09e90cb444be332d70e8d665f18f7
7
- data.tar.gz: 40931b5cc4f30ec6d59061ce1a951124f0dd3a13772533b9cb44da42b30efe6dbb4bb7c6e468e7e5da1929b024b7ffaf4d72aa4d5d323b9cbfe7677a0492504c
6
+ metadata.gz: 87e960d40a0bc8f861fa7e1cdd97efb184d6608d3c197204132436b432fa18f4f43c416d039ecfadcffa3e8256ea9c215728ea1ae06a4969bd202f0003857d9d
7
+ data.tar.gz: 51534f2bdaf7ad87e4d83053011ba6ba20c77226d8de9b680a207cea481343ff1509d7c46f58fa91ab833db474fe1f558cc50e076dd99da8501e28bb879c5a04
@@ -1,6 +1,7 @@
1
1
  module DocmagoClient
2
2
  class Railtie < Rails::Railtie
3
3
  initializer 'docmago_client' do |_app|
4
+ DocmagoClient.logger = Rails.logger
4
5
  ActiveSupport.on_load :action_controller do
5
6
  DocmagoClient::Railtie.setup_actioncontroller
6
7
  end
@@ -30,12 +31,14 @@ module DocmagoClient
30
31
  options = default_options.merge(options)
31
32
  options[:content] ||= render_to_string(options)
32
33
 
33
- response = DocmagoClient.create(options)
34
+ docmago_response = DocmagoClient.create(options)
35
+ logger.info "Docmago response - status: #{docmago_response.code}; size: #{docmago_response.body.size}"
34
36
 
35
- if response.code == 200
36
- send_data response, filename: "#{options[:name]}.pdf", type: 'application/pdf', disposition: 'attachment'
37
+ if docmago_response.code == 200
38
+ response.headers['Content-Length'] = docmago_response.body.size.to_s
39
+ send_data docmago_response, filename: "#{options[:name]}.pdf", type: 'application/pdf', disposition: 'attachment'
37
40
  else
38
- render inline: response.body, status: response.code
41
+ render inline: docmago_response.body, status: docmago_response.code
39
42
  end
40
43
  end
41
44
  end
@@ -1,3 +1,3 @@
1
1
  module DocmagoClient
2
- VERSION = '0.4.1'
2
+ VERSION = '0.4.2'.freeze
3
3
  end
@@ -19,6 +19,14 @@ module DocmagoClient
19
19
 
20
20
  base_uri ENV['DOCMAGO_URL'] || 'https://docmago.com/api'
21
21
 
22
+ class << self
23
+ attr_writer :logger
24
+
25
+ def logger
26
+ @logger ||= Logger.new($stdout)
27
+ end
28
+ end
29
+
22
30
  def self.base_uri(uri = nil)
23
31
  default_options[:base_uri] = uri ? uri : default_options[:base_uri] || ENV['DOCMAGO_URL']
24
32
  default_options[:base_uri]
@@ -30,16 +38,16 @@ module DocmagoClient
30
38
  end
31
39
 
32
40
  def self.create!(options = {})
33
- raise ArgumentError.new 'please pass in an options hash' unless options.is_a? Hash
41
+ raise ArgumentError, 'please pass in an options hash' unless options.is_a? Hash
34
42
  create options.merge(raise_exception_on_failure: true)
35
43
  end
36
44
 
37
45
  # when given a block, hands the block a TempFile of the resulting document
38
46
  # otherwise, just returns the response
39
47
  def self.create(options = {})
40
- raise ArgumentError.new 'please pass in an options hash' unless options.is_a? Hash
48
+ raise ArgumentError, 'please pass in an options hash' unless options.is_a? Hash
41
49
  if options[:content].nil? || options[:content].empty?
42
- raise DocmagoClient::Error::NoContentError.new('must supply :content')
50
+ raise DocmagoClient::Error::NoContentError.new, 'must supply :content'
43
51
  end
44
52
 
45
53
  default_options = {
@@ -88,12 +96,12 @@ module DocmagoClient
88
96
  end
89
97
 
90
98
  def self.list_docs!(options = {})
91
- raise ArgumentError.new 'please pass in an options hash' unless options.is_a? Hash
99
+ raise ArgumentError, 'please pass in an options hash' unless options.is_a? Hash
92
100
  list_docs options.merge(raise_exception_on_failure: true)
93
101
  end
94
102
 
95
103
  def self.list_docs(options = {})
96
- raise ArgumentError.new 'please pass in an options hash' unless options.is_a? Hash
104
+ raise ArgumentError, 'please pass in an options hash' unless options.is_a? Hash
97
105
  default_options = {
98
106
  page: 1,
99
107
  per_page: 100,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docmago_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Habermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-09 00:00:00.000000000 Z
11
+ date: 2016-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '4.1'
89
+ version: '4.2'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '4.1'
96
+ version: '4.2'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: sqlite3
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '2.4'
117
+ version: '2.7'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '2.4'
124
+ version: '2.7'
125
125
  description: Makes it easy to create PDF documents through the Docmago API.
126
126
  email:
127
127
  - jan@habermann24.com
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  version: '0'
157
157
  requirements: []
158
158
  rubyforge_project:
159
- rubygems_version: 2.4.5
159
+ rubygems_version: 2.5.1
160
160
  signing_key:
161
161
  specification_version: 4
162
162
  summary: Client for the Docmago API (www.docmago.com)