zpdf 0.0.3 → 4.1.5

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: aa813b999c3c6fd27cf9af84169693f4d73a71d9
4
- data.tar.gz: 07698d99c1a158f1f378b21440e2ccbfcae003c0
3
+ metadata.gz: 1877894f32e99c4707a25ae3740060b09a6aecca
4
+ data.tar.gz: 7f23f063b1253cbc185e910816a459992492f880
5
5
  SHA512:
6
- metadata.gz: faff8830a08f6b14e4a6ba1efc6bc64981a47b0063a960b6bc23618a34123519e37ef355436da198e32707a1cd6d981589ae8c8d9c010d5c416b4f8d5dc7798a
7
- data.tar.gz: 99dad4f3c47aed065b0aedca0d5a42d886fd5d61bdb5beae963bcfb9b2516f84b3ee25f934316ecbdce7206309e59ea1bb1fe71dc94cf241abb90ac746fbe5a5
6
+ metadata.gz: dae26182c2a270f358971828c6899f485ea2d2963666787216a17bb2ed1171b70978363966e5d0eb8bb54c7f4420923869fe31820df23adbded966cee21ef263
7
+ data.tar.gz: a9c79b1121259fe159a8f2472574a1bb1bea472d480a5752534c500f5334305eaaa2024bfbe2408fbff00738ba7c32450585c9529b9cadcc5582af1ad81c5553
@@ -0,0 +1,9 @@
1
+
2
+ # 0.0.4 (September 14, 2016)
3
+
4
+ * Updated to work with Rails 4.0, 4.1 and 4.2
5
+
6
+ # 0.0.3 (March 31, 2015)
7
+
8
+ * Initial release. Compatible with Rails 3 and Ruby 1.9.2
9
+
@@ -27,12 +27,13 @@ module ZPdf #:nodoc:
27
27
  abstract!
28
28
 
29
29
  include AbstractController::Rendering
30
- include AbstractController::Layouts
31
30
  include AbstractController::Helpers
32
31
  include AbstractController::Translation
33
32
  include AbstractController::AssetPaths
34
33
  include AbstractController::Logger
35
34
 
35
+ include ActionView::Layouts
36
+
36
37
  helper ZPdf::PdfHelper
37
38
 
38
39
  private_class_method :new #:nodoc:
@@ -6,7 +6,7 @@ module ZPdf
6
6
  source_root File.join(File.dirname(__FILE__),'templates')
7
7
 
8
8
  def create_controller_module
9
- template "controller_module_template.rb", 'lib/pdf_controller_methods.rb'
9
+ template "controller_module_template.rb", 'app/controllers/concerns/pdf_controller_methods.rb'
10
10
  end
11
11
  end
12
12
  end
@@ -1,4 +1,3 @@
1
- require 'iconv'
2
1
 
3
2
  # USAGE:
4
3
  # This module provides basic methods to send PDF content. Simply include this module
@@ -22,36 +21,26 @@ require 'iconv'
22
21
  # end
23
22
  #
24
23
 
25
- module PdfControllerMethods
26
24
 
27
- # uncomment and implement if you want to add custom functionality when this module is
28
- # included.
29
- # def self.included(base)
30
- # base.class_eval <<-EOV
31
- # def do_something_when_pdf_controller_methods_are_included
32
- # end
33
- # EOV
34
- # end
25
+ module PdfControllerMethods
35
26
 
36
27
  protected
37
- # convert a file name to ISO-8859-1, so that all browsers correctly parse it.
28
+
29
+ # convert a file name to ISO-8859-1, that most browsers parse correctly.
38
30
  def sanitize_file_name(name)
39
- c = Iconv.new('ISO-8859-15','UTF-8')
40
- s = c.iconv(name.gsub(/[—–]/,'-'))
41
- s.gsub!(/^.*(\\|\/)/, '')
42
- s.gsub(/[\:\*\?\"\<\>\|]/, '_')
31
+ # NOTE: We could use ActiveSupport::Inflector#transliterate also, but that would remove diacritics also...
32
+ name.gsub! /^.*(\\|\/)/, ''
33
+ name.gsub! /[\:\*\?\"\<\>\|]/, '_'
34
+ name.gsub! "—", "-"
35
+ return name.encode('ISO-8859-1', :invalid => :replace, :undef => :replace, :replace => '_')
43
36
  end
44
37
 
45
38
  def send_pdf_content(pdf_content,options = {})
46
- force_download = options[:force_download] || false
47
- file_name = options[:file_name] || self.class.name.underscore
48
- # content type is 'iso-8859-1' because we want the header values (namely the filename) to
49
- # be interpreted as such.
50
- headers["Content-Type"] ||= 'application/pdf; charset=iso-8859-1'
51
- if force_download
52
- headers["Content-Disposition"] = "attachment; filename=\"#{sanitize_file_name(file_name)}\""
53
- end
54
- render :text => pdf_content, :layout => false
39
+ force_download = options[:force_download] || false
40
+ file_name = options[:file_name] || self.class.name.underscore
41
+ headers["Content-Type"] ||= 'application/pdf; charset=iso-8859-1'
42
+ headers["Content-Disposition"] = "#{force_download ? 'attachment' : 'inline'}; filename=\"#{sanitize_file_name(file_name)}\""
43
+ render :text => pdf_content, :layout => false
55
44
  end
56
45
 
57
46
  end
@@ -6,7 +6,7 @@ module ZPdf
6
6
  class ProducerGenerator < Erb::Generators::Base
7
7
  source_root File.join(File.dirname(__FILE__),'templates')
8
8
 
9
- argument :actions, :type => :array, :default => [], :banner => "method method"
9
+ argument :actions, :type => :array, :default => ['my_document'], :banner => "method method"
10
10
 
11
11
  def create_renderer_file
12
12
  template "producer_template.rb", File.join('app/pdf_producers', class_path, "#{file_name}.rb")
@@ -16,7 +16,7 @@ module ZPdf
16
16
  rails_root = Rails.root.to_s + "/"
17
17
  config = Rails.application.config
18
18
  paths = Rails.application.paths
19
- pdf_views_path = ( (config.zpdf ? config.zpdf.pdf_views_path : nil) || paths.app.views.to_a.first).gsub(rails_root,'')
19
+ pdf_views_path = ( (config.zpdf ? config.zpdf.pdf_views_path : nil) || paths['app/views'].first).gsub(rails_root,'')
20
20
 
21
21
  base_path = File.join(pdf_views_path,class_path,file_name)
22
22
  empty_directory base_path
@@ -1,5 +1,4 @@
1
1
  require 'thread'
2
- require 'iconv'
3
2
 
4
3
  module ZPdf
5
4
 
@@ -55,8 +54,9 @@ module ZPdf
55
54
 
56
55
  cmd << " file:///#{html_files[:content].path} #{outfile_path}"
57
56
  puts "\n\nexecuting #{cmd}\n\n" if @verbose
58
- # avoid errors on systems where command processor is not UTF-8
59
- `#{Iconv.new('ISO-8859-1//TRANSLIT','UTF-8').iconv(cmd)}`
57
+ # TODO: check if errors can occur with systems where command processor is not UTF-8
58
+ # if so, we could force encoding to something else
59
+ `#{cmd}`
60
60
  if File.exists?(outfile_path)
61
61
  output = File.open(outfile_path,'rb') { |f| f.read }
62
62
  File.unlink(outfile_path)
@@ -103,7 +103,7 @@ module ZPdf
103
103
  end
104
104
 
105
105
  def self.find_wkhtmltopdf_executable
106
- rbCfg = defined?(RbConfig) ? RbConfig : Config
106
+ rbCfg = RbConfig
107
107
  if rbCfg::CONFIG['host_os'] =~ /mswin|mingw/ # windows?
108
108
  ENV['PATH'].split(';').each do |p|
109
109
  exec_path = File.join(p,'wkhtmltopdf.exe')
@@ -4,29 +4,28 @@ require "rails"
4
4
  module ZPdf
5
5
  class Railtie < Rails::Railtie
6
6
  config.zpdf = ActiveSupport::OrderedOptions.new
7
-
7
+ config.eager_load_namespaces << ZPdf
8
+
8
9
  initializer "zpdf.set_configs" do |app|
9
10
  paths = app.config.paths
10
11
  options = app.config.zpdf
11
-
12
- options.assets_dir ||= paths.public.to_a.first
13
- options.javascripts_dir ||= paths.public.javascripts.to_a.first
14
- options.stylesheets_dir ||= paths.public.stylesheets.to_a.first
15
12
 
16
13
  # by default, the views path for ZPdf::Base is the same as other views
17
- pdf_views_path = options.pdf_views_path || paths.app.views.to_a.first
14
+ pdf_views_path = options.pdf_views_path || paths['app/views'].first
18
15
 
19
16
  ActiveSupport.on_load(:zpdf) do
20
17
  include app.routes.url_helpers
21
- prepend_view_path pdf_views_path
22
- options.each { |k,v| send("#{k}=", v) }
18
+ append_view_path pdf_views_path
19
+ options.each { |k,v|
20
+ send("#{k}=", v)
21
+ }
23
22
  end
24
23
  end
25
-
24
+
26
25
  generators do
27
26
  load File.expand_path('./generators/producers/producer.rb',File.dirname(__FILE__))
28
27
  load File.expand_path('./generators/controller_module/controller_module.rb',File.dirname(__FILE__))
29
28
  end
30
-
29
+
31
30
  end
32
31
  end
@@ -2,7 +2,7 @@ module ZPdf
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 2
5
+ TINY = 4
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -1,7 +1,7 @@
1
1
  zpdf_path = File.expand_path(File.dirname(__FILE__))
2
2
  $:.unshift(zpdf_path) if File.directory?(zpdf_path) && !$:.include?(zpdf_path)
3
3
 
4
- require 'rails'
4
+ require 'active_support/rails'
5
5
  require 'active_support/core_ext/module/attr_internal'
6
6
  require 'active_support/lazy_load_hooks'
7
7
  require 'abstract_controller'
@@ -12,13 +12,7 @@ require 'z_pdf/railtie'
12
12
  module ZPdf
13
13
  extend ::ActiveSupport::Autoload
14
14
 
15
- # autoload :AdvAttrAccessor
16
- # autoload :Collector
17
15
  autoload :Base
18
- # autoload :DeliveryMethods
19
- # autoload :DeprecatedApi
20
- # autoload :MailHelper
21
- # autoload :OldApi
22
16
  # autoload :TestCase
23
17
  # autoload :TestHelper
24
18
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zpdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 4.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Bedard
@@ -9,53 +9,65 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-31 00:00:00.000000000 Z
12
+ date: 2016-09-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: 0.8.7
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '>='
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: 0.8.7
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: actionpack
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - '>='
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: 3.0.3
34
+ version: 4.1.0
35
+ - - "<"
36
+ - !ruby/object:Gem::Version
37
+ version: 5.0.0
35
38
  type: :runtime
36
39
  prerelease: false
37
40
  version_requirements: !ruby/object:Gem::Requirement
38
41
  requirements:
39
- - - '>='
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 4.1.0
45
+ - - "<"
40
46
  - !ruby/object:Gem::Version
41
- version: 3.0.3
47
+ version: 5.0.0
42
48
  - !ruby/object:Gem::Dependency
43
- name: expectations
49
+ name: actionview
44
50
  requirement: !ruby/object:Gem::Requirement
45
51
  requirements:
46
- - - '>='
52
+ - - ">="
47
53
  - !ruby/object:Gem::Version
48
- version: 2.0.0
54
+ version: 4.1.0
55
+ - - "<"
56
+ - !ruby/object:Gem::Version
57
+ version: 5.0.0
49
58
  type: :runtime
50
59
  prerelease: false
51
60
  version_requirements: !ruby/object:Gem::Requirement
52
61
  requirements:
53
- - - '>='
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 4.1.0
65
+ - - "<"
54
66
  - !ruby/object:Gem::Version
55
- version: 2.0.0
67
+ version: 5.0.0
56
68
  description: ZPdf allows to produce PDF content based on ERB templates. It easily
57
- integrates into a Rails 3 application and operates on a paradigm very similar to
58
- Rails 3 ActionMailer.
69
+ integrates into a Rails application and operates on a paradigm very similar to Rails
70
+ ActionMailer.
59
71
  email:
60
72
  - zzeligg@gmail.com
61
73
  - steph@zboing.ca
@@ -63,23 +75,25 @@ executables: []
63
75
  extensions: []
64
76
  extra_rdoc_files: []
65
77
  files:
78
+ - CHANGELOG.md
66
79
  - lib/z_pdf/base.rb
80
+ - lib/z_pdf/generators/controller_module/USAGE
67
81
  - lib/z_pdf/generators/controller_module/controller_module.rb
68
82
  - lib/z_pdf/generators/controller_module/templates/controller_module_template.rb
69
- - lib/z_pdf/generators/controller_module/USAGE
83
+ - lib/z_pdf/generators/producers/USAGE
70
84
  - lib/z_pdf/generators/producers/producer.rb
71
85
  - lib/z_pdf/generators/producers/templates/producer_template.rb
72
86
  - lib/z_pdf/generators/producers/templates/view_template.html.erb
73
87
  - lib/z_pdf/generators/producers/templates/view_template_footer.html.erb
74
88
  - lib/z_pdf/generators/producers/templates/view_template_header.html.erb
75
- - lib/z_pdf/generators/producers/USAGE
76
89
  - lib/z_pdf/html_pdf_object.rb
77
90
  - lib/z_pdf/railtie.rb
78
91
  - lib/z_pdf/version.rb
79
92
  - lib/z_pdf/z_pdf_helper.rb
80
93
  - lib/zpdf.rb
81
94
  homepage: https://rubygems.org/gems/zpdf
82
- licenses: []
95
+ licenses:
96
+ - MIT
83
97
  metadata: {}
84
98
  post_install_message:
85
99
  rdoc_options: []
@@ -87,17 +101,17 @@ require_paths:
87
101
  - lib
88
102
  required_ruby_version: !ruby/object:Gem::Requirement
89
103
  requirements:
90
- - - '>='
104
+ - - ">="
91
105
  - !ruby/object:Gem::Version
92
- version: 1.9.2
106
+ version: 2.0.0
93
107
  required_rubygems_version: !ruby/object:Gem::Requirement
94
108
  requirements:
95
- - - '>='
109
+ - - ">="
96
110
  - !ruby/object:Gem::Version
97
111
  version: '0'
98
112
  requirements: []
99
113
  rubyforge_project:
100
- rubygems_version: 2.0.14
114
+ rubygems_version: 2.5.1
101
115
  signing_key:
102
116
  specification_version: 4
103
117
  summary: HTML-based PDF rendering engine (using wkhtmltopdf)