ballmer 0.0.1 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fcae2435035fbc72f36f7e7f793b1c952da690da
4
- data.tar.gz: 884e3214b7a0b7acb1653a1ce40c7b3c52f3ef84
3
+ metadata.gz: ee1efee77928b527001187d49afd66daa1b4e171
4
+ data.tar.gz: 8599a605f1333712b023a80d27f63c34cea2f986
5
5
  SHA512:
6
- metadata.gz: 62c5311693846c3db3a07146b5df427b5146ebd017f370aab8b5eae98acfcc6bb94b5a8e390cf5f7999f341e28924ec07a43c1a3c5e86196dc73c49266957be2
7
- data.tar.gz: 3190b41051a7c694d9574ea83d4d82b1b999a0f95d4e7266ea32a38298a0e81dbb6f699f46be1a69dd883bd53f0f5caf6334c984f9350c70b58b2997c41f2e57
6
+ metadata.gz: a82783df915fa6271d4339009ec28cc8bb44cd54e16b9356bb4c46e29d3009d7cfc0c0a940c7806f418ef85f16238f8871c2d08b2144a8ed636c698f7c2979cc
7
+ data.tar.gz: 7bb1ed8fc4e263bb076fe9824cdb78ef695a7ed634879e14cfaa7750da1fe88a40e38774b3c47340de478c972f4070b8dd491e3e61f143ec3ceb8b136ede4d48
data/README.md CHANGED
@@ -1,18 +1,20 @@
1
1
  # Ballmer
2
2
 
3
- [![Build Status](https://travis-ci.org/polleverywhere/ballmer.png?branch=master)](https://travis-ci.org/polleverywhere/ballmer)
3
+ [![Build Status](https://travis-ci.org/polleverywhere/ballmer.png?branch=master)](https://travis-ci.org/polleverywhere/ballmer) [![Code Climate](https://codeclimate.com/repos/52ce169f6956805d89000475/badges/e90c7084bdc02bda6000/gpa.png)](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, but basic abstraction that allows:
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
- # Open a pptx file
35
- p = Ballmer::Presentation.open("./fixtures/Presentation3.pptx")
36
- # Copy the first slide into the last position
37
- p.sides.push p.slides.first
38
- # Now save the file.
39
- p.save
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 is a complicating beast. If you need to grock documents you can help!
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
@@ -4,4 +4,9 @@ require "nokogiri"
4
4
  module Ballmer
5
5
  autoload :Presentation, 'ballmer/presentation'
6
6
  autoload :Document, 'ballmer/document'
7
+
8
+ # Get an absolute path relative to ballmer.
9
+ def self.path(*args)
10
+ File.expand_path(File.join('..', args), __FILE__)
11
+ end
7
12
  end
@@ -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
- @doc.content_types[Slide::CONTENT_TYPE].each { |path| block.call slide path }
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
@@ -1,3 +1,3 @@
1
1
  module Ballmer
2
- VERSION = "0.0.1"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -9,6 +9,10 @@ describe Ballmer::Presentation do
9
9
  end
10
10
  end
11
11
 
12
+ it "should have slides#length" do
13
+ subject.slides.length.should == 3
14
+ end
15
+
12
16
  context "slides" do
13
17
  let(:original) { subject.slides.to_a.first }
14
18
  let(:copy) { subject.slides.push original }
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ballmer do
4
+ describe ".path" do
5
+ it "should resolve path" do
6
+ File.should exist(Ballmer.path('../spec/fixtures/presentation3.pptx'))
7
+ end
8
+ end
9
+ end
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: 0.0.1
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-01-09 00:00:00.000000000 Z
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.0
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: