textile2pdf 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.
- data/LICENSE +20 -0
- data/README.textile +10 -0
- data/bin/textile2pdf +16 -0
- data/spec/textile2pdf_spec.rb +8 -0
- data/src/textile2pdf.rb +31 -0
- data/src/textile2pdf/setup.rb +20 -0
- data/src/textile2pdf/version.rb +5 -0
- metadata +116 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Fredrik Wallgren
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
20
|
+
|
data/README.textile
ADDED
data/bin/textile2pdf
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)) + '/../src/')
|
6
|
+
|
7
|
+
require 'textile2pdf'
|
8
|
+
|
9
|
+
if ARGV.flags.file?
|
10
|
+
Textile2PDF.parse_file(ARGV.flags.file)
|
11
|
+
else
|
12
|
+
Dir.glob("*.textile").each do |file|
|
13
|
+
Textile2PDF.parse_file(file)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
data/src/textile2pdf.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
require 'pdfkit'
|
4
|
+
require 'redcloth'
|
5
|
+
|
6
|
+
require "textile2pdf/version"
|
7
|
+
require "textile2pdf/setup"
|
8
|
+
|
9
|
+
module Textile2PDF
|
10
|
+
def self.parse_file(file)
|
11
|
+
contents = File.open(file, 'rb') { |f| f.read }
|
12
|
+
doc = RedCloth.new(contents)
|
13
|
+
doc.filter_html = true
|
14
|
+
html = doc.to_html
|
15
|
+
|
16
|
+
kit = PDFKit.new(html)
|
17
|
+
|
18
|
+
stylesheet = 'textile2pdf.css'
|
19
|
+
stylesheet = ARGV.flags.stylesheet if ARGV.flags.stylesheet?
|
20
|
+
|
21
|
+
kit.stylesheets << stylesheet if File.exists?(stylesheet)
|
22
|
+
|
23
|
+
output_dir = Dir.getwd
|
24
|
+
output_dir = ARGV.flags.outputdir if ARGV.flags.outputdir?
|
25
|
+
FileUtils.mkdir_p(output_dir) unless File.directory?(output_dir)
|
26
|
+
|
27
|
+
filename = File.basename(file, File.extname(file))
|
28
|
+
file = kit.to_file(File.join(output_dir, "#{filename}.pdf"))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'optiflag'
|
2
|
+
|
3
|
+
module Textile2PDF extend OptiFlagSet
|
4
|
+
optional_flag 'file' do
|
5
|
+
description 'The file to convert if you do not want to convert all in the current folder'
|
6
|
+
alternate_forms 'f'
|
7
|
+
end
|
8
|
+
optional_flag 'outputdir' do
|
9
|
+
description 'The directory to save parsed files if you do not want to use the current folder'
|
10
|
+
alternate_forms 'o'
|
11
|
+
end
|
12
|
+
optional_flag 'stylesheet' do
|
13
|
+
description 'The stylesheet to use if you do not have one in the current folder'
|
14
|
+
alternate_forms 's'
|
15
|
+
end
|
16
|
+
usage_flag 'h', 'help', '?'
|
17
|
+
|
18
|
+
and_process!
|
19
|
+
end
|
20
|
+
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: textile2pdf
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Fredrik Wallgren
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-04-29 00:00:00 +02:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: wkhtmltopdf-binary
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pdfkit
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: "0"
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: RedCloth
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: optiflag
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
type: :runtime
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: rspec
|
62
|
+
prerelease: false
|
63
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
type: :development
|
70
|
+
version_requirements: *id005
|
71
|
+
description: Simple utillity to convert textile to pdf files. Useful for reports etc.
|
72
|
+
email: fredrik.wallgren@gmail.com
|
73
|
+
executables:
|
74
|
+
- textile2pdf
|
75
|
+
extensions: []
|
76
|
+
|
77
|
+
extra_rdoc_files: []
|
78
|
+
|
79
|
+
files:
|
80
|
+
- bin/textile2pdf
|
81
|
+
- src/textile2pdf.rb
|
82
|
+
- src/textile2pdf/version.rb
|
83
|
+
- src/textile2pdf/setup.rb
|
84
|
+
- spec/textile2pdf_spec.rb
|
85
|
+
- LICENSE
|
86
|
+
- README.textile
|
87
|
+
has_rdoc: true
|
88
|
+
homepage: https://github.com/walle/textile2pdf
|
89
|
+
licenses: []
|
90
|
+
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
|
94
|
+
require_paths:
|
95
|
+
- - src
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: "0"
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: "0"
|
108
|
+
requirements: []
|
109
|
+
|
110
|
+
rubyforge_project: textile2pdf
|
111
|
+
rubygems_version: 1.5.2
|
112
|
+
signing_key:
|
113
|
+
specification_version: 3
|
114
|
+
summary: Simple utillity to convert textile to pdf files.
|
115
|
+
test_files: []
|
116
|
+
|