kd 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/bin/kd +65 -0
  3. metadata +103 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b835964ef02c3fec5e2addfcd43f5a61711e455c
4
+ data.tar.gz: 56b45e7bca5e2bc1e7ed293b32ba8b287ef1c21c
5
+ SHA512:
6
+ metadata.gz: 2ca6c710923f51c00964b21019a6e593ecc34c64a337bda24b6d8ec5aac7cb66b00550e76d9bb39b1c4ab8947482398125a68321fef22fd63bef8a58d53e2c41
7
+ data.tar.gz: 873787fc7f8f39454fd065bd188ae8c637db7cf157255598cddcc134a1d4ee34cb0be86d671dd688274cb60f2183e1af2b46b179559a200cf44d3f2e8ae86b78
data/bin/kd ADDED
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'colorize'
4
+ require 'kramdown'
5
+
6
+ def usage
7
+ puts "Usage: ".blue + "kd ".cyan + "<input-file-1> [input-file-2] ... ".green + "[-h|--html] [-p|--pdf]".yellow
8
+ end
9
+
10
+ def check_args(args, *flags)
11
+ retval = flags.any?{ |f| args.include?(f) }
12
+ flags.each { |f| args.delete(f) }
13
+ retval
14
+ end
15
+
16
+ def check_html(args)
17
+ check_args(args, '-h', '--html')
18
+ end
19
+
20
+ def check_pdf(args)
21
+ check_args(args, '-p', '--pdf')
22
+ end
23
+
24
+ def check_help(args)
25
+ check_args(args, '--help')
26
+ end
27
+
28
+ args = ARGV.dup
29
+
30
+ if args.count.zero? || check_help(args)
31
+ usage
32
+ Process.exit(0)
33
+ end
34
+
35
+ html = check_html(args)
36
+ pdf = check_pdf(args)
37
+
38
+ html = pdf = true if !html && !pdf
39
+
40
+ # all that should be left are files
41
+ unless args.count > 0
42
+ puts "Error: No input files".red
43
+ Process.exit(1)
44
+ end
45
+
46
+ args.each do |input_file|
47
+ unless File.exists?(input_file)
48
+ puts "Error processing '#{input_file}'. File does not exist!".red
49
+ next
50
+ end
51
+
52
+ k = Kramdown::Document.new(File.read("#{input_file}"))
53
+
54
+ if html
55
+ outfile = "#{input_file.gsub(/\.md$/i, '')}.html"
56
+ puts "Writing html file '#{outfile}'".green
57
+ File.write(outfile, k.to_html)
58
+ end
59
+
60
+ if pdf
61
+ outfile = "#{input_file.gsub(/\.md$/i, '')}.pdf"
62
+ puts "Writing pdf file '#{outfile}'".green
63
+ File.write(outfile, k.to_pdf)
64
+ end
65
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kd
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ben Porter
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: kramdown
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: prawn
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: prawn-table
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.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.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: colorize
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.7'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.7'
69
+ description: Compiles a kramdown file to pdf and html. This can be done with the
70
+ kramdown gem, but this gem just simplifies the interface
71
+ email: BenjaminPorter86@gmail.com
72
+ executables:
73
+ - kd
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - bin/kd
78
+ homepage: http://rubygems.org/gems/kd
79
+ licenses:
80
+ - MIT
81
+ metadata: {}
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubyforge_project:
98
+ rubygems_version: 2.2.2
99
+ signing_key:
100
+ specification_version: 4
101
+ summary: Compiles a kramdown file to pdf and html
102
+ test_files: []
103
+ has_rdoc: