pressman 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .idea
19
+ *.iml
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pressman.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Michaël Rigart
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Pressman
2
+
3
+ Pressman is an experimental, multi-format e-book generator. It takes textile files and converts them to multiple e-book formats.
4
+
5
+ Pressman is still experimental and I wouldn't advice anyone on using it in a production environment! It's all hacked together
6
+ for a little proof of concept.
7
+
8
+ ## Installation
9
+
10
+ Install it yourself as:
11
+
12
+ $ gem install pressman
13
+
14
+ For the PDF generation, pressman relies on pdfkit, which relies on wkhtmltopdf. So don't forget to install it as well.
15
+
16
+ $ brew install wkhtmltopdf
17
+
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/bin/pressman ADDED
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
3
+
4
+ require 'pressman'
5
+
6
+ ARGV << '--help' if ARGV.empty?
7
+
8
+ aliases = {
9
+ "n" => "new",
10
+ "b" => "build"
11
+ }
12
+
13
+ command = ARGV.shift
14
+ command = aliases[command] || command
15
+
16
+ case command
17
+ when 'new'
18
+ Pressman::Generator::App.start
19
+ when 'build'
20
+ Pressman::Builders::Builder.start
21
+ else
22
+ puts "Error: Command not recognized" unless %w(-h --help).include?(command)
23
+ puts <<-EOT
24
+ Usage: pressman COMMAND [ARGS]
25
+
26
+ The most common pressman commands are:
27
+ new Create a new pressman project. "pressman new name_of_book" creates a
28
+ new book project called NameOfBook in "./name_of_book"
29
+ build Builds a new book from your textile based upon arguments passed (short-cut alias: "b")
30
+
31
+
32
+ All commands can be run with -h for more information.
33
+ EOT
34
+ end
35
+
data/lib/pressman.rb ADDED
@@ -0,0 +1,19 @@
1
+ require 'thor'
2
+ require 'thor/group'
3
+
4
+ require 'yaml'
5
+ require 'erb'
6
+ require 'RedCloth'
7
+ require 'pdfkit'
8
+
9
+ require 'pressman/version'
10
+ require 'pressman/generator/app'
11
+
12
+ require 'pressman/builders/builder'
13
+ require 'pressman/builders/html_builder'
14
+ require 'pressman/builders/latex_builder'
15
+ require 'pressman/builders/pdf_builder'
16
+
17
+ module Pressman
18
+ # Your code goes here...
19
+ end
@@ -0,0 +1,31 @@
1
+ module Pressman
2
+ module Builders
3
+
4
+ class Builder
5
+ attr_accessor :filename
6
+
7
+ def self.start
8
+ @@config = YAML.load_file "book.yml"
9
+
10
+ Pressman::Builders::HtmlBuilder.new if ARGV.empty? || ARGV.include?("html")
11
+ Pressman::Builders::LatexBuilder.new if ARGV.empty? || ARGV.include?("tex")
12
+ Pressman::Builders::PdfBuilder.new if ARGV.empty? || ARGV.include?("pdf")
13
+ end
14
+
15
+
16
+ private
17
+
18
+ def render(path)
19
+ t = ERB.new(File.read(path))
20
+ t.result(binding)
21
+ end
22
+
23
+ def display
24
+ file = File.exists?("templates/#{@filename}.#{extension}.erb")? "templates/#{@filename}.#{extension}.erb" : "templates/default.#{extension}.erb"
25
+
26
+ render(file)
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,51 @@
1
+ module Pressman
2
+ module Builders
3
+ class HtmlBuilder < Builder
4
+
5
+ def initialize
6
+ Dir.mkdir(extension) unless File.exists?(extension)
7
+
8
+ copy_assets
9
+
10
+ Dir.glob("book/*.textile") do |file|
11
+ @filename = File.basename(file, ".textile")
12
+ File.open("#{extension}/#{@filename}.html", 'w') {|f| f.write(render("templates/layout.html.erb")) }
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ def copy_assets
19
+ # CSS
20
+ src = "templates/assets/stylesheets/stylesheet.#{extension}.css"
21
+ if File.exists?(src)
22
+ dst = "html/assets/stylesheets/stylesheet.#{extension}.css"
23
+ FileUtils.mkdir_p(File.dirname(dst))
24
+ FileUtils.cp src, dst
25
+ end
26
+
27
+ # JS
28
+ src = "templates/assets/javascripts/javascript.#{extension}.js"
29
+ if File.exists?(src)
30
+ dst = "html/assets/javascripts/javascript.#{extension}.css"
31
+ FileUtils.mkdir_p(File.dirname(dst))
32
+ FileUtils.cp_r src, dst
33
+ end
34
+
35
+ # Images
36
+ src = "templates/assets/images"
37
+ if File.exists?(src)
38
+ dst = "html/assets/images"
39
+ FileUtils.mkdir_p(dst)
40
+ FileUtils.cp_r(src, dst)
41
+ end
42
+ end
43
+
44
+ def content
45
+ RedCloth.new(File.read("book/#{@filename}.textile")).to_html
46
+ end
47
+
48
+ def extension; "html" end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,23 @@
1
+ module Pressman
2
+ module Builders
3
+ class LatexBuilder < Builder
4
+
5
+ def initialize
6
+ File.delete("#{@@config['title']}.tex") if File.exist?("#{@@config['title']}.tex")
7
+ Dir.glob("*/*.textile") do |file|
8
+ @filename = File.basename(file, ".textile")
9
+ File.open("#{@@config['title']}.tex", 'a') {|f| f.write(render("templates/layout.#{extension}.erb")) }
10
+ end
11
+ end
12
+
13
+
14
+ private
15
+
16
+ def content
17
+ RedCloth.new(File.read("book/#{@filename}.textile")).to_latex
18
+ end
19
+
20
+ def extension; "tex" end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,39 @@
1
+ module Pressman
2
+ module Builders
3
+ class PdfBuilder < Builder
4
+
5
+ attr_accessor :pdf_content
6
+
7
+ def initialize
8
+ File.delete("#{@@config['title']}.pdf") if File.exist?("#{@@config['title']}.pdf")
9
+
10
+
11
+ @pdf_content = ""
12
+ Dir.glob("*/*.textile") do |file|
13
+ @filename = File.basename(file, ".textile")
14
+
15
+ content
16
+
17
+ @pdf_content += render("templates/default.#{extension}.erb")
18
+ end
19
+
20
+ pdf = PDFKit.new(render("templates/layout.#{extension}.erb"))
21
+ pdf.to_file("#{@@config['title']}.pdf")
22
+ end
23
+
24
+
25
+ private
26
+
27
+ def content
28
+ RedCloth.new(File.read("book/#{@filename}.textile")).to_html
29
+ end
30
+
31
+ def css
32
+ File.read("templates/assets/stylesheets/stylesheet.pdf.css")
33
+ end
34
+
35
+ def extension; "pdf" end
36
+
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,20 @@
1
+ module Pressman
2
+ module Generator
3
+ class App < Thor::Group
4
+ include Thor::Actions
5
+
6
+ desc "Generates a new book"
7
+
8
+ argument :app_name
9
+
10
+ def self.source_root
11
+ File.dirname(__FILE__)
12
+ end
13
+
14
+ def create_base_project
15
+ raise GeneratorArgumentsError if app_name.nil?
16
+ directory "app", "#{app_name}"
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,7 @@
1
+ title: <YOUR BOOKNAME>
2
+ subtitle: <YOUR SUBTITLE>
3
+ isbn: <YOUR ISBN>
4
+ author: <YOUR NAME>
5
+ publisher: <YOUR PUBLISHER>
6
+ language: <BOOK LANGUAGE>
7
+ publish_date: <PUBLISHING DATE>
@@ -0,0 +1,3 @@
1
+ body {
2
+ font: italic bold 12px/30px Georgia, serif;
3
+ }
@@ -0,0 +1 @@
1
+ <%= content %>
@@ -0,0 +1 @@
1
+ <%= content %>
@@ -0,0 +1 @@
1
+ <%= content %>
@@ -0,0 +1,25 @@
1
+ <!doctype html>
2
+ <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
3
+ <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
4
+ <!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
5
+ <!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
6
+ <head>
7
+ <meta charset="utf-8">
8
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
9
+
10
+ <title></title>
11
+ <meta name="author" content="">
12
+ <meta name="description" content="">
13
+
14
+ <meta name="viewport" content="width=device-width">
15
+ <link rel="stylesheet" href="assets/stylesheets/stylesheet.html.css">
16
+ </head>
17
+ <body>
18
+ <%= display %>
19
+
20
+ <footer>
21
+ <p>&copy;</p>
22
+ </footer>
23
+ </body>
24
+ </html>
25
+
@@ -0,0 +1,22 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
6
+
7
+ <title></title>
8
+
9
+ <meta name="viewport" content="width=device-width">
10
+ <style>
11
+ <%= css %>
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <%= display %>
16
+
17
+ <footer>
18
+ <p>&copy;</p>
19
+ </footer>
20
+ </body>
21
+ </html>
22
+
@@ -0,0 +1 @@
1
+ <%= display %>
@@ -0,0 +1,3 @@
1
+ module Pressman
2
+ VERSION = "0.0.1"
3
+ end
data/pressman.gemspec ADDED
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/pressman/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Michaël Rigart"]
6
+ gem.email = ["michael@netronix.be"]
7
+ gem.description = %q{Pressman is an experimental, multi-format e-book generator.}
8
+ gem.summary = %q{Pressman is an experimental, multi-format e-book generator.}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "pressman"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Pressman::VERSION
17
+
18
+ gem.add_dependency "thor"
19
+ gem.add_dependency "RedCloth"
20
+ gem.add_dependency "pdfkit"
21
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pressman
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Michaël Rigart
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: &70202890131240 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70202890131240
25
+ - !ruby/object:Gem::Dependency
26
+ name: RedCloth
27
+ requirement: &70202890130800 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70202890130800
36
+ - !ruby/object:Gem::Dependency
37
+ name: pdfkit
38
+ requirement: &70202890130120 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70202890130120
47
+ description: Pressman is an experimental, multi-format e-book generator.
48
+ email:
49
+ - michael@netronix.be
50
+ executables:
51
+ - pressman
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - .gitignore
56
+ - Gemfile
57
+ - LICENSE
58
+ - README.md
59
+ - Rakefile
60
+ - bin/pressman
61
+ - lib/pressman.rb
62
+ - lib/pressman/builders/builder.rb
63
+ - lib/pressman/builders/html_builder.rb
64
+ - lib/pressman/builders/latex_builder.rb
65
+ - lib/pressman/builders/pdf_builder.rb
66
+ - lib/pressman/generator/app.rb
67
+ - lib/pressman/generator/app/book.yml
68
+ - lib/pressman/generator/app/book/index.textile
69
+ - lib/pressman/generator/app/templates/assets/images/.gitkeep
70
+ - lib/pressman/generator/app/templates/assets/javascripts/.gitkeep
71
+ - lib/pressman/generator/app/templates/assets/stylesheets/.gitkeep
72
+ - lib/pressman/generator/app/templates/assets/stylesheets/stylesheet.html.css
73
+ - lib/pressman/generator/app/templates/assets/stylesheets/stylesheet.pdf.css
74
+ - lib/pressman/generator/app/templates/default.html.erb
75
+ - lib/pressman/generator/app/templates/default.pdf.erb
76
+ - lib/pressman/generator/app/templates/default.tex.erb
77
+ - lib/pressman/generator/app/templates/layout.html.erb
78
+ - lib/pressman/generator/app/templates/layout.pdf.erb
79
+ - lib/pressman/generator/app/templates/layout.tex.erb
80
+ - lib/pressman/version.rb
81
+ - pressman.gemspec
82
+ homepage: ''
83
+ licenses: []
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubyforge_project:
102
+ rubygems_version: 1.8.11
103
+ signing_key:
104
+ specification_version: 3
105
+ summary: Pressman is an experimental, multi-format e-book generator.
106
+ test_files: []