simple_docx_generator 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -0
- data/.rspec +0 -0
- data/.travis.yml +0 -0
- data/Gemfile +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +3 -2
- data/Rakefile +0 -0
- data/coverage.vim +0 -0
- data/lib/simple_docx_generator.rb +0 -0
- data/lib/simple_docx_generator/mydocx.rb +21 -0
- data/lib/simple_docx_generator/version.rb +1 -1
- data/simple_docx_generator.gemspec +7 -6
- data/spec/fixtures/Fax_cover_sheet.docx +0 -0
- data/spec/fixtures/document_xml.xml +50 -0
- data/spec/fixtures/helloworld.docx +0 -0
- data/spec/fixtures/old_document_xml.xml +50 -0
- data/spec/fixtures/output_Fax_cover_sheet.docx +0 -0
- data/spec/fixtures/output_helloworld.docx +0 -0
- data/spec/simple_docx_generator/mydocx_spec.rb +0 -0
- data/spec/simple_docx_generator_spec.rb +24 -0
- data/spec/spec_helper.rb +0 -0
- metadata +19 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1abf314f8643ae4ea4c5a1b913913ce2c1e53b2a
|
4
|
+
data.tar.gz: 1d071145ca10f1debbed240306750541806352f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c4174f4950d1b3a785623faff9796bae14ca710a5853c43035095188d08877eafe623cbe3615d093f29f4d995174892dfe3e5b00e0cf25d509882c82e73e7e2
|
7
|
+
data.tar.gz: 4ad7c72e62dd26340a77717dca618bb8b4bb62a0700af277733c84f483f365d659dbb8a6c3aca27a344e36be751fa8f48e77a9ed86863d405cc79b503cac9f72
|
data/.gitignore
CHANGED
File without changes
|
data/.rspec
CHANGED
File without changes
|
data/.travis.yml
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/LICENSE.txt
CHANGED
File without changes
|
data/README.md
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/simple_docx_generator.svg)](https://badge.fury.io/rb/simple_docx_generator)
|
1
2
|
[![Dependency Status](https://gemnasium.com/badges/github.com/seventhsense/simple_docx_generator.svg)](https://gemnasium.com/github.com/seventhsense/simple_docx_generator)
|
2
3
|
[![Code Climate](https://codeclimate.com/github/seventhsense/simple_docx_generator/badges/gpa.svg)](https://codeclimate.com/github/seventhsense/simple_docx_generator)
|
3
4
|
[![Test Coverage](https://codeclimate.com/github/seventhsense/simple_docx_generator/badges/coverage.svg)](https://codeclimate.com/github/seventhsense/simple_docx_generator/coverage)
|
@@ -12,7 +13,7 @@ RubyやRailsからdocxファイルの@@で囲まれた文字列を置換えま
|
|
12
13
|
|
13
14
|
Add this line to your application's Gemfile:
|
14
15
|
|
15
|
-
gem 'simple_docx_generator'
|
16
|
+
gem 'simple_docx_generator'
|
16
17
|
|
17
18
|
And then execute:
|
18
19
|
|
@@ -20,7 +21,7 @@ And then execute:
|
|
20
21
|
|
21
22
|
Or install it yourself as:
|
22
23
|
|
23
|
-
$ gem install simple_docx_generator
|
24
|
+
$ gem install simple_docx_generator
|
24
25
|
|
25
26
|
## Usage
|
26
27
|
|
data/Rakefile
CHANGED
File without changes
|
data/coverage.vim
CHANGED
File without changes
|
File without changes
|
@@ -111,6 +111,27 @@ class MyDocx
|
|
111
111
|
File.join @dir, filename
|
112
112
|
end
|
113
113
|
|
114
|
+
def document_xml
|
115
|
+
@document_xml.to_xml
|
116
|
+
end
|
117
|
+
|
118
|
+
def update_xml xml_text
|
119
|
+
buffer = Zip::OutputStream.write_buffer(::StringIO.new('')) do |out|
|
120
|
+
Zip::InputStream.open(File.join(@dir, @filename)) do |input|
|
121
|
+
while (entry = input.get_next_entry)
|
122
|
+
out.put_next_entry(entry.name)
|
123
|
+
if entry.name == 'word/document.xml'
|
124
|
+
out.write xml_text
|
125
|
+
else
|
126
|
+
out.write input.read
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
File.open(File.join(@dir, @filename), 'wb') {|f| f.write(buffer.string)}
|
132
|
+
initialize File.join(@dir, @filename)
|
133
|
+
end
|
134
|
+
|
114
135
|
private
|
115
136
|
def set_document_xml(path_to_template)
|
116
137
|
Zip::File.open(path_to_template) do |zip_files|
|
@@ -10,7 +10,8 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.email = ["seventh@scimpr.com"]
|
11
11
|
gem.description = %q{テンプレートdocxに値を代入して新しいdocxファイルを生成します。}
|
12
12
|
gem.summary = %q{テンプレートdocxに値を代入して新しいdocxファイルを生成します。}
|
13
|
-
gem.homepage = ""
|
13
|
+
gem.homepage = "https://github.com/seventhsense/simple_docx_generator"
|
14
|
+
gem.license = "MIT"
|
14
15
|
|
15
16
|
gem.files = `git ls-files`.split($/)
|
16
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -22,9 +23,9 @@ Gem::Specification.new do |gem|
|
|
22
23
|
gem.add_runtime_dependency "rmagick" , "2.16.0"
|
23
24
|
gem.add_runtime_dependency "htmlentities" , "4.3.4"
|
24
25
|
gem.add_runtime_dependency "ydocx" , "1.2.5"
|
25
|
-
gem.add_development_dependency "rspec"
|
26
|
-
gem.add_development_dependency "rake"
|
27
|
-
gem.add_development_dependency "simplecov"
|
28
|
-
gem.add_development_dependency "simplecov-vim"
|
29
|
-
gem.add_development_dependency "codeclimate-test-reporter"
|
26
|
+
gem.add_development_dependency "rspec", "~> 0"
|
27
|
+
gem.add_development_dependency "rake", "~> 0"
|
28
|
+
gem.add_development_dependency "simplecov", "~> 0"
|
29
|
+
gem.add_development_dependency "simplecov-vim", "~> 0"
|
30
|
+
gem.add_development_dependency "codeclimate-test-reporter", "~> 0"
|
30
31
|
end
|
File without changes
|
@@ -0,0 +1,50 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
2
|
+
<w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable="w14 wp14">
|
3
|
+
<w:body>
|
4
|
+
<w:p w:rsidR="00C1481B" w:rsidRDefault="00AC3A69">
|
5
|
+
<w:r>
|
6
|
+
<w:rPr>
|
7
|
+
<w:rFonts w:hint="eastAsia"/>
|
8
|
+
</w:rPr>
|
9
|
+
<w:t>@@hello3@@ @@world4@@</w:t>
|
10
|
+
</w:r>
|
11
|
+
<w:r w:rsidR="00683BFC">
|
12
|
+
<w:rPr>
|
13
|
+
<w:rFonts w:hint="eastAsia"/>
|
14
|
+
</w:rPr>
|
15
|
+
<w:t xml:space="preserve"> @@hello@@</w:t>
|
16
|
+
</w:r>
|
17
|
+
</w:p>
|
18
|
+
<w:p w:rsidR="00994119" w:rsidRDefault="00994119">
|
19
|
+
<w:r>
|
20
|
+
<w:rPr>
|
21
|
+
<w:rFonts w:hint="eastAsia"/>
|
22
|
+
</w:rPr>
|
23
|
+
<w:t>@@hello.checkbox@@</w:t>
|
24
|
+
</w:r>
|
25
|
+
</w:p>
|
26
|
+
<w:p w:rsidR="00360B33" w:rsidRPr="005F6C11" w:rsidRDefault="0035296C" w:rsidP="00FE2006">
|
27
|
+
<w:pPr>
|
28
|
+
<w:ind w:firstLine="840"/>
|
29
|
+
<w:rPr>
|
30
|
+
<w:b/>
|
31
|
+
</w:rPr>
|
32
|
+
</w:pPr>
|
33
|
+
<w:r>
|
34
|
+
<w:rPr>
|
35
|
+
<w:rFonts w:hint="eastAsia"/>
|
36
|
+
<w:b/>
|
37
|
+
</w:rPr>
|
38
|
+
<w:t>@@hello.text@@ @@hello.text@@ @@hello2.text@@</w:t>
|
39
|
+
</w:r>
|
40
|
+
<w:bookmarkStart w:id="0" w:name="_GoBack"/>
|
41
|
+
<w:bookmarkEnd w:id="0"/>
|
42
|
+
</w:p>
|
43
|
+
<w:sectPr w:rsidR="00360B33" w:rsidRPr="005F6C11">
|
44
|
+
<w:pgSz w:w="11906" w:h="16838"/>
|
45
|
+
<w:pgMar w:top="1985" w:right="1701" w:bottom="1701" w:left="1701" w:header="851" w:footer="992" w:gutter="0"/>
|
46
|
+
<w:cols w:space="425"/>
|
47
|
+
<w:docGrid w:type="lines" w:linePitch="360"/>
|
48
|
+
</w:sectPr>
|
49
|
+
</w:body>
|
50
|
+
</w:document>
|
Binary file
|
@@ -0,0 +1,50 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
2
|
+
<w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable="w14 wp14">
|
3
|
+
<w:body>
|
4
|
+
<w:p w:rsidR="00C1481B" w:rsidRDefault="00AC3A69">
|
5
|
+
<w:r>
|
6
|
+
<w:rPr>
|
7
|
+
<w:rFonts w:hint="eastAsia"/>
|
8
|
+
</w:rPr>
|
9
|
+
<w:t>@@hello@@ @@world@@</w:t>
|
10
|
+
</w:r>
|
11
|
+
<w:r w:rsidR="00683BFC">
|
12
|
+
<w:rPr>
|
13
|
+
<w:rFonts w:hint="eastAsia"/>
|
14
|
+
</w:rPr>
|
15
|
+
<w:t xml:space="preserve"> @@hello@@</w:t>
|
16
|
+
</w:r>
|
17
|
+
</w:p>
|
18
|
+
<w:p w:rsidR="00994119" w:rsidRDefault="00994119">
|
19
|
+
<w:r>
|
20
|
+
<w:rPr>
|
21
|
+
<w:rFonts w:hint="eastAsia"/>
|
22
|
+
</w:rPr>
|
23
|
+
<w:t>@@hello.checkbox@@</w:t>
|
24
|
+
</w:r>
|
25
|
+
</w:p>
|
26
|
+
<w:p w:rsidR="00360B33" w:rsidRPr="005F6C11" w:rsidRDefault="0035296C" w:rsidP="00FE2006">
|
27
|
+
<w:pPr>
|
28
|
+
<w:ind w:firstLine="840"/>
|
29
|
+
<w:rPr>
|
30
|
+
<w:b/>
|
31
|
+
</w:rPr>
|
32
|
+
</w:pPr>
|
33
|
+
<w:r>
|
34
|
+
<w:rPr>
|
35
|
+
<w:rFonts w:hint="eastAsia"/>
|
36
|
+
<w:b/>
|
37
|
+
</w:rPr>
|
38
|
+
<w:t>@@hello.text@@ @@hello.text@@ @@hello2.text@@</w:t>
|
39
|
+
</w:r>
|
40
|
+
<w:bookmarkStart w:id="0" w:name="_GoBack"/>
|
41
|
+
<w:bookmarkEnd w:id="0"/>
|
42
|
+
</w:p>
|
43
|
+
<w:sectPr w:rsidR="00360B33" w:rsidRPr="005F6C11">
|
44
|
+
<w:pgSz w:w="11906" w:h="16838"/>
|
45
|
+
<w:pgMar w:top="1985" w:right="1701" w:bottom="1701" w:left="1701" w:header="851" w:footer="992" w:gutter="0"/>
|
46
|
+
<w:cols w:space="425"/>
|
47
|
+
<w:docGrid w:type="lines" w:linePitch="360"/>
|
48
|
+
</w:sectPr>
|
49
|
+
</w:body>
|
50
|
+
</w:document>
|
Binary file
|
Binary file
|
File without changes
|
@@ -108,5 +108,29 @@ describe MyDocx do
|
|
108
108
|
html.should include '<div class="myclass">'
|
109
109
|
end
|
110
110
|
end
|
111
|
+
|
112
|
+
describe "access @document_xml" do
|
113
|
+
it "can access @document_xml" do
|
114
|
+
document_xml = @mydocx.document_xml
|
115
|
+
document_xml.should include '<w:t>@@hello.text@@ @@hello.text@@ @@hello2.text@@</w:t>'
|
116
|
+
# File.open 'spec/fixtures/old_document_xml.xml', 'w' do |text|
|
117
|
+
# text.puts document_xml
|
118
|
+
# end
|
119
|
+
end
|
120
|
+
|
121
|
+
it "can save new document_xml" do
|
122
|
+
xml = File.read 'spec/fixtures/document_xml.xml'
|
123
|
+
@mydocx.update_xml xml
|
124
|
+
keys = @mydocx.keys
|
125
|
+
old_xml = File.read 'spec/fixtures/old_document_xml.xml'
|
126
|
+
@mydocx.update_xml old_xml
|
127
|
+
keys.should include "@@hello3@@", "@@world4@@"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
# describe "keys_index" do
|
132
|
+
# keys_index = @mydocx.keys_index
|
133
|
+
# p keys_index
|
134
|
+
# end
|
111
135
|
end
|
112
136
|
|
data/spec/spec_helper.rb
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_docx_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- seventhsense
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -84,70 +84,70 @@ dependencies:
|
|
84
84
|
name: rspec
|
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: :development
|
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: rake
|
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: :development
|
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
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: simplecov
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - "
|
122
|
+
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: simplecov-vim
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- - "
|
129
|
+
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- - "
|
136
|
+
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: codeclimate-test-reporter
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- - "
|
143
|
+
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '0'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- - "
|
150
|
+
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
description: テンプレートdocxに値を代入して新しいdocxファイルを生成します。
|
@@ -170,14 +170,17 @@ files:
|
|
170
170
|
- lib/simple_docx_generator/version.rb
|
171
171
|
- simple_docx_generator.gemspec
|
172
172
|
- spec/fixtures/Fax_cover_sheet.docx
|
173
|
+
- spec/fixtures/document_xml.xml
|
173
174
|
- spec/fixtures/helloworld.docx
|
175
|
+
- spec/fixtures/old_document_xml.xml
|
174
176
|
- spec/fixtures/output_Fax_cover_sheet.docx
|
175
177
|
- spec/fixtures/output_helloworld.docx
|
176
178
|
- spec/simple_docx_generator/mydocx_spec.rb
|
177
179
|
- spec/simple_docx_generator_spec.rb
|
178
180
|
- spec/spec_helper.rb
|
179
|
-
homepage:
|
180
|
-
licenses:
|
181
|
+
homepage: https://github.com/seventhsense/simple_docx_generator
|
182
|
+
licenses:
|
183
|
+
- MIT
|
181
184
|
metadata: {}
|
182
185
|
post_install_message:
|
183
186
|
rdoc_options: []
|
@@ -201,7 +204,9 @@ specification_version: 4
|
|
201
204
|
summary: テンプレートdocxに値を代入して新しいdocxファイルを生成します。
|
202
205
|
test_files:
|
203
206
|
- spec/fixtures/Fax_cover_sheet.docx
|
207
|
+
- spec/fixtures/document_xml.xml
|
204
208
|
- spec/fixtures/helloworld.docx
|
209
|
+
- spec/fixtures/old_document_xml.xml
|
205
210
|
- spec/fixtures/output_Fax_cover_sheet.docx
|
206
211
|
- spec/fixtures/output_helloworld.docx
|
207
212
|
- spec/simple_docx_generator/mydocx_spec.rb
|