documentum 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 85e56c7da4521d9ff3302f683e2c07ac609e9faa
4
+ data.tar.gz: 012fc858a1115b74d4088a42d36007d525ebf78d
5
+ SHA512:
6
+ metadata.gz: 45770c13b39aae5eda509d6871fcfabbb1dee4727bdd06ff4027234637031390842ffc33b108a09b1ea9c3bf79b12598e13557ce85ffa304393e1003f017678a
7
+ data.tar.gz: 5427735565d5bc7bb4c9d5b880c254579411c98a4dd8aea5ce01ed0a500ff60496e3be3d542abd65dd7e6f2d5f8dd4d64ff7f172069e383d6b25953e4cd3c878
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 JC Grubbs
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,47 @@
1
+ # Documentum
2
+
3
+ Documentum is a small command-line utility and Ruby library for generating PDF
4
+ documents from markdown rendered into a HAML template and applying
5
+ custom stylesheets.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application"s Gemfile:
10
+
11
+ gem "documentum"
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install documentum
20
+
21
+ ## Usage
22
+
23
+ Documentum can be used either as a command-line utility or as a library.
24
+
25
+ ### Library Use
26
+
27
+ ```ruby
28
+ markdown_files = ["/path/to/markdown1.md", "/path/to/markdown2.md"]
29
+ template_file = "/path/to/template.haml"
30
+ stylesheet_files = ["/path/to/styles1.css", "/path/to/styles2.css"]
31
+ output_dir = "/path/to/output/dir"
32
+
33
+ Documentum.generate(markdown_files, template_file, output_dir,
34
+ stylesheet_filenames: stylesheet_files)
35
+ ```
36
+
37
+ ### Command-line Use
38
+
39
+ [ Comming Soon... ]
40
+
41
+ ## Contributing
42
+
43
+ 1. Fork it ( https://github.com/[my-github-username]/documentum/fork )
44
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
45
+ 3. Commit your changes (`git commit -am "Add some feature"`)
46
+ 4. Push to the branch (`git push origin my-new-feature`)
47
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "documentum/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "documentum"
8
+ spec.version = Documentum::VERSION
9
+ spec.authors = ["JC Grubbs"]
10
+ spec.email = ["jc@devmynd.com"]
11
+ spec.summary = %q{Command line utility for generating PDF documents from markdown with custom stylesheets and haml templates.}
12
+ spec.description = %q{Command line utility for generating PDF documents from markdown with custom stylesheets and haml templates.}
13
+ spec.homepage = "http://github.com/thegrubbsian/documentum"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "activesupport", ">= 4.0.0"
22
+ spec.add_dependency "haml", "4.0.5"
23
+ spec.add_dependency "pdfkit", "0.6.2"
24
+ spec.add_dependency "pry"
25
+ spec.add_dependency "redcarpet", "3.1.2"
26
+ spec.add_dependency "wkhtmltopdf-binary", "0.9.9.1"
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.6"
29
+ spec.add_development_dependency "rake"
30
+ end
@@ -0,0 +1,21 @@
1
+ require "haml"
2
+ require "pdfkit"
3
+ require "pathname"
4
+ require "documentum/version"
5
+ require "active_support/all"
6
+ require "documentum/generator"
7
+
8
+ module Documentum
9
+
10
+ def self.generate(markdown_filenames, template_filename,
11
+ output_dir, stylesheet_filenames: [], options: {})
12
+ stylesheets = Array.wrap(stylesheet_filenames)
13
+ generator = Documentum::Generator.new(template_filename, output_dir,
14
+ stylesheet_filenames: stylesheets, options: options)
15
+ Array.wrap(markdown_filenames).each do |filename|
16
+ generator.generate_pdf(filename)
17
+ end
18
+ end
19
+
20
+
21
+ end
@@ -0,0 +1,38 @@
1
+ module Documentum
2
+ class Generator
3
+
4
+ attr_reader :template_filename, :stylesheet_filenames, :output_dir, :options
5
+
6
+ def initialize(template_filename, output_dir, stylesheet_filenames: [], options: {})
7
+ @template_filename = template_filename
8
+ @stylesheet_filenames = stylesheet_filenames
9
+ @output_dir = output_dir
10
+ end
11
+
12
+ def generate_pdf(markdown_filename)
13
+ html = generate_html(markdown_filename)
14
+ engine = PDFKit.new(html, page_size: "Letter")
15
+ engine.stylesheets += @stylesheet_filenames
16
+ engine.to_file(output_path(markdown_filename))
17
+ end
18
+
19
+ private
20
+
21
+ def output_path(markdown_filename)
22
+ path = Pathname.new(markdown_filename)
23
+ filename = path.basename.to_s.sub(path.extname, ".pdf")
24
+ "#{@output_dir}/#{filename}"
25
+ end
26
+
27
+ def template
28
+ @template ||= File.read(@template_filename)
29
+ end
30
+
31
+ def generate_html(markdown_filename)
32
+ markdown = File.read(markdown_filename)
33
+ engine = Haml::Engine.new(template)
34
+ engine.render(Object.new, { content: markdown })
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,3 @@
1
+ module Documentum
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,7 @@
1
+ body {
2
+ font-family: Helvetica, sans-serif;
3
+ }
4
+
5
+ h1, h2 {
6
+ font-style: italic;
7
+ }
@@ -0,0 +1,6 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %body
5
+ :markdown
6
+ #{content}
data/test.md ADDED
@@ -0,0 +1,7 @@
1
+ # Test
2
+
3
+ This is a test of the things and the stuff
4
+
5
+ ## Header 2
6
+
7
+ And some more content
metadata ADDED
@@ -0,0 +1,170 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: documentum
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - JC Grubbs
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 4.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 4.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: haml
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 4.0.5
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 4.0.5
41
+ - !ruby/object:Gem::Dependency
42
+ name: pdfkit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.6.2
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.6.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: redcarpet
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 3.1.2
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 3.1.2
83
+ - !ruby/object:Gem::Dependency
84
+ name: wkhtmltopdf-binary
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 0.9.9.1
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 0.9.9.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: bundler
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.6'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.6'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Command line utility for generating PDF documents from markdown with
126
+ custom stylesheets and haml templates.
127
+ email:
128
+ - jc@devmynd.com
129
+ executables: []
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - ".gitignore"
134
+ - Gemfile
135
+ - LICENSE.txt
136
+ - README.md
137
+ - Rakefile
138
+ - documentum.gemspec
139
+ - lib/documentum.rb
140
+ - lib/documentum/generator.rb
141
+ - lib/documentum/version.rb
142
+ - stylesheet.css
143
+ - template.haml
144
+ - test.md
145
+ homepage: http://github.com/thegrubbsian/documentum
146
+ licenses:
147
+ - MIT
148
+ metadata: {}
149
+ post_install_message:
150
+ rdoc_options: []
151
+ require_paths:
152
+ - lib
153
+ required_ruby_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ required_rubygems_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ requirements: []
164
+ rubyforge_project:
165
+ rubygems_version: 2.2.2
166
+ signing_key:
167
+ specification_version: 4
168
+ summary: Command line utility for generating PDF documents from markdown with custom
169
+ stylesheets and haml templates.
170
+ test_files: []