redmine_api_helper 0.3.35
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of redmine_api_helper might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/.gitattributes +2 -0
- data/.gitignore +11 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE +339 -0
- data/README.md +30 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/date_helper/date.rb +311 -0
- data/lib/odf_writer/bookmark.rb +110 -0
- data/lib/odf_writer/bookmark_reader.rb +77 -0
- data/lib/odf_writer/document.rb +371 -0
- data/lib/odf_writer/field.rb +174 -0
- data/lib/odf_writer/field_reader.rb +78 -0
- data/lib/odf_writer/image.rb +176 -0
- data/lib/odf_writer/image_reader.rb +76 -0
- data/lib/odf_writer/images.rb +89 -0
- data/lib/odf_writer/list_style.rb +336 -0
- data/lib/odf_writer/nested.rb +156 -0
- data/lib/odf_writer/odf_helper.rb +57 -0
- data/lib/odf_writer/parser/default.rb +691 -0
- data/lib/odf_writer/path_finder.rb +114 -0
- data/lib/odf_writer/section.rb +120 -0
- data/lib/odf_writer/section_reader.rb +61 -0
- data/lib/odf_writer/style.rb +483 -0
- data/lib/odf_writer/table.rb +135 -0
- data/lib/odf_writer/table_reader.rb +61 -0
- data/lib/odf_writer/template.rb +234 -0
- data/lib/odf_writer/text.rb +97 -0
- data/lib/odf_writer/text_reader.rb +77 -0
- data/lib/odf_writer/version.rb +29 -0
- data/lib/redmine_api_helper/api_helper.rb +333 -0
- data/lib/redmine_api_helper/args_helper.rb +106 -0
- data/lib/redmine_api_helper/attachments_api_helper.rb +52 -0
- data/lib/redmine_api_helper/define_api_helpers.rb +78 -0
- data/lib/redmine_api_helper/document_categories_api_helper.rb +38 -0
- data/lib/redmine_api_helper/groups_api_helper.rb +80 -0
- data/lib/redmine_api_helper/helpers.rb +50 -0
- data/lib/redmine_api_helper/issue_priorities_api_helper.rb +38 -0
- data/lib/redmine_api_helper/issue_relations_api_helper.rb +66 -0
- data/lib/redmine_api_helper/issue_statuses_api_helper.rb +36 -0
- data/lib/redmine_api_helper/issues_api_helper.rb +124 -0
- data/lib/redmine_api_helper/my_account_api_helper.rb +45 -0
- data/lib/redmine_api_helper/news_api_helper.rb +73 -0
- data/lib/redmine_api_helper/project_memberships_api_helper.rb +77 -0
- data/lib/redmine_api_helper/projects_api_helper.rb +73 -0
- data/lib/redmine_api_helper/roles_api_helper.rb +52 -0
- data/lib/redmine_api_helper/scripts_api_helper.rb +87 -0
- data/lib/redmine_api_helper/search_api_helper.rb +38 -0
- data/lib/redmine_api_helper/time_entries_api_helper.rb +73 -0
- data/lib/redmine_api_helper/time_entry_activities_api_helper.rb +38 -0
- data/lib/redmine_api_helper/trackers_api_helper.rb +38 -0
- data/lib/redmine_api_helper/users_api_helper.rb +73 -0
- data/lib/redmine_api_helper/version.rb +24 -0
- data/lib/redmine_api_helper/wiki_pages_api_helper.rb +66 -0
- data/lib/redmine_api_helper.rb +88 -0
- data/redmine_api_helper.gemspec +36 -0
- metadata +162 -0
@@ -0,0 +1,114 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# Ruby Gem to create a self populating Open Document Format (.odf) text file.
|
4
|
+
#
|
5
|
+
# Copyright 2021 Stephan Wenzel <stephan.wenzel@drwpatent.de>
|
6
|
+
#
|
7
|
+
# This program is free software; you can redistribute it and/or
|
8
|
+
# modify it under the terms of the GNU General Public License
|
9
|
+
# as published by the Free Software Foundation; either version 2
|
10
|
+
# of the License, or (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program; if not, write to the Free Software
|
19
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
20
|
+
#
|
21
|
+
|
22
|
+
module ODFWriter
|
23
|
+
|
24
|
+
########################################################################################
|
25
|
+
#
|
26
|
+
# PathFinder: find all fields and set name
|
27
|
+
#
|
28
|
+
########################################################################################
|
29
|
+
class PathFinder
|
30
|
+
|
31
|
+
######################################################################################
|
32
|
+
#
|
33
|
+
# constants
|
34
|
+
#
|
35
|
+
######################################################################################
|
36
|
+
IGNORE = {
|
37
|
+
:fields => /\A_/,
|
38
|
+
:texts => /\A_/,
|
39
|
+
:bookmarks => /\A_/,
|
40
|
+
:images => /\A_/,
|
41
|
+
:tables => /\A_|\ATable/i,
|
42
|
+
:sections => /\A_|\ASection/i
|
43
|
+
}.freeze
|
44
|
+
|
45
|
+
class << self
|
46
|
+
####################################################################################
|
47
|
+
#
|
48
|
+
# trail: find path in odt document, whereby only sections and tabes are searched as ancestors
|
49
|
+
#
|
50
|
+
# node: Nokogiri node
|
51
|
+
# leaf: hash, f.i. {:fields => ["NAME", "STREET", "ZIP", "PLACE"]}
|
52
|
+
#
|
53
|
+
# options:
|
54
|
+
# :root => :content | :styles, defaults to :root
|
55
|
+
# :paths => :auto vivifying-hash, defaults to it
|
56
|
+
#
|
57
|
+
####################################################################################
|
58
|
+
def trail( node, leaf, options={})
|
59
|
+
|
60
|
+
# ignore
|
61
|
+
ignore = IGNORE.merge(options[:ignore].to_h)
|
62
|
+
|
63
|
+
# determine root
|
64
|
+
root = options[:root] || :root
|
65
|
+
|
66
|
+
# create auto-vivifying hash
|
67
|
+
paths = options[:paths] || Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }
|
68
|
+
|
69
|
+
# for tables and sections add level with node name
|
70
|
+
ancestors = node.ancestors.reverse.select{|ancestor| %w(section table).include?(ancestor.name)}
|
71
|
+
|
72
|
+
path = [:files, root] + ancestors.map do |ancestor|
|
73
|
+
filter_node(ancestor, ignore)
|
74
|
+
end.flatten #map
|
75
|
+
|
76
|
+
# add each field in a nested hash
|
77
|
+
paths.dig(*path)[leaf.keys.first] = paths.dig(*path)[leaf.keys.first].presence || [] # cannot do '||=''
|
78
|
+
paths.dig(*path)[leaf.keys.first] += filter_leafs(leaf, ignore)
|
79
|
+
paths
|
80
|
+
end #def
|
81
|
+
|
82
|
+
###################################################################################
|
83
|
+
#
|
84
|
+
# private
|
85
|
+
#
|
86
|
+
###################################################################################
|
87
|
+
private
|
88
|
+
|
89
|
+
def filter_node(node, ignore)
|
90
|
+
case node.name
|
91
|
+
when "section"
|
92
|
+
node.attr("text:name").to_s.match?(Regexp.new(ignore[:sections].to_s)) ? [] : [:sections, node.attr("text:name")]
|
93
|
+
when "table"
|
94
|
+
node.attr("table:name").to_s.match?(Regexp.new(ignore[:tables].to_s)) ? [] : [:tables, node.attr("table:name")]
|
95
|
+
else
|
96
|
+
[]
|
97
|
+
end #case
|
98
|
+
end #def
|
99
|
+
|
100
|
+
def filter_leafs(leaf, ignore)
|
101
|
+
case leaf.keys.first
|
102
|
+
when :fields
|
103
|
+
Array(leaf.values.first).select{|val| !val.match?(Regexp.new(ignore[:fields].to_s))}
|
104
|
+
when :texts
|
105
|
+
Array(leaf.values.first).select{|val| !val.match?(Regexp.new(ignore[:texts].to_s))}
|
106
|
+
when :bookmarks
|
107
|
+
Array(leaf.values.first).select{|val| !val.match?(Regexp.new(ignore[:bookmarks].to_s))}
|
108
|
+
when :images
|
109
|
+
Array(leaf.values.first).select{|val| !val.match?(Regexp.new(ignore[:images].to_s))}
|
110
|
+
end #case
|
111
|
+
end #def
|
112
|
+
end #self
|
113
|
+
end #class
|
114
|
+
end #module
|
@@ -0,0 +1,120 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# Ruby Gem to create a self populating Open Document Format (.odf) text file.
|
4
|
+
#
|
5
|
+
# Copyright 2021 Stephan Wenzel <stephan.wenzel@drwpatent.de>
|
6
|
+
#
|
7
|
+
# This program is free software; you can redistribute it and/or
|
8
|
+
# modify it under the terms of the GNU General Public License
|
9
|
+
# as published by the Free Software Foundation; either version 2
|
10
|
+
# of the License, or (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program; if not, write to the Free Software
|
19
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
20
|
+
#
|
21
|
+
|
22
|
+
module ODFWriter
|
23
|
+
|
24
|
+
########################################################################################
|
25
|
+
#
|
26
|
+
# Section: poulate and grow sections
|
27
|
+
#
|
28
|
+
########################################################################################
|
29
|
+
class Section
|
30
|
+
include Nested
|
31
|
+
|
32
|
+
attr_accessor :name, :collection, :proc
|
33
|
+
|
34
|
+
######################################################################################
|
35
|
+
#
|
36
|
+
# initialize
|
37
|
+
#
|
38
|
+
######################################################################################
|
39
|
+
def initialize(options)
|
40
|
+
@name = options[:name]
|
41
|
+
@field = options[:field]
|
42
|
+
@key = @field || @name
|
43
|
+
@collection = options[:collection]
|
44
|
+
@proc = options[:proc]
|
45
|
+
|
46
|
+
@fields = []
|
47
|
+
@bookmarks = []
|
48
|
+
@images = []
|
49
|
+
@texts = []
|
50
|
+
@tables = []
|
51
|
+
@sections = []
|
52
|
+
end #def
|
53
|
+
|
54
|
+
######################################################################################
|
55
|
+
#
|
56
|
+
# get_section_content
|
57
|
+
#
|
58
|
+
######################################################################################
|
59
|
+
def get_section_content( doc )
|
60
|
+
return unless @section_node = find_section_node(doc)
|
61
|
+
@section_node.content
|
62
|
+
end #def
|
63
|
+
|
64
|
+
######################################################################################
|
65
|
+
#
|
66
|
+
# replace!
|
67
|
+
#
|
68
|
+
######################################################################################
|
69
|
+
def replace!(doc, manifest, file, row = nil)
|
70
|
+
|
71
|
+
return unless @section_node = find_section_node(doc)
|
72
|
+
|
73
|
+
@collection = items(row, @key, @proc) if row
|
74
|
+
|
75
|
+
@collection.each do |item|
|
76
|
+
|
77
|
+
new_section = get_section_node
|
78
|
+
#
|
79
|
+
# experimental: new node must be added to doc prior to replace!
|
80
|
+
# else new_section does not have a name space
|
81
|
+
#
|
82
|
+
@section_node.before(new_section)
|
83
|
+
|
84
|
+
@tables.each { |t| t.replace!(new_section, manifest, file, item) }
|
85
|
+
@sections.each { |s| s.replace!(new_section, manifest, file, item) }
|
86
|
+
@texts.each { |t| t.replace!(new_section, item) }
|
87
|
+
@fields.each { |f| f.replace!(new_section, item) }
|
88
|
+
@bookmarks.each { |b| b.replace!(new_section, item) }
|
89
|
+
@images.each { |b| b.replace!(new_section, manifest, file, item) }
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
Image.unique_image_names( doc) if @images.present?
|
94
|
+
|
95
|
+
@section_node.remove
|
96
|
+
|
97
|
+
end #def
|
98
|
+
|
99
|
+
######################################################################################
|
100
|
+
#
|
101
|
+
# private
|
102
|
+
#
|
103
|
+
######################################################################################
|
104
|
+
private
|
105
|
+
|
106
|
+
def find_section_node(doc)
|
107
|
+
sections = doc.xpath(".//text:section[@text:name='#{@name}']")
|
108
|
+
sections.empty? ? nil : sections.first
|
109
|
+
end #def
|
110
|
+
|
111
|
+
def get_section_node
|
112
|
+
node = @section_node.dup
|
113
|
+
name = node.get_attribute('text:name').to_s
|
114
|
+
@idx ||=0; @idx +=1
|
115
|
+
node.set_attribute('text:name', "#{name}_#{@idx}")
|
116
|
+
node
|
117
|
+
end #def
|
118
|
+
|
119
|
+
end #class
|
120
|
+
end #module
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# Ruby Gem to create a self populating Open Document Format (.odf) text file.
|
4
|
+
#
|
5
|
+
# Copyright 2021 Stephan Wenzel <stephan.wenzel@drwpatent.de>
|
6
|
+
#
|
7
|
+
# This program is free software; you can redistribute it and/or
|
8
|
+
# modify it under the terms of the GNU General Public License
|
9
|
+
# as published by the Free Software Foundation; either version 2
|
10
|
+
# of the License, or (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program; if not, write to the Free Software
|
19
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
20
|
+
#
|
21
|
+
|
22
|
+
module ODFWriter
|
23
|
+
|
24
|
+
########################################################################################
|
25
|
+
#
|
26
|
+
# SectionReader: find all sections and set name
|
27
|
+
#
|
28
|
+
########################################################################################
|
29
|
+
class SectionReader
|
30
|
+
|
31
|
+
attr_accessor :name
|
32
|
+
|
33
|
+
######################################################################################
|
34
|
+
#
|
35
|
+
# initialize
|
36
|
+
#
|
37
|
+
######################################################################################
|
38
|
+
def initialize(opts)
|
39
|
+
@name = opts[:name]
|
40
|
+
end #def
|
41
|
+
|
42
|
+
######################################################################################
|
43
|
+
#
|
44
|
+
# sections
|
45
|
+
#
|
46
|
+
######################################################################################
|
47
|
+
def sections( doc )
|
48
|
+
nodes( doc ).keys
|
49
|
+
end #def
|
50
|
+
|
51
|
+
######################################################################################
|
52
|
+
#
|
53
|
+
# nodes
|
54
|
+
#
|
55
|
+
######################################################################################
|
56
|
+
def nodes( doc )
|
57
|
+
doc.xpath(".//text:section").map{|node| [node.attr("text:name"), node] }.to_h
|
58
|
+
end #def
|
59
|
+
|
60
|
+
end #class
|
61
|
+
end #module
|