comicinfo 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f66dfb29761ad9d67b58cb229eeb3806205ecc417162830fa7688075b7886fba
4
+ data.tar.gz: bec2db8b6b877f0f6b35a7e3123653a7216dc653d847bcd16fa1112b5fe896a2
5
+ SHA512:
6
+ metadata.gz: f3094240a2e409a5dd41834ba35c2a4cc3ce73ad0e834b14db06d93dd344629dc318dba0760d1a1f8e56a7e6876832d9422b9d34264caca489ea2561f05eda37
7
+ data.tar.gz: 9de5a0f9c1f14a79139fa6837051a290deb5a1fb43eaa0dc2631153466daf2659d9914befae597669a5fd7c7198496ef5245f28a9554b957aada6ace71d4589e
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.4.6
data/CHANGELOG.md ADDED
@@ -0,0 +1,41 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.0.0] - 2025-10-05
9
+
10
+ ### Added
11
+ - Complete ComicInfo v2.0 XML schema support
12
+ - `ComicInfo.load()` method for loading from file paths or XML strings
13
+ - `ComicInfo::Issue` class with full field access via Ruby method names
14
+ - `ComicInfo::Page` objects with complete ComicPageInfo attribute support
15
+ - Multi-value field support with both string and array access methods
16
+ - Comprehensive enum validation for BlackAndWhite, Manga, AgeRating fields
17
+ - Range validation for CommunityRating (0.0-5.0)
18
+ - Unicode and international character support
19
+ - Manga-specific features (right-to-left detection, language handling)
20
+ - JSON export via `#to_json` method
21
+ - YAML export via `#to_yaml` method
22
+ - Hash export via `#to_h` method with symbol keys
23
+ - Convenience predicate methods (`#manga?`, `#right_to_left?`, `#black_and_white?`)
24
+ - Page filtering methods (`#cover_pages`, `#story_pages`)
25
+ - Custom exception classes with detailed error messages
26
+ - Comprehensive test suite
27
+
28
+ ### Features
29
+ - **Reading**: Load and parse ComicInfo.xml files with full schema compliance
30
+ - **Validation**: Strict enum and range validation with helpful error messages
31
+ - **Export**: Multiple export formats (JSON, YAML, Hash) for data interchange
32
+ - **Unicode**: Full support for international characters and XML entities
33
+ - **Pages**: Complete page object model with type predicates and attributes
34
+ - **Multi-value**: Smart handling of comma/space-separated field values
35
+
36
+ ## [0.1.0] - 2025-01-XX
37
+
38
+ ### Added
39
+ - Initial project structure
40
+ - Basic gem skeleton
41
+ - Development dependencies setup
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ veganstraightedge@gmail.com.
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Shane Becker
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,295 @@
1
+ # ComicInfo Ruby Gem
2
+
3
+ A Ruby gem that provides an idiomatic interface for reading and writing ComicInfo.xml files,
4
+ following the official ComicInfo schema specifications from the
5
+ [Anansi Project](https://github.com/anansi-project/comicinfo).
6
+
7
+ ![Ruby](https://img.shields.io/badge/ruby-%3E%3D%203.4.6-ruby.svg)
8
+ ![Gem Version](https://badge.fury.io/rb/comicinfo.svg)
9
+ ![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)
10
+
11
+ ## Features
12
+
13
+ - 📚 **Complete Schema Support**: Full ComicInfo v2.0 schema implementation
14
+ - 🔧 **Idiomatic Ruby API**: Ruby-style interface with proper method naming
15
+ - 📁 **Flexible Loading**: Load from file paths or XML strings
16
+ - 🌍 **Unicode Support**: Full Unicode and special character handling
17
+ - 📖 **Manga Support**: Right-to-left reading direction and manga-specific fields
18
+ - ✅ **Comprehensive Validation**: Schema-compliant enum validation and type coercion
19
+ - 🚨 **Detailed Error Handling**: Custom exception classes with helpful error messages
20
+ - 📊 **Export Support**: JSON and YAML serialization with hash representation (in progress)
21
+
22
+ ## Installation
23
+
24
+ Add this line to your application's Gemfile:
25
+
26
+ ```ruby
27
+ gem 'comicinfo'
28
+ ```
29
+
30
+ And then execute:
31
+
32
+ ```sh
33
+ bundle install
34
+ ```
35
+
36
+ Or install it yourself as:
37
+
38
+ ```sh
39
+ gem install comicinfo
40
+ ```
41
+
42
+ ## Usage
43
+
44
+ ### Loading ComicInfo Files
45
+
46
+ ```ruby
47
+ require 'comicinfo'
48
+
49
+ # Load from file path
50
+ comic = ComicInfo.load 'path/to/ComicInfo.xml'
51
+
52
+ # Load from XML string
53
+ xml_content = File.read 'ComicInfo.xml'
54
+ comic = ComicInfo.load xml_content
55
+ ```
56
+
57
+ ### Accessing Comic Information
58
+
59
+ ```ruby
60
+ # Basic information
61
+ puts comic.title #=> "The Amazing Spider-Man"
62
+ puts comic.series #=> "The Amazing Spider-Man"
63
+ puts comic.number #=> "1"
64
+ puts comic.count #=> 600
65
+ puts comic.volume #=> 3
66
+
67
+ # Publication details
68
+ puts comic.publisher #=> "Marvel Comics"
69
+ puts comic.year #=> 2018
70
+ puts comic.month #=> 3
71
+ puts comic.day #=> 15
72
+
73
+ # Creator information
74
+ puts comic.writer #=> "Dan Slott, Christos Gage"
75
+ puts comic.penciller #=> "Ryan Ottley"
76
+ puts comic.cover_artist #=> "Ryan Ottley"
77
+
78
+ # Content details
79
+ puts comic.page_count #=> 20
80
+ puts comic.genre #=> "Superhero, Action, Adventure"
81
+ puts comic.language_iso #=> "en-US"
82
+ puts comic.format #=> "Digital"
83
+
84
+ # Ratings and reviews
85
+ puts comic.age_rating #=> "Teen"
86
+ puts comic.community_rating #=> 4.25
87
+ ```
88
+
89
+ ### Convenience Methods
90
+
91
+ ```ruby
92
+ # Boolean helpers
93
+ puts comic.manga? #=> false
94
+ puts comic.right_to_left? #=> false
95
+ puts comic.black_and_white? #=> false
96
+
97
+ # Page information
98
+ puts comic.pages? #=> true
99
+ puts comic.pages.length #=> 12
100
+
101
+ # Get specific page types
102
+ covers = comic.cover_pages
103
+ stories = comic.story_pages
104
+
105
+ # Multi-value fields as arrays
106
+ characters = comic.characters #=> ["Spider-Man", "Peter Parker", ...]
107
+ teams = comic.teams #=> ["Avengers"]
108
+ locations = comic.locations #=> ["New York City", "Manhattan", ...]
109
+ genres = comic.genres #=> ["Superhero", "Action", "Adventure"]
110
+ web_urls = comic.web_urls #=> ["https://marvel.com/...", "https://comicvine.com/..."]
111
+ ```
112
+
113
+ ### Working with Pages
114
+
115
+ ```ruby
116
+ comic.pages.each do |page|
117
+ puts "Page #{page.image}: #{page.type}"
118
+ puts " Double page: #{page.double_page?}" if page.double_page?
119
+ puts " Bookmark: #{page.bookmark}" if page.bookmarked?
120
+ puts " Dimensions: #{page.image_width}x#{page.image_height}" if page.dimensions_available?
121
+ end
122
+
123
+ # Page type checks
124
+ page = comic.pages.first
125
+ puts page.cover? #=> true for FrontCover, BackCover, InnerCover
126
+ puts page.story? #=> true for Story pages
127
+ puts page.deleted? #=> true for Deleted pages
128
+ ```
129
+
130
+ ### Manga Support
131
+
132
+ ```ruby
133
+ # Load a manga ComicInfo file
134
+ manga = ComicInfo.load 'path/to/manga/ComicInfo.xml')
135
+
136
+ puts manga.title #=> "進撃の巨人"
137
+ puts manga.series #=> "Attack on Titan"
138
+ puts manga.manga #=> "YesAndRightToLeft"
139
+ puts manga.right_to_left? #=> true
140
+ puts manga.language_iso #=> "ja-JP"
141
+ puts manga.black_and_white? #=> true
142
+ puts manga.black_and_white #=> "Yes"
143
+ ```
144
+
145
+ ### Error Handling
146
+
147
+ ```ruby
148
+ begin
149
+ comic = ComicInfo.load('nonexistent.xml')
150
+ rescue ComicInfo::Errors::FileError => e
151
+ puts "File error: #{e.message}"
152
+ rescue ComicInfo::Errors::ParseError => e
153
+ puts "Parse error: #{e.message}"
154
+ rescue ComicInfo::Errors::InvalidEnumError => e
155
+ puts "Invalid enum: #{e.field} = '#{e.value}', valid: #{e.valid_values}"
156
+ rescue ComicInfo::Errors::RangeError => e
157
+ puts "Out of range: #{e.field} = #{e.value}, range: #{e.min}..#{e.max}"
158
+ rescue ComicInfo::Errors::TypeCoercionError => e
159
+ puts "Type coercion error: #{e.message}"
160
+ end
161
+ ```
162
+
163
+ ## Schema Support
164
+
165
+ This gem fully supports the ComicInfo v2.0 XSD schema with all field types:
166
+
167
+ ### String Fields
168
+ - Title, Series, Number, Summary, Notes
169
+ - Creator fields (Writer, Penciller, Inker, Colorist, Letterer, CoverArtist, Editor, Translator)
170
+ - Publication fields (Publisher, Imprint, Genre, Web, LanguageISO, Format)
171
+ - Character/Location fields (Characters, Teams, Locations, MainCharacterOrTeam)
172
+ - Story fields (StoryArc, StoryArcNumber, SeriesGroup, ScanInformation, Review)
173
+
174
+ ### Integer Fields
175
+ - Count, Volume, AlternateCount, PageCount
176
+ - Date fields (Year, Month, Day)
177
+
178
+ ### Enum Fields
179
+ - BlackAndWhite: "Unknown", "No", "Yes"
180
+ - Manga: "Unknown", "No", "Yes", "YesAndRightToLeft"
181
+ - AgeRating: Various ESRB and international ratings
182
+
183
+ ### Decimal Fields
184
+ - CommunityRating: 0.0 to 5.0 range with validation
185
+
186
+ ### Complex Fields
187
+ - Pages: Array of ComicPageInfo objects with full attribute support
188
+ - Page types: FrontCover, BackCover, InnerCover, Roundup, Story, Advertisement, Editorial, Letters, Preview, Other, Deleted
189
+
190
+ ### Export Formats
191
+ - **JSON**: Complete serialization with all fields
192
+ - **YAML**: Human-readable format with array structures
193
+ - **Hash**: Ruby hash representation with symbol keys
194
+
195
+ ### Data Export
196
+
197
+ ```ruby
198
+ comic = ComicInfo.load 'path/to/ComicInfo.xml'
199
+
200
+ # Export as JSON
201
+ json_string = comic.to_json
202
+ puts JSON.pretty_generate(JSON.parse(json_string))
203
+
204
+ # Export as YAML
205
+ yaml_string = comic.to_yaml
206
+ puts yaml_string
207
+
208
+ # Export as Hash
209
+ hash = comic.to_h
210
+ puts hash[:title] #=> "The Amazing Spider-Man"
211
+ puts hash[:characters] #=> ["Spider-Man", "Peter Parker", ...]
212
+ puts hash[:pages].length #=> 12
213
+ ```
214
+
215
+ ## Development
216
+
217
+ After checking out the repo, run `bin/setup` to install dependencies.
218
+ Then, run `rake spec` to run the tests.
219
+ You can also run `bin/console` for an interactive prompt that will allow you to experiment.
220
+
221
+ To install this gem onto your local machine, run `bundle exec rake install`.
222
+ To release a new version, update the version number in `version.rb`,
223
+ and then run `bundle exec rake release`,
224
+ which will create a git tag for the version,
225
+ push git commits and the created tag,
226
+ and push the `.gem` file to [rubygems.org](https://rubygems.org).
227
+
228
+ ### Running Tests
229
+
230
+ ```sh
231
+ # Run all tests
232
+ bundle exec rspec
233
+
234
+ # Run with documentation format
235
+ bundle exec rspec --format documentation
236
+
237
+ # Run specific test file
238
+ bundle exec rspec spec/comic_info_spec.rb
239
+ ```
240
+
241
+ ### Code Quality
242
+
243
+ ```sh
244
+ # Run RuboCop linter
245
+ bundle exec rubocop
246
+
247
+ # Auto-fix correctable issues
248
+ bundle exec rubocop --autocorrect
249
+ ```
250
+
251
+ ## Implementation Status
252
+
253
+ ### Current Features ✅
254
+ - **Core Reading**: Complete ComicInfo.xml parsing
255
+ - **Schema Compliance**: Full ComicInfo v2.0 support
256
+ - **Field Types**: String, Integer, Decimal, Enum, Boolean, Arrays
257
+ - **Multi-value Fields**: Both string and array access methods
258
+ - **Issue &Page Support**: Complete Issue and nested Page objects
259
+ - **Error Handling**: Custom exceptions with detailed messages
260
+ - **Data Export**: JSON and YAML serialization
261
+ - **Validation**: Enum values, ranges, type coercion
262
+ - **Unicode Support**: International characters and special symbols
263
+ - **Test Coverage**: 156 comprehensive test cases
264
+
265
+ ### Planned Features 🚧
266
+ - **XML Generation**: Writing ComicInfo.xml files
267
+ - **CLI Tool**: Command-line interface for file manipulation
268
+ - **Schema Migration**: Support for multiple ComicInfo versions
269
+
270
+ ### Schema Versions
271
+ - ✅ **ComicInfo v2.0**: Full support (current)
272
+ - 🚧 **ComicInfo v2.1**: Planned
273
+ - 🚧 **ComicInfo v1.0**: Planned
274
+
275
+ ## Contributing
276
+
277
+ Bug reports and pull requests are welcome on GitHub at https://github.com/veganstraightedge/comicinfo.
278
+ This project is intended to be a safe, welcoming space for collaboration,
279
+ and contributors are expected to adhere to the
280
+ [code of conduct](https://github.com/veganstraightedge/comicinfo/blob/main/CODE_OF_CONDUCT.md).
281
+
282
+ ## License
283
+
284
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
285
+
286
+ ## Code of Conduct
287
+
288
+ Everyone interacting in the ComicInfo project's codebases,
289
+ issue trackers, chat rooms and mailing lists is expected to follow the
290
+ [code of conduct](https://github.com/veganstraightedge/comicinfo/blob/main/CODE_OF_CONDUCT.md).
291
+
292
+ ## Acknowledgments
293
+
294
+ - [Anansi Project](https://github.com/anansi-project/comicinfo) for the ComicInfo schema specification
295
+ - [Nokogiri](https://nokogiri.org/) for XML parsing capabilities
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new :spec
5
+
6
+ require 'rubocop/rake_task'
7
+
8
+ RuboCop::RakeTask.new
9
+
10
+ task default: %i[spec rubocop]