plans 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f36f44001dbc8ddb84a61c9095b71c3e24fc69a7
4
- data.tar.gz: 7ebd2e8cd146d988773051f9cfd45a8b23c756e6
3
+ metadata.gz: 7ac32cb6c1b729bd93cf76a59f72e6ef8b52fc01
4
+ data.tar.gz: b8e4e7780348f4534fa8b7d3b4c450be6191e235
5
5
  SHA512:
6
- metadata.gz: 8c2c886d74043230a8b91e53ad529b1d47123b5f1fdf7b98540e90282d7b3a14cbc69ecb58860bdb23766760bb72752ab5b8e3312c752c57806efbf760fc39c7
7
- data.tar.gz: 76c9b7a979b23e11b020a3df2619a8ea152c044c862860fc11beb3150426f0245ed4edfec0341eedcb4da84cb63ed90c4b1100661aeced923ea20d1b71deccc2
6
+ metadata.gz: 3ca5d8a0a21ca4b9948ea5fb49100ddbd2d5af82e78ec9cbb69537015b7f67cd05528f44e9b06b3a57164f82552ec6ff28dad0339681c86c0219517a4946d4bc
7
+ data.tar.gz: d6042203795eb8036ff9f4fa83fb8d019b04d6595171966e3c2a5fdb5fded404c0f99a3d20657acbcc7137d2f78c1a54b5e9f13eabc6047d1913781de7f9ad37
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- plans (0.1.0)
4
+ plans (0.2.0)
5
5
  thor
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -34,6 +34,10 @@ ImageMagick works pretty much the same way.
34
34
 
35
35
  You also need Microsoft Word. :)
36
36
 
37
+ Plans can also create PDFs. If you want to create PDFs of your markdown documents you will need to install a XeLaTeX engine for use by Pandoc. [BasicTex](https://tug.org/mactex/morepackages.html) will work. You can also install this with homebrew.
38
+
39
+ $ brew install Caskroom/cask/basictex
40
+
37
41
  ## Installation
38
42
 
39
43
  Install it:
data/lib/plans/cli.rb CHANGED
@@ -4,6 +4,7 @@ require 'plans/list'
4
4
  require 'plans/init'
5
5
  require 'plans/publish'
6
6
  require 'plans/thumbs'
7
+ require 'plans/pdf'
7
8
 
8
9
  module Plans
9
10
  class CLI < Thor
@@ -114,6 +115,30 @@ module Plans
114
115
  Thumbs.new(shell, options).do(path)
115
116
  end
116
117
 
118
+
119
+ desc 'pdf', 'Create an PDF version of the document'
120
+ long_desc <<-PDF
121
+ `plans pdf` will create a PDF version of the document.
122
+
123
+ The document type is determined by inspecting the template.yml.
124
+
125
+ Overwrites any previously published versions of the PDF document.
126
+
127
+ > $ plans pdf
128
+ PDF
129
+ method_option :toc,
130
+ {:type => :boolean,
131
+ :default => false,
132
+ :desc => 'Add a table of contents to the PDF document. Not included by default.'}
133
+ method_option :open,
134
+ {:type => :boolean,
135
+ :default => true,
136
+ :desc => 'Open the published document after it has been rendered by Pandoc.'}
137
+
138
+ def pdf (path = '.')
139
+ Pdf.new(shell, options).do(path)
140
+ end
141
+
117
142
  end
118
143
  end
119
144
 
data/lib/plans/pdf.rb ADDED
@@ -0,0 +1,43 @@
1
+ require 'plans/publish'
2
+
3
+ module Plans
4
+ class Pdf < Publish
5
+
6
+ def do(path)
7
+ # Create the thumbnails first.
8
+ say 'Updating thumbnails.'
9
+ Thumbs.new(shell, options).do(path)
10
+
11
+ path = pathname(path)
12
+ toc_flag = options[:toc] ? "--toc" : ""
13
+ open_flag = options[:open]
14
+
15
+ source_file = path + 'README.md'
16
+ check_source_file(source_file)
17
+
18
+ doc_type = get_doctype(path)
19
+
20
+ output_dir = path + 'publish'
21
+ # Make the publish directory if it does not exist.
22
+ FileUtils.mkdir output_dir unless Dir.exist? output_dir
23
+ output_file = output_dir + "#{doc_type}.pdf"
24
+
25
+ # We need to set the current working directory to where the markdown file is so
26
+ # the images render correctly.
27
+ # Pandoc only looks in the current working directory.
28
+ Dir.chdir(path) do
29
+ `pandoc #{toc_flag} #{source_file} --standalone --latex-engine=xelatex -o #{output_file}`
30
+ end
31
+
32
+ # Get the return code from pandoc.
33
+ pandoc_return = $?.to_i
34
+ check_pandoc_return(pandoc_return)
35
+
36
+ say "#{doc_type} published as PDF.", :green
37
+
38
+ # Open the PDF if requested
39
+ `open #{output_file}` if open_flag
40
+ end
41
+
42
+ end
43
+ end
data/lib/plans/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Plans
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plans
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Cook
@@ -152,6 +152,7 @@ files:
152
152
  - lib/plans/init.rb
153
153
  - lib/plans/list.rb
154
154
  - lib/plans/new.rb
155
+ - lib/plans/pdf.rb
155
156
  - lib/plans/publish.rb
156
157
  - lib/plans/thumbs.rb
157
158
  - lib/plans/version.rb