krammer 1.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: eec4f12d6bd188c500fd680828c23737c378b90d
4
+ data.tar.gz: 157d6c0fcefc53da6695a0578541598ccabddf07
5
+ SHA512:
6
+ metadata.gz: 01cea28f0af27d850bccd02b29ed59c1ad513387d3fbda9ee1baa18f813c924c83b535b3df26fd58a791458bb1edc34f4c0a65dafe14c4cef83dc14d5931b016
7
+ data.tar.gz: 4063e0c9ad9d10667dcd96cf5e730448efeb0b1c9d1527c0af7871c206e17ede2bc412c087599028fb2ae3da759aa54a422163940829b424d1709597884da704
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.gem
11
+ *.bundle
12
+ *.so
13
+ *.o
14
+ *.a
15
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in krammer.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,35 @@
1
+ Modified University of Illinois/NCSA License:
2
+
3
+ Copyright © 2015, Kento Kaneko. All rights reserved.
4
+
5
+ Developed by:
6
+
7
+ Kento Kaneko
8
+
9
+ https://github.com/kentokaneko/krammer
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
12
+ this software and associated documentation files (the “Software”), to deal with
13
+ the Software without restriction, including without limitation the rights to
14
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
15
+ the Software, and to permit persons to whom the Software is furnished to do so,
16
+ subject to the following conditions:
17
+
18
+ * Redistributions of source code must retain the above copyright notice, this
19
+ list of conditions and the following disclaimers.
20
+
21
+ * Redistributions in binary form must reproduce the above copyright notice, this
22
+ list of conditions and the following disclaimers in the documentation and/or
23
+ other materials provided with the distribution.
24
+
25
+ * Neither the name "Krammer" nor the names of its contributors may be used to
26
+ endorse or promote products derived from this Software without specific prior
27
+ written permission.
28
+
29
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
31
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32
+ CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
35
+ SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,55 @@
1
+ # Krammer
2
+
3
+ A (Markdown -> PDF) convertor written in Ruby.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'krammer'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install krammer
20
+
21
+ ## Requirements
22
+
23
+ This project currently supports OS X Mavericks.
24
+
25
+ The project requires the installation of [kramdown](http://kramdown.gettalong.org) and pdflatex, which is included in the [MacTex](https://www.tug.org/mactex/) distribution.
26
+
27
+ ## Usage
28
+
29
+ First, set the shell variable KRAMMER\_AUTHOR and KRAMMER\_TEMPLATE as follows:
30
+
31
+ $ export KRAMMER_AUTHOR="Name"
32
+ $ export KRAMMER_TEMPLATE="/path/to/template.erb"
33
+
34
+ You can put these lines in your .bash_profile/.bashrc file for persistence.
35
+
36
+ Then type:
37
+
38
+ $ cd /path/to/project/directory
39
+ $ krammer
40
+
41
+ or:
42
+
43
+ $ krammer /path/to/project/directory
44
+
45
+ ## Contributing
46
+
47
+ 1. Fork it ( https://github.com/[my-github-username]/krammer/fork )
48
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
49
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
50
+ 4. Push to the branch (`git push origin my-new-feature`)
51
+ 5. Create a new Pull Request
52
+
53
+ ## License
54
+
55
+ The license is located [here](https://github.com/kentokaneko/krammer/blob/master/LICENSE.txt).
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/krammer ADDED
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "pathname"
4
+ require "yaml"
5
+ require "date"
6
+ require "kramdown"
7
+ require "erb"
8
+
9
+ class Info
10
+ def initialize(hash)
11
+ hash.each do |key, value|
12
+ singleton_class.send(:define_method, key) { value }
13
+ end
14
+ end
15
+
16
+ def get_binding()
17
+ binding
18
+ end
19
+ end
20
+
21
+ path = ""
22
+ directory = ""
23
+
24
+ if ARGV.length == 0
25
+ unless result = Dir.glob("*.markdown")[0]
26
+ puts "\n\"*.markdown\" file not found in working directory..."
27
+ exit 1
28
+ else
29
+ path = Pathname.new(result)
30
+ end
31
+ elsif ARGV.length == 1
32
+
33
+ if (path = Pathname.new(ARGV[0])).relative?
34
+ path = Pathname.new(Dir.pwd + "/" + ARGV[0])
35
+ end
36
+
37
+ unless path.exist?
38
+ puts "\nInvalid path..."
39
+ exit 1
40
+ end
41
+
42
+ else
43
+ puts "\nToo many parameters..."
44
+ exit 1
45
+ end
46
+
47
+ Dir.chdir(path.parent)
48
+
49
+ fm = /^-{3}\n(.*\n)*?-{3}\n+/
50
+
51
+ time = NIL
52
+
53
+ while true
54
+
55
+ if time == File.mtime(path)
56
+ sleep(0.1)
57
+ next
58
+ end
59
+
60
+ unless source = open(path, "r").read
61
+ source = ""
62
+ end
63
+
64
+ unless yml = source[fm]
65
+ puts "\nInvalid YAML front matter\nRe-processing in 5 seconds..."
66
+ sleep(5.0)
67
+ next
68
+ end
69
+
70
+ unless meta = YAML.load(yml)
71
+ meta = Hash.new
72
+ end
73
+
74
+ title = meta.has_key?("title") ? meta["title"] : "[Title]"
75
+
76
+ author = meta.has_key?("author") ? meta["author"] : `echo $KRAMMER_AUTHOR`.strip
77
+ author.sub!(/^$/, "[Author]")
78
+
79
+ date = meta.has_key?("date") ? meta["date"] : DateTime.now
80
+ date = date.strftime("%-d %B %Y")
81
+
82
+ content = source.sub(fm, "")
83
+ body = Kramdown::Document.new(content, :auto_ids => false).to_latex
84
+
85
+ output = ERB.new(File.read(`echo $KRAMMER_TEMPLATE`.strip)).result(Info.new(title: title, author: author, date: date, body: body).get_binding)
86
+ open("output.tex", "w").write(output)
87
+
88
+ puts `pdflatex -halt-on-error output.tex`
89
+ puts "\nLast Update: #{DateTime.now.strftime("%Y-%m-%d %H:%M:%S.%L")}"
90
+
91
+ time = File.mtime(path)
92
+ end
data/krammer.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'krammer/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "krammer"
8
+ spec.version = Krammer::VERSION
9
+ spec.authors = ["Kento Kaneko"]
10
+ spec.email = ["kaneko2 [at] illinois [dot] edu"]
11
+ spec.summary = %q{A Markdown -> PDF convertor written in Ruby.}
12
+ spec.description = %q{A Markdown -> PDF convertor written in Ruby.}
13
+ spec.homepage = "https://github.com/kentokaneko/kentokaneko.github.io"
14
+ spec.license = "Modified University of Illinois/NCSA"
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_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+
24
+ spec.add_dependency "kramdown"
25
+ end
@@ -0,0 +1,3 @@
1
+ module Krammer
2
+ VERSION = "1.0.0"
3
+ end
data/lib/krammer.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "krammer/version"
2
+
3
+ module Krammer
4
+ # Your code goes here...
5
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: krammer
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Kento Kaneko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
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: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: kramdown
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: A Markdown -> PDF convertor written in Ruby.
56
+ email:
57
+ - kaneko2 [at] illinois [dot] edu
58
+ executables:
59
+ - krammer
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - .gitignore
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.markdown
67
+ - Rakefile
68
+ - bin/krammer
69
+ - krammer.gemspec
70
+ - lib/krammer.rb
71
+ - lib/krammer/version.rb
72
+ homepage: https://github.com/kentokaneko/kentokaneko.github.io
73
+ licenses:
74
+ - Modified University of Illinois/NCSA
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.4.5
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: A Markdown -> PDF convertor written in Ruby.
96
+ test_files: []