ballmer 0.0.1 → 1.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.
- checksums.yaml +4 -4
- data/README.md +25 -15
- data/lib/ballmer.rb +5 -0
- data/lib/ballmer/presentation/slides.rb +10 -1
- data/lib/ballmer/version.rb +1 -1
- data/spec/lib/ballmer/presentation_spec.rb +4 -0
- data/spec/lib/ballmer_spec.rb +9 -0
- metadata +25 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee1efee77928b527001187d49afd66daa1b4e171
|
4
|
+
data.tar.gz: 8599a605f1333712b023a80d27f63c34cea2f986
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a82783df915fa6271d4339009ec28cc8bb44cd54e16b9356bb4c46e29d3009d7cfc0c0a940c7806f418ef85f16238f8871c2d08b2144a8ed636c698f7c2979cc
|
7
|
+
data.tar.gz: 7bb1ed8fc4e263bb076fe9824cdb78ef695a7ed634879e14cfaa7750da1fe88a40e38774b3c47340de478c972f4070b8dd491e3e61f143ec3ceb8b136ede4d48
|
data/README.md
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
# Ballmer
|
2
2
|
|
3
|
-
[](https://travis-ci.org/polleverywhere/ballmer)
|
3
|
+
[](https://travis-ci.org/polleverywhere/ballmer) [](https://codeclimate.com/repos/52ce169f6956805d89000475/feed)
|
4
4
|
|
5
5
|
The Ballmer gem provides the basis for modifying Office documents in Ruby. It provides access to low-level primitives including:
|
6
6
|
|
7
|
-
* Unzip/zip Office document formats
|
8
|
-
* Low level "part" abstraction and rels resolution
|
9
|
-
* Direct access to manipulating/munging XML
|
7
|
+
* Unzip/zip Office document formats
|
8
|
+
* Low level "part" abstraction and "rels" resolution
|
9
|
+
* Direct access to manipulating/munging XML
|
10
10
|
|
11
|
-
PowerPoint is the only format with a higher-level
|
11
|
+
PowerPoint is the only format with a higher-level abstraction that allows:
|
12
12
|
|
13
|
-
* Copying and inserting slides
|
14
|
-
* Reading slide notes in the most basic sense
|
15
|
-
* Writing to slidenotes via a subset of markdown (only paragraphs)
|
13
|
+
* Copying and inserting slides
|
14
|
+
* Reading slide notes in the most basic sense
|
15
|
+
* Writing to slidenotes via a subset of markdown (only paragraphs)
|
16
|
+
|
17
|
+
While Word and Excel don't have these abstractions, Ballmer has a "Document" class that can still be used to resolve and manipulate document parts.
|
16
18
|
|
17
19
|
## Installation
|
18
20
|
|
@@ -30,18 +32,26 @@ Or install it yourself as:
|
|
30
32
|
|
31
33
|
## Usage
|
32
34
|
|
35
|
+
Its highly recommended to get comfortable with [Nokogiri](http://nokogiri.org) and [XPath queries](http://nokogiri.org/tutorials/searching_a_xml_html_document.html). Here's an example of what Ballmer can do:
|
36
|
+
|
33
37
|
```ruby
|
34
|
-
|
35
|
-
|
36
|
-
#
|
37
|
-
|
38
|
-
#
|
39
|
-
|
38
|
+
require 'ballmer'
|
39
|
+
|
40
|
+
# Open a pptx file.
|
41
|
+
prez = Ballmer::Presentation.open Ballmer.path("../spec/fixtures/presentation3.pptx")
|
42
|
+
# Copy the first slide into the last position.
|
43
|
+
prez.slides.push prez.slides.first
|
44
|
+
# Lets manipulate some XML using XPath queries and Nokogiri.
|
45
|
+
prez.edit_xml 'docProps/app.xml' do |xml|
|
46
|
+
xml.at_xpath('/xmlns:Properties/xmlns:Company').content = 'Acme Inc.'
|
47
|
+
end
|
48
|
+
# Now save the file contents.
|
49
|
+
# prez.save
|
40
50
|
```
|
41
51
|
|
42
52
|
## Contributing
|
43
53
|
|
44
|
-
Microsoft Office
|
54
|
+
Microsoft Office documents are a complicating beast. I don't intend no support all functionality, but I do think there's a lot of value in higher-level abstractions for various document formats. If you are working on a project and build these abstractions I'd love to merge those with Ballmer.
|
45
55
|
|
46
56
|
1. Fork it
|
47
57
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
data/lib/ballmer.rb
CHANGED
@@ -13,9 +13,14 @@ module Ballmer
|
|
13
13
|
|
14
14
|
def each(&block)
|
15
15
|
# TODO - Do NOT read content-types, but read Rels instead (and move this type casting in there.)
|
16
|
-
|
16
|
+
slides.each { |path| block.call slide path }
|
17
17
|
end
|
18
18
|
|
19
|
+
def size
|
20
|
+
slides.size
|
21
|
+
end
|
22
|
+
alias :length :size
|
23
|
+
|
19
24
|
# This method is crazy because it has to manipulate a ton of files within the PPTX. Most of
|
20
25
|
# what happens in here I figured out by diff-ing PPTX files that had copies of identical slides, but
|
21
26
|
# a different number of slides.
|
@@ -162,6 +167,10 @@ module Ballmer
|
|
162
167
|
@doc.content_types.parts Slide::CONTENT_TYPE
|
163
168
|
end
|
164
169
|
|
170
|
+
def slides
|
171
|
+
@doc.content_types[Slide::CONTENT_TYPE]
|
172
|
+
end
|
173
|
+
|
165
174
|
# Microsoft decided it would be cool to start at 1 instead of 0
|
166
175
|
# for the part indices, so this deals with that seperatly
|
167
176
|
def next_number
|
data/lib/ballmer/version.rb
CHANGED
metadata
CHANGED
@@ -1,111 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ballmer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brad Gessler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-23 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: guard-rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '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: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: terminal-notifier-guard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
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: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: pry
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
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'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: zipruby
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: nokogiri
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
description: Open and manipulate Office files.
|
@@ -120,9 +120,9 @@ executables:
|
|
120
120
|
extensions: []
|
121
121
|
extra_rdoc_files: []
|
122
122
|
files:
|
123
|
-
- .gitignore
|
124
|
-
- .rspec
|
125
|
-
- .travis.yml
|
123
|
+
- ".gitignore"
|
124
|
+
- ".rspec"
|
125
|
+
- ".travis.yml"
|
126
126
|
- Gemfile
|
127
127
|
- Guardfile
|
128
128
|
- LICENSE.txt
|
@@ -159,6 +159,7 @@ files:
|
|
159
159
|
- spec/lib/ballmer/presentation/notes_parser_spec.rb
|
160
160
|
- spec/lib/ballmer/presentation/tags_spec.rb
|
161
161
|
- spec/lib/ballmer/presentation_spec.rb
|
162
|
+
- spec/lib/ballmer_spec.rb
|
162
163
|
- spec/spec_helper.rb
|
163
164
|
homepage: ''
|
164
165
|
licenses:
|
@@ -170,17 +171,17 @@ require_paths:
|
|
170
171
|
- lib
|
171
172
|
required_ruby_version: !ruby/object:Gem::Requirement
|
172
173
|
requirements:
|
173
|
-
- -
|
174
|
+
- - ">="
|
174
175
|
- !ruby/object:Gem::Version
|
175
176
|
version: '0'
|
176
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
178
|
requirements:
|
178
|
-
- -
|
179
|
+
- - ">="
|
179
180
|
- !ruby/object:Gem::Version
|
180
181
|
version: '0'
|
181
182
|
requirements: []
|
182
183
|
rubyforge_project:
|
183
|
-
rubygems_version: 2.2.
|
184
|
+
rubygems_version: 2.2.2
|
184
185
|
signing_key:
|
185
186
|
specification_version: 4
|
186
187
|
summary: Manipulate Office files in Ruby.
|
@@ -195,4 +196,6 @@ test_files:
|
|
195
196
|
- spec/lib/ballmer/presentation/notes_parser_spec.rb
|
196
197
|
- spec/lib/ballmer/presentation/tags_spec.rb
|
197
198
|
- spec/lib/ballmer/presentation_spec.rb
|
199
|
+
- spec/lib/ballmer_spec.rb
|
198
200
|
- spec/spec_helper.rb
|
201
|
+
has_rdoc:
|