standard-procedure-consolidate 0.1.1 → 0.1.2

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: f240fafdaf4fea72b63ba38b70c0e49736bb46a3f1f793ed79030f0f184d7760
4
- data.tar.gz: '08930023d6b6865933a65a1cbefcd026d3a33b56323f702b5b46c9eedb76a210'
3
+ metadata.gz: 5647faddeab8829e8494e02b4b87acc33276e7f293fa147f3b15b1dd2a6d4c09
4
+ data.tar.gz: e867ef111010caa13eef6da80f11ccaa7ee0d780f82309a8f4d976bcff058545
5
5
  SHA512:
6
- metadata.gz: b205661ee1cd85599254559477ef73809086a9c232036c34a090b706437a01f46a947def4dfe3a90c12b50a0a589dcac671c1b5c5f1d9cea69bfadf160de5b02
7
- data.tar.gz: 917b84c6116e50936b1de0a31605c345d8ec4ac48c466bd97afec9f937ebe81b67f0b56f9c5a75fda735d71f496382ef714d7b5e9012878b2f1af4223833a8d0
6
+ metadata.gz: 3f7e9ebff0ec1706b59983eb8b1f32132e58af066f3e4de56a4e05c55ea2f365a236cc513e5571930cd0173ddaebd6329a7d628cb5a137b0ac1b1b365f1d5672
7
+ data.tar.gz: cab09a1aa8f2338b24397fd2eb2252c4244b4890dd965581657fcd025197948a9290896e0fa519ab782719f25b34f292e17f44de3c15f13329b1fe964550162b
@@ -0,0 +1,7 @@
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the
2
+ // README at: https://github.com/devcontainers/templates/tree/main/src/ruby
3
+ {
4
+ "name": "Ruby",
5
+ "image": "mcr.microsoft.com/devcontainers/ruby:1-3.2-bullseye",
6
+ "postCreateCommand": "bundle install"
7
+ }
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.2.2
data/CHANGELOG.md CHANGED
@@ -8,3 +8,8 @@
8
8
  ## [0.1.1] - 2023-08-02
9
9
 
10
10
  - Added `examine` to list the merge fields within a document
11
+
12
+ ## [0.1.2] - 2023-08-23
13
+
14
+ - Added untested support for headers and footers
15
+ - this work was done in a rush to deal with a customer requirement - tests to come soon
data/README.md CHANGED
@@ -33,13 +33,17 @@ NOTE: The merge fields are case-sensitive - which is why they should be supplied
33
33
 
34
34
  ## Development
35
35
 
36
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
36
+ The repo contains a .devcontainer folder - this contains instructions for a development container that has everything needed to build the project. Once the container has started, you can use `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
37
37
 
38
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
38
+ `bundle exec rake install` will install the gem on your local machine (obviously not from within the devcontainer though). To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
39
39
 
40
40
  ## Contributing
41
41
 
42
- Bug reports and pull requests are welcome on GitHub at https://github.com/standard-procedure/standard-procedure-consolidate. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/standard-procedure/standard-procedure-consolidate/blob/main/CODE_OF_CONDUCT.md).
42
+ Bug reports and pull requests are welcome on GitHub at https://github.com/standard-procedure/standard-procedure-consolidate.
43
+
44
+ When adding commit messages, please explain _why_ the change is being made.
45
+
46
+ When submitting a pull request, please ensure that there is an RSpec detailing how the feature works and please explain, in the pull request itself, the reasoning behind adding the feature.
43
47
 
44
48
  ## License
45
49
 
@@ -47,4 +51,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
47
51
 
48
52
  ## Code of Conduct
49
53
 
50
- Everyone interacting in the Standard::Procedure::Consolidate project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/standard-procedure-consolidate/blob/main/CODE_OF_CONDUCT.md).
54
+ Everyone interacting in the Standard::Procedure::Consolidate project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/standard-procedure/standard-procedure-consolidate/blob/main/CODE_OF_CONDUCT.md).
@@ -0,0 +1 @@
1
+ 055a4ccf5326b9f737e0222cecfdbaee34554fc42dcfaf017807e643fdc1ceb06b35329fe6a8ca32805c7ca3adf0c7df39b6bc32766208d69820243cde0a3648
@@ -17,11 +17,13 @@ module Consolidate
17
17
  def data fields = {}
18
18
  fields = fields.transform_keys(&:to_s)
19
19
 
20
- result = doc.dup
21
- result = substitute_style_one_with result, fields
22
- result = substitute_style_two_with result, fields
20
+ @documents.each do |name, document|
21
+ result = document.dup
22
+ result = substitute_style_one_with result, fields
23
+ result = substitute_style_two_with result, fields
23
24
 
24
- @output["word/document.xml"] = result.serialize save_with: 0
25
+ @output[name] = result.serialize save_with: 0
26
+ end
25
27
  end
26
28
 
27
29
  def write_to path
@@ -38,19 +40,22 @@ module Consolidate
38
40
 
39
41
  attr_reader :zip
40
42
  attr_reader :xml
41
- attr_reader :doc
43
+ attr_reader :documents
42
44
  attr_accessor :output
43
45
 
44
46
  def initialize(path, force_settings: true, &block)
45
47
  raise "No block given" unless block
46
48
  @output = {}
49
+ @documents = {}
47
50
  set_standard_settings if force_settings
48
51
  begin
49
52
  @zip = Zip::File.open(path)
50
- @xml = @zip.read("word/document.xml")
51
- @doc = Nokogiri::XML(xml) { |x| x.noent }
52
-
53
- yield self
53
+ ["word/document.xml", "word/header1.xml", "word/footer1.xml"].each do |document|
54
+ next unless @zip.find_entry(document)
55
+ xml = @zip.read document
56
+ @documents[document] = Nokogiri::XML(xml) { |x| x.noent }
57
+ yield self
58
+ end
54
59
  ensure
55
60
  @zip.close
56
61
  end
@@ -61,17 +66,21 @@ module Consolidate
61
66
  end
62
67
 
63
68
  def extract_style_one
64
- (doc / "//w:fldSimple").collect do |field|
65
- value = field.attributes["instr"].value.strip
66
- value.include?("MERGEFIELD") ? value.gsub("MERGEFIELD", "").strip : nil
67
- end.compact
69
+ documents.collect do |name, document|
70
+ (document / "//w:fldSimple").collect do |field|
71
+ value = field.attributes["instr"].value.strip
72
+ value.include?("MERGEFIELD") ? value.gsub("MERGEFIELD", "").strip : nil
73
+ end.compact
74
+ end.flatten
68
75
  end
69
76
 
70
77
  def extract_style_two
71
- (doc / "//w:instrText").collect do |instr|
72
- value = instr.inner_text
73
- value.include?("MERGEFIELD") ? value.gsub("MERGEFIELD", "").strip : nil
74
- end.compact
78
+ documents.collect do |name, document|
79
+ (document / "//w:instrText").collect do |instr|
80
+ value = instr.inner_text
81
+ value.include?("MERGEFIELD") ? value.gsub("MERGEFIELD", "").strip : nil
82
+ end.compact
83
+ end.flatten
75
84
  end
76
85
 
77
86
  def substitute_style_one_with document, fields
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Consolidate
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standard-procedure-consolidate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rahoul Baruah
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-03 00:00:00.000000000 Z
11
+ date: 2023-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -46,7 +46,9 @@ executables:
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
+ - ".devcontainer/devcontainer.json"
49
50
  - ".rspec"
51
+ - ".ruby-version"
50
52
  - ".standard.yml"
51
53
  - CHANGELOG.md
52
54
  - CODE_OF_CONDUCT.md
@@ -54,6 +56,7 @@ files:
54
56
  - README.md
55
57
  - Rakefile
56
58
  - checksums/standard-procedure-consolidate-0.1.0.gem.sha512
59
+ - checksums/standard-procedure-consolidate-0.1.2.gem.sha512
57
60
  - exe/consolidate
58
61
  - lib/consolidate.rb
59
62
  - lib/consolidate/docx/merge.rb
@@ -68,7 +71,7 @@ metadata:
68
71
  homepage_uri: https://github.com/standard-procedure/standard-procedure-consolidate
69
72
  source_code_uri: https://github.com/standard-procedure/standard-procedure-consolidate
70
73
  changelog_uri: https://github.com/standard-procedure/standard-procedure-consolidate/blob/main/CHANGELOG.md
71
- post_install_message:
74
+ post_install_message:
72
75
  rdoc_options: []
73
76
  require_paths:
74
77
  - lib
@@ -83,8 +86,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
86
  - !ruby/object:Gem::Version
84
87
  version: '0'
85
88
  requirements: []
86
- rubygems_version: 3.4.14
87
- signing_key:
89
+ rubygems_version: 3.4.10
90
+ signing_key:
88
91
  specification_version: 4
89
92
  summary: Simple ruby mailmerge for Microsoft Word .docx files.
90
93
  test_files: []