docx 0.2.07 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/docx/elements.rb CHANGED
@@ -1,3 +1,3 @@
1
- require 'docx/elements/bookmark'
2
- require 'docx/elements/element'
1
+ require 'docx/elements/bookmark'
2
+ require 'docx/elements/element'
3
3
  require 'docx/elements/text'
@@ -5,7 +5,7 @@ module Docx
5
5
  class Bookmark
6
6
  include Element
7
7
  attr_accessor :name
8
-
8
+
9
9
  def self.tag
10
10
  'bookmarkStart'
11
11
  end
@@ -17,14 +17,14 @@ module Docx
17
17
 
18
18
  # Insert text before bookmarkStart node
19
19
  def insert_text_before(text)
20
- text_run = get_run_after
21
- text_run.text = "#{text}#{text_run.text}"
20
+ text_run = get_run_before
21
+ text_run.text = "#{text_run.text}#{text}"
22
22
  end
23
23
 
24
24
  # Insert text after bookmarkStart node
25
25
  def insert_text_after(text)
26
- text_run = get_run_before
27
- text_run.text = "#{text_run.text}#{text}"
26
+ text_run = get_run_after
27
+ text_run.text = "#{text}#{text_run.text}"
28
28
  end
29
29
 
30
30
  # insert multiple lines starting with paragraph containing bookmark node.
@@ -51,7 +51,7 @@ module Docx
51
51
 
52
52
  # Get text run immediately prior to bookmark node
53
53
  def get_run_before
54
- # at_xpath returns the first match found and preceding-sibling returns siblings in the
54
+ # at_xpath returns the first match found and preceding-sibling returns siblings in the
55
55
  # order they appear in the document not the order as they appear when moving out from
56
56
  # the starting node
57
57
  if not (r_nodes = @node.xpath("./preceding-sibling::w:r")).empty?
@@ -65,8 +65,10 @@ module Docx
65
65
  def html_tag(name, options = {})
66
66
  content = options[:content]
67
67
  styles = options[:styles]
68
+ attributes = options[:attributes]
68
69
 
69
70
  html = "<#{name.to_s}"
71
+
70
72
  unless styles.nil? || styles.empty?
71
73
  styles_array = []
72
74
  styles.each do |property, value|
@@ -74,6 +76,13 @@ module Docx
74
76
  end
75
77
  html << " style=\"#{styles_array.join('')}\""
76
78
  end
79
+
80
+ unless attributes.nil? || attributes.empty?
81
+ attributes.each do |attr_name, attr_value|
82
+ html << " #{attr_name}=\"#{attr_value}\""
83
+ end
84
+ end
85
+
77
86
  html << ">"
78
87
  html << content if content
79
88
  html << "</#{name.to_s}>"
@@ -1,17 +1,17 @@
1
- module Docx
2
- module Elements
3
- class Text
4
- include Element
5
- delegate :content, :content=, :to => :@node
6
-
7
- def self.tag
8
- 't'
9
- end
10
-
11
-
12
- def initialize(node)
13
- @node = node
14
- end
15
- end
16
- end
1
+ module Docx
2
+ module Elements
3
+ class Text
4
+ include Element
5
+ delegate :content, :content=, :to => :@node
6
+
7
+ def self.tag
8
+ 't'
9
+ end
10
+
11
+
12
+ def initialize(node)
13
+ @node = node
14
+ end
15
+ end
16
+ end
17
17
  end
data/lib/docx/version.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Docx #:nodoc:
2
- VERSION = '0.2.07'
4
+ VERSION = '0.6.1'
3
5
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.07
5
- prerelease:
4
+ version: 0.6.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Christopher Hunt
@@ -10,68 +9,99 @@ authors:
10
9
  - Higgins Dragon
11
10
  - Toms Mikoss
12
11
  - Sebastian Wittenkamp
13
- autorequire:
12
+ autorequire:
14
13
  bindir: bin
15
14
  cert_chain: []
16
- date: 2014-10-29 00:00:00.000000000 Z
15
+ date: 2021-05-05 00:00:00.000000000 Z
17
16
  dependencies:
18
17
  - !ruby/object:Gem::Dependency
19
18
  name: nokogiri
20
19
  requirement: !ruby/object:Gem::Requirement
21
- none: false
22
20
  requirements:
23
- - - ~>
21
+ - - "~>"
24
22
  - !ruby/object:Gem::Version
25
- version: '1.5'
23
+ version: '1.10'
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.10.4
26
27
  type: :runtime
27
28
  prerelease: false
28
29
  version_requirements: !ruby/object:Gem::Requirement
29
- none: false
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ - - ">="
32
35
  - !ruby/object:Gem::Version
33
- version: '1.5'
36
+ version: 1.10.4
34
37
  - !ruby/object:Gem::Dependency
35
38
  name: rubyzip
36
39
  requirement: !ruby/object:Gem::Requirement
37
- none: false
38
40
  requirements:
39
- - - ~>
41
+ - - "~>"
40
42
  - !ruby/object:Gem::Version
41
- version: 1.1.6
43
+ version: '2.0'
42
44
  type: :runtime
43
45
  prerelease: false
44
46
  version_requirements: !ruby/object:Gem::Requirement
45
- none: false
46
47
  requirements:
47
- - - ~>
48
+ - - "~>"
48
49
  - !ruby/object:Gem::Version
49
- version: 1.1.6
50
+ version: '2.0'
51
+ - !ruby/object:Gem::Dependency
52
+ name: coveralls_reborn
53
+ requirement: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '0.21'
58
+ type: :development
59
+ prerelease: false
60
+ version_requirements: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - "~>"
63
+ - !ruby/object:Gem::Version
64
+ version: '0.21'
65
+ - !ruby/object:Gem::Dependency
66
+ name: rake
67
+ requirement: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '13.0'
72
+ type: :development
73
+ prerelease: false
74
+ version_requirements: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - "~>"
77
+ - !ruby/object:Gem::Version
78
+ version: '13.0'
50
79
  - !ruby/object:Gem::Dependency
51
80
  name: rspec
52
81
  requirement: !ruby/object:Gem::Requirement
53
- none: false
54
82
  requirements:
55
- - - ! '>='
83
+ - - "~>"
56
84
  - !ruby/object:Gem::Version
57
- version: '0'
85
+ version: '3.7'
58
86
  type: :development
59
87
  prerelease: false
60
88
  version_requirements: !ruby/object:Gem::Requirement
61
- none: false
62
89
  requirements:
63
- - - ! '>='
90
+ - - "~>"
64
91
  - !ruby/object:Gem::Version
65
- version: '0'
66
- description: a ruby library/gem for interacting with .docx files
92
+ version: '3.7'
93
+ description: thin wrapper around rubyzip and nokogiri as a way to get started with
94
+ docx files
67
95
  email:
68
96
  - chrahunt@gmail.com
69
97
  executables: []
70
98
  extensions: []
71
99
  extra_rdoc_files: []
72
100
  files:
73
- - README.md
74
101
  - LICENSE.md
102
+ - README.md
103
+ - lib/docx.rb
104
+ - lib/docx/containers.rb
75
105
  - lib/docx/containers/container.rb
76
106
  - lib/docx/containers/paragraph.rb
77
107
  - lib/docx/containers/table.rb
@@ -79,38 +109,34 @@ files:
79
109
  - lib/docx/containers/table_column.rb
80
110
  - lib/docx/containers/table_row.rb
81
111
  - lib/docx/containers/text_run.rb
82
- - lib/docx/containers.rb
83
112
  - lib/docx/core_ext/module.rb
84
113
  - lib/docx/document.rb
114
+ - lib/docx/elements.rb
85
115
  - lib/docx/elements/bookmark.rb
86
116
  - lib/docx/elements/element.rb
87
117
  - lib/docx/elements/text.rb
88
- - lib/docx/elements.rb
89
118
  - lib/docx/version.rb
90
- - lib/docx.rb
91
119
  homepage: https://github.com/chrahunt/docx
92
- licenses: []
93
- post_install_message:
120
+ licenses:
121
+ - MIT
122
+ metadata: {}
123
+ post_install_message:
94
124
  rdoc_options: []
95
125
  require_paths:
96
126
  - lib
97
127
  required_ruby_version: !ruby/object:Gem::Requirement
98
- none: false
99
128
  requirements:
100
- - - ! '>='
129
+ - - ">="
101
130
  - !ruby/object:Gem::Version
102
- version: '0'
131
+ version: 2.5.0
103
132
  required_rubygems_version: !ruby/object:Gem::Requirement
104
- none: false
105
133
  requirements:
106
- - - ! '>='
134
+ - - ">="
107
135
  - !ruby/object:Gem::Version
108
136
  version: '0'
109
137
  requirements: []
110
- rubyforge_project:
111
- rubygems_version: 1.8.28
112
- signing_key:
113
- specification_version: 3
138
+ rubygems_version: 3.0.3
139
+ signing_key:
140
+ specification_version: 4
114
141
  summary: a ruby library/gem for interacting with .docx files
115
142
  test_files: []
116
- has_rdoc: