princely 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/princely.rb +18 -12
- data/lib/princely/version.rb +1 -1
- metadata +44 -7
- data/VERSION +0 -1
data/lib/princely.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# PrinceXML Ruby interface.
|
1
|
+
# PrinceXML Ruby interface.
|
2
2
|
# http://www.princexml.com
|
3
3
|
#
|
4
4
|
# Library by Subimage Interactive - http://www.subimage.com
|
@@ -14,7 +14,6 @@
|
|
14
14
|
# :type => 'application/pdf'
|
15
15
|
# )
|
16
16
|
#
|
17
|
-
$:.unshift(File.dirname(__FILE__))
|
18
17
|
require 'logger'
|
19
18
|
require 'princely/rails' if defined?(Rails)
|
20
19
|
|
@@ -29,6 +28,7 @@ class Princely
|
|
29
28
|
raise "Cannot find prince command-line app in $PATH" if @exe_path.length == 0
|
30
29
|
raise "Cannot find prince command-line app at #{@exe_path}" if @exe_path && !File.executable?(@exe_path)
|
31
30
|
@style_sheets = ''
|
31
|
+
@cmd_args = ''
|
32
32
|
@log_file = options[:log_file]
|
33
33
|
@logger = options[:logger]
|
34
34
|
end
|
@@ -38,7 +38,7 @@ class Princely
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def log_file
|
41
|
-
@log_file ||= defined?(Rails) ?
|
41
|
+
@log_file ||= defined?(Rails) ?
|
42
42
|
Rails.root.join("log/prince.log") :
|
43
43
|
File.expand_path(File.dirname(__FILE__) + "/log/prince.log")
|
44
44
|
end
|
@@ -54,7 +54,7 @@ class Princely
|
|
54
54
|
`which prince`.chomp
|
55
55
|
end
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
# Sets stylesheets...
|
59
59
|
# Can pass in multiple paths for css files.
|
60
60
|
#
|
@@ -63,17 +63,23 @@ class Princely
|
|
63
63
|
@style_sheets << " -s #{sheet} "
|
64
64
|
end
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
|
+
# Sets arbitrary command line arguments
|
68
|
+
def add_cmd_args(str)
|
69
|
+
@cmd_args << " #{str} "
|
70
|
+
end
|
71
|
+
|
67
72
|
# Returns fully formed executable path with any command line switches
|
68
73
|
# we've set based on our variables.
|
69
74
|
#
|
70
75
|
def exe_path
|
71
76
|
# Add any standard cmd line arguments we need to pass
|
72
77
|
@exe_path << " --input=html --server --log=#{log_file} "
|
78
|
+
@exe_path << @cmd_args
|
73
79
|
@exe_path << @style_sheets
|
74
80
|
return @exe_path
|
75
81
|
end
|
76
|
-
|
82
|
+
|
77
83
|
# Makes a pdf from a passed in string.
|
78
84
|
#
|
79
85
|
# Returns PDF as a stream, so we can use send_data to shoot
|
@@ -81,15 +87,15 @@ class Princely
|
|
81
87
|
#
|
82
88
|
def pdf_from_string(string, output_file = '-')
|
83
89
|
path = self.exe_path()
|
84
|
-
# Don't spew errors to the standard out...and set up to take IO
|
90
|
+
# Don't spew errors to the standard out...and set up to take IO
|
85
91
|
# as input and output
|
86
92
|
path << ' --silent - -o -'
|
87
|
-
|
93
|
+
|
88
94
|
# Show the command used...
|
89
95
|
logger.info "\n\nPRINCE XML PDF COMMAND"
|
90
96
|
logger.info path
|
91
97
|
logger.info ''
|
92
|
-
|
98
|
+
|
93
99
|
# Actually call the prince command, and pass the entire data stream back.
|
94
100
|
pdf = IO.popen(path, "w+")
|
95
101
|
pdf.puts(string)
|
@@ -102,15 +108,15 @@ class Princely
|
|
102
108
|
|
103
109
|
def pdf_from_string_to_file(string, output_file)
|
104
110
|
path = self.exe_path()
|
105
|
-
# Don't spew errors to the standard out...and set up to take IO
|
111
|
+
# Don't spew errors to the standard out...and set up to take IO
|
106
112
|
# as input and output
|
107
113
|
path << " --silent - -o '#{output_file}' >> '#{log_file}' 2>> '#{log_file}'"
|
108
|
-
|
114
|
+
|
109
115
|
# Show the command used...
|
110
116
|
logger.info "\n\nPRINCE XML PDF COMMAND"
|
111
117
|
logger.info path
|
112
118
|
logger.info ''
|
113
|
-
|
119
|
+
|
114
120
|
# Actually call the prince command, and pass the entire data stream back.
|
115
121
|
pdf = IO.popen(path, "w+")
|
116
122
|
pdf.puts(string)
|
data/lib/princely/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: princely
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,8 +10,40 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
14
|
-
dependencies:
|
13
|
+
date: 2013-05-04 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: rake
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :development
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
15
47
|
description: A wrapper for the PrinceXML PDF generation library.
|
16
48
|
email:
|
17
49
|
- michael@intridea.com
|
@@ -24,7 +56,6 @@ files:
|
|
24
56
|
- MIT-LICENSE
|
25
57
|
- README.rdoc
|
26
58
|
- Rakefile
|
27
|
-
- VERSION
|
28
59
|
- lib/princely.rb
|
29
60
|
- lib/princely/pdf_helper.rb
|
30
61
|
- lib/princely/rails.rb
|
@@ -38,18 +69,24 @@ require_paths:
|
|
38
69
|
required_ruby_version: !ruby/object:Gem::Requirement
|
39
70
|
none: false
|
40
71
|
requirements:
|
41
|
-
- -
|
72
|
+
- - '>='
|
42
73
|
- !ruby/object:Gem::Version
|
43
74
|
version: '0'
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
hash: 978515199395042526
|
44
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
79
|
none: false
|
46
80
|
requirements:
|
47
|
-
- -
|
81
|
+
- - '>='
|
48
82
|
- !ruby/object:Gem::Version
|
49
83
|
version: '0'
|
84
|
+
segments:
|
85
|
+
- 0
|
86
|
+
hash: 978515199395042526
|
50
87
|
requirements: []
|
51
88
|
rubyforge_project:
|
52
|
-
rubygems_version: 1.8.
|
89
|
+
rubygems_version: 1.8.25
|
53
90
|
signing_key:
|
54
91
|
specification_version: 3
|
55
92
|
summary: A simple Rails wrapper for the PrinceXML PDF generation library.
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.2.6
|