docstache 0.0.1 → 0.0.2
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 +13 -0
- data/lib/docstache/document.rb +2 -2
- data/lib/docstache/version.rb +1 -1
- metadata +11 -11
- data/README.rdoc +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6755758d881843dbac0475960fe9234c627bcae
|
4
|
+
data.tar.gz: 5d86fa6e76ac7ca3bdde8e5a657d7b84a47cec79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bcd5f84babf9bbbc494d276ba483765f160c968ccd16e069183eabdedcef256322ef7918044c465aaa707bfefc7a6fa74b7a86a02517887d4974f754f4f1083
|
7
|
+
data.tar.gz: 2f474a94f96b6ec2c2b97fe91a8ed88c6e3eb86e8d355110e4696fc3e332d6061ee63df6c7c022ed650600df7d90b2d35f0e119966779aeb6f35849b58a450aa
|
data/README.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
[](http://badge.fury.io/rb/docstache)
|
2
|
+
|
3
|
+
#Docstache
|
4
|
+
|
5
|
+
_Documentation is on pause until I finish up basic functionality. But thanks for checking it out!_
|
6
|
+
|
7
|
+
## Features
|
8
|
+
|
9
|
+
* Mustache style data interpolation into Microsoft Word .docx files
|
10
|
+
* This includes loops, and conditional blocks
|
11
|
+
* Merging together multiple documents (documents are joined by a page break)
|
12
|
+
* No more hassles with Word splitting up your tags across multiple XML tags. We gotcha.
|
13
|
+
* Error detection for word documents, just in case we don't gotcha.
|
data/lib/docstache/document.rb
CHANGED
@@ -8,8 +8,8 @@ module Docstache
|
|
8
8
|
zip_files = paths.map{|p| Zip::File.open(p)}
|
9
9
|
documents = zip_files.map{|f| Nokogiri::XML(unzip_read(f, "word/document.xml"))}
|
10
10
|
documents.each do |doc|
|
11
|
-
@document.
|
12
|
-
@document.
|
11
|
+
@document.css('w|p').last.add_next_sibling(page_break)
|
12
|
+
@document.css('w|p').last.add_next_sibling(doc.css('w|body > *:not(w|sectPr)'))
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
data/lib/docstache/version.rb
CHANGED
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docstache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Will Cosgrove
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.6'
|
20
20
|
type: :runtime
|
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.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rubyzip
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.1'
|
34
34
|
type: :runtime
|
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: '1.1'
|
41
41
|
description: Integrates data into MS Word docx template files. Processing supports
|
@@ -46,10 +46,10 @@ executables: []
|
|
46
46
|
extensions: []
|
47
47
|
extra_rdoc_files: []
|
48
48
|
files:
|
49
|
-
-
|
49
|
+
- .gitignore
|
50
50
|
- Gemfile
|
51
51
|
- LICENSE.txt
|
52
|
-
- README.
|
52
|
+
- README.md
|
53
53
|
- Rakefile
|
54
54
|
- docstache.gemspec
|
55
55
|
- lib/docstache.rb
|
@@ -71,17 +71,17 @@ require_paths:
|
|
71
71
|
- lib
|
72
72
|
required_ruby_version: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - '>='
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0'
|
77
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
-
- -
|
79
|
+
- - '>='
|
80
80
|
- !ruby/object:Gem::Version
|
81
81
|
version: '0'
|
82
82
|
requirements: []
|
83
83
|
rubyforge_project:
|
84
|
-
rubygems_version: 2.
|
84
|
+
rubygems_version: 2.0.14
|
85
85
|
signing_key:
|
86
86
|
specification_version: 4
|
87
87
|
summary: Merges Hash of Data into Word docx template files using mustache syntax
|
data/README.rdoc
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
= Turns a docx file template and a data set into a fully formed docx document
|
2
|
-
Inspired from [https://github.com/jawspeak/ruby-docx-templater] and [https://github.com/michaelfranzl/docx_converter], this takes a .docx file and uses it as a template to create a new docx, with your data
|
3
|
-
|
4
|
-
== Features
|
5
|
-
|
6
|
-
* All manipulation in memory (great if you have sensitive data)
|
7
|
-
* Global key/value substitutions by entering a `$KEY$` anywhere in the word document, with whatever formatting you want.
|
8
|
-
* Multi-row loops inside tables, also with whatever your formatting you wish. `#BEGIN_ROW:XYZ#`... `#END_ROW:XYZ#` see tests/example
|
9
|
-
* Allows for embedded loops through fully recursive parsing of the document
|
10
|
-
|
11
|
-
== Usage
|
12
|
-
* Create your docx "template" in Word
|
13
|
-
* Install rvm and bundler
|
14
|
-
* Run `bundle install`.
|
15
|
-
* Render new docx files from the template, ex: `ruby render_docx_template.rb`. Look for a rendered_*.docx file.
|
16
|
-
* Sample output with tests: `rake spec` (unit tests) `rake integration` (opens word)
|
17
|
-
|
18
|
-
__MS WORD is painful__ You will probably need to modify your docx document in word until such a time as all flags to replace are set properly within a single XML element. You can’t have Word’s split a string of characters across multiple xml elements in your template document.
|
19
|
-
Test the template and keep fixing it until the fields are all set properly.
|
20
|
-
|
21
|
-
I frequently use this workflow:
|
22
|
-
- Cut string to replace out to notepad
|
23
|
-
- Paste string back into MS Word
|
24
|
-
- Save Word Document
|