ruby_powerpoint 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ruby_powerpoint.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 TODO: Write your name
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.rdoc ADDED
@@ -0,0 +1,49 @@
1
+ = RubyPowerpoint -- Parser for Powerpoint(pptx) files.
2
+
3
+ RubyPowerpoint is a simple Ruby gem that can extract text from Powerpont(pptx) files.
4
+
5
+
6
+ == Installation
7
+
8
+ RubyPowerpont can be used from the command line or as part of a Ruby web framework. To install the gem using terminal, run the following command:
9
+
10
+ gem install ruby_powerpoint
11
+
12
+ To use it in Rails, add this line to your Gemfile:
13
+
14
+ gem "ruby_powerpoint"
15
+
16
+
17
+ == Basic Usage
18
+ RubyPowerpoint can simply parse a PowerPoint file(pptx) by extractng text from each slide:
19
+
20
+ require 'powerpint'
21
+ deck = RubyPowerpoint::Presentation.new "specs/fixtures/sample.ppts"
22
+ slide = deck.slides[0]
23
+
24
+ puts slde.content # => ["Prsentation Header", "Presentation Notes...", "12"]
25
+
26
+
27
+ == Contributing
28
+
29
+ Contributions are welcomed. You can fork a repository, add your code changes to the forked branch, ensure all existing unit tests pass, create new unit tests cover your new changes and finally create a pull request.
30
+
31
+ After forking and then cloning the repository locally, install Bundler and then use it
32
+ to install the development gem dependecies:
33
+
34
+ gem install bundler
35
+ bundle install
36
+
37
+ Once this is complete, you should be able to run the test suite:
38
+
39
+ rake
40
+
41
+
42
+ == Bug Reporting
43
+
44
+ Please use the {Issues}[https://github.com/pythonicrubyist/ruby_powerpoint/issues] page to report bugs or suggest new enhancements.
45
+
46
+
47
+ == License
48
+
49
+ RubyPowerpoint has been published under {MIT License}[https://github.com/pythonicrubyist/ruby_powerpoint/blob/master/LICENSE.txt]
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new('spec')
5
+
6
+ # If you want to make this the default task
7
+ task :default => :spec
@@ -0,0 +1,8 @@
1
+ require "ruby_powerpoint/version"
2
+ require 'ruby_powerpoint/presentation'
3
+ require 'ruby_powerpoint/slide'
4
+
5
+
6
+ module RubyPowerpoint
7
+ # Your code goes here...
8
+ end
@@ -0,0 +1,29 @@
1
+ require 'zip/zipfilesystem'
2
+ require 'nokogiri'
3
+
4
+ module RubyPowerpoint
5
+
6
+ class RubyPowerpoint::Presentation
7
+
8
+ attr_reader :files
9
+
10
+ def initialize path
11
+ raise 'Not a valid file format.' unless (['.pptx'].include? File.extname(path).downcase)
12
+ @files = Zip::ZipFile.open path
13
+ end
14
+
15
+ def slides
16
+ slides = Array.new
17
+ @files.each_with_index do |doc, i|
18
+ if doc.name.include? 'ppt/slides/slide'
19
+ slides.push RubyPowerpoint::Slide.new(self, doc.name, i)
20
+ end
21
+ end
22
+ slides
23
+ end
24
+
25
+ def close
26
+ @files.close
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,27 @@
1
+ require 'zip/zipfilesystem'
2
+ require 'nokogiri'
3
+
4
+ module RubyPowerpoint
5
+ class RubyPowerpoint::Slide
6
+
7
+ attr_reader :presentation,
8
+ :path,
9
+ :ndex
10
+
11
+ def initialize presentation, path, index
12
+ @presentation = presentation
13
+ @path = path
14
+ @index = index
15
+ end
16
+
17
+ def content
18
+ content = Array.new
19
+ doc = @presentation.files.file.open @path
20
+ xml = Nokogiri::XML::Document.parse doc
21
+ xml.xpath('//a:t').each do |node|
22
+ content.push node.text
23
+ end
24
+ content
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ module RubyPowerpoint
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ruby_powerpoint/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ruby_powerpoint"
8
+ spec.version = RubyPowerpoint::VERSION
9
+ spec.authors = ["pythonicrubyist"]
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{A Ruby gem for Parsng text from PowerPoint(pptx) files.}
13
+ spec.homepage = "https://github.com/pythonicrubyist/ruby_powerpoint"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.required_ruby_version = '>= 1.9.2'
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency 'rspec', '~> 2.13.0'
26
+
27
+ spec.add_dependency 'nokogiri', '~> 1.6.0'
28
+ spec.add_dependency 'rubyzip', '~> 0.9.9'
29
+ end
@@ -0,0 +1 @@
1
+ ,ramtin,ramtin-VirtualBox,26.06.2013 14:02,file:///home/ramtin/.config/libreoffice/3;
File without changes
Binary file
data/spec/test_spec.rb ADDED
@@ -0,0 +1,24 @@
1
+ require 'ruby_powerpoint'
2
+
3
+ describe 'RubyPowerpoint trying to parsing an invalid file.' do
4
+ it 'not open an XLS file successfully.' do
5
+ lambda { RubyPowerpoint::Presentation.new 'specs/fixtures/invalid.xls' }.should raise_error 'Not a valid file format.'
6
+ end
7
+ end
8
+
9
+ describe 'RubyPowerpoint parsing a sample PPTX file' do
10
+ before(:all) do
11
+ @deck = RubyPowerpoint::Presentation.new 'spec/fixtures/sample.pptx'
12
+ end
13
+
14
+ after(:all) do
15
+ @deck.close
16
+ end
17
+
18
+ it 'open a PPTX file successfully.' do
19
+ @deck.should_not be_nil
20
+ @deck.slides.should_not eql []
21
+ @deck.slides.first.content.should eql ["Some header here", "Some content here."]
22
+ @deck.slides.last.content.should eql ["WTF?", "What the hell s gong on?", "1234", "asdf", "34", "6"]
23
+ end
24
+ end
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby_powerpoint
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - pythonicrubyist
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-06-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 2.13.0
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.13.0
62
+ - !ruby/object:Gem::Dependency
63
+ name: nokogiri
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 1.6.0
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.6.0
78
+ - !ruby/object:Gem::Dependency
79
+ name: rubyzip
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 0.9.9
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 0.9.9
94
+ description: A Ruby gem that can extract text from PowerPoint(pptx) files.
95
+ email:
96
+ - pythonicrubyist@gmail.com
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files: []
100
+ files:
101
+ - .gitignore
102
+ - Gemfile
103
+ - LICENSE.txt
104
+ - README.rdoc
105
+ - Rakefile
106
+ - lib/ruby_powerpoint.rb
107
+ - lib/ruby_powerpoint/presentation.rb
108
+ - lib/ruby_powerpoint/slide.rb
109
+ - lib/ruby_powerpoint/version.rb
110
+ - ruby_powerpoint.gemspec
111
+ - spec/fixtures/.~lock.sample.pptx#
112
+ - spec/fixtures/invalid.xls
113
+ - spec/fixtures/sample.pptx
114
+ - spec/test_spec.rb
115
+ homepage: https://github.com/pythonicrubyist/ruby_powerpoint
116
+ licenses:
117
+ - MIT
118
+ post_install_message:
119
+ rdoc_options: []
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: 1.9.2
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ requirements: []
135
+ rubyforge_project:
136
+ rubygems_version: 1.8.25
137
+ signing_key:
138
+ specification_version: 3
139
+ summary: A Ruby gem for Parsng text from PowerPoint(pptx) files.
140
+ test_files:
141
+ - spec/fixtures/.~lock.sample.pptx#
142
+ - spec/fixtures/invalid.xls
143
+ - spec/fixtures/sample.pptx
144
+ - spec/test_spec.rb