publication 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eed95b2cee49f975f37e6e251e75af511b7f1c06
4
- data.tar.gz: 92a7da07ec827a23d46ed73212cdf238951e8021
3
+ metadata.gz: 32ba88788a3092b7c375fccd9317e164b8b88033
4
+ data.tar.gz: 3d62228be86e7a4082a1e881905bf2050391054e
5
5
  SHA512:
6
- metadata.gz: 0b098c41df826bba86bf73ae3810d090ddbfebe536ee7c1549db94187d73893210d07cbf4f00c798ff277deee823b1139d4b58e1c683f784390b9c558a5696c9
7
- data.tar.gz: 3b34d9a9138e4a4077d2f4d4039dbae051ea31158c9a6799e35b94cd9ed1ddba93eb282403c7d275246ff5cd4396f34ec7712db45957fb1f852fb20a08b1d322
6
+ metadata.gz: 10cc69eda68bf5648e31871109619cf8153f4f4c7674ea1db4e2a42c91520c9c831782ff87bdfe9abca3dd50c827328dbe0aa68cfeaea64ef5f9a265e1ed8128
7
+ data.tar.gz: 65085a76d4efb748a4a7844a9f1d49c3a15f17c6d4b6179efde7673cc9c34bf088adc5a02006e5067c5db16a5be349287b6544fd72f20ce352588278f79ef057
data/bin/publication ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
3
+ require 'publication/cli'
4
+ require 'benchmark'
5
+
6
+ begin
7
+ ENV['THOR_DEBUG'] = '1'
8
+ etime = Benchmark.realtime { Publication::CLI.start(ARGV) }
9
+ $stderr.puts "Completed in #{etime}s"
10
+ rescue Thor::UndefinedCommandError, Thor::UnknownArgumentError, Thor::AmbiguousCommandError, Thor::InvocationError => e
11
+ $stderr.puts(e.message)
12
+ exit(64)
13
+ rescue Thor::Error => e
14
+ $stderr.puts(e.message)
15
+ exit(1)
16
+ end
@@ -0,0 +1,4 @@
1
+ require 'active_support/all'
2
+ require 'publication/dependencies'
3
+ require 'publication/publish'
4
+ require 'publication/rake_tasks' if defined? Rake
@@ -0,0 +1,16 @@
1
+ require 'thor'
2
+ require 'publication'
3
+
4
+ class Publication::CLI < Thor
5
+
6
+ desc 'publish', 'Create a new publication of the desired format'
7
+ method_option :output, type: :string, required: false, banner: 'OUTPUT', desc: 'Name of the output file', aliases: '-o', default: 'output'
8
+ method_option :paths, type: :string, required: false, banner: 'DIR', desc: 'Glob of source directory tree, parsed lexically and recursively', aliases: '-p', default: 'doc/**/*'
9
+ method_option :formats, type: :array, required: false, banner: 'FORMATS', desc: 'Formats to output, space separated', aliases: '-f', default: ['epub', 'epub3', 'pdf', 'html']
10
+ method_option :type, type: :string, required: false, banner: 'FORMAT', desc: 'Type (format) of input files', aliases: '-t', default: 'markdown'
11
+ #method_option :extraopts, type: :string, required: false, banner: 'EXTRA', desc: 'Extra options to pass to pandoc (advanced)', aliases: '-e' # not yet used
12
+ def publish
13
+ opts = options.deep_symbolize_keys
14
+ Publication::Publisher.new(**opts).publish
15
+ end
16
+ end
@@ -0,0 +1,60 @@
1
+ require 'mkmf'
2
+ require 'tmpdir'
3
+
4
+ PANDOC_MIN_VERSION = '1.6' # min version with epub
5
+ PANDOC_URL = 'https://github.com/jgm/pandoc/releases/download/1.17.0.2/pandoc-1.17.0.2-1-amd64.deb' # FIXME
6
+
7
+ module MakeMakefile::Logging
8
+ @logfile = File::NULL
9
+ end
10
+
11
+ module Publication
12
+ module Dependencies
13
+ extend self
14
+
15
+ def satisfied?
16
+ has_pandoc
17
+ has_latex
18
+ end
19
+
20
+ def satisfy
21
+ get_pandoc
22
+ get_latex
23
+ end
24
+
25
+ private
26
+
27
+ def has_pandoc
28
+ pandoc = find_executable 'pandoc'
29
+ unless pandoc
30
+ puts 'Pandoc is not installed'
31
+ return false
32
+ end
33
+ version = `#{pandoc} -v`.lines.first.split(/\s+/).last
34
+ unless Gem::Version.new(version) > Gem::Version.new(PANDOC_MIN_VERSION)
35
+ puts "Pandoc version #{version} too old (require #{PANDOC_MIN_VERSION})"
36
+ return false
37
+ end
38
+ true
39
+ end
40
+
41
+ def has_latex
42
+ find_executable 'pdflatex'
43
+ end
44
+
45
+ # FIXME make this conditional to different types of platforms
46
+ def get_pandoc
47
+ return if has_pandoc
48
+ Dir.mktmpdir do |dir|
49
+ Dir.chdir(dir) do
50
+ system("wget #{PANDOC_URL} -O pandoc.deb")
51
+ system("dpkg -i pandoc.deb")
52
+ end
53
+ end
54
+ end
55
+
56
+ def get_latex
57
+ system('apt-get install -y --force-yes texlive-full')
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,21 @@
1
+ require 'pandoc-ruby'
2
+
3
+ module Publication
4
+ class Publisher
5
+
6
+ def initialize(paths: nil, type: nil, output: nil, formats: [])
7
+ @paths = Dir["#{Dir.pwd}/#{paths}"]
8
+ @type = type
9
+ @output = output
10
+ @formats = formats
11
+ fail "No input files found at #{paths}" if @paths.empty?
12
+ fail "No output format specified" if @formats.empty?
13
+ end
14
+
15
+ def publish
16
+ @formats.each do |format|
17
+ PandocRuby.new(@paths, from: @type, output: "#{@output}.#{format}").convert
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ require 'rake'
2
+
3
+ module Publisher
4
+ # Loads all rake tasks when terraform_dsl is included by a rake script
5
+ module Tasks
6
+ extend self
7
+
8
+ def load_all
9
+ Dir.glob("#{File.expand_path('../../tasks', __FILE__)}/*.rake").each { |r| load r }
10
+ end
11
+ end
12
+ end
13
+
14
+ Publisher::Tasks.load_all
@@ -1,3 +1,3 @@
1
1
  module Publication
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -0,0 +1,9 @@
1
+ desc 'Assert that dependencies are installed'
2
+ task 'check_depends' do
3
+ Publication::Dependencies.satisfied?
4
+ end
5
+
6
+ desc 'Install necessary dependencies'
7
+ task 'get_depends' do
8
+ Publication::Dependencies.satisfy
9
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: publication
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dale Hamel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-24 00:00:00.000000000 Z
11
+ date: 2016-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pandoc-ruby
@@ -39,47 +39,61 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.19.1
41
41
  - !ruby/object:Gem::Dependency
42
- name: pry
42
+ name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 0.10.3
48
- type: :development
47
+ version: 10.4.2
48
+ type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 0.10.3
54
+ version: 10.4.2
55
55
  - !ruby/object:Gem::Dependency
56
- name: pry-byebug
56
+ name: activesupport
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 3.3.0
61
+ version: 4.2.5
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 4.2.5
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 0.10.3
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - '='
67
81
  - !ruby/object:Gem::Version
68
- version: 3.3.0
82
+ version: 0.10.3
69
83
  - !ruby/object:Gem::Dependency
70
- name: rake
84
+ name: pry-byebug
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - '='
74
88
  - !ruby/object:Gem::Version
75
- version: 10.4.2
89
+ version: 3.3.0
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - '='
81
95
  - !ruby/object:Gem::Version
82
- version: 10.4.2
96
+ version: 3.3.0
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: simplecov
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -110,11 +124,19 @@ dependencies:
110
124
  version: 3.2.0
111
125
  description: Use pandoc to easily publish in different formats
112
126
  email: dale.hamel@srvthe.net
113
- executables: []
127
+ executables:
128
+ - publication
114
129
  extensions: []
115
130
  extra_rdoc_files: []
116
131
  files:
132
+ - bin/publication
133
+ - lib/publication.rb
134
+ - lib/publication/cli.rb
135
+ - lib/publication/dependencies.rb
136
+ - lib/publication/publish.rb
137
+ - lib/publication/rake_tasks.rb
117
138
  - lib/publication/version.rb
139
+ - lib/tasks/publication.rake
118
140
  homepage: https://github.com/dalehamel/publication
119
141
  licenses:
120
142
  - MIT