docx 0.6.0 → 0.6.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
  SHA256:
3
- metadata.gz: 6dd59a023e1430fce917809931fe955651324db4fadb7a55d9a380731240466e
4
- data.tar.gz: eb91759397bdc0782691c6ed46b37a67a031ab580d590568a7f221a223d2f80c
3
+ metadata.gz: 2d330b3e0314db11795c19864a96cfe839e9c9959211f0b1b54af5270f4157c4
4
+ data.tar.gz: 291e34e45c7d56185cdf5716fc15e9143b2134bea6d14102cf699e0d3cd6f8f5
5
5
  SHA512:
6
- metadata.gz: c722c427338ceb1f4d8c926c4e3b2a8c2b2de9889e77a9b78fec4ffe2270b633dfd8f843a31ed17a77b6b5d09d9e9d8b4c88e52569b3c410d1f8ae9183c76c6d
7
- data.tar.gz: 41af211af034071991a920f1ed00e9ee9c8e5e739f41553c8b263081e7626183bc21e38735bfed88f01fdea0599f13a313cfc0ea1f9cc8331edff97e5cd5c40d
6
+ metadata.gz: cbbe86dd086c4cae691af852e596d7a416e6e08fac56ad76ba03e5d44b12285eb84391204afe3df4d53b4a2a760149a791a03efc4cc08942565d4cead0014d62
7
+ data.tar.gz: 107a8e8aaad25115b824812681335fb072aebad3945e3263b622105b6847c6c25abb30ca4c5cbd5753ea1b3940f27a91e6a82dc3fb7f126dcf465e18e314ed32
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # docx
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/docx.svg)](https://badge.fury.io/rb/docx)
4
- [![Build Status](https://travis-ci.org/ruby-docx/docx.svg?branch=master)](https://travis-ci.org/ruby-docx/docx)
4
+ [![Ruby](https://github.com/ruby-docx/docx/workflows/Ruby/badge.svg)](https://github.com/ruby-docx/docx/actions?query=workflow%3ARuby)
5
5
  [![Coverage Status](https://coveralls.io/repos/github/ruby-docx/docx/badge.svg?branch=master)](https://coveralls.io/github/ruby-docx/docx?branch=master)
6
6
  [![Gitter](https://badges.gitter.im/ruby-docx/community.svg)](https://gitter.im/ruby-docx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
7
7
 
@@ -11,7 +11,7 @@ A ruby library/gem for interacting with `.docx` files. currently capabilities in
11
11
 
12
12
  ### Prerequisites
13
13
 
14
- - Ruby 2.4 or later
14
+ - Ruby 2.5 or later
15
15
 
16
16
  ### Install
17
17
 
@@ -134,6 +134,35 @@ end
134
134
  doc.save('example-edited.docx')
135
135
  ```
136
136
 
137
+ ### Writing to tables
138
+
139
+ ``` ruby
140
+ require 'docx'
141
+
142
+ # Create a Docx::Document object for our existing docx file
143
+ doc = Docx::Document.open('tables.docx')
144
+
145
+ # Iterate over each table
146
+ doc.tables.each do |table|
147
+ last_row = table.rows.last
148
+
149
+ # Copy last row and insert a new one before last row
150
+ new_row = last_row.copy
151
+ new_row.insert_before(last_row)
152
+
153
+ # Substitute text in each cell of this new row
154
+ new_row.cells.each do |cell|
155
+ cell.paragraphs.each do |paragraph|
156
+ paragraph.each_text_run do |text|
157
+ text.substitute('_placeholder_', 'replacement value')
158
+ end
159
+ end
160
+ end
161
+ end
162
+
163
+ doc.save('tables-edited.docx')
164
+ ```
165
+
137
166
  ### Advanced
138
167
 
139
168
  ``` ruby
data/lib/docx/document.rb CHANGED
@@ -30,8 +30,7 @@ module Docx
30
30
  @zip = Zip::File.open_buffer(path_or_io)
31
31
  end
32
32
 
33
- document = @zip.find_entry('word/document.xml')
34
- document ||= @zip.find_entry('word/document2.xml')
33
+ document = @zip.glob('word/document*.xml').first
35
34
  raise Errno::ENOENT if document.nil?
36
35
 
37
36
  @document_xml = document.get_input_stream.read
data/lib/docx/version.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Docx #:nodoc:
2
- VERSION = '0.6.0'
4
+ VERSION = '0.6.1'
3
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Hunt
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2020-10-14 00:00:00.000000000 Z
15
+ date: 2021-05-05 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: nokogiri
@@ -49,19 +49,19 @@ dependencies:
49
49
  - !ruby/object:Gem::Version
50
50
  version: '2.0'
51
51
  - !ruby/object:Gem::Dependency
52
- name: coveralls
52
+ name: coveralls_reborn
53
53
  requirement: !ruby/object:Gem::Requirement
54
54
  requirements:
55
55
  - - "~>"
56
56
  - !ruby/object:Gem::Version
57
- version: '0.8'
57
+ version: '0.21'
58
58
  type: :development
59
59
  prerelease: false
60
60
  version_requirements: !ruby/object:Gem::Requirement
61
61
  requirements:
62
62
  - - "~>"
63
63
  - !ruby/object:Gem::Version
64
- version: '0.8'
64
+ version: '0.21'
65
65
  - !ruby/object:Gem::Dependency
66
66
  name: rake
67
67
  requirement: !ruby/object:Gem::Requirement
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0'
137
137
  requirements: []
138
- rubygems_version: 3.1.2
138
+ rubygems_version: 3.0.3
139
139
  signing_key:
140
140
  specification_version: 4
141
141
  summary: a ruby library/gem for interacting with .docx files