nokogiri_schematron_builder 0.1.0 → 0.1.3

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: 24f02a10a7493555198daad2202e63376d1e7bbc9af7b91c79318d4c36239c41
4
- data.tar.gz: 9bf5e2b1ac5e0e6a7949bcef45331e8277a823a13cecb5b8c387ccdadee41c34
3
+ metadata.gz: 35ab25309264d992dcaeb53e7ba9e5d464a38c48cea1c34f1516ea21e97529e9
4
+ data.tar.gz: b2a4b40c93cda3d52c9e7e740ad2b13489f89efbc14077322881fe13fa2f3556
5
5
  SHA512:
6
- metadata.gz: babe38706760546dfbb24513d9a9453c4156769837279c75967a253e8fd5bea48fb101c014c25299973e960d59d280dc5de5413a2ce63aac80de9a64320a4928
7
- data.tar.gz: 175f4df54fa99d350c8823519c3d22c68be65c5912f98bf4605b949580bbd803590ffe703a6aa662d4a47509aff00a0439b65ca5b455e9f8c05e94b908b0bce7
6
+ metadata.gz: fce61ec49eb9e2e95725a04a366c4a2cd3dbb5123f02ee289f1253f7dc0c58170e03aeeb91f5ce16ff918c049b969c6dbfaa3d05053375d5595f6d1d5c52a695
7
+ data.tar.gz: 308ec3df6cc0cf780209b7b4a9509a141cc53b585b125d642519978a715395b01479e377a1135c4561399b06503f6924fa114c816e1570eb7ea956255eea0823
data/CHANGELOG.md ADDED
@@ -0,0 +1,28 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## [0.1.3] - 2024-11-07
6
+
7
+ ### Changed
8
+ - Separate positional and keyword arguments (support Ruby 3.0 and higher).
9
+
10
+ ## [0.1.2] - 2021-08-30
11
+
12
+ ### Changed
13
+ - Upgrade `bundler` and `rake` dependencies.
14
+
15
+ ## [0.1.1] - 2019-11-07
16
+
17
+ ### Added
18
+ - This `CHANGELOG.md` file.
19
+
20
+ ### Changed
21
+ - Rename attribute from `Nokogiri::XML::Schematron::Pattern#name` to `Nokogiri::XML::Schematron::Pattern#title`.
22
+ - Map `Nokogiri::XML::Schematron::Pattern#title` attribute to `<sch:title>` XML element (previously `@name` XML attribute).
23
+ - Map `Nokogiri::XML::Schematron::Schema#title` attribute to `<sch:title>` XML element (previously, `@title` XML attribute).
24
+
25
+ ## [0.1.0] - 2019-10-20
26
+
27
+ ### Added
28
+ - Initial commit.
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  nokogiri_schematron_builder
2
2
 
3
- Copyright (c) 2019, Battelle Memorial Institute
3
+ Copyright (c) 2019-2024, Battelle Memorial Institute
4
4
  All rights reserved.
5
5
 
6
6
  1. Battelle Memorial Institute (hereinafter Battelle) hereby grants permission
data/README.md CHANGED
@@ -31,7 +31,7 @@ Create the schema using the domain-specific language:
31
31
  ```ruby
32
32
  schema = Nokogiri::XML::Schematron::Schema.new(title: "Example schema") do
33
33
  ns(prefix: "ex", uri: "http://example.com/ns#")
34
- pattern(name: "Example pattern") do
34
+ pattern(title: "Example pattern") do
35
35
  rule(context: "/") do
36
36
  assert(test: "count(ex:A) &gt;= 1", message: "element \"ex:A\" is REQUIRED")
37
37
  end
@@ -50,7 +50,7 @@ Or, equivalently:
50
50
  ```ruby
51
51
  schema = Nokogiri::XML::Schematron::Schema.new(title: "Example schema") do
52
52
  ns(prefix: "ex", uri: "http://example.com/ns#")
53
- pattern(name: "Example pattern") do
53
+ pattern(title: "Example pattern") do
54
54
  context("/") do
55
55
  require("ex:A") do
56
56
  permit("ex:B") do
@@ -78,9 +78,11 @@ The result is:
78
78
 
79
79
  ```xml
80
80
  <?xml version="1.0" encoding="UTF-8"?>
81
- <sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" title="Example schema">
81
+ <sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron">
82
+ <sch:title>Example schema</sch:title>
82
83
  <sch:ns prefix="ex" uri="http://example.com/ns#"/>
83
- <sch:pattern name="Example pattern">
84
+ <sch:pattern>
85
+ <sch:title>Example pattern</sch:title>
84
86
  <sch:rule context="/">
85
87
  <sch:assert test="count(ex:A) &gt;= 1">element "ex:A" is REQUIRED</sch:assert>
86
88
  </sch:rule>
@@ -56,8 +56,8 @@ module Nokogiri
56
56
  #
57
57
  # is a descendent of this class, defines methods that are equivalent to:
58
58
  #
59
- # def name(*args, &block)
60
- # base = DescendentOfBase.new(self, *args, &block)
59
+ # def name(*args, **options, &block)
60
+ # base = DescendentOfBase.new(self, *args, **options, &block)
61
61
  # @children << base
62
62
  # base
63
63
  # end
@@ -66,8 +66,8 @@ module Nokogiri
66
66
  # @param klass [Class] the class.
67
67
  # @return [void]
68
68
  def element(name, klass)
69
- define_method(name.to_sym) do |*args, &block|
70
- base = klass.send(:new, self, *args, &block)
69
+ define_method(name.to_sym) do |*args, **options, &block|
70
+ base = klass.send(:new, self, *args, **options, &block)
71
71
  instance_variable_get(:@children) << base
72
72
  base
73
73
  end
@@ -107,8 +107,8 @@ module Nokogiri
107
107
  #
108
108
  # @return [Nokogiri::XML::Builder]
109
109
  # @see https://www.rubydoc.info/github/sparklemotion/nokogiri/Nokogiri/XML/Builder#initialize-instance_method
110
- def to_builder(*args)
111
- ::Nokogiri::XML::Builder.new(*args) do |xml|
110
+ def to_builder(*args, **options)
111
+ ::Nokogiri::XML::Builder.new(*args, **options) do |xml|
112
112
  build!(xml)
113
113
  end
114
114
  end
@@ -13,7 +13,7 @@ module Nokogiri
13
13
  # @option options [String] :two_words_connector the sign or word used to join the elements in arrays with two elements.
14
14
  # @option options [String] :last_word_connector the sign or word used to join the last element in arrays with three or more elements.
15
15
  # @return [String] the comma-separated sentence.
16
- def self.to_sentence(array, options = {})
16
+ def self.to_sentence(array, **options)
17
17
  case array.length
18
18
  when 0
19
19
  ''
@@ -10,19 +10,19 @@ module Nokogiri
10
10
  #
11
11
  # For example:
12
12
  #
13
- # pattern = Nokogiri::XML::Schematron::Pattern.new(nil, id: "pattern1", name: "Example pattern")
14
- # # => #<Nokogiri::XML::Schematron::Pattern:0x00007f8486a71f18 @parent=nil, @children=[], @options={:id=>"pattern1", :name=>"Example pattern"}>
13
+ # pattern = Nokogiri::XML::Schematron::Pattern.new(nil, id: "pattern1", title: "Example pattern")
14
+ # # => #<Nokogiri::XML::Schematron::Pattern:0x00007f8486a71f18 @parent=nil, @children=[], @options={:id=>"pattern1", :title=>"Example pattern"}>
15
15
  # pattern.to_builder.to_xml
16
- # # => "<?xml version=\"1.0\"?>\n<sch:pattern xmlns:sch=\"http://purl.oclc.org/dsdl/schematron\" id=\"pattern1\" name=\"Example pattern\"/>\n"
16
+ # # => "<?xml version=\"1.0\"?>\n<sch:pattern xmlns:sch=\"http://purl.oclc.org/dsdl/schematron\" id=\"pattern1\">\n <sch:title>Example pattern</sch:title>\n</sch:pattern>\n"
17
17
  #
18
18
  class Pattern < Nokogiri::XML::Schematron::Base
19
19
  # @!attribute [rw] id
20
20
  # @return [String] the value of the +@id+ XML attribute.
21
21
  attribute :id
22
22
 
23
- # @!attribute [rw] name
24
- # @return [String] the value of the +@name+ XML attribute.
25
- attribute :name
23
+ # @!attribute [rw] title
24
+ # @return [String] the value of the +@title+ XML element.
25
+ attribute :title
26
26
 
27
27
  # @!method context(context, **options, &block)
28
28
  # Create a new +Node::Context+ object.
@@ -132,13 +132,21 @@ module Nokogiri
132
132
  protected
133
133
 
134
134
  def build!(xml)
135
- xml["sch"].send(:pattern, %w(id name).inject(xmlns) { |acc, method_name|
135
+ xml["sch"].send(:pattern, %w(id).inject(xmlns) { |acc, method_name|
136
136
  unless (s = send(method_name.to_sym)).nil?
137
137
  acc[method_name.to_s] = s
138
138
  end
139
139
 
140
140
  acc
141
141
  }) do
142
+ %w(title).each do |method_name|
143
+ unless (s = send(method_name.to_sym)).nil?
144
+ xml["sch"].send(method_name.to_sym, xmlns) do
145
+ xml.text(s)
146
+ end
147
+ end
148
+ end
149
+
142
150
  super(xml)
143
151
  end
144
152
 
@@ -13,7 +13,7 @@ module Nokogiri
13
13
  # schema = Nokogiri::XML::Schematron::Schema.new(id: "schema1", title: "Example schema")
14
14
  # # => #<Nokogiri::XML::Schematron::Schema:0x00007fa1fb9e3b68 @parent=nil, @children=[], @options={:id=>"schema1", :title=>"Example schema"}>
15
15
  # schema.to_builder.to_xml
16
- # # => "<?xml version=\"1.0\"?>\n<sch:schema xmlns:sch=\"http://purl.oclc.org/dsdl/schematron\" id=\"schema1\" title=\"Example schema\"/>\n"
16
+ # # => "<?xml version=\"1.0\"?>\n<sch:schema xmlns:sch=\"http://purl.oclc.org/dsdl/schematron\" id=\"schema1\">\n <sch:title>Example schema</sch:title>\n</sch:schema>\n"
17
17
  #
18
18
  class Schema < Nokogiri::XML::Schematron::Base
19
19
  # @!attribute [rw] id
@@ -21,7 +21,7 @@ module Nokogiri
21
21
  attribute :id
22
22
 
23
23
  # @!attribute [rw] title
24
- # @return [String] the value of the +@title+ XML attribute.
24
+ # @return [String] the value of the +@title+ XML element.
25
25
  attribute :title
26
26
 
27
27
  # @!method ns(**options, &block)
@@ -47,7 +47,7 @@ module Nokogiri
47
47
  # Create a new +Pattern+ object.
48
48
  # @param options [Hash<Symbol, Object>] the options.
49
49
  # @option options [String] :id the value of the +@id+ XML attribute.
50
- # @option options [String] :name the value of the +@name+ XML attribute.
50
+ # @option options [String] :title the value of the +@title+ XML element.
51
51
  # @yieldparam pattern [Nokogiri::XML::Schematron::Pattern] the internal representation of the +<sch:pattern>+ XML element.
52
52
  # @yieldreturn [void]
53
53
  # @return [Nokogiri::XML::Schematron::Pattern] the +Pattern+ object.
@@ -57,7 +57,7 @@ module Nokogiri
57
57
  #
58
58
  # @param options [Hash<Symbol, Object>] the options.
59
59
  # @option options [#to_s] :id the value of the +@id+ XML attribute.
60
- # @option options [#to_s] :title the value of the +@title+ XML attribute.
60
+ # @option options [#to_s] :title the value of the +@title+ XML element.
61
61
  # @yieldparam schema [Nokogiri::XML::Schematron::Schema] the internal representation of the +<sch:schema>+ XML element.
62
62
  # @yieldreturn [void]
63
63
  def initialize(**options, &block)
@@ -67,13 +67,21 @@ module Nokogiri
67
67
  protected
68
68
 
69
69
  def build!(xml)
70
- xml["sch"].send(:schema, %w(id title).inject(xmlns) { |acc, method_name|
70
+ xml["sch"].send(:schema, %w(id).inject(xmlns) { |acc, method_name|
71
71
  unless (s = send(method_name.to_sym)).nil?
72
72
  acc[method_name.to_s] = s
73
73
  end
74
74
 
75
75
  acc
76
76
  }) do
77
+ %w(title).each do |method_name|
78
+ unless (s = send(method_name.to_sym)).nil?
79
+ xml["sch"].send(method_name.to_sym, xmlns) do
80
+ xml.text(s)
81
+ end
82
+ end
83
+ end
84
+
77
85
  super(xml)
78
86
  end
79
87
 
@@ -1,7 +1,7 @@
1
1
  module Nokogiri
2
2
  module XML
3
3
  module Schematron
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.3"
5
5
  end
6
6
  end
7
7
  end
@@ -33,6 +33,6 @@ Gem::Specification.new do |spec|
33
33
 
34
34
  spec.add_dependency "nokogiri"
35
35
 
36
- spec.add_development_dependency "bundler", "~> 1.16"
37
- spec.add_development_dependency "rake", "~> 10.0"
36
+ spec.add_development_dependency "bundler", ">= 2.2.10"
37
+ spec.add_development_dependency "rake", ">= 12.3.3"
38
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nokogiri_schematron_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Borkum
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-21 00:00:00.000000000 Z
11
+ date: 2024-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -28,30 +28,30 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.16'
33
+ version: 2.2.10
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.16'
40
+ version: 2.2.10
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: 12.3.3
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: 12.3.3
55
55
  description: NokogiriSchematronBuilder is a Ruby library for building Schematron XML
56
56
  documents using Nokogiri.
57
57
  email:
@@ -61,6 +61,7 @@ extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
63
  - ".gitignore"
64
+ - CHANGELOG.md
64
65
  - Gemfile
65
66
  - LICENSE.txt
66
67
  - README.md
@@ -91,7 +92,7 @@ homepage: https://github.com/pnnl/nokogiri_schematron_builder
91
92
  licenses:
92
93
  - BSD-2-Clause
93
94
  metadata: {}
94
- post_install_message:
95
+ post_install_message:
95
96
  rdoc_options: []
96
97
  require_paths:
97
98
  - lib
@@ -106,9 +107,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
107
  - !ruby/object:Gem::Version
107
108
  version: '0'
108
109
  requirements: []
109
- rubyforge_project:
110
- rubygems_version: 2.7.6
111
- signing_key:
110
+ rubygems_version: 3.5.9
111
+ signing_key:
112
112
  specification_version: 4
113
113
  summary: Build Schematron XML documents using Nokogiri.
114
114
  test_files: []