xsd 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.rubocop.yml +124 -0
  4. data/CHANGELOG.md +5 -0
  5. data/CODE_OF_CONDUCT.md +84 -0
  6. data/Gemfile +6 -0
  7. data/LICENSE +21 -0
  8. data/Makefile +7 -0
  9. data/README.md +68 -0
  10. data/Rakefile +25 -0
  11. data/lib/xsd/base_object.rb +347 -0
  12. data/lib/xsd/exceptions.rb +12 -0
  13. data/lib/xsd/generator.rb +137 -0
  14. data/lib/xsd/objects/all.rb +22 -0
  15. data/lib/xsd/objects/annotation.rb +19 -0
  16. data/lib/xsd/objects/any.rb +31 -0
  17. data/lib/xsd/objects/any_attribute.rb +30 -0
  18. data/lib/xsd/objects/appinfo.rb +13 -0
  19. data/lib/xsd/objects/attribute.rb +72 -0
  20. data/lib/xsd/objects/attribute_group.rb +18 -0
  21. data/lib/xsd/objects/choice.rb +33 -0
  22. data/lib/xsd/objects/complex_content.rb +25 -0
  23. data/lib/xsd/objects/complex_type.rb +82 -0
  24. data/lib/xsd/objects/documentation.rb +18 -0
  25. data/lib/xsd/objects/element.rb +130 -0
  26. data/lib/xsd/objects/extension.rb +14 -0
  27. data/lib/xsd/objects/facet.rb +12 -0
  28. data/lib/xsd/objects/field.rb +13 -0
  29. data/lib/xsd/objects/group.rb +32 -0
  30. data/lib/xsd/objects/import.rb +67 -0
  31. data/lib/xsd/objects/key.rb +25 -0
  32. data/lib/xsd/objects/keyref.rb +33 -0
  33. data/lib/xsd/objects/list.rb +18 -0
  34. data/lib/xsd/objects/restriction.rb +49 -0
  35. data/lib/xsd/objects/schema.rb +155 -0
  36. data/lib/xsd/objects/selector.rb +15 -0
  37. data/lib/xsd/objects/sequence.rb +33 -0
  38. data/lib/xsd/objects/simple_content.rb +19 -0
  39. data/lib/xsd/objects/simple_type.rb +35 -0
  40. data/lib/xsd/objects/union.rb +23 -0
  41. data/lib/xsd/objects/unique.rb +18 -0
  42. data/lib/xsd/shared/attribute_container.rb +17 -0
  43. data/lib/xsd/shared/based.rb +37 -0
  44. data/lib/xsd/shared/complex_typed.rb +28 -0
  45. data/lib/xsd/shared/element_container.rb +12 -0
  46. data/lib/xsd/shared/min_max_occurs.rb +46 -0
  47. data/lib/xsd/shared/referenced.rb +24 -0
  48. data/lib/xsd/shared/simple_typed.rb +14 -0
  49. data/lib/xsd/validator.rb +90 -0
  50. data/lib/xsd/version.rb +5 -0
  51. data/lib/xsd/xml.rb +111 -0
  52. data/lib/xsd.rb +42 -0
  53. data/xsd.gemspec +45 -0
  54. metadata +239 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9808a3d7cd5e73e6646222be452a476e4fc5f27997e3bc17e3016bc27c4ebda1
4
+ data.tar.gz: 4a1fd4f0877002b60b1274f5b9c2cde51b5ac8c3c1872964feb8bef5fddd7972
5
+ SHA512:
6
+ metadata.gz: '02650138ed60e27ad29e606b0a39fd7e7443de91f249486e178d39c40f7e59da556448fc8af5e52696a353345744ecc98639163a8a01cb48a54ff416f01a92a4'
7
+ data.tar.gz: 8d246d14bdcba114e6d72b878f187c89480a8571b8e6ea57753a06507d37a6526a9c9aeb000669bfb78b248cad1cbea1c74a6dd8cacab8aa4fbb20c18786ed93
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,124 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rake
4
+ - rubocop-rspec
5
+
6
+ AllCops:
7
+ TargetRubyVersion: 3.2.2
8
+ NewCops: enable
9
+ SuggestExtensions: false
10
+
11
+ Gemspec/RequireMFA:
12
+ Enabled: false
13
+
14
+ Gemspec/RequiredRubyVersion:
15
+ Enabled: false
16
+
17
+ Layout/ExtraSpacing:
18
+ Enabled: false
19
+
20
+ Layout/HashAlignment:
21
+ Enabled: false
22
+
23
+ Layout/LineLength:
24
+ Enabled: false
25
+
26
+ Lint/HashCompareByIdentity:
27
+ Enabled: false
28
+
29
+ Layout/SpaceAroundOperators:
30
+ Enabled: false
31
+
32
+ Lint/DuplicateMethods:
33
+ Enabled: false
34
+
35
+ Lint/IneffectiveAccessModifier:
36
+ Enabled: false
37
+
38
+ Lint/UnderscorePrefixedVariableName:
39
+ Enabled: false
40
+
41
+ Metrics/AbcSize:
42
+ Enabled: false
43
+
44
+ Metrics/BlockLength:
45
+ Exclude:
46
+ - 'spec/**/*_spec.rb'
47
+
48
+ Metrics/BlockNesting:
49
+ Enabled: false
50
+
51
+ Metrics/ClassLength:
52
+ Enabled: false
53
+
54
+ Metrics/CyclomaticComplexity:
55
+ Enabled: false
56
+
57
+ Metrics/MethodLength:
58
+ Enabled: false
59
+
60
+ Metrics/PerceivedComplexity:
61
+ Enabled: false
62
+
63
+ Naming/MemoizedInstanceVariableName:
64
+ Enabled: false
65
+
66
+ Naming/MethodParameterName:
67
+ Enabled: false
68
+
69
+ Performance/MapCompact:
70
+ Enabled: false
71
+
72
+ Performance/RedundantBlockCall:
73
+ Enabled: false
74
+
75
+ Performance/RegexpMatch:
76
+ Enabled: false
77
+
78
+ RSpec/ExampleLength:
79
+ Max: 10
80
+
81
+ RSpec/MultipleExpectations:
82
+ Max: 8
83
+
84
+ RSpec/NoExpectationExample:
85
+ Enabled: false
86
+
87
+ RSpec/RepeatedExample:
88
+ Enabled: false
89
+
90
+ Style/ConditionalAssignment:
91
+ Enabled: false
92
+
93
+ Style/Documentation:
94
+ Enabled: false
95
+
96
+ Style/DoubleNegation:
97
+ Enabled: false
98
+
99
+ Style/EachWithObject:
100
+ Enabled: false
101
+
102
+ Style/HashSyntax:
103
+ Enabled: false
104
+
105
+ Style/IfUnlessModifier:
106
+ Enabled: false
107
+
108
+ Style/NegatedIfElseCondition:
109
+ Enabled: false
110
+
111
+ Style/NumericPredicate:
112
+ Enabled: false
113
+
114
+ Style/OptionalBooleanParameter:
115
+ Enabled: false
116
+
117
+ Style/RedundantBegin:
118
+ Enabled: false
119
+
120
+ Style/RedundantSelf:
121
+ Enabled: false
122
+
123
+ Style/SlicingWithRange:
124
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [1.0.0] - 2023-04-25
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at a.polyanskiy@outlook.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in xsd_to_json.gemspec
6
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Ekzo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/Makefile ADDED
@@ -0,0 +1,7 @@
1
+ test:
2
+ bundle exec rake test
3
+
4
+ lint:
5
+ bundle exec rake rubocop
6
+
7
+ .PHONY: test
data/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # XSD
2
+
3
+ [![Ruby](https://github.com/ekzo-dev/ruby-xsd/actions/workflows/main.yml/badge.svg)][githubactions]
4
+
5
+ [githubactions]: https://github.com/omniauth/omniauth/actions/workflows/main.yml
6
+
7
+ The Ruby XSD library is an [XML Schema](https://www.w3.org/2001/XMLSchema) implementation for Ruby. Provides easy and
8
+ flexible access to XSD information.
9
+
10
+ ## Installation
11
+
12
+ Install as a gem
13
+
14
+ $ gem install xsd
15
+
16
+ Or add it to your Gemfile
17
+
18
+ ```ruby
19
+ gem 'xsd'
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ ```ruby
25
+ require 'xsd'
26
+
27
+ # Load ruby-xsd
28
+ reader = XSD::XML.new(:xsd_file => 'some.xsd')
29
+
30
+ # Get attributes
31
+ attribute = reader['NewReleaseMessage']['@MessageSchemaVersionId']
32
+
33
+ # Get atrribute information
34
+ attribute.name # => 'MessageSchemaVersionId'
35
+ attribute.type # => 'xs:string'
36
+ attribute.required? # => true
37
+
38
+ # Get element information
39
+ element = reader['NewReleaseMessage']['ResourceList']['SoundRecording']
40
+ element.min_occurs # => 0
41
+ element.max_occurs # => :unbounded
42
+ element.type # => 'ern:SoundRecording'
43
+ element.complex_type # => XSD::ComplexType
44
+ ```
45
+
46
+ ## Development
47
+
48
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can
49
+ also run `bin/console` for an interactive prompt that will allow you to experiment.
50
+
51
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the
52
+ version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version,
53
+ push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
54
+
55
+ ## Contributing
56
+
57
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ruby-xsd. This project is intended
58
+ to be a safe, welcoming space for collaboration, and contributors are expected to adhere to
59
+ the [code of conduct](https://github.com/[USERNAME]/ruby-xsd/blob/main/CODE_OF_CONDUCT.md).
60
+
61
+ ## License
62
+
63
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
64
+
65
+ ## Code of Conduct
66
+
67
+ Everyone interacting in the Ruby::Xsd project's codebases, issue trackers, chat rooms and mailing lists is expected to
68
+ follow the [code of conduct](https://github.com/[USERNAME]/ruby-xsd/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ desc 'Run all specs'
7
+ RSpec::Core::RakeTask.new(:spec) do |t|
8
+ t.pattern = 'spec/**/*_spec.rb'
9
+ t.verbose = false
10
+ end
11
+
12
+ require 'rubocop/rake_task'
13
+
14
+ RuboCop::RakeTask.new do |t|
15
+ t.options = ['--display-cop-names']
16
+ end
17
+
18
+ desc 'Run tests'
19
+ task test: :spec
20
+
21
+ desc 'Run linter'
22
+ task lint: :rubocop
23
+
24
+ desc 'Run linter and tests'
25
+ task default: %i[lint spec]