docmago_client 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -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
|
data/lib/docmago_client.rb
CHANGED
@@ -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/
|
11
|
-
|
12
|
-
|
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"
|
data/test/dummy/log/test.log
CHANGED
@@ -371,3 +371,201 @@ Completed 200 OK in 63ms (Views: 62.7ms | ActiveRecord: 0.0ms)
|
|
371
371
|
[1m[35m (0.1ms)[0m rollback transaction
|
372
372
|
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
373
373
|
[1m[35m (0.0ms)[0m rollback transaction
|
374
|
+
Connecting to database specified by database.yml
|
375
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
376
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
377
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
391
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
392
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
393
|
+
Connecting to database specified by database.yml
|
394
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
395
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
396
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
411
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
412
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
413
|
+
Connecting to database specified by database.yml
|
414
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
415
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
416
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
431
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
432
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
433
|
+
Connecting to database specified by database.yml
|
434
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
435
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
436
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
452
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
453
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
454
|
+
Connecting to database specified by database.yml
|
455
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
456
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
457
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
473
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
474
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
475
|
+
Connecting to database specified by database.yml
|
476
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
477
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
478
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
493
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
494
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
495
|
+
Connecting to database specified by database.yml
|
496
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
497
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
498
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
511
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
512
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
513
|
+
Connecting to database specified by database.yml
|
514
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
515
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
516
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
529
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
530
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
531
|
+
Connecting to database specified by database.yml
|
532
|
+
[1m[36m (0.3ms)[0m [1mbegin transaction[0m
|
533
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
534
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
549
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
550
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
551
|
+
Connecting to database specified by database.yml
|
552
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
553
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
554
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
570
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
571
|
+
[1m[35m (0.0ms)[0m 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.
|
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/
|
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
|