pptxt 0.1.0 → 0.1.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 +4 -4
- data/bin/pptxt +20 -12
- data/lib/pptxt/error.rb +2 -0
- data/lib/pptxt/missing_dependency.rb +7 -0
- data/lib/{pptxt_slide.rb → pptxt/slide.rb} +8 -5
- data/lib/pptxt/unknown_xml.rb +7 -0
- data/lib/pptxt.rb +12 -7
- metadata +8 -7
- data/lib/pptxt_error.rb +0 -16
- data/lib/pptxt_exit_status.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0acefbb422ba5b2b9bc4c0aeac6e5fa00ec53a66
|
4
|
+
data.tar.gz: 833dcfaa4f1899be33af1eb5b39b3cbe6de64eaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6911494c23daca9c3643a9848c4512149ea50462d3dc570e33029f329d239fae7dc0703010610c4d42a36c66324117e74829dca64b024683c6c07566fe80c34a
|
7
|
+
data.tar.gz: d23b98bb4331f8c086cfb3e9b153f4b41505da3491be7ef87cf3c1ec24094d53aef6e61a7154b7b0dbabe10d9af5cd02c8b726098aea273a58414ea774ff56c7
|
data/bin/pptxt
CHANGED
@@ -4,8 +4,16 @@ require "io/wait"
|
|
4
4
|
require "optparse"
|
5
5
|
require "pathname"
|
6
6
|
require "pptxt"
|
7
|
-
|
8
|
-
|
7
|
+
|
8
|
+
class PPtxtExit
|
9
|
+
GOOD = 0
|
10
|
+
INVALID_OPTION = 1
|
11
|
+
INVALID_ARGUMENT = 2
|
12
|
+
MISSING_ARGUMENT = 3
|
13
|
+
EXTRA_ARGUMENTS = 4
|
14
|
+
FILE_DOES_NOT_EXIST = 5
|
15
|
+
MISSING_UTILITY = 6
|
16
|
+
end
|
9
17
|
|
10
18
|
def parse(args)
|
11
19
|
options = Hash.new
|
@@ -23,7 +31,7 @@ def parse(args)
|
|
23
31
|
"Configure git repo to use pptxt"
|
24
32
|
) do
|
25
33
|
PPtxt.configure_git
|
26
|
-
exit
|
34
|
+
exit PPtxtExit::GOOD
|
27
35
|
end
|
28
36
|
|
29
37
|
opts.on("-d", "--detailed", "Display full xml") do
|
@@ -40,12 +48,12 @@ def parse(args)
|
|
40
48
|
"Configure git to use pptxt globally"
|
41
49
|
) do
|
42
50
|
PPtxt.configure_git(true)
|
43
|
-
exit
|
51
|
+
exit PPtxtExit::GOOD
|
44
52
|
end
|
45
53
|
|
46
54
|
opts.on("-h", "--help", "Display this help message") do
|
47
55
|
puts opts
|
48
|
-
exit
|
56
|
+
exit PPtxtExit::GOOD
|
49
57
|
end
|
50
58
|
|
51
59
|
opts.on("-s", "--slideshow", "Display as slideshow") do
|
@@ -58,33 +66,33 @@ def parse(args)
|
|
58
66
|
rescue OptionParser::InvalidOption => e
|
59
67
|
puts e.message
|
60
68
|
puts parser
|
61
|
-
exit
|
69
|
+
exit PPtxtExit::INVALID_OPTION
|
62
70
|
rescue OptionParser::InvalidArgument => e
|
63
71
|
puts e.message
|
64
72
|
puts parser
|
65
|
-
exit
|
73
|
+
exit PPtxtExit::INVALID_ARGUMENT
|
66
74
|
rescue OptionParser::MissingArgument => e
|
67
75
|
puts e.message
|
68
76
|
puts parser
|
69
|
-
exit
|
77
|
+
exit PPtxtExit::MISSING_ARGUMENT
|
70
78
|
end
|
71
79
|
|
72
80
|
if (args.empty?)
|
73
81
|
puts parser
|
74
|
-
exit
|
82
|
+
exit PPtxtExit::MISSING_ARGUMENT
|
75
83
|
elsif (args.length > 1)
|
76
84
|
puts parser
|
77
|
-
exit
|
85
|
+
exit PPtxtExit::EXTRA_ARGUMENTS
|
78
86
|
end
|
79
87
|
|
80
88
|
if (!Pathname.new(args[0]).expand_path.exist?)
|
81
89
|
puts "#{args[0]} does not exist!"
|
82
|
-
exit
|
90
|
+
exit PPtxtExit::FILE_DOES_NOT_EXIST
|
83
91
|
end
|
84
92
|
|
85
93
|
options["pptx"] = args[0].strip
|
86
94
|
if (options["pptx"] == "/dev/null")
|
87
|
-
exit
|
95
|
+
exit PPtxtExit::GOOD
|
88
96
|
end
|
89
97
|
|
90
98
|
return options
|
data/lib/pptxt/error.rb
ADDED
@@ -1,4 +1,4 @@
|
|
1
|
-
class PPtxtSlide
|
1
|
+
class PPtxt::PPtxtSlide
|
2
2
|
def detailed
|
3
3
|
ret = Array.new
|
4
4
|
num_indents = 0
|
@@ -23,7 +23,7 @@ class PPtxtSlide
|
|
23
23
|
indents = Array.new(num_indents, " ").join
|
24
24
|
ret.push("#{indents}#{line}")
|
25
25
|
else
|
26
|
-
raise
|
26
|
+
raise PPtxt::UnknownXML.new(line)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -40,11 +40,12 @@ class PPtxtSlide
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def handle_format(str, format, lvl, list_index)
|
43
|
+
filler = Array.new(lvl, " ").join
|
43
44
|
case format
|
44
45
|
when "bullet"
|
45
|
-
return "#{
|
46
|
+
return "#{filler}- #{str}"
|
46
47
|
when "number"
|
47
|
-
return "#{
|
48
|
+
return "#{filler}#{list_index}. #{str}"
|
48
49
|
else
|
49
50
|
return str
|
50
51
|
end
|
@@ -103,7 +104,9 @@ class PPtxtSlide
|
|
103
104
|
@title += " " if (!first_time && was_newline)
|
104
105
|
@title += line[5..-1]
|
105
106
|
elsif (in_subtitle)
|
106
|
-
|
107
|
+
if (!first_time && was_newline)
|
108
|
+
@subtitle += " "
|
109
|
+
end
|
107
110
|
@subtitle += line[5..-1]
|
108
111
|
elsif(ignore)
|
109
112
|
break
|
data/lib/pptxt.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require "pptxt_error"
|
2
|
-
require "pptxt_slide"
|
3
1
|
require "scoobydoo"
|
4
2
|
|
5
3
|
class PPtxt
|
@@ -7,7 +5,7 @@ class PPtxt
|
|
7
5
|
|
8
6
|
def self.configure_git(global = false)
|
9
7
|
if (ScoobyDoo.where_are_you("git").nil?)
|
10
|
-
raise
|
8
|
+
raise PPtxt::MissingDependency.new("git")
|
11
9
|
end
|
12
10
|
|
13
11
|
# Configure git
|
@@ -50,13 +48,15 @@ class PPtxt
|
|
50
48
|
|
51
49
|
def create_slides
|
52
50
|
slides = %x(
|
53
|
-
|
54
|
-
|
51
|
+
unzip -l "#{@pptx}" | \grep -E "ppt/slides/[^_]" |
|
52
|
+
awk '{print $4}' | sort -k 1.17n
|
55
53
|
).split("\n")
|
56
54
|
|
57
55
|
count = 0
|
58
56
|
slides.each do |slide|
|
59
|
-
xml = %x(
|
57
|
+
xml = %x(
|
58
|
+
unzip -qc "#{@pptx}" #{slide}).gsub("<", "\n<"
|
59
|
+
)
|
60
60
|
count += 1
|
61
61
|
@slides.push(PPtxtSlide.new(xml, count))
|
62
62
|
end
|
@@ -68,9 +68,14 @@ class PPtxt
|
|
68
68
|
@slides = Array.new
|
69
69
|
|
70
70
|
if (ScoobyDoo.where_are_you("unzip").nil?)
|
71
|
-
raise
|
71
|
+
raise PPtxt::MissingDependency.new("unzip")
|
72
72
|
end
|
73
73
|
|
74
74
|
create_slides
|
75
75
|
end
|
76
76
|
end
|
77
|
+
|
78
|
+
require "pptxt/error"
|
79
|
+
require "pptxt/missing_dependency"
|
80
|
+
require "pptxt/slide"
|
81
|
+
require "pptxt/unknown_xml"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pptxt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Whittaker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
version: '0.1'
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 0.1.
|
42
|
+
version: 0.1.1
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
version: '0.1'
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: 0.1.
|
52
|
+
version: 0.1.1
|
53
53
|
description: This gem can extract the xml info from a pptx and convert to human-readable
|
54
54
|
text. It was intended to be used with git for seeing changes between revisions.
|
55
55
|
email: mjwhitta@gmail.com
|
@@ -60,9 +60,10 @@ extra_rdoc_files: []
|
|
60
60
|
files:
|
61
61
|
- bin/pptxt
|
62
62
|
- lib/pptxt.rb
|
63
|
-
- lib/
|
64
|
-
- lib/
|
65
|
-
- lib/
|
63
|
+
- lib/pptxt/error.rb
|
64
|
+
- lib/pptxt/missing_dependency.rb
|
65
|
+
- lib/pptxt/slide.rb
|
66
|
+
- lib/pptxt/unknown_xml.rb
|
66
67
|
homepage: http://mjwhitta.github.io/pptxt
|
67
68
|
licenses:
|
68
69
|
- GPL-3.0
|
data/lib/pptxt_error.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
module PPtxtError
|
2
|
-
class Error < RuntimeError
|
3
|
-
end
|
4
|
-
|
5
|
-
class MissingDependency < Error
|
6
|
-
def initialize(tool)
|
7
|
-
super("Missing dependency: #{tool}")
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
class UnknownXML < Error
|
12
|
-
def initialize(line)
|
13
|
-
super("Unknown line in xml: #{line}")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|