docx-builder 0.1.11 → 0.1.13

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5847fb8238c628a1907025033216d203c41d4dcb6798a8d3d4d9538d05af4a2e
4
- data.tar.gz: 7ce08edfa70098ce12c5c436d6fed7a73a7de59539f35ea6dd61734e3d452d33
3
+ metadata.gz: 647fc0a676e9e89d5c524065eb3ef33c543eb0d3730e062651178a20369034a4
4
+ data.tar.gz: bef01a5005273274367163c7cdcd58142bc086c5c7f18506929fe7315297a430
5
5
  SHA512:
6
- metadata.gz: e4f6190d0f1bb16a313740edbc5dca7feab7ec812b8748905a7329bd67dc3bc1be48166e62d95629e0a69654d058e57830767b8e7be395dc1a373e47612baf15
7
- data.tar.gz: 27993bea930a31617d205684c66bca679da3e2b1d02e5be983a14facac29609a60b83858666283d0e00dcefb26d126612f146a71fdeb68766dd169c3d5de9acf
6
+ metadata.gz: 44b5758d199bc5ec64514a81d8aecd420125c7f846feda1654a546b92768643641f4254fd05eb43085db7c8e593ae8e2361791ab52b5fc792c6f642aeabac840
7
+ data.tar.gz: 1db1450803e102a75f1c02edc3a3b278fcf4f3faf89ca1b49bdf95e97d04a920ddb2627a51b4c2baa0887ebb8961a5a632963d79c78c1c69eb21e5d802054be9
@@ -0,0 +1,75 @@
1
+ name: CI - Checks
2
+ on:
3
+ push:
4
+ branches-ignore:
5
+ - master
6
+
7
+ jobs:
8
+
9
+ # lint:
10
+ # name: Linters verification
11
+ # runs-on: ubuntu-18.04
12
+
13
+ # steps:
14
+
15
+ # - name: Checkout code
16
+ # uses: actions/checkout@v2
17
+
18
+ # - name: Checkout deployment repo
19
+ # uses: actions/checkout@v2
20
+ # with:
21
+ # repository: cash-me/deployment
22
+ # ssh-key: ${{ secrets.DEPLOYMENT_KEY }}
23
+ # path: '.github/deployment'
24
+
25
+ # - name: Setup Ruby
26
+ # uses: ruby/setup-ruby@v1
27
+ # with:
28
+ # ruby-version: '2.7.2'
29
+
30
+ # - name: Ruby gem cache
31
+ # uses: actions/cache@v1
32
+ # with:
33
+ # path: vendor/bundle
34
+ # key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
35
+ # restore-keys: |
36
+ # ${{ runner.os }}-gems-
37
+
38
+ # - name: Linters
39
+ # uses: ./.github/deployment/actions/linters/rails
40
+
41
+ # test:
42
+ # name: Run tests
43
+ # needs: lint
44
+ # runs-on: ubuntu-18.04
45
+
46
+ # services:
47
+ # postgres:
48
+ # image: postgres:11.6
49
+ # ports: ["5432:5432"]
50
+ # options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
51
+
52
+ # steps:
53
+ # - uses: actions/checkout@v2
54
+
55
+ # - name: Checkout deployment repo
56
+ # uses: actions/checkout@v2
57
+ # with:
58
+ # repository: cash-me/deployment
59
+ # ssh-key: ${{ secrets.DEPLOYMENT_KEY }}
60
+ # path: '.github/deployment'
61
+
62
+ # - uses: actions/setup-ruby@v1
63
+ # with:
64
+ # ruby-version: '2.7.2'
65
+
66
+ # - name: Tests
67
+ # uses: ./.github/deployment/actions/tests/rails
68
+ # with:
69
+ # cc_reporter_id: ${{ secrets.CC_TEST_REPORTER_ID }}
70
+
71
+ ci-workflow:
72
+ # needs: test
73
+ runs-on: ubuntu-18.04
74
+ steps:
75
+ - run: exit 0
data/.gitignore CHANGED
@@ -5,7 +5,7 @@
5
5
  /doc/
6
6
  /pkg/
7
7
  /spec/reports/
8
- /tmp/
8
+ /tmp/output.docx
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ gemspec
7
7
 
8
8
  gem "rake", "~> 13.0"
9
9
  gem "rspec", "~> 3.0"
10
- gem "zip", "~> 2.0.2"
10
+ gem 'rubyzip', require: 'zip'
11
11
  gem "rubocop", "~> 0.80"
12
12
  gem "nokogiri", "~> 1.11.1"
13
13
 
data/Gemfile.lock ADDED
@@ -0,0 +1,65 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ docx-builder (0.2.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ byebug (11.1.3)
11
+ diff-lcs (1.4.4)
12
+ mini_portile2 (2.5.0)
13
+ nokogiri (1.11.3)
14
+ mini_portile2 (~> 2.5.0)
15
+ racc (~> 1.4)
16
+ parallel (1.20.1)
17
+ parser (3.0.1.0)
18
+ ast (~> 2.4.1)
19
+ racc (1.5.2)
20
+ rainbow (3.0.0)
21
+ rake (13.0.3)
22
+ regexp_parser (2.1.1)
23
+ rexml (3.2.5)
24
+ rspec (3.10.0)
25
+ rspec-core (~> 3.10.0)
26
+ rspec-expectations (~> 3.10.0)
27
+ rspec-mocks (~> 3.10.0)
28
+ rspec-core (3.10.1)
29
+ rspec-support (~> 3.10.0)
30
+ rspec-expectations (3.10.1)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.10.0)
33
+ rspec-mocks (3.10.2)
34
+ diff-lcs (>= 1.2.0, < 2.0)
35
+ rspec-support (~> 3.10.0)
36
+ rspec-support (3.10.2)
37
+ rubocop (0.93.1)
38
+ parallel (~> 1.10)
39
+ parser (>= 2.7.1.5)
40
+ rainbow (>= 2.2.2, < 4.0)
41
+ regexp_parser (>= 1.8)
42
+ rexml
43
+ rubocop-ast (>= 0.6.0)
44
+ ruby-progressbar (~> 1.7)
45
+ unicode-display_width (>= 1.4.0, < 2.0)
46
+ rubocop-ast (1.4.1)
47
+ parser (>= 2.7.1.5)
48
+ ruby-progressbar (1.11.0)
49
+ rubyzip (2.3.0)
50
+ unicode-display_width (1.7.0)
51
+
52
+ PLATFORMS
53
+ ruby
54
+
55
+ DEPENDENCIES
56
+ byebug
57
+ docx-builder!
58
+ nokogiri (~> 1.11.1)
59
+ rake (~> 13.0)
60
+ rspec (~> 3.0)
61
+ rubocop (~> 0.80)
62
+ rubyzip
63
+
64
+ BUNDLED WITH
65
+ 2.1.4
data/lib/docx/builder.rb CHANGED
@@ -14,14 +14,19 @@ module Docx
14
14
  class Error < StandardError; end
15
15
 
16
16
  class Template
17
- SECTIONS = %w( word/header1.xml word/document.xml )
18
-
17
+
19
18
  def initialize(path)
20
19
  @document = Docx::Decoder.to_xml(path)
20
+ @sections = ["word/document.xml"]
21
+ @document.each do |file|
22
+ if file.name.include? "word/header"
23
+ @sections.push(file.name)
24
+ end
25
+ end
21
26
  end
22
27
 
23
28
  def render(data)
24
- SECTIONS.map do |section|
29
+ @sections.map do |section|
25
30
  cleaned_document = clean(@document.read(section))
26
31
  erb_template = build_erb_template(cleaned_document)
27
32
  processed_document = render_erb_template(erb_template, data)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Docx
4
4
  module Builder
5
- VERSION = "0.1.11"
5
+ VERSION = "0.1.13"
6
6
  end
7
7
  end
data/lib/docx/decoder.rb CHANGED
@@ -5,7 +5,10 @@ require 'zip'
5
5
  module Docx
6
6
  module Decoder
7
7
  def self.to_xml(path)
8
- Zip::File.open(path)
8
+ Zip::File.open(path) do |file|
9
+ @zipfile = file
10
+ end
11
+ @zipfile
9
12
  end
10
13
  end
11
14
  end
data/tmp/.gitkeep ADDED
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docx-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paulo Soares
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-23 00:00:00.000000000 Z
11
+ date: 2021-04-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Builds a new docx file using ERB template
14
14
  email:
@@ -17,12 +17,13 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - ".github/workflows/main.yml"
20
+ - ".github/workflows/ci.yaml"
21
21
  - ".gitignore"
22
22
  - ".rspec"
23
23
  - ".rubocop.yml"
24
24
  - CODE_OF_CONDUCT.md
25
25
  - Gemfile
26
+ - Gemfile.lock
26
27
  - LICENSE.txt
27
28
  - README.md
28
29
  - Rakefile
@@ -36,6 +37,7 @@ files:
36
37
  - lib/docx/encoder.rb
37
38
  - lib/docx/xml_processor.rb
38
39
  - publish.sh
40
+ - tmp/.gitkeep
39
41
  homepage: https://github.com/cash-me/docx-builder
40
42
  licenses:
41
43
  - MIT
@@ -1,18 +0,0 @@
1
- name: Ruby
2
-
3
- on: [push,pull_request]
4
-
5
- jobs:
6
- build:
7
- runs-on: ubuntu-latest
8
- steps:
9
- - uses: actions/checkout@v2
10
- - name: Set up Ruby
11
- uses: ruby/setup-ruby@v1
12
- with:
13
- ruby-version: 2.7.2
14
- - name: Run the default task
15
- run: |
16
- gem install bundler -v 2.2.2
17
- bundle install
18
- bundle exec rake