verku 0.8.0.p

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 (60) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.gitignore +49 -0
  4. data/BUILD.md +6 -0
  5. data/Gemfile +14 -0
  6. data/Gemfile.lock +82 -0
  7. data/LICENSE.md +22 -0
  8. data/README.md +149 -0
  9. data/Rakefile +72 -0
  10. data/VERSION +1 -0
  11. data/bin/verku +5 -0
  12. data/lib/verku.rb +56 -0
  13. data/lib/verku/adapters/markdown.rb +44 -0
  14. data/lib/verku/cli.rb +93 -0
  15. data/lib/verku/dependency.rb +19 -0
  16. data/lib/verku/exporter.rb +77 -0
  17. data/lib/verku/extensions/string.rb +19 -0
  18. data/lib/verku/generator.rb +55 -0
  19. data/lib/verku/parser.rb +85 -0
  20. data/lib/verku/parser/epub.rb +187 -0
  21. data/lib/verku/parser/html.rb +245 -0
  22. data/lib/verku/parser/mobi.rb +17 -0
  23. data/lib/verku/parser/pdf.rb +54 -0
  24. data/lib/verku/parser/txt.rb +1 -0
  25. data/lib/verku/stats.rb +114 -0
  26. data/lib/verku/stream.rb +27 -0
  27. data/lib/verku/toc.rb +6 -0
  28. data/lib/verku/toc/epub.rb +41 -0
  29. data/lib/verku/toc/html.rb +78 -0
  30. data/lib/verku/version.rb +10 -0
  31. data/templates/config.erb +80 -0
  32. data/templates/cover.jpg +0 -0
  33. data/templates/dp-logo.png +0 -0
  34. data/templates/epub/back.erb +22 -0
  35. data/templates/epub/copyright.erb +46 -0
  36. data/templates/epub/cover.erb +12 -0
  37. data/templates/epub/cover.html +12 -0
  38. data/templates/epub/page.erb +15 -0
  39. data/templates/epub/user.css +500 -0
  40. data/templates/extras.tex +1 -0
  41. data/templates/html/copyright.erb +46 -0
  42. data/templates/html/layout.css +352 -0
  43. data/templates/html/layout.erb +45 -0
  44. data/templates/html/syntax.css +58 -0
  45. data/templates/html/thanks.erb +21 -0
  46. data/templates/html/user.css +7 -0
  47. data/templates/latex.erb +416 -0
  48. data/templates/merovex-logo.jpg +0 -0
  49. data/templates/merovex-logo.png +0 -0
  50. data/templates/pdf/layout.erb +418 -0
  51. data/templates/rakefile.rb +103 -0
  52. data/templates/readme.erb +3 -0
  53. data/templates/text/01-Getting-Started.md +27 -0
  54. data/templates/text/02-Creating-Chapters.md +22 -0
  55. data/templates/text/03-Generating-Output.md +2 -0
  56. data/templates/text/10-Test-Markdown.md +157 -0
  57. data/test/helper.rb +34 -0
  58. data/test/test_bookmaker.rb +7 -0
  59. data/verku.gemspec +142 -0
  60. metadata +317 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 442de3423f5f8e5268f95b494a9450886e1d3032
4
+ data.tar.gz: 6347249ddf181730113455c7c98ec56026d96e7a
5
+ SHA512:
6
+ metadata.gz: 895a5bbf4444e26cb30f90bfcce36f2e4d95e0181fd5cf60f624fda9c19b9e6e3d13b6645e6ecdc35a2a241754416e2b8fb464523b3b6052e478cd7a78c7765e
7
+ data.tar.gz: c70dd55462cd5075243be7f1bf728303b5d2c0f8105aa37fe3ed6fed746343e366864d427e6291c0bea60363d48d59a49349149eb5b3e2e36174a5c031a49469
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.gitignore ADDED
@@ -0,0 +1,49 @@
1
+ # rcov generated
2
+ coverage
3
+ coverage.data
4
+
5
+ # rdoc generated
6
+ rdoc
7
+
8
+ # yard generated
9
+ doc
10
+ .yardoc
11
+
12
+ # bundler
13
+ .bundle
14
+
15
+ # jeweler generated
16
+ pkg
17
+
18
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
19
+ #
20
+ # * Create a file at ~/.gitignore
21
+ # * Include files you want ignored
22
+ # * Run: git config --global core.excludesfile ~/.gitignore
23
+ #
24
+ # After doing this, these files will be ignored in all your git projects,
25
+ # saving you from having to 'pollute' every project you touch with them
26
+ #
27
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
28
+ #
29
+ # For MacOS:
30
+ #
31
+ #.DS_Store
32
+
33
+ # For TextMate
34
+ #*.tmproj
35
+ #tmtags
36
+
37
+ # For emacs:
38
+ #*~
39
+ #\#*
40
+ #.\#*
41
+
42
+ # For vim:
43
+ #*.swp
44
+
45
+ # For redcar:
46
+ #.redcar
47
+
48
+ # For rubinius:
49
+ #*.rbc
data/BUILD.md ADDED
@@ -0,0 +1,6 @@
1
+ # Build
2
+
3
+ https://github.com/radar/guides/blob/master/gem-development.md
4
+
5
+ * `rake build` which will build a local copy of our gem,
6
+ * `gem install pkg/foodie-0.1.0.gem` to install it.
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "rdoc", "~> 3.12"
11
+ gem "bundler", "~> 1.0"
12
+ gem "jeweler", "~> 2.0.1"
13
+ gem "simplecov", ">= 0"
14
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,82 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (4.2.5)
5
+ i18n (~> 0.7)
6
+ json (~> 1.7, >= 1.7.7)
7
+ minitest (~> 5.1)
8
+ thread_safe (~> 0.3, >= 0.3.4)
9
+ tzinfo (~> 1.1)
10
+ addressable (2.4.0)
11
+ builder (3.2.2)
12
+ descendants_tracker (0.0.4)
13
+ thread_safe (~> 0.3, >= 0.3.1)
14
+ docile (1.1.5)
15
+ faraday (0.9.2)
16
+ multipart-post (>= 1.2, < 3)
17
+ git (1.2.9.1)
18
+ github_api (0.13.1)
19
+ addressable (~> 2.4.0)
20
+ descendants_tracker (~> 0.0.4)
21
+ faraday (~> 0.8, < 0.10)
22
+ hashie (>= 3.4)
23
+ multi_json (>= 1.7.5, < 2.0)
24
+ oauth2
25
+ hashie (3.4.3)
26
+ highline (1.7.8)
27
+ i18n (0.7.0)
28
+ jeweler (2.0.1)
29
+ builder
30
+ bundler (>= 1.0)
31
+ git (>= 1.2.5)
32
+ github_api
33
+ highline (>= 1.6.15)
34
+ nokogiri (>= 1.5.10)
35
+ rake
36
+ rdoc
37
+ json (1.8.3)
38
+ jwt (1.5.2)
39
+ mini_portile2 (2.0.0)
40
+ minitest (5.8.3)
41
+ multi_json (1.11.2)
42
+ multi_xml (0.5.5)
43
+ multipart-post (2.0.0)
44
+ nokogiri (1.6.7.1)
45
+ mini_portile2 (~> 2.0.0.rc2)
46
+ oauth2 (1.0.0)
47
+ faraday (>= 0.8, < 0.10)
48
+ jwt (~> 1.0)
49
+ multi_json (~> 1.3)
50
+ multi_xml (~> 0.5)
51
+ rack (~> 1.2)
52
+ rack (1.6.4)
53
+ rake (10.4.2)
54
+ rdoc (3.12.2)
55
+ json (~> 1.4)
56
+ shoulda (3.5.0)
57
+ shoulda-context (~> 1.0, >= 1.0.1)
58
+ shoulda-matchers (>= 1.4.1, < 3.0)
59
+ shoulda-context (1.2.1)
60
+ shoulda-matchers (2.8.0)
61
+ activesupport (>= 3.0.0)
62
+ simplecov (0.11.1)
63
+ docile (~> 1.1.0)
64
+ json (~> 1.8)
65
+ simplecov-html (~> 0.10.0)
66
+ simplecov-html (0.10.0)
67
+ thread_safe (0.3.5)
68
+ tzinfo (1.2.2)
69
+ thread_safe (~> 0.1)
70
+
71
+ PLATFORMS
72
+ ruby
73
+
74
+ DEPENDENCIES
75
+ bundler (~> 1.0)
76
+ jeweler (~> 2.0.1)
77
+ rdoc (~> 3.12)
78
+ shoulda
79
+ simplecov
80
+
81
+ BUNDLED WITH
82
+ 1.12.5
data/LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Ben Wilson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,149 @@
1
+ Verku
2
+ =========
3
+
4
+ Verku provides authors a free, ruby-based production toolchain for self-published paper and electronic books using the [LaTeX](http://www.latex-project.org/) document preparation system. The code base borrows heavily from [Kitabu](https://github.com/fnando/kitabu), while replacing [Prince](http://princexml.com) as the PDF generator (due to licensing issues).
5
+
6
+ What Does Verku Provide?
7
+ ----------------------------
8
+
9
+ * Write using Markdown
10
+ * Paper Support: Book-quality PDF output (6"x9") using LaTeX's [Memoir](http://www.ctan.org/tex-archive/macros/latex/contrib/memoir) class, suitable for publishing via [Createspace](https://www.createspace.com).
11
+ * Electronic Support: HTML, Epub and Mobi output (using [kindlegen](http://kindlegen.s3.amazonaws.com)).
12
+ * Table of Contents automatically generated from chapter titles
13
+
14
+ Installation
15
+ -------------
16
+
17
+ To install Verku, you’ll need a working [Ruby](http://www.ruby-lang.org) 1.9+ installation.
18
+
19
+ $ gem install verku
20
+
21
+ <!--
22
+
23
+ After installing Verku, run the following command to check your external
24
+ dependencies.
25
+
26
+ $ verku check
27
+
28
+ KindleGen: Converts ePub e-books into .mobi files.
29
+ Installed.
30
+
31
+ html2text: Converts HTML documents into plain text.
32
+ Not installed.
33
+
34
+ pygments.rb: A generic syntax highlight. If installed, replaces CodeRay.
35
+ Not installed.
36
+
37
+ There's no requirements here; just make sure you cleared the correct dependency based
38
+ on the formats you want to compile to.
39
+
40
+ -->
41
+
42
+ How to Use Verku
43
+ --------------------
44
+
45
+ To create a new Verku project, execute the following on the command line:
46
+
47
+ $ verku new mybook
48
+
49
+ This command creates a directory <tt>mybook</tt> with the following structure (may be slightly different in production):
50
+
51
+ mybook
52
+ ├── _verku.yml
53
+ ├── _images
54
+ │ ├── cover.jpg
55
+ │ └── logo.png
56
+ ├── _templates
57
+ │ ├── epub
58
+ │ │ ├── cover.erb
59
+ │ │ ├── cover.png
60
+ │ │ ├── page.erb
61
+ │ │ └── user.css
62
+ │ └── html
63
+ │ ├── layout.css
64
+ │ ├── layout.erb
65
+ │ ├── syntax.css
66
+ │ └── user.css
67
+ ├── builds
68
+ └── docs
69
+ └── 01_Chapter
70
+ └──01_Welcome.tex
71
+
72
+ The <tt>_verku.yml</tt> file holds the project's metadata. Update the relevant fields.
73
+
74
+ Now it's time to write your e-book. All your book content will be placed on the text directory. Verku requires you to separate your book into chapters. A chapter is nothing but a directory that holds lots of text files. The e-book will be generated using every folder/file alphabetically. So be sure to use a sequential numbering as the name. Here's a sample:
75
+
76
+ * text
77
+ * 01_Introduction
78
+ * 01_introduction.tex
79
+ * 02_What_is_Ruby_on_Rails
80
+ * 01_MVC.tex
81
+ * 02_DRY.tex
82
+ * 03_Convention_Over_Configuration.tex
83
+ * 03_Installing_Ruby_on_Rails
84
+ * 01_Installing.tex
85
+ * 02_Mac_OS_X_instructions.tex
86
+ * 03_Windows_instructions.tex
87
+ * 04_Ubuntu_Linux_instructions.tex
88
+
89
+
90
+ When you're ready to view your progress, the commands below will compile the book into the <tt>output/</tt> directory in the appropriate format:
91
+
92
+ Compile into: PDF, HTML, Epub, Mobi
93
+
94
+ $ verku compile
95
+
96
+ Compile into a specific format:
97
+
98
+ $ verku compile --only [pdf|html|epub|mobi]
99
+
100
+ When compiling into HTML, Epub or Mobi, **Verku** generates the Table of Contents (TOC) based on the h2-h6 tags. The h1 tag is discarded because it's meant to be the book title.
101
+
102
+ To print the TOC, you need to print a variable called +toc+, using the eRb tag.
103
+
104
+ <%= toc %>
105
+
106
+ To create valid Mobi for Kindle, you need an appropriate cover image. **Verku** looks for <tt>image/cover.jpg</tt>, and compiles it into the Epub and Mobi files. Refer to the Kindle documentation for the cover requirements.
107
+
108
+ ### Dependencies
109
+
110
+ **Verku** needs the following dependencies satisfied:
111
+
112
+ * [xelatex](http://en.wikipedia.org/wiki/XeTeX), available on via MacTeX (Mac) and MiKTex (Windows, unconfirmed).
113
+ * LaTex to HTML conversion done within the gem itself.
114
+ * HTML to EPUB via [Merovex-EeePub](https://github.com/Merovex/eeepub). Install it directly from Github
115
+ * EPUB to Mobi via [Kindlegen](http://kindlegen.s3.amazonaws.com)
116
+ * Patience - This was developed for my own writing purposes, and is likely incomplete as of this writing.
117
+
118
+ ### References
119
+
120
+ * [LaTeX](http://en.wikipedia.org/wiki/LaTeX) [http://www.latex-project.org/](http://www.latex-project.org/)
121
+
122
+ ## Samples
123
+
124
+ ## Maintainer
125
+
126
+ * Ben Wilson [http://dausha.net](http://dausha.net)
127
+
128
+ ## License
129
+
130
+ (The MIT License)
131
+
132
+ Permission is hereby granted, free of charge, to any person obtaining
133
+ a copy of this software and associated documentation files (the
134
+ 'Software'), to deal in the Software without restriction, including
135
+ without limitation the rights to use, copy, modify, merge, publish,
136
+ distribute, sublicense, and/or sell copies of the Software, and to
137
+ permit persons to whom the Software is furnished to do so, subject to
138
+ the following conditions:
139
+
140
+ The above copyright notice and this permission notice shall be
141
+ included in all copies or substantial portions of the Software.
142
+
143
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
144
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
145
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
146
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
147
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
148
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
149
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,72 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ require './lib/verku/version.rb'
16
+ Jeweler::Tasks.new do |gem|
17
+
18
+ gem.name = "verku"
19
+ gem.version = Verku::Version::STRING
20
+ gem.authors = ["Merovex"]
21
+ gem.email = ["dausha+verku@gmail.com"]
22
+ gem.homepage = "https://github.com/Merovex/verku"
23
+ gem.summary = %q{Verku is a Ruby & LaTeX based production toolchain for self-publishers.}
24
+ gem.description = %q{Verku provides authors a free, ruby-based production toolchain for self-published paper and electronic books using the LaTeX document preparation system.}
25
+
26
+ gem.rubyforge_project = "verku"
27
+
28
+ gem.files = `git ls-files`.split("\n")
29
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
30
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
31
+ gem.require_paths = ["lib"]
32
+
33
+ # https://github.com/technicalpickles/jeweler
34
+
35
+ # specify any dependencies here; for example:
36
+ gem.add_dependency "activesupport"
37
+ gem.add_development_dependency "aruba"
38
+ gem.add_development_dependency "cucumber"
39
+ gem.add_dependency "rubyzip"
40
+ gem.add_dependency "zip-zip"
41
+ gem.add_dependency "eeepub"
42
+ gem.add_dependency "kramdown"
43
+ gem.add_dependency "thor"
44
+ gem.add_dependency "nokogiri"
45
+ gem.add_dependency "notifier"
46
+ end
47
+ Jeweler::RubygemsDotOrgTasks.new
48
+
49
+ require 'rake/testtask'
50
+ Rake::TestTask.new(:test) do |test|
51
+ test.libs << 'lib' << 'test'
52
+ test.pattern = 'test/**/test_*.rb'
53
+ test.verbose = true
54
+ end
55
+
56
+ desc "Code coverage detail"
57
+ task :simplecov do
58
+ ENV['COVERAGE'] = "true"
59
+ Rake::Task['test'].execute
60
+ end
61
+
62
+ task :default => :test
63
+
64
+ require 'rdoc/task'
65
+ Rake::RDocTask.new do |rdoc|
66
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
67
+
68
+ rdoc.rdoc_dir = 'rdoc'
69
+ rdoc.title = "verku #{version}"
70
+ rdoc.rdoc_files.include('README*')
71
+ rdoc.rdoc_files.include('lib/**/*.rb')
72
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.7.0
data/bin/verku ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby -*-
3
+
4
+ require "verku"
5
+ Verku::Cli.start
data/lib/verku.rb ADDED
@@ -0,0 +1,56 @@
1
+ # require "verku/version"
2
+ require "active_support/all"
3
+ require 'fileutils'
4
+ #require "awesome_print"
5
+ require "eeepub"
6
+ require "erb"
7
+ require "logger"
8
+ require "nokogiri"
9
+ require "notifier"
10
+ require "open3"
11
+ require "optparse"
12
+ require "ostruct"
13
+ require "tempfile"
14
+ require "pathname"
15
+ require "thor"
16
+ require "thor/group"
17
+ require "yaml"
18
+ require "cgi"
19
+
20
+ module Verku
21
+
22
+ require "verku/extensions/string"
23
+ ROOT = Pathname.new(File.dirname(__FILE__) + "/..")
24
+
25
+ autoload :Cli, "verku/cli"
26
+ autoload :Dependency, "verku/dependency"
27
+ autoload :Exporter, "verku/exporter"
28
+ autoload :Generator, "verku/generator"
29
+ autoload :Markdown, "verku/adapters/markdown"
30
+ autoload :Parser, "verku/parser"
31
+ autoload :Stats, "verku/stats"
32
+ autoload :Stream, "verku/stream"
33
+ autoload :Structure, "verku/structure"
34
+ autoload :TOC, "verku/toc"
35
+ # autoload :Version, "verku/version"
36
+
37
+ Encoding.default_internal = "utf-8"
38
+ Encoding.default_external = "utf-8"
39
+
40
+ def self.config(root_dir = nil)
41
+ root_dir ||= Pathname.new(Dir.pwd)
42
+ path = root_dir.join("_verku.yml")
43
+
44
+ raise "Invalid Verku directory; couldn't found #{path} file." unless File.file?(path)
45
+ content = File.read(path)
46
+ erb = ERB.new(content).result
47
+
48
+ YAML.load(erb)#.with_indifferent_access
49
+ end
50
+ def self.logger
51
+ @logger ||= Logger.new(File.open("/tmp/verku.log", "a"))
52
+ end
53
+ def self.hi
54
+ puts "hi"
55
+ end
56
+ end