berkeley_library-tind 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/build.yml +18 -0
- data/.gitignore +388 -0
- data/.idea/inspectionProfiles/Project_Default.xml +20 -0
- data/.idea/misc.xml +4 -0
- data/.idea/modules.xml +8 -0
- data/.idea/tind.iml +138 -0
- data/.idea/vcs.xml +6 -0
- data/.rubocop.yml +334 -0
- data/.ruby-version +1 -0
- data/.simplecov +8 -0
- data/.yardopts +1 -0
- data/CHANGES.md +58 -0
- data/Dockerfile +57 -0
- data/Gemfile +3 -0
- data/Jenkinsfile +18 -0
- data/LICENSE.md +21 -0
- data/README.md +73 -0
- data/Rakefile +20 -0
- data/berkeley_library-tind.gemspec +50 -0
- data/bin/tind-export +14 -0
- data/docker-compose.yml +15 -0
- data/lib/berkeley_library/tind.rb +3 -0
- data/lib/berkeley_library/tind/api.rb +1 -0
- data/lib/berkeley_library/tind/api/api.rb +132 -0
- data/lib/berkeley_library/tind/api/api_exception.rb +131 -0
- data/lib/berkeley_library/tind/api/collection.rb +82 -0
- data/lib/berkeley_library/tind/api/date_range.rb +67 -0
- data/lib/berkeley_library/tind/api/format.rb +32 -0
- data/lib/berkeley_library/tind/api/search.rb +100 -0
- data/lib/berkeley_library/tind/config.rb +103 -0
- data/lib/berkeley_library/tind/export.rb +1 -0
- data/lib/berkeley_library/tind/export/column.rb +54 -0
- data/lib/berkeley_library/tind/export/column_group.rb +144 -0
- data/lib/berkeley_library/tind/export/column_group_list.rb +131 -0
- data/lib/berkeley_library/tind/export/column_width_calculator.rb +76 -0
- data/lib/berkeley_library/tind/export/config.rb +154 -0
- data/lib/berkeley_library/tind/export/csv_exporter.rb +29 -0
- data/lib/berkeley_library/tind/export/export.rb +47 -0
- data/lib/berkeley_library/tind/export/export_command.rb +168 -0
- data/lib/berkeley_library/tind/export/export_exception.rb +8 -0
- data/lib/berkeley_library/tind/export/export_format.rb +67 -0
- data/lib/berkeley_library/tind/export/exporter.rb +105 -0
- data/lib/berkeley_library/tind/export/filter.rb +52 -0
- data/lib/berkeley_library/tind/export/no_results_error.rb +7 -0
- data/lib/berkeley_library/tind/export/ods_exporter.rb +138 -0
- data/lib/berkeley_library/tind/export/row.rb +24 -0
- data/lib/berkeley_library/tind/export/row_metrics.rb +18 -0
- data/lib/berkeley_library/tind/export/table.rb +175 -0
- data/lib/berkeley_library/tind/export/table_metrics.rb +116 -0
- data/lib/berkeley_library/tind/marc.rb +1 -0
- data/lib/berkeley_library/tind/marc/xml_reader.rb +144 -0
- data/lib/berkeley_library/tind/module_info.rb +14 -0
- data/lib/berkeley_library/util/arrays.rb +178 -0
- data/lib/berkeley_library/util/logging.rb +1 -0
- data/lib/berkeley_library/util/ods/spreadsheet.rb +170 -0
- data/lib/berkeley_library/util/ods/xml/content_doc.rb +26 -0
- data/lib/berkeley_library/util/ods/xml/document_node.rb +57 -0
- data/lib/berkeley_library/util/ods/xml/element_node.rb +106 -0
- data/lib/berkeley_library/util/ods/xml/loext/table_protection.rb +26 -0
- data/lib/berkeley_library/util/ods/xml/manifest/file_entry.rb +42 -0
- data/lib/berkeley_library/util/ods/xml/manifest/manifest.rb +73 -0
- data/lib/berkeley_library/util/ods/xml/manifest_doc.rb +26 -0
- data/lib/berkeley_library/util/ods/xml/namespace.rb +46 -0
- data/lib/berkeley_library/util/ods/xml/office/automatic_styles.rb +181 -0
- data/lib/berkeley_library/util/ods/xml/office/body.rb +17 -0
- data/lib/berkeley_library/util/ods/xml/office/document_content.rb +98 -0
- data/lib/berkeley_library/util/ods/xml/office/document_styles.rb +39 -0
- data/lib/berkeley_library/util/ods/xml/office/font_face_decls.rb +30 -0
- data/lib/berkeley_library/util/ods/xml/office/scripts.rb +17 -0
- data/lib/berkeley_library/util/ods/xml/office/spreadsheet.rb +37 -0
- data/lib/berkeley_library/util/ods/xml/office/styles.rb +39 -0
- data/lib/berkeley_library/util/ods/xml/style/cell_style.rb +58 -0
- data/lib/berkeley_library/util/ods/xml/style/column_style.rb +36 -0
- data/lib/berkeley_library/util/ods/xml/style/default_style.rb +31 -0
- data/lib/berkeley_library/util/ods/xml/style/family.rb +85 -0
- data/lib/berkeley_library/util/ods/xml/style/font_face.rb +46 -0
- data/lib/berkeley_library/util/ods/xml/style/paragraph_properties.rb +30 -0
- data/lib/berkeley_library/util/ods/xml/style/row_style.rb +37 -0
- data/lib/berkeley_library/util/ods/xml/style/style.rb +44 -0
- data/lib/berkeley_library/util/ods/xml/style/table_cell_properties.rb +40 -0
- data/lib/berkeley_library/util/ods/xml/style/table_column_properties.rb +30 -0
- data/lib/berkeley_library/util/ods/xml/style/table_properties.rb +25 -0
- data/lib/berkeley_library/util/ods/xml/style/table_row_properties.rb +28 -0
- data/lib/berkeley_library/util/ods/xml/style/table_style.rb +27 -0
- data/lib/berkeley_library/util/ods/xml/style/text_properties.rb +52 -0
- data/lib/berkeley_library/util/ods/xml/styles_doc.rb +26 -0
- data/lib/berkeley_library/util/ods/xml/table/named_expressions.rb +17 -0
- data/lib/berkeley_library/util/ods/xml/table/repeatable.rb +38 -0
- data/lib/berkeley_library/util/ods/xml/table/table.rb +193 -0
- data/lib/berkeley_library/util/ods/xml/table/table_cell.rb +46 -0
- data/lib/berkeley_library/util/ods/xml/table/table_column.rb +43 -0
- data/lib/berkeley_library/util/ods/xml/table/table_row.rb +136 -0
- data/lib/berkeley_library/util/ods/xml/text/p.rb +118 -0
- data/lib/berkeley_library/util/paths.rb +111 -0
- data/lib/berkeley_library/util/stringios.rb +30 -0
- data/lib/berkeley_library/util/strings.rb +42 -0
- data/lib/berkeley_library/util/sys_exits.rb +15 -0
- data/lib/berkeley_library/util/times.rb +22 -0
- data/lib/berkeley_library/util/uris.rb +44 -0
- data/lib/berkeley_library/util/uris/appender.rb +162 -0
- data/lib/berkeley_library/util/uris/requester.rb +62 -0
- data/lib/berkeley_library/util/uris/validator.rb +32 -0
- data/rakelib/bundle.rake +8 -0
- data/rakelib/coverage.rake +11 -0
- data/rakelib/gem.rake +54 -0
- data/rakelib/rubocop.rake +18 -0
- data/rakelib/spec.rake +2 -0
- data/spec/.rubocop.yml +40 -0
- data/spec/berkeley_library/tind/api/api_exception_spec.rb +91 -0
- data/spec/berkeley_library/tind/api/api_spec.rb +143 -0
- data/spec/berkeley_library/tind/api/collection_spec.rb +74 -0
- data/spec/berkeley_library/tind/api/date_range_spec.rb +110 -0
- data/spec/berkeley_library/tind/api/format_spec.rb +54 -0
- data/spec/berkeley_library/tind/api/search_spec.rb +364 -0
- data/spec/berkeley_library/tind/config_spec.rb +86 -0
- data/spec/berkeley_library/tind/export/column_group_spec.rb +29 -0
- data/spec/berkeley_library/tind/export/column_spec.rb +43 -0
- data/spec/berkeley_library/tind/export/config_spec.rb +206 -0
- data/spec/berkeley_library/tind/export/export_command_spec.rb +169 -0
- data/spec/berkeley_library/tind/export/export_format_spec.rb +59 -0
- data/spec/berkeley_library/tind/export/export_matcher.rb +112 -0
- data/spec/berkeley_library/tind/export/export_spec.rb +150 -0
- data/spec/berkeley_library/tind/export/exporter_spec.rb +125 -0
- data/spec/berkeley_library/tind/export/row_spec.rb +118 -0
- data/spec/berkeley_library/tind/export/table_spec.rb +322 -0
- data/spec/berkeley_library/tind/marc/xml_reader_spec.rb +93 -0
- data/spec/berkeley_library/util/arrays_spec.rb +340 -0
- data/spec/berkeley_library/util/ods/spreadsheet_spec.rb +124 -0
- data/spec/berkeley_library/util/ods/xml/content_doc_spec.rb +121 -0
- data/spec/berkeley_library/util/ods/xml/manifest/file_entry_spec.rb +27 -0
- data/spec/berkeley_library/util/ods/xml/manifest/manifest_spec.rb +33 -0
- data/spec/berkeley_library/util/ods/xml/office/document_content_spec.rb +60 -0
- data/spec/berkeley_library/util/ods/xml/style/automatic_styles_spec.rb +37 -0
- data/spec/berkeley_library/util/ods/xml/style/family_spec.rb +57 -0
- data/spec/berkeley_library/util/ods/xml/table/table_row_spec.rb +179 -0
- data/spec/berkeley_library/util/ods/xml/table/table_spec.rb +218 -0
- data/spec/berkeley_library/util/paths_spec.rb +90 -0
- data/spec/berkeley_library/util/stringios_spec.rb +34 -0
- data/spec/berkeley_library/util/strings_spec.rb +27 -0
- data/spec/berkeley_library/util/times_spec.rb +39 -0
- data/spec/berkeley_library/util/uris_spec.rb +118 -0
- data/spec/data/collection-names.txt +438 -0
- data/spec/data/collections.json +4827 -0
- data/spec/data/disjoint-records.xml +187 -0
- data/spec/data/record-184453.xml +58 -0
- data/spec/data/record-184458.xml +63 -0
- data/spec/data/record-187888.xml +78 -0
- data/spec/data/records-api-search-cjk-p1.xml +6381 -0
- data/spec/data/records-api-search-cjk-p2.xml +5 -0
- data/spec/data/records-api-search-p1.xml +4506 -0
- data/spec/data/records-api-search-p2.xml +4509 -0
- data/spec/data/records-api-search-p3.xml +4506 -0
- data/spec/data/records-api-search-p4.xml +4509 -0
- data/spec/data/records-api-search-p5.xml +4506 -0
- data/spec/data/records-api-search-p6.xml +2436 -0
- data/spec/data/records-api-search-p7.xml +5 -0
- data/spec/data/records-api-search.xml +234 -0
- data/spec/data/records-manual-search.xml +547 -0
- data/spec/spec_helper.rb +30 -0
- data/test/profile/table_from_records_profile.rb +46 -0
- metadata +585 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'berkeley_library/util/ods/xml/element_node'
|
2
|
+
|
3
|
+
module BerkeleyLibrary
|
4
|
+
module Util
|
5
|
+
module ODS
|
6
|
+
module XML
|
7
|
+
module Style
|
8
|
+
class FontFace < XML::ElementNode
|
9
|
+
DEFAULT_FONT_FACE = 'Liberation Sans'.freeze
|
10
|
+
|
11
|
+
attr_reader :name, :svg_family, :family_generic, :font_pitch
|
12
|
+
|
13
|
+
def initialize(name, doc:, svg_family: nil, family_generic: nil, font_pitch: nil)
|
14
|
+
super(:style, 'font-face', doc: doc)
|
15
|
+
|
16
|
+
set_attribute('name', name)
|
17
|
+
set_attribute(:svg, 'font-family', svg_family || to_family(name))
|
18
|
+
set_attribute('font-family-generic', family_generic) if family_generic
|
19
|
+
set_attribute('font-pitch', font_pitch) if font_pitch
|
20
|
+
end
|
21
|
+
|
22
|
+
class << self
|
23
|
+
def default_face(doc:)
|
24
|
+
FontFace.new(FontFace::DEFAULT_FONT_FACE, family_generic: 'swiss', font_pitch: 'variable', doc: doc)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def to_family(name)
|
31
|
+
# TODO: https://www.w3.org/TR/CSS2/syndata.html#value-def-identifier
|
32
|
+
name =~ /^[[:alpha:]][[:alnum:]]*$/ ? name : quote_name(name)
|
33
|
+
end
|
34
|
+
|
35
|
+
def quote_name(name)
|
36
|
+
return name.inspect if name.include?("'")
|
37
|
+
|
38
|
+
"'#{name}'"
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'berkeley_library/util/ods/xml/element_node'
|
2
|
+
|
3
|
+
module BerkeleyLibrary
|
4
|
+
module Util
|
5
|
+
module ODS
|
6
|
+
module XML
|
7
|
+
module Style
|
8
|
+
class ParagraphProperties < ElementNode
|
9
|
+
|
10
|
+
DEFAULT_TAB_STOP_DISTANCE = '0.5in'.freeze
|
11
|
+
|
12
|
+
attr_reader :tab_stop_distance
|
13
|
+
|
14
|
+
def initialize(tab_stop_distance = DEFAULT_TAB_STOP_DISTANCE, doc:)
|
15
|
+
super(:style, 'paragraph-properties', doc: doc)
|
16
|
+
@tab_stop_distance = tab_stop_distance
|
17
|
+
set_default_attributes!
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def set_default_attributes!
|
23
|
+
set_attribute('tab-stop-distance', tab_stop_distance)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'berkeley_library/util/ods/xml/style/style'
|
2
|
+
require 'berkeley_library/util/ods/xml/style/table_row_properties'
|
3
|
+
|
4
|
+
module BerkeleyLibrary
|
5
|
+
module Util
|
6
|
+
module ODS
|
7
|
+
module XML
|
8
|
+
module Style
|
9
|
+
class RowStyle < Style
|
10
|
+
|
11
|
+
DEFAULT_HEIGHT = '0.25in'.freeze
|
12
|
+
|
13
|
+
attr_reader :height
|
14
|
+
|
15
|
+
# Initializes a new cell style. Note that this should not be called
|
16
|
+
# directly, but only from {XML::Office::AutomaticStyles#add_row_style}.
|
17
|
+
#
|
18
|
+
# @param name [String] the name of the style
|
19
|
+
# @param height [String] the row height
|
20
|
+
# @param styles [XML::Office::AutomaticStyles] the document styles
|
21
|
+
def initialize(name, height = nil, styles:)
|
22
|
+
super(name, :table_row, doc: styles.doc)
|
23
|
+
@height = height || DEFAULT_HEIGHT
|
24
|
+
add_default_children!
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def add_default_children!
|
30
|
+
children << TableRowProperties.new(height, doc: doc)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'berkeley_library/util/ods/xml/element_node'
|
2
|
+
require 'berkeley_library/util/ods/xml/style/family'
|
3
|
+
|
4
|
+
module BerkeleyLibrary
|
5
|
+
module Util
|
6
|
+
module ODS
|
7
|
+
module XML
|
8
|
+
module Style
|
9
|
+
class Style < XML::ElementNode
|
10
|
+
include Comparable
|
11
|
+
|
12
|
+
attr_reader :style_name, :family
|
13
|
+
|
14
|
+
def initialize(style_name, family, doc:)
|
15
|
+
super(:style, 'style', doc: doc)
|
16
|
+
|
17
|
+
@style_name = style_name
|
18
|
+
@family = Family.ensure_family(family)
|
19
|
+
|
20
|
+
set_default_attributes!
|
21
|
+
end
|
22
|
+
|
23
|
+
def <=>(other)
|
24
|
+
return 0 if other.equal?(self)
|
25
|
+
return nil unless other.instance_of?(self.class)
|
26
|
+
|
27
|
+
s_index, o_index = [style_name, other.style_name].map { |n| family.index_part(n) }
|
28
|
+
return style_name <=> other.style_name unless s_index && o_index
|
29
|
+
|
30
|
+
s_index <=> o_index
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def set_default_attributes!
|
36
|
+
set_attribute('name', style_name)
|
37
|
+
set_attribute('family', family)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'berkeley_library/util/ods/xml/element_node'
|
2
|
+
|
3
|
+
module BerkeleyLibrary
|
4
|
+
module Util
|
5
|
+
module ODS
|
6
|
+
module XML
|
7
|
+
module Style
|
8
|
+
class TableCellProperties < ElementNode
|
9
|
+
|
10
|
+
# rubocop:disable Style/KeywordParametersOrder
|
11
|
+
def initialize(protected, wrap: false, doc:)
|
12
|
+
super(:style, 'table-cell-properties', doc: doc)
|
13
|
+
@protected = protected
|
14
|
+
@wrap = wrap
|
15
|
+
set_default_attributes!
|
16
|
+
end
|
17
|
+
# rubocop:enable Style/KeywordParametersOrder
|
18
|
+
|
19
|
+
def protected?
|
20
|
+
@protected
|
21
|
+
end
|
22
|
+
|
23
|
+
def wrap?
|
24
|
+
@wrap
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def set_default_attributes!
|
30
|
+
set_attribute(:style, 'cell-protect', protected? ? 'protected' : 'none')
|
31
|
+
set_attribute(:style, 'vertical-align', 'top')
|
32
|
+
set_attribute('print-content', 'true')
|
33
|
+
set_attribute(:fo, 'wrap-option', 'wrap') if wrap?
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'berkeley_library/util/ods/xml/element_node'
|
2
|
+
|
3
|
+
module BerkeleyLibrary
|
4
|
+
module Util
|
5
|
+
module ODS
|
6
|
+
module XML
|
7
|
+
module Style
|
8
|
+
class TableRowProperties < ElementNode
|
9
|
+
attr_reader :height
|
10
|
+
|
11
|
+
def initialize(height, doc:)
|
12
|
+
super(:style, 'table-row-properties', doc: doc)
|
13
|
+
@height = height
|
14
|
+
|
15
|
+
set_default_attributes!
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def set_default_attributes!
|
21
|
+
set_attribute('row-height', height)
|
22
|
+
set_attribute(:fo, 'break-before', 'auto')
|
23
|
+
set_attribute('use-optimal-row-height', 'true')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'berkeley_library/util/ods/xml/element_node'
|
2
|
+
|
3
|
+
module BerkeleyLibrary
|
4
|
+
module Util
|
5
|
+
module ODS
|
6
|
+
module XML
|
7
|
+
module Style
|
8
|
+
class TableProperties < ElementNode
|
9
|
+
def initialize(doc:)
|
10
|
+
super(:style, 'table-properties', doc: doc)
|
11
|
+
set_default_attributes!
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def set_default_attributes!
|
17
|
+
set_attribute(:table, 'display', 'true')
|
18
|
+
set_attribute('writing-mode', 'lr-tb')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'berkeley_library/util/ods/xml/element_node'
|
2
|
+
|
3
|
+
module BerkeleyLibrary
|
4
|
+
module Util
|
5
|
+
module ODS
|
6
|
+
module XML
|
7
|
+
module Style
|
8
|
+
class TableColumnProperties < ElementNode
|
9
|
+
attr_reader :width
|
10
|
+
|
11
|
+
def initialize(width, doc:)
|
12
|
+
super(:style, 'table-column-properties', doc: doc)
|
13
|
+
@width = width
|
14
|
+
set_default_attributes!
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def set_default_attributes!
|
20
|
+
set_attribute(:fo, 'break-before', 'auto')
|
21
|
+
set_attribute('column-width', width)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'berkeley_library/util/ods/xml/style/style'
|
2
|
+
require 'berkeley_library/util/ods/xml/style/family'
|
3
|
+
require 'berkeley_library/util/ods/xml/style/table_properties'
|
4
|
+
|
5
|
+
module BerkeleyLibrary
|
6
|
+
module Util
|
7
|
+
module ODS
|
8
|
+
module XML
|
9
|
+
module Style
|
10
|
+
class TableStyle < Style
|
11
|
+
# Initializes a new table style. Note that this should not be called
|
12
|
+
# directly, but only from {XML::Office::AutomaticStyles#add_table_style}.
|
13
|
+
#
|
14
|
+
# @param name [String] the name of the style
|
15
|
+
# @param styles [XML::Office::AutomaticStyles] the document styles
|
16
|
+
def initialize(name, styles:)
|
17
|
+
super(name, :table, doc: styles.doc)
|
18
|
+
|
19
|
+
set_attribute('master-page-name', 'Default')
|
20
|
+
children << TableProperties.new(doc: doc)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'berkeley_library/util/ods/xml/element_node'
|
2
|
+
|
3
|
+
module BerkeleyLibrary
|
4
|
+
module Util
|
5
|
+
module ODS
|
6
|
+
module XML
|
7
|
+
module Style
|
8
|
+
class TextProperties < ElementNode
|
9
|
+
|
10
|
+
FONT_WEIGHT_ATTRS = %w[font-weight font-weight-asian font-weight-complex].freeze
|
11
|
+
COLOR_RE = /^#[[:xdigit:]]{6}$/.freeze
|
12
|
+
|
13
|
+
attr_reader :color, :font_name, :language, :country, :font_weight
|
14
|
+
|
15
|
+
# rubocop:disable Metrics/ParameterLists, Style/KeywordParametersOrder
|
16
|
+
def initialize(color: nil, font_name: nil, font_weight: nil, language: 'en', country: 'US', doc:)
|
17
|
+
super(:style, 'text-properties', doc: doc)
|
18
|
+
@color = ensure_color(color)
|
19
|
+
@font_name = font_name
|
20
|
+
@language = language
|
21
|
+
@country = country
|
22
|
+
@font_weight = font_weight
|
23
|
+
set_default_attributes!
|
24
|
+
end
|
25
|
+
# rubocop:enable Metrics/ParameterLists, Style/KeywordParametersOrder
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def set_default_attributes!
|
30
|
+
set_attribute('font-name', font_name) if font_name
|
31
|
+
set_attribute(:fo, 'language', language) if language
|
32
|
+
set_attribute(:fo, 'country', country) if country
|
33
|
+
set_attribute(:fo, 'color', color) if color
|
34
|
+
set_font_weight_attributes!
|
35
|
+
end
|
36
|
+
|
37
|
+
def set_font_weight_attributes!
|
38
|
+
FONT_WEIGHT_ATTRS.each { |attr| set_attribute(:fo, attr, font_weight) } if font_weight
|
39
|
+
end
|
40
|
+
|
41
|
+
def ensure_color(color)
|
42
|
+
return unless color
|
43
|
+
raise ArgumentError, "Not a valid hex color: #{color.inspect}" unless color =~ COLOR_RE
|
44
|
+
|
45
|
+
color.downcase
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'berkeley_library/util/ods/xml/document_node'
|
3
|
+
require 'berkeley_library/util/ods/xml/office/document_styles'
|
4
|
+
|
5
|
+
module BerkeleyLibrary
|
6
|
+
module Util
|
7
|
+
module ODS
|
8
|
+
module XML
|
9
|
+
class StylesDoc < DocumentNode
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
super('styles.xml')
|
13
|
+
end
|
14
|
+
|
15
|
+
def root_element_node
|
16
|
+
document_styles
|
17
|
+
end
|
18
|
+
|
19
|
+
def document_styles
|
20
|
+
@document_styles ||= Office::DocumentStyles.new(doc: doc)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'berkeley_library/util/ods/xml/element_node'
|
2
|
+
|
3
|
+
module BerkeleyLibrary
|
4
|
+
module Util
|
5
|
+
module ODS
|
6
|
+
module XML
|
7
|
+
module Table
|
8
|
+
class NamedExpressions < XML::ElementNode
|
9
|
+
def initialize(doc:)
|
10
|
+
super(:table, 'named-expressions', doc: doc)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module BerkeleyLibrary
|
2
|
+
module Util
|
3
|
+
module ODS
|
4
|
+
module XML
|
5
|
+
module Table
|
6
|
+
class Repeatable < XML::ElementNode
|
7
|
+
|
8
|
+
attr_reader :table, :attr_name_num_repeated, :number_repeated
|
9
|
+
|
10
|
+
def initialize(name, attr_name_num_repeated, number_repeated, table:)
|
11
|
+
super(:table, name, doc: table.doc)
|
12
|
+
@table = table
|
13
|
+
@attr_name_num_repeated = attr_name_num_repeated
|
14
|
+
self.number_repeated = number_repeated
|
15
|
+
end
|
16
|
+
|
17
|
+
def number_repeated=(value)
|
18
|
+
raise ArgumentError, "Invalid number of repeats: #{value.inspect} => #{value.to_i}" if (repeats = value.to_i) <= 0
|
19
|
+
|
20
|
+
if repeats == 1
|
21
|
+
clear_attribute(attr_name_num_repeated)
|
22
|
+
else
|
23
|
+
set_attribute(attr_name_num_repeated, repeats)
|
24
|
+
end
|
25
|
+
|
26
|
+
@number_repeated = repeats
|
27
|
+
end
|
28
|
+
|
29
|
+
def increment_repeats!
|
30
|
+
self.number_repeated += 1
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|