mdnotes 0.1.5 → 0.1.6

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.
Files changed (2) hide show
  1. data/lib/mdnotes.rb +14 -5
  2. metadata +7 -7
data/lib/mdnotes.rb CHANGED
@@ -74,22 +74,30 @@ class MDNotes
74
74
 
75
75
 
76
76
  def publish_notes
77
- publishing = (@params['p'] || @params['publish']) && (require 'pdfkit')
77
+ require 'fileutils'
78
+ require 'pdfkit'
79
+
80
+ publishing = (@params['p'] || @params['publish'])
78
81
 
79
82
  if publishing
80
83
  pdf_home = "./pdf"
81
84
  Dir::mkdir(pdf_home) unless FileTest::directory?(pdf_home)
82
85
 
83
86
  Dir["./html/*.html"].each do |html|
87
+
84
88
  f_name = html.split("/")[-1].split(".")[0]
89
+ output_file = File.join(".", "pdf", f_name + ".pdf")
90
+ html_file = File.open(html, 'r') { |f| f.read }
85
91
 
86
- html_file = open(html).read
92
+ # Delete the file first.
93
+ FileUtils.rm output_file if FileTest.exists? output_file
87
94
 
88
95
  puts "Publishing #{f_name}..."
96
+
89
97
  kit = PDFKit.new(html_file, :page_size => 'Letter')
90
- kit.to_file( File.join(".", "pdf", f_name + ".pdf"))
98
+ kit.to_file(output_file)
91
99
  end
92
- puts "Notes published."
100
+ puts "Notes published."
93
101
  end
94
102
 
95
103
  end
@@ -108,7 +116,8 @@ class MDNotes
108
116
  puts "Use [mdnotes] to 'compile' your notes into html. These will be located in the html/ folder."
109
117
  puts "Use [mdnotes -p] or [mdnotes --publish] to create pdf's of your notes. These will be located in the pdf/ folder"
110
118
  puts "If you want to include images in your notes you can place them in the images folder located under ./html/images. Use ![alt-text](./images/my_image.png) to reference an image."
111
- puts
119
+ puts
120
+ puts "You can find this at https://bitbucket.org/ugorelik/mdnotes"
112
121
  puts
113
122
  else
114
123
  check_directories
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mdnotes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-26 00:00:00.000000000Z
12
+ date: 2012-01-30 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdiscount
16
- requirement: &70327175998660 !ruby/object:Gem::Requirement
16
+ requirement: &70176378415140 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70327175998660
24
+ version_requirements: *70176378415140
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: pdfkit
27
- requirement: &70327175998080 !ruby/object:Gem::Requirement
27
+ requirement: &70176378414700 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70327175998080
35
+ version_requirements: *70176378414700
36
36
  description: Suite for taking easy notes in markdown and then converting to html and
37
37
  pdf.
38
38
  email: uri.gore@gmail.com
@@ -65,7 +65,7 @@ requirements:
65
65
  - rdiscount
66
66
  - pdfkit
67
67
  rubyforge_project:
68
- rubygems_version: 1.8.10
68
+ rubygems_version: 1.8.15
69
69
  signing_key:
70
70
  specification_version: 3
71
71
  summary: Suite for taking easy notes in markdown and then converting to html and pdf.