docmago_client 0.0.1 → 0.0.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.
@@ -0,0 +1,33 @@
1
+ module DocmagoClient
2
+ class Railtie < Rails::Railtie
3
+
4
+ initializer "docmago_client" do |app|
5
+ ActiveSupport.on_load :action_controller do
6
+ DocmagoClient::Railtie.setup_actioncontroller
7
+ end
8
+ end
9
+
10
+ def self.setup_actioncontroller
11
+ unless Mime::Type.lookup_by_extension("pdf")
12
+ Mime::Type.register "application/pdf", :pdf
13
+ end
14
+
15
+ ActionController::Renderers.add :pdf do |filename, options|
16
+ default_options = {
17
+ :name => filename||controller_name,
18
+ :test_mode => !Rails.env.production?,
19
+ }
20
+ options = default_options.merge(options)
21
+ options[:content] ||= render_to_string(options)
22
+
23
+ response = DocmagoClient.create(options)
24
+
25
+ if response.code == 200
26
+ send_data response, :filename => "#{options[:name]}.pdf", :type => "application/pdf", :disposition => "attachment"
27
+ else
28
+ render :inline => response.body, :status => response.code
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,3 +1,3 @@
1
1
  module DocmagoClient
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -7,16 +7,9 @@ require 'docmago_client/error'
7
7
 
8
8
  if defined?(Rails)
9
9
  if Rails.respond_to?(:version) && Rails.version =~ /^3/
10
- require 'docmago_client/pdf_renderer'
11
-
12
- module DocmagoClient
13
- class Railtie < Rails::Railtie
14
-
15
- initializer "docmago_client" do |app|
16
- DocmagoClient::PdfRenderer.init(:config => app.config)
17
- end
18
- end
19
- end
10
+ require 'docmago_client/railtie'
11
+ else
12
+ raise "docmago_client #{DocmagoClient::VERSION} is not compatible with Rails 2.3 or older"
20
13
  end
21
14
  end
22
15
 
@@ -0,0 +1 @@
1
+ DocmagoClient.api_key "test"
@@ -371,3 +371,201 @@ Completed 200 OK in 63ms (Views: 62.7ms | ActiveRecord: 0.0ms)
371
371
   (0.1ms) rollback transaction
372
372
   (0.0ms) begin transaction
373
373
   (0.0ms) rollback transaction
374
+ Connecting to database specified by database.yml
375
+  (0.2ms) begin transaction
376
+  (0.0ms) rollback transaction
377
+  (0.0ms) begin transaction
378
+
379
+
380
+ Started GET "/home" for 127.0.0.1 at 2012-08-04 15:13:45 +0200
381
+ Processing by HomeController#index as HTML
382
+ Rendered home/index.html.erb within layouts/application (1.7ms)
383
+ Completed 200 OK in 10ms (Views: 9.6ms | ActiveRecord: 0.0ms)
384
+
385
+
386
+ Started GET "/home.pdf" for 127.0.0.1 at 2012-08-04 15:13:45 +0200
387
+ Processing by HomeController#index as PDF
388
+ Rendered home/index.pdf.erb (0.2ms)
389
+ Completed 500 Internal Server Error in 2ms
390
+  (0.1ms) rollback transaction
391
+  (0.0ms) begin transaction
392
+  (0.0ms) rollback transaction
393
+ Connecting to database specified by database.yml
394
+  (0.2ms) begin transaction
395
+  (0.0ms) rollback transaction
396
+  (0.0ms) begin transaction
397
+
398
+
399
+ Started GET "/home" for 127.0.0.1 at 2012-08-04 16:41:14 +0200
400
+ Processing by HomeController#index as HTML
401
+ Rendered home/index.html.erb within layouts/application (2.1ms)
402
+ Completed 200 OK in 10ms (Views: 9.4ms | ActiveRecord: 0.0ms)
403
+
404
+
405
+ Started GET "/home.pdf" for 127.0.0.1 at 2012-08-04 16:41:14 +0200
406
+ Processing by HomeController#index as PDF
407
+ Rendered home/index.pdf.erb (0.2ms)
408
+ Rendered inline template (0.4ms)
409
+ Completed 401 Unauthorized in 56481ms (Views: 56481.1ms | ActiveRecord: 0.0ms)
410
+  (0.1ms) rollback transaction
411
+  (0.1ms) begin transaction
412
+  (0.0ms) rollback transaction
413
+ Connecting to database specified by database.yml
414
+  (0.2ms) begin transaction
415
+  (0.0ms) rollback transaction
416
+  (0.0ms) begin transaction
417
+
418
+
419
+ Started GET "/home" for 127.0.0.1 at 2012-08-04 16:42:21 +0200
420
+ Processing by HomeController#index as HTML
421
+ Rendered home/index.html.erb within layouts/application (1.7ms)
422
+ Completed 200 OK in 9ms (Views: 8.3ms | ActiveRecord: 0.0ms)
423
+
424
+
425
+ Started GET "/home.pdf" for 127.0.0.1 at 2012-08-04 16:42:21 +0200
426
+ Processing by HomeController#index as PDF
427
+ Rendered home/index.pdf.erb (0.2ms)
428
+ Rendered inline template (0.5ms)
429
+ Completed 401 Unauthorized in 973ms (Views: 972.9ms | ActiveRecord: 0.0ms)
430
+  (0.1ms) rollback transaction
431
+  (0.0ms) begin transaction
432
+  (0.1ms) rollback transaction
433
+ Connecting to database specified by database.yml
434
+  (0.2ms) begin transaction
435
+  (0.0ms) rollback transaction
436
+  (0.0ms) begin transaction
437
+
438
+
439
+ Started GET "/home" for 127.0.0.1 at 2012-08-04 16:43:02 +0200
440
+ Processing by HomeController#index as HTML
441
+ Rendered home/index.html.erb within layouts/application (1.8ms)
442
+ Completed 200 OK in 9ms (Views: 8.7ms | ActiveRecord: 0.0ms)
443
+
444
+
445
+ Started GET "/home.pdf" for 127.0.0.1 at 2012-08-04 16:43:02 +0200
446
+ Processing by HomeController#index as PDF
447
+ Rendered home/index.pdf.erb (0.2ms)
448
+ Rendered text template (0.0ms)
449
+ Sent data contents.pdf (2.9ms)
450
+ Completed 200 OK in 2849ms (Views: 2848.5ms | ActiveRecord: 0.0ms)
451
+  (0.1ms) rollback transaction
452
+  (0.0ms) begin transaction
453
+  (0.0ms) rollback transaction
454
+ Connecting to database specified by database.yml
455
+  (0.2ms) begin transaction
456
+  (0.0ms) rollback transaction
457
+  (0.0ms) begin transaction
458
+
459
+
460
+ Started GET "/home" for 127.0.0.1 at 2012-08-04 16:43:30 +0200
461
+ Processing by HomeController#index as HTML
462
+ Rendered home/index.html.erb within layouts/application (1.6ms)
463
+ Completed 200 OK in 8ms (Views: 8.1ms | ActiveRecord: 0.0ms)
464
+
465
+
466
+ Started GET "/home.pdf" for 127.0.0.1 at 2012-08-04 16:43:30 +0200
467
+ Processing by HomeController#index as PDF
468
+ Rendered home/index.pdf.erb (0.2ms)
469
+ Rendered text template (0.0ms)
470
+ Sent data contents.pdf (3.1ms)
471
+ Completed 200 OK in 1062ms (Views: 1062.1ms | ActiveRecord: 0.0ms)
472
+  (0.1ms) rollback transaction
473
+  (0.0ms) begin transaction
474
+  (0.0ms) rollback transaction
475
+ Connecting to database specified by database.yml
476
+  (0.2ms) begin transaction
477
+  (0.0ms) rollback transaction
478
+  (0.0ms) begin transaction
479
+
480
+
481
+ Started GET "/home" for 127.0.0.1 at 2012-08-04 16:43:52 +0200
482
+ Processing by HomeController#index as HTML
483
+ Rendered home/index.html.erb within layouts/application (1.6ms)
484
+ Completed 200 OK in 9ms (Views: 8.2ms | ActiveRecord: 0.0ms)
485
+
486
+
487
+ Started GET "/home.pdf" for 127.0.0.1 at 2012-08-04 16:43:52 +0200
488
+ Processing by HomeController#index as PDF
489
+ Rendered home/index.pdf.erb (0.2ms)
490
+ Rendered inline template (0.5ms)
491
+ Completed 401 Unauthorized in 965ms (Views: 964.8ms | ActiveRecord: 0.0ms)
492
+  (0.1ms) rollback transaction
493
+  (0.0ms) begin transaction
494
+  (0.0ms) rollback transaction
495
+ Connecting to database specified by database.yml
496
+  (0.2ms) begin transaction
497
+  (0.0ms) rollback transaction
498
+  (0.0ms) begin transaction
499
+
500
+
501
+ Started GET "/home" for 127.0.0.1 at 2012-08-04 17:03:12 +0200
502
+ Processing by HomeController#index as HTML
503
+ Rendered home/index.html.erb within layouts/application (1.9ms)
504
+ Completed 200 OK in 10ms (Views: 9.9ms | ActiveRecord: 0.0ms)
505
+
506
+
507
+ Started GET "/home.pdf" for 127.0.0.1 at 2012-08-04 17:03:12 +0200
508
+ Processing by HomeController#index as PDF
509
+ Completed 500 Internal Server Error in 0ms
510
+  (0.1ms) rollback transaction
511
+  (0.0ms) begin transaction
512
+  (0.0ms) rollback transaction
513
+ Connecting to database specified by database.yml
514
+  (0.2ms) begin transaction
515
+  (0.0ms) rollback transaction
516
+  (0.0ms) begin transaction
517
+
518
+
519
+ Started GET "/home" for 127.0.0.1 at 2012-08-04 17:03:26 +0200
520
+ Processing by HomeController#index as HTML
521
+ Rendered home/index.html.erb within layouts/application (1.6ms)
522
+ Completed 200 OK in 9ms (Views: 8.3ms | ActiveRecord: 0.0ms)
523
+
524
+
525
+ Started GET "/home.pdf" for 127.0.0.1 at 2012-08-04 17:03:26 +0200
526
+ Processing by HomeController#index as PDF
527
+ Completed 500 Internal Server Error in 0ms
528
+  (0.1ms) rollback transaction
529
+  (0.0ms) begin transaction
530
+  (0.0ms) rollback transaction
531
+ Connecting to database specified by database.yml
532
+  (0.3ms) begin transaction
533
+  (0.0ms) rollback transaction
534
+  (0.0ms) begin transaction
535
+
536
+
537
+ Started GET "/home" for 127.0.0.1 at 2012-08-04 17:04:19 +0200
538
+ Processing by HomeController#index as HTML
539
+ Rendered home/index.html.erb within layouts/application (1.6ms)
540
+ Completed 200 OK in 9ms (Views: 8.5ms | ActiveRecord: 0.0ms)
541
+
542
+
543
+ Started GET "/home.pdf" for 127.0.0.1 at 2012-08-04 17:04:19 +0200
544
+ Processing by HomeController#index as PDF
545
+ Rendered home/index.pdf.erb (0.2ms)
546
+ Rendered inline template (0.4ms)
547
+ Completed 401 Unauthorized in 984ms (Views: 983.9ms | ActiveRecord: 0.0ms)
548
+  (0.1ms) rollback transaction
549
+  (0.1ms) begin transaction
550
+  (0.1ms) rollback transaction
551
+ Connecting to database specified by database.yml
552
+  (0.2ms) begin transaction
553
+  (0.0ms) rollback transaction
554
+  (0.0ms) begin transaction
555
+
556
+
557
+ Started GET "/home" for 127.0.0.1 at 2012-08-04 17:04:34 +0200
558
+ Processing by HomeController#index as HTML
559
+ Rendered home/index.html.erb within layouts/application (1.7ms)
560
+ Completed 200 OK in 9ms (Views: 8.4ms | ActiveRecord: 0.0ms)
561
+
562
+
563
+ Started GET "/home.pdf" for 127.0.0.1 at 2012-08-04 17:04:34 +0200
564
+ Processing by HomeController#index as PDF
565
+ Rendered home/index.pdf.erb (0.2ms)
566
+ Rendered text template (0.0ms)
567
+ Sent data contents.pdf (2.9ms)
568
+ Completed 200 OK in 1022ms (Views: 1022.1ms | ActiveRecord: 0.0ms)
569
+  (0.1ms) rollback transaction
570
+  (0.0ms) begin transaction
571
+  (0.0ms) rollback transaction
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docmago_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -84,7 +84,7 @@ extra_rdoc_files: []
84
84
  files:
85
85
  - lib/docmago_client/error.rb
86
86
  - lib/docmago_client/exception.rb
87
- - lib/docmago_client/pdf_renderer.rb
87
+ - lib/docmago_client/railtie.rb
88
88
  - lib/docmago_client/version.rb
89
89
  - lib/docmago_client.rb
90
90
  - lib/tasks/docmago_client_tasks.rake
@@ -108,6 +108,7 @@ files:
108
108
  - test/dummy/config/environments/production.rb
109
109
  - test/dummy/config/environments/test.rb
110
110
  - test/dummy/config/initializers/backtrace_silencers.rb
111
+ - test/dummy/config/initializers/docmago.rb
111
112
  - test/dummy/config/initializers/inflections.rb
112
113
  - test/dummy/config/initializers/mime_types.rb
113
114
  - test/dummy/config/initializers/secret_token.rb
@@ -171,6 +172,7 @@ test_files:
171
172
  - test/dummy/config/environments/production.rb
172
173
  - test/dummy/config/environments/test.rb
173
174
  - test/dummy/config/initializers/backtrace_silencers.rb
175
+ - test/dummy/config/initializers/docmago.rb
174
176
  - test/dummy/config/initializers/inflections.rb
175
177
  - test/dummy/config/initializers/mime_types.rb
176
178
  - test/dummy/config/initializers/secret_token.rb
@@ -1,15 +0,0 @@
1
- module DocmagoClient
2
- module PdfRenderer
3
- def self.init(options={})
4
- require "action_controller"
5
- unless Mime::Type.lookup_by_extension("pdf")
6
- Mime::Type.register "application/pdf", :pdf
7
- end
8
-
9
- ActionController::Renderers.add :pdf do |filename, options|
10
- pdf = DocmagoClient.create(:content => render_to_string(options))
11
- send_data(pdf, :filename => "#{filename}.pdf", :type => "application/pdf", :disposition => "attachment")
12
- end
13
- end
14
- end
15
- end