docraptor-cli 0.0.4 → 0.1.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: 3861beebf73e13d32696baab15abdcfd024ee27e
4
- data.tar.gz: 6bb03d210ddc751d310f01480290f8b39ca28fa5
3
+ metadata.gz: 728d1be587631813091655e13ceaad145e55ece5
4
+ data.tar.gz: a159b7a50d484292fe2f64160d09960909fab681
5
5
  SHA512:
6
- metadata.gz: d4d8a642ca6e6fb4fdb6dafaeb2c677006049a12cb3e2bd7ea97d846e744656da733426c05e956291bb349a0fefa429af1072b567d9d58e42590f5d8561c7beb
7
- data.tar.gz: a00392e4d111a2646b0699a258fb189f7e6d8dc35b0fd0969c637057dff6489b4243d946f51e3a995c30d987a357506c7ee75555e911ede378d7c9aa2e41b31f
6
+ metadata.gz: eaf07e23b371c5c50298201e7287a8b34f8d65265444cb5233b3386c7f9b055c31df70de5674c57ae57dfe426863affacc683ea0174df6a2077e676f05c5abf5
7
+ data.tar.gz: 3c7fca6ccddc55604e018c339a4bc79d0290b6b9f4fd2b7a5c73edeadaf5d4da8c6384dcbd149a96464802a28bfc94fb69c939b576d273435780e2acd1ad4bd4
@@ -1,3 +1,6 @@
1
+ ### 0.1.0 [July 14, 2016]
2
+ * add [`callback_url` option](https://docraptor.com/documentation/api#api_callback_url)
3
+
1
4
  ### 0.0.4 [May 23, 2016]
2
5
  * Don't use bundler to load gems during execution
3
6
  * Use short binary name when showing help
data/README.md CHANGED
@@ -54,6 +54,38 @@ We have guides for doing some of the common things:
54
54
  * [CSS Media Selector](https://docraptor.com/documentation/api#api_basic_pdf) to make the page look exactly as it does in your browser
55
55
  * Protect content with [HTTP authentication](https://docraptor.com/documentation/api#api_http_user) or [proxies](https://docraptor.com/documentation/api#api_http_proxy) so only DocRaptor can access them
56
56
 
57
+ ## Testing Callbacks
58
+
59
+ The `--callback-url` option can be used to set a URL that will receive a POST request after your document has successfully been processed. You can simulate this in your *nix development environment using a couple of simple tools: [`nc`](http://linux.die.net/man/1/nc) and [`ngrok`](https://ngrok.com/).
60
+
61
+ Let's say you had some document content in a file named `test.html`. To test the callback URL, start a new console and type:
62
+
63
+ ```
64
+ nc -lk 9001
65
+ ```
66
+
67
+ This will listen on port `9001` for requests. Now open another console and type in:
68
+ ```
69
+ ngrok http 9001
70
+ ```
71
+
72
+ This will setup an external URL that port forwards to port `9001` on your computer (conveniently being listened to by `nc`). Note the ngrok http URL. It should look something like `http://87654321.ngrok.io`. Copy that URL and open a third console where we will generate our document:
73
+ ```
74
+ bin/docraptor test.html --async --callback_url "http://87654321.ngrok.io"
75
+ ```
76
+
77
+ After the document has been generated, if we go to our console running `nc`, we should see we got an HTTP POST request that looks something like this:
78
+
79
+ ```
80
+ POST / HTTP/1.1
81
+ Connection: close
82
+ Host: d94c779c.ngrok.io
83
+ Content-Length: 139
84
+ Content-Type: application/x-www-form-urlencoded
85
+ X-Forwarded-For: 54.158.114.123
86
+
87
+ download_url=https%3A%2F%2Fdocraptor.com%2Fdownload%2Fe4eabaca-f811-49f8-9375-fcb9cdeae5aa&download_id=e4eabaca-f811-49f8-9375-fcb9cdeae5aa
88
+ ```
57
89
 
58
90
  ## More Help
59
91
 
@@ -53,6 +53,10 @@ opt_parser = OptionParser.new do |opts|
53
53
  options[:async] = async
54
54
  end
55
55
 
56
+ opts.on("--callback_url url", "Set a callback URL to be notified upon success.") do |callback_url|
57
+ options[:callback_url] = callback_url
58
+ end
59
+
56
60
  opts.on("-d", "--debug", "Enable debug logging.") do
57
61
  options[:debug] = true
58
62
  end
@@ -236,6 +240,8 @@ all_doc_attributes = {
236
240
  ignore_resource_errors: options[:ignore_resource_errors],
237
241
  }
238
242
 
243
+ all_doc_attributes[:callback_url] = options[:callback_url] if options[:callback_url]
244
+
239
245
  all_doc_attributes[:prince_options][:version] = options[:prince_version] if options[:prince_version]
240
246
  all_doc_attributes[:prince_options][:javascript] = options[:prince_javascript] if options[:prince_javascript]
241
247
  all_doc_attributes[:prince_options][:media] = options[:prince_media] if options[:prince_media]
@@ -1,3 +1,3 @@
1
1
  module DocRaptorCli
2
- VERSION = "0.0.4"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docraptor-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elijah Miller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-23 00:00:00.000000000 Z
11
+ date: 2016-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docraptor