ruby_powerpoint 1.2 → 1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/README.rdoc +7 -4
- data/lib/ruby_powerpoint/slide.rb +3 -3
- data/lib/ruby_powerpoint/version.rb +1 -1
- data/ruby_powerpoint.gemspec +2 -2
- data/spec/test_spec.rb +6 -3
- metadata +19 -18
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NjY3OTA1NDc2ZDc3NjY3ZDZkZjM3NzAzZmM2ZDk2NDU2MTQxMDM4Zg==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 53a44c25294ef3900612c27b24f1a8b2a91cf1f8
|
4
|
+
data.tar.gz: 0a0fb51b00a702e6b3ac5053961e96008133fef7
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
M2M5MTBmMGEzOTMwNzY2Y2UyMWYwMTBlMDc5NTQ4MzU4NjM2ZWNjMWVhODMz
|
11
|
-
MjY3YzdhMzgwMDBkYzE1YTIwM2I5NDM0MTNhMWQwOTczYTcwOTI=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NTAxNWNlZGU3ODAyNDE3ZmIwMWZjYzgzYmYyNDAxMjYwMTM5NzFlNzFkYjc1
|
14
|
-
ZmY0ZGZiNmU5NjE5MDFjYjJkNTM5MzQ5MmE5N2Q4OWI1NWY3NDcxZmQzMDI1
|
15
|
-
NWZlYjg3NmVlZjc3ZmQ5MWZkYzc1NmRiZmY3MTc3NzlhYTA4Y2E=
|
6
|
+
metadata.gz: 48cc641f200a6bfbaeab7e2b241faec19758c7afdda98f64ce90eb805d8bd74fe4d953482de74ff9ce5c921f15544d7b04612759e229fde2a953ec241e6e96b8
|
7
|
+
data.tar.gz: 34a7a2dd49ff9cd49ae1d4cb117d0ab73a31c6fc8670fe144a889c74ab527f6a2770b42086763fdd43c359968c1b4f4ca9dd391028401a797ac68a7d7b9a4e4f
|
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= RubyPowerpoint -- Parser for Powerpoint(pptx) files.
|
2
2
|
|
3
|
-
|
3
|
+
ruby_powerpoint is a Ruby gem that can extract title, content and images from Powerpont(pptx) slides.
|
4
4
|
|
5
5
|
|
6
6
|
== Installation
|
@@ -15,15 +15,18 @@ To use it in Rails, add this line to your Gemfile:
|
|
15
15
|
|
16
16
|
|
17
17
|
== Basic Usage
|
18
|
-
RubyPowerpoint can
|
18
|
+
RubyPowerpoint can parse a PowerPoint file(pptx) by extractng text and images from each slide:
|
19
19
|
|
20
20
|
require 'ruby_powerpoint'
|
21
21
|
|
22
22
|
deck = RubyPowerpoint::Presentation.new "specs/fixtures/sample.pptx"
|
23
23
|
|
24
24
|
deck.slides.each do |slide|
|
25
|
-
|
26
|
-
|
25
|
+
slide.content # => ["Presentation Notes...", "12345"]
|
26
|
+
slide.title # => "Prsentation Header"
|
27
|
+
slide.images # => ["\xE3=\xA8h\x8E\x17\...."] Byte Stream
|
28
|
+
# Saving the image byte stream to a file:
|
29
|
+
File.open('temp.jpg', 'w'){|f| f.puts slide.images[0]}
|
27
30
|
end
|
28
31
|
|
29
32
|
|
@@ -59,7 +59,7 @@ module RubyPowerpoint
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def title_elements(xml)
|
62
|
-
shape_elements(xml).select{|shape| element_is_title(shape)}
|
62
|
+
shape_elements(xml).select{ |shape| element_is_title(shape) }
|
63
63
|
end
|
64
64
|
|
65
65
|
def content_elements(xml)
|
@@ -67,7 +67,7 @@ module RubyPowerpoint
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def image_elements(xml)
|
70
|
-
xml.css('Relationship').select{ |node| element_is_image(node)}
|
70
|
+
xml.css('Relationship').select{ |node| element_is_image(node) }
|
71
71
|
end
|
72
72
|
|
73
73
|
def shape_elements(xml)
|
@@ -75,7 +75,7 @@ module RubyPowerpoint
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def element_is_title(shape)
|
78
|
-
shape.xpath('.//p:nvSpPr/p:nvPr/p:ph').select{|prop| prop['type'] == 'title' || prop['type'] == 'ctrTitle'}.length > 0
|
78
|
+
shape.xpath('.//p:nvSpPr/p:nvPr/p:ph').select{ |prop| prop['type'] == 'title' || prop['type'] == 'ctrTitle' }.length > 0
|
79
79
|
end
|
80
80
|
|
81
81
|
def element_is_image(node)
|
data/ruby_powerpoint.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = RubyPowerpoint::VERSION
|
9
9
|
spec.authors = ["pythonicrubyist"]
|
10
10
|
spec.email = ["pythonicrubyist@gmail.com"]
|
11
|
-
spec.description = %q{A Ruby gem that can extract text from PowerPoint(pptx) files.}
|
12
|
-
spec.summary = %q{
|
11
|
+
spec.description = %q{A Ruby gem that can extract text and images from PowerPoint (pptx) files.}
|
12
|
+
spec.summary = %q{ruby_powerpoint is a Ruby gem that can extract title, content and images from Powerpont (pptx) slides.}
|
13
13
|
spec.homepage = "https://github.com/pythonicrubyist/ruby_powerpoint"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
data/spec/test_spec.rb
CHANGED
@@ -15,14 +15,19 @@ describe 'RubyPowerpoint parsing a sample PPTX file' do
|
|
15
15
|
@deck.close
|
16
16
|
end
|
17
17
|
|
18
|
-
it '
|
18
|
+
it 'parse a PPTX file successfully.' do
|
19
19
|
@deck.should_not be_nil
|
20
20
|
@deck.slides.should_not eql []
|
21
21
|
@deck.slides.first.content.should eql ["Some test ", "Powerpoint"]
|
22
22
|
@deck.slides.first.content.should eql ["Some test ", "Powerpoint"]
|
23
|
+
image_byte_stream_1 = @deck.slides.first.images.first.read
|
24
|
+
File.open('temp_1.jpg', 'w'){|f| f.puts image_byte_stream_1}
|
25
|
+
|
23
26
|
@deck.slides.first.images.first.should_not eql nil #"ppt/media/image1.jpeg"
|
24
27
|
@deck.slides.last.title.should eql "Some title here"
|
25
28
|
@deck.slides.last.content.should eql ["Some title here", "Some txt here", "Some ", "more text here."]
|
29
|
+
image_byte_stream_2 = @deck.slides.last.images.first.read
|
30
|
+
File.open('temp_2.jpg', 'w'){|f| f.puts image_byte_stream_2}
|
26
31
|
end
|
27
32
|
end
|
28
33
|
|
@@ -68,6 +73,4 @@ describe 'open rime.pptx file' do
|
|
68
73
|
@deck.slides[7].title.should eql "What if we have two"
|
69
74
|
end
|
70
75
|
end
|
71
|
-
|
72
|
-
|
73
76
|
end
|
metadata
CHANGED
@@ -1,93 +1,93 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_powerpoint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.4'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pythonicrubyist
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 2.13.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 2.13.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: nokogiri
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 1.6.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.6.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rubyzip
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 0.9.9
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.9.9
|
83
|
-
description: A Ruby gem that can extract text from PowerPoint(pptx) files.
|
83
|
+
description: A Ruby gem that can extract text and images from PowerPoint (pptx) files.
|
84
84
|
email:
|
85
85
|
- pythonicrubyist@gmail.com
|
86
86
|
executables: []
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
|
-
- .gitignore
|
90
|
+
- ".gitignore"
|
91
91
|
- Gemfile
|
92
92
|
- LICENSE.txt
|
93
93
|
- README.rdoc
|
@@ -111,20 +111,21 @@ require_paths:
|
|
111
111
|
- lib
|
112
112
|
required_ruby_version: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
|
-
- -
|
114
|
+
- - ">="
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: 1.9.2
|
117
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
118
|
requirements:
|
119
|
-
- -
|
119
|
+
- - ">="
|
120
120
|
- !ruby/object:Gem::Version
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
123
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.2.
|
124
|
+
rubygems_version: 2.2.2
|
125
125
|
signing_key:
|
126
126
|
specification_version: 4
|
127
|
-
summary:
|
127
|
+
summary: ruby_powerpoint is a Ruby gem that can extract title, content and images
|
128
|
+
from Powerpont (pptx) slides.
|
128
129
|
test_files:
|
129
130
|
- spec/fixtures/invalid.xls
|
130
131
|
- spec/fixtures/rime.pptx
|