openxml-docx 0.10.5 → 0.10.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +7 -5
  3. data/lib/openxml/docx/package.rb +14 -8
  4. data/lib/openxml/docx/properties/on_off_property.rb +3 -2
  5. data/lib/openxml/docx/properties/toggle_property.rb +6 -10
  6. data/lib/openxml/docx/version.rb +1 -1
  7. data/spec/properties/bidi_spec.rb +3 -4
  8. data/spec/properties/bold_spec.rb +3 -4
  9. data/spec/properties/cant_split_spec.rb +3 -4
  10. data/spec/properties/caps_spec.rb +3 -4
  11. data/spec/properties/complex_bold_spec.rb +3 -4
  12. data/spec/properties/complex_italics_spec.rb +3 -4
  13. data/spec/properties/complex_script_formatting_spec.rb +3 -4
  14. data/spec/properties/compress_punctuation_spec.rb +12 -3
  15. data/spec/properties/contextual_spacing_spec.rb +3 -4
  16. data/spec/properties/emboss_spec.rb +3 -4
  17. data/spec/properties/even_and_odd_headers_spec.rb +3 -4
  18. data/spec/properties/form_protection_spec.rb +3 -4
  19. data/spec/properties/hidden_spec.rb +3 -4
  20. data/spec/properties/hidden_style_spec.rb +3 -4
  21. data/spec/properties/hidden_text_spec.rb +3 -4
  22. data/spec/properties/hide_mark_spec.rb +3 -4
  23. data/spec/properties/imprint_spec.rb +3 -4
  24. data/spec/properties/italics_spec.rb +3 -4
  25. data/spec/properties/keep_lines_spec.rb +3 -4
  26. data/spec/properties/keep_next_spec.rb +3 -4
  27. data/spec/properties/kinsoku_spec.rb +12 -3
  28. data/spec/properties/math_spec.rb +3 -4
  29. data/spec/properties/mirror_indent_spec.rb +3 -4
  30. data/spec/properties/no_wrap_spec.rb +3 -4
  31. data/spec/properties/page_break_before_spec.rb +3 -4
  32. data/spec/properties/primary_style_spec.rb +3 -4
  33. data/spec/properties/right_to_left_spec.rb +3 -4
  34. data/spec/properties/semi_hidden_spec.rb +2 -3
  35. data/spec/properties/snap_to_grid_spec.rb +12 -3
  36. data/spec/properties/spec_vanish_spec.rb +3 -4
  37. data/spec/properties/style_auto_redefinition_spec.rb +3 -4
  38. data/spec/properties/style_lock_spec.rb +3 -4
  39. data/spec/properties/supress_auto_hyphens_spec.rb +3 -4
  40. data/spec/properties/supress_line_numbers_spec.rb +3 -4
  41. data/spec/properties/supress_overlap_spec.rb +3 -4
  42. data/spec/properties/table_header_spec.rb +3 -4
  43. data/spec/properties/title_page_spec.rb +3 -4
  44. data/spec/properties/unhide_when_used_spec.rb +3 -4
  45. data/spec/properties/web_hidden_spec.rb +3 -4
  46. data/spec/properties/widow_control_spec.rb +13 -3
  47. data/spec/properties/word_wrap_spec.rb +13 -3
  48. data/spec/section_spec.rb +4 -4
  49. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 83b80fb3e76c1777ecc53959807d74d79f384902
4
- data.tar.gz: bf561fbe368a0d1533d5fd726065a1cf801f4ee1
3
+ metadata.gz: cb6fb253a34f3c7919c6dbc7adaf421c6ee3a72c
4
+ data.tar.gz: 1ff1d8ca864e3d95c9fce8d1259cd56234def356
5
5
  SHA512:
6
- metadata.gz: bc95a3ec56c670a36de88de57b5e96a221e284c08d00c5eae3cc85eb45c78eeaa4b17f9cf4ac24b53f93f396cf1164754100a5e06a1cf96ee4a318e2ef0f4031
7
- data.tar.gz: ff1cf70b3015775728f306f11283c44d21adea29e239c2118a1eecfd00e3dbcd7d1c471d1c812873d16302d7634e9470264942f62a77d3a59b501131ec831e15
6
+ metadata.gz: a3826c5a0da2891945597b88aaa0b195e1754217a8e292a14efc0e526dc24bc33ab48e4633da4a22ce191f78e919090984eaf554941962ef0207e554b4c8b097
7
+ data.tar.gz: 95673e5763a453c7b70dd1b8836382126400bc4f1816efe4e718ccaf6c6509143e2de14c750acfcd1f7c009e58d62806b6a9ff1cca29370dc184fd645b1e92c3
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openxml-docx (0.10.5)
4
+ openxml-docx (0.10.6)
5
5
  nokogiri
6
6
  openxml-package (>= 0.2.2)
7
7
 
@@ -13,14 +13,16 @@ GEM
13
13
  docile (1.1.5)
14
14
  json (1.8.3)
15
15
  method_source (0.8.2)
16
- mini_portile2 (2.0.0)
17
- nokogiri (1.6.7.2)
18
- mini_portile2 (~> 2.0.0.rc2)
16
+ mini_portile2 (2.1.0)
17
+ nokogiri (1.6.8)
18
+ mini_portile2 (~> 2.1.0)
19
+ pkg-config (~> 1.1.7)
19
20
  openxml-package (0.2.4)
20
21
  nokogiri
21
22
  ox
22
23
  rubyzip (~> 1.1.0)
23
- ox (2.3.0)
24
+ ox (2.4.3)
25
+ pkg-config (1.1.7)
24
26
  pry (0.10.3)
25
27
  coderay (~> 1.1.0)
26
28
  method_source (~> 0.8.1)
@@ -69,23 +69,29 @@ module OpenXml
69
69
 
70
70
  def embed_image(path: nil, content_type: nil, into_part: nil)
71
71
  return if path.nil?
72
- into_part = document unless into_part.respond_to?(:relationships)
73
72
 
74
73
  extension_match = path.match(/\.(?<extension>[^\.]+?)(?:\?.+)?$/)
75
74
  content_type ||= extension_match[:extension] if extension_match
76
75
  return if content_type.nil?
77
76
 
77
+ open(path, "rb") do |source_image|
78
+ embed_image_data(data: source_image.read, content_type: content_type, into_part: into_part)
79
+ end
80
+ end
81
+
82
+ def embed_image_data(data: nil, content_type: nil, into_part: nil)
83
+ return if data.nil? || content_type.nil?
84
+ into_part = document unless into_part.respond_to?(:relationships)
85
+
78
86
  content_type = "jpeg" if content_type == "jpg"
79
87
  content_type = content_type.to_sym
80
88
 
81
- open(path, "rb") do |source_image|
82
- destination_image_name = "image#{image_names.count + 1}.#{content_type}"
83
- add_part "word/media/#{destination_image_name}", OpenXml::Parts::UnparsedPart.new(source_image.read)
84
- image_names << destination_image_name
89
+ destination_image_name = "image#{image_names.count + 1}.#{content_type}"
90
+ add_part "word/media/#{destination_image_name}", OpenXml::Parts::UnparsedPart.new(data)
91
+ image_names << destination_image_name
85
92
 
86
- image_relationship = into_part.relationships.add_relationship REL_IMAGE, "media/#{destination_image_name}"
87
- image_relationship.id
88
- end
93
+ image_relationship = into_part.relationships.add_relationship REL_IMAGE, "media/#{destination_image_name}"
94
+ image_relationship.id
89
95
  end
90
96
 
91
97
  def add_header(header)
@@ -4,11 +4,12 @@ module OpenXml
4
4
  class OnOffProperty < ValueProperty
5
5
 
6
6
  def ok_values
7
- [nil, :on, :off]
7
+ [true, false, :on, :off] # :on and :off are from the Transitional Spec
8
8
  end
9
9
 
10
10
  def to_xml(xml)
11
- xml["w"].public_send(tag, "w:val" => value) if value
11
+ return xml["w"].public_send(tag) if value == true
12
+ xml["w"].public_send(tag, "w:val" => value)
12
13
  end
13
14
 
14
15
  end
@@ -1,16 +1,12 @@
1
1
  module OpenXml
2
2
  module Docx
3
3
  module Properties
4
- class ToggleProperty < ValueProperty
5
-
6
- def ok_values
7
- [nil, true, false]
8
- end
9
-
10
- def to_xml(xml)
11
- xml["w"].public_send(tag) if value
12
- end
13
-
4
+ class ToggleProperty < OnOffProperty
5
+ # Toggle properties are no different in representation than on/off properties;
6
+ # rather, the difference is in how they compose with one another (cf.
7
+ # Section 17.7.3). It's helpful, then, to retain the concept, but entirely
8
+ # unnecessary to duplicate implementation.
9
+ # cf. Section A.6.9 of the spec, and Section A.7.9 of the transitional spec.
14
10
  end
15
11
  end
16
12
  end
@@ -1,5 +1,5 @@
1
1
  module OpenXml
2
2
  module Docx
3
- VERSION = "0.10.5"
3
+ VERSION = "0.10.6"
4
4
  end
5
5
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::Bidi do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :bidi, name: "bidi"
6
+ it_should_use tag: :bidi, name: "bidi", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::Bidi do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:bidi w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::Bold do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :b, name: "bold"
6
+ it_should_use tag: :b, name: "bold", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::Bold do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:b w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::CantSplit do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :cantSplit, name: "cant_split"
6
+ it_should_use tag: :cantSplit, name: "cant_split", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::CantSplit do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:cantSplit w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::Caps do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :caps, name: "caps"
6
+ it_should_use tag: :caps, name: "caps", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::Caps do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:caps w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::ComplexBold do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :bCs, name: "complex_bold"
6
+ it_should_use tag: :bCs, name: "complex_bold", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::ComplexBold do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:bCs w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::ComplexItalics do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :iCs, name: "complex_italics"
6
+ it_should_use tag: :iCs, name: "complex_italics", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::ComplexItalics do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:iCs w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::ComplexScriptFormatting do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :cs, name: "complex_script_formatting"
6
+ it_should_use tag: :cs, name: "complex_script_formatting", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::ComplexScriptFormatting do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:cs w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,17 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::CompressPunctuation do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :topLinePunct, name: "compress_punctuation"
6
+ it_should_use tag: :topLinePunct, name: "compress_punctuation", value: true
7
+
8
+ with_value(true) do
9
+ it_should_work
10
+ it_should_output "<w:topLinePunct/>"
11
+ end
12
+
13
+ with_value(false) do
14
+ it_should_work
15
+ it_should_output "<w:topLinePunct w:val=\"false\"/>"
16
+ end
7
17
 
8
18
  with_value(:on) do
9
19
  it_should_work
@@ -16,8 +26,7 @@ describe OpenXml::Docx::Properties::CompressPunctuation do
16
26
  end
17
27
 
18
28
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
29
+ it_should_not_work
21
30
  end
22
31
 
23
32
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::ContextualSpacing do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :contextualSpacing, name: "contextual_spacing"
6
+ it_should_use tag: :contextualSpacing, name: "contextual_spacing", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::ContextualSpacing do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:contextualSpacing w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::Emboss do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :emboss, name: "emboss"
6
+ it_should_use tag: :emboss, name: "emboss", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::Emboss do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:emboss w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::EvenAndOddHeaders do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :evenAndOddHeaders, name: "even_and_odd_headers"
6
+ it_should_use tag: :evenAndOddHeaders, name: "even_and_odd_headers", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::EvenAndOddHeaders do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:evenAndOddHeaders w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::FormProtection do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :formProt, name: "form_protection"
6
+ it_should_use tag: :formProt, name: "form_protection", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::FormProtection do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:formProt w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::Hidden do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :hidden, name: "hidden"
6
+ it_should_use tag: :hidden, name: "hidden", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::Hidden do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:hidden w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::HiddenStyle do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :hidden, name: "hidden_style"
6
+ it_should_use tag: :hidden, name: "hidden_style", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::HiddenStyle do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:hidden w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::HiddenText do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :vanish, name: "hidden_text"
6
+ it_should_use tag: :vanish, name: "hidden_text", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::HiddenText do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:vanish w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::HideMark do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :hideMark, name: "hide_mark"
6
+ it_should_use tag: :hideMark, name: "hide_mark", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::HideMark do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:hideMark w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::Imprint do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :imprint, name: "imprint"
6
+ it_should_use tag: :imprint, name: "imprint", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::Imprint do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:imprint w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::Italics do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :i, name: "italics"
6
+ it_should_use tag: :i, name: "italics", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::Italics do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:i w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::KeepLines do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :keepLines, name: "keep_lines"
6
+ it_should_use tag: :keepLines, name: "keep_lines", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::KeepLines do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:keepLines w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::KeepNext do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :keepNext, name: "keep_next"
6
+ it_should_use tag: :keepNext, name: "keep_next", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::KeepNext do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:keepNext w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,17 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::Kinsoku do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :kinsoku, name: "kinsoku"
6
+ it_should_use tag: :kinsoku, name: "kinsoku", value: true
7
+
8
+ with_value(true) do
9
+ it_should_work
10
+ it_should_output "<w:kinsoku/>"
11
+ end
12
+
13
+ with_value(false) do
14
+ it_should_work
15
+ it_should_output "<w:kinsoku w:val=\"false\"/>"
16
+ end
7
17
 
8
18
  with_value(:on) do
9
19
  it_should_work
@@ -16,8 +26,7 @@ describe OpenXml::Docx::Properties::Kinsoku do
16
26
  end
17
27
 
18
28
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
29
+ it_should_not_work
21
30
  end
22
31
 
23
32
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::Math do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :oMath, name: "math"
6
+ it_should_use tag: :oMath, name: "math", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::Math do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:oMath w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::MirrorIndent do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :mirrorIndent, name: "mirror_indent"
6
+ it_should_use tag: :mirrorIndent, name: "mirror_indent", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::MirrorIndent do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:mirrorIndent w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::NoWrap do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :noWrap, name: "no_wrap"
6
+ it_should_use tag: :noWrap, name: "no_wrap", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::NoWrap do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:noWrap w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::PageBreakBefore do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :pageBreakBefore, name: "page_break_before"
6
+ it_should_use tag: :pageBreakBefore, name: "page_break_before", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::PageBreakBefore do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:pageBreakBefore w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::PrimaryStyle do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :qFormat, name: "primary_style"
6
+ it_should_use tag: :qFormat, name: "primary_style", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::PrimaryStyle do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:qFormat w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::RightToLeft do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :rtl, name: "right_to_left"
6
+ it_should_use tag: :rtl, name: "right_to_left", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::RightToLeft do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:rtl w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::SemiHidden do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:semiHidden w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::SnapToGrid do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :snapToGrid, name: "snap_to_grid"
6
+ it_should_use tag: :snapToGrid, name: "snap_to_grid", value: true
7
7
 
8
8
  with_value(:on) do
9
9
  it_should_work
@@ -15,9 +15,18 @@ describe OpenXml::Docx::Properties::SnapToGrid do
15
15
  it_should_output "<w:snapToGrid w:val=\"off\"/>"
16
16
  end
17
17
 
18
- with_value(nil) do
18
+ with_value(true) do
19
+ it_should_work
20
+ it_should_output "<w:snapToGrid/>"
21
+ end
22
+
23
+ with_value(false) do
19
24
  it_should_work
20
- it_should_output ""
25
+ it_should_output "<w:snapToGrid w:val=\"false\"/>"
26
+ end
27
+
28
+ with_value(nil) do
29
+ it_should_not_work
21
30
  end
22
31
 
23
32
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::SpecVanish do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :specVanish, name: "spec_vanish"
6
+ it_should_use tag: :specVanish, name: "spec_vanish", value: false
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::SpecVanish do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:specVanish w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::StyleAutoRedefinition do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :autoRedefine, name: "style_auto_redefinition"
6
+ it_should_use tag: :autoRedefine, name: "style_auto_redefinition", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::StyleAutoRedefinition do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:autoRedefine w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::StyleLock do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :locked, name: "style_lock"
6
+ it_should_use tag: :locked, name: "style_lock", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::StyleLock do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:locked w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::SupressAutoHyphens do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :supressAutoHyphens, name: "supress_auto_hyphens"
6
+ it_should_use tag: :supressAutoHyphens, name: "supress_auto_hyphens", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::SupressAutoHyphens do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:supressAutoHyphens w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::SupressLineNumbers do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :supressLineNumbers, name: "supress_line_numbers"
6
+ it_should_use tag: :supressLineNumbers, name: "supress_line_numbers", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::SupressLineNumbers do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:supressLineNumbers w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::SupressOverlap do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :supressOverlap, name: "supress_overlap"
6
+ it_should_use tag: :supressOverlap, name: "supress_overlap", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::SupressOverlap do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:supressOverlap w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::TableHeader do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :tblHeader, name: "table_header"
6
+ it_should_use tag: :tblHeader, name: "table_header", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::TableHeader do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:tblHeader w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::TitlePage do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :titlePg, name: "title_page"
6
+ it_should_use tag: :titlePg, name: "title_page", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::TitlePage do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:titlePg w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::UnhideWhenUsed do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :unhideWhenUsed, name: "unhide_when_used"
6
+ it_should_use tag: :unhideWhenUsed, name: "unhide_when_used", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::UnhideWhenUsed do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:unhideWhenUsed w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::WebHidden do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :webHidden, name: "web_hidden"
6
+ it_should_use tag: :webHidden, name: "web_hidden", value: true
7
7
 
8
8
  with_value(true) do
9
9
  it_should_work
@@ -12,12 +12,11 @@ describe OpenXml::Docx::Properties::WebHidden do
12
12
 
13
13
  with_value(false) do
14
14
  it_should_work
15
- it_should_output ""
15
+ it_should_output "<w:webHidden w:val=\"false\"/>"
16
16
  end
17
17
 
18
18
  with_value(nil) do
19
- it_should_work
20
- it_should_output ""
19
+ it_should_not_work
21
20
  end
22
21
 
23
22
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::WidowControl do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :widowControl, name: "widow_control"
6
+ it_should_use tag: :widowControl, name: "widow_control", value: true
7
7
 
8
8
  with_value(:on) do
9
9
  it_should_work
@@ -15,9 +15,19 @@ describe OpenXml::Docx::Properties::WidowControl do
15
15
  it_should_output "<w:widowControl w:val=\"off\"/>"
16
16
  end
17
17
 
18
- with_value(nil) do
18
+ with_value(true) do
19
+ it_should_work
20
+ it_should_output "<w:widowControl/>"
21
+ end
22
+
23
+ with_value(false) do
19
24
  it_should_work
20
- it_should_output ""
25
+ it_should_output "<w:widowControl w:val=\"false\"/>"
26
+ end
27
+
28
+
29
+ with_value(nil) do
30
+ it_should_not_work
21
31
  end
22
32
 
23
33
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe OpenXml::Docx::Properties::WordWrap do
4
4
  include ValuePropertyTestMacros
5
5
 
6
- it_should_use tag: :wordWrap, name: "word_wrap"
6
+ it_should_use tag: :wordWrap, name: "word_wrap", value: true
7
7
 
8
8
  with_value(:on) do
9
9
  it_should_work
@@ -15,9 +15,19 @@ describe OpenXml::Docx::Properties::WordWrap do
15
15
  it_should_output "<w:wordWrap w:val=\"off\"/>"
16
16
  end
17
17
 
18
- with_value(nil) do
18
+ with_value(true) do
19
+ it_should_work
20
+ it_should_output "<w:wordWrap/>"
21
+ end
22
+
23
+ with_value(false) do
19
24
  it_should_work
20
- it_should_output ""
25
+ it_should_output "<w:wordWrap w:val=\"false\"/>"
26
+ end
27
+
28
+
29
+ with_value(nil) do
30
+ it_should_not_work
21
31
  end
22
32
 
23
33
  end
@@ -14,14 +14,14 @@ describe OpenXml::Docx::Section do
14
14
  it_should_have_property :page_size
15
15
  it_should_have_property :paper_source
16
16
 
17
- it_should_have_value_property :bidi
18
- it_should_have_value_property :form_protection
17
+ it_should_have_value_property :bidi, with_value: true
18
+ it_should_have_value_property :form_protection, with_value: true
19
19
  it_should_have_value_property :rtl_gutter
20
20
  it_should_have_value_property :text_direction, with_value: :lr
21
21
  it_should_have_value_property :type, as_instance_of: :section_type, with_value: :oddPage
22
22
  it_should_have_value_property :vertical_alignment, as_instance_of: :vertical_text_alignment, with_value: :both
23
- it_should_have_value_property :title_page
24
- it_should_have_value_property :even_and_odd_headers
23
+ it_should_have_value_property :title_page, with_value: true
24
+ it_should_have_value_property :even_and_odd_headers, with_value: true
25
25
 
26
26
  context "if no attribute are set" do
27
27
  before(:each) do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openxml-docx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.5
4
+ version: 0.10.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gene Doyel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-26 00:00:00.000000000 Z
11
+ date: 2017-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri