rizzy 0.1.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: f7ea68ab1a6a1a72a9778ef875afc364da2b77a165900b108897c135efc3cf31
4
+ data.tar.gz: b49a431ed0e28da35e0f37a5bcf23bfee968a4403610b29a0ffd830cd4db928c
5
+ SHA512:
6
+ metadata.gz: 8861dcaf5e50bfaf6fdef578a14db1a9206bb2ee50527228c5c39ec4bfb38f7aaa5fdefce1f8122e54423c9d94f3428d13d942ff71741fcbf4901771974521e3
7
+ data.tar.gz: bdd47013da7a4e807cf58e16b64fb4ace62640b621cb1acd88719e4d1448cf4a6138216d9022c680cb7a11cbb9f16f0bc1bc42611a2bca99144d372b63b7b84b
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.1
3
+
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
6
+
7
+ Style/StringLiteralsInInterpolation:
8
+ EnforcedStyle: double_quotes
@@ -0,0 +1,25 @@
1
+ {
2
+ // Use IntelliSense to learn about possible attributes.
3
+ // Hover to view descriptions of existing attributes.
4
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
+ "version": "0.2.0",
6
+ "configurations": [
7
+ {
8
+ "type": "ruby_lsp",
9
+ "name": "Debug script",
10
+ "request": "launch",
11
+ "program": "ruby ${file}"
12
+ },
13
+ {
14
+ "type": "ruby_lsp",
15
+ "name": "Debug test",
16
+ "request": "launch",
17
+ "program": "ruby -Itest ${relativeFile}"
18
+ },
19
+ {
20
+ "type": "ruby_lsp",
21
+ "name": "Attach debugger",
22
+ "request": "attach"
23
+ }
24
+ ]
25
+ }
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2025-10-24
4
+
5
+ - Initial release
data/CLAUDE.md ADDED
@@ -0,0 +1,73 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ <!-- ## Tutorial Mode
6
+ You are never to write code, but your focus is to teach the user. The user is writing their first ruby gem and wants to learn and internalise core cocnepts of ruby language and gem files. Focus on explaining step by step and explain the mechanics. -->
7
+
8
+ ## Project Overview
9
+
10
+ Rizzy is a Ruby gem project initialized from the standard bundler gem template. It's currently in early development with placeholder content.
11
+
12
+ - Ruby version requirement: >= 3.1.0
13
+ - Testing framework: RSpec
14
+ - Linting: RuboCop
15
+ - CI: GitHub Actions (testing on Ruby 3.3.3)
16
+
17
+ ## Development Commands
18
+
19
+ ### Setup
20
+ ```bash
21
+ bin/setup # Install dependencies
22
+ ```
23
+
24
+ ### Testing
25
+ ```bash
26
+ rake spec # Run all tests
27
+ rspec # Run all tests (alternative)
28
+ rspec spec/path/to/specific_spec.rb # Run a specific test file
29
+ ```
30
+
31
+ ### Linting
32
+ ```bash
33
+ rake rubocop # Run RuboCop linter
34
+ rubocop -a # Auto-fix RuboCop issues
35
+ ```
36
+
37
+ ### Combined Tasks
38
+ ```bash
39
+ rake # Run default task (spec + rubocop)
40
+ ```
41
+
42
+ ### Interactive Console
43
+ ```bash
44
+ bin/console # Launch IRB with the gem loaded
45
+ ```
46
+
47
+ ### Local Installation
48
+ ```bash
49
+ bundle exec rake install # Install gem locally
50
+ ```
51
+
52
+ ## Code Architecture
53
+
54
+ ### Module Structure
55
+ - `lib/rizzy.rb` - Main entry point, defines the `Rizzy` module with base `Error` class
56
+ - `lib/rizzy/version.rb` - Version constant (currently 0.1.0)
57
+ - Additional module files should go in `lib/rizzy/` directory
58
+
59
+ ### Code Style
60
+ - RuboCop enforces double quotes for strings (both regular and interpolated)
61
+ - All Ruby files should start with `# frozen_string_literal: true`
62
+ - Target Ruby version: 3.1
63
+
64
+ ### Testing
65
+ - RSpec is configured with monkey patching disabled
66
+ - Test files go in `spec/` directory
67
+ - Use `.rspec_status` for example status persistence
68
+ - Syntax: use `expect` style (not `should`)
69
+
70
+ ### File Organization
71
+ - Executable files: `exe/` directory (currently none)
72
+ - Binary helpers: `bin/` directory (console, setup)
73
+ - Type signatures: `sig/` directory (RBS files)
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Andrew Boeckh
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,3 @@
1
+ # Rizzy
2
+
3
+ A gem for parsing and writing .ris files
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "reference"
4
+
5
+ # Rizzy parsing logic
6
+ module Rizzy
7
+ TAG_TO_FIELD = {
8
+ "TY" => { attr: :type, multiple: false },
9
+ "DB" => { attr: :database, multiple: false },
10
+ "ID" => { attr: :id, multiple: false },
11
+ "DO" => { attr: :doi, multiple: false },
12
+ "T1" => { attr: :title, multiple: false },
13
+ "TI" => { attr: :title, multiple: false },
14
+ "Y1" => { attr: :year, multiple: false },
15
+ "PY" => { attr: :year, multiple: false },
16
+ "N2" => { attr: :abstract, multiple: false },
17
+ "AB" => { attr: :abstract, multiple: false },
18
+ "M3" => { attr: :type_of_work, multiple: false },
19
+ "JF" => { attr: :journal_full, multiple: false },
20
+ "VL" => { attr: :volume, multiple: false },
21
+ "IS" => { attr: :issue, multiple: false },
22
+ "SP" => { attr: :start_page, multiple: false },
23
+ "EP" => { attr: :end_page, multiple: false },
24
+ "CY" => { attr: :country, multiple: false },
25
+ "SN" => { attr: :isbn, multiple: false },
26
+ "NL" => { attr: :alternate_journal, multiple: false },
27
+ "LA" => { attr: :language, multiple: false },
28
+ "PT" => { attr: :publication_type, multiple: false },
29
+ "A1" => { attr: :authors, multiple: true },
30
+ "AU" => { attr: :authors, multiple: true },
31
+ "AI" => { attr: :author_identifiers, multiple: true },
32
+ "A2" => { attr: :secondary_authors, multiple: true },
33
+ "KW" => { attr: :keywords, multiple: true },
34
+ "PB" => { attr: :publishers, multiple: true },
35
+ "AD" => { attr: :addresses, multiple: true },
36
+ "M1" => { attr: :miscellaneous_ones, multiple: true },
37
+ "M2" => { attr: :miscellaneous_twos, multiple: true },
38
+ "L2" => { attr: :urls, multiple: true },
39
+ "UR" => { attr: :urls, multiple: true }
40
+ }.freeze
41
+
42
+ def self.parse(content)
43
+ str = normalize_encoding(content)
44
+ entries = str.split("ER -")
45
+ references = []
46
+ entries.each do |entry|
47
+ reference = process_entry(entry)
48
+ references << process_entry(entry) unless reference[:type].nil?
49
+ end
50
+ references
51
+ end
52
+
53
+ def self.normalize_encoding(string)
54
+ str = string.dup
55
+ return str if str.encoding.name == "UTF-8" && str.valid_encoding?
56
+
57
+ str.encode("UTF-8")
58
+ end
59
+
60
+ def self.process_entry(entry)
61
+ data = Hash.new { |h, k| h[k] = [] if k.to_s.end_with?("s") }
62
+ lines = entry.lines
63
+ lines.each do |line|
64
+ elements = line.split(" - ")
65
+ next if elements.length != 2
66
+
67
+ add_entry(elements[0], elements[1].strip, data)
68
+ end
69
+ Reference.new(**data)
70
+ end
71
+
72
+ def self.add_entry(tag, entry, data)
73
+ mapping = TAG_TO_FIELD[tag]
74
+ return if mapping.nil?
75
+
76
+ attr = mapping[:attr]
77
+ if mapping[:multiple]
78
+ data[attr] << entry
79
+ else
80
+ data[attr] = entry
81
+ end
82
+ end
83
+
84
+ private_class_method :normalize_encoding
85
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rizzy
4
+ Reference = Struct.new(
5
+ :type, # TY
6
+ :database, # DB
7
+ :id, # ID
8
+ :doi, # DO
9
+ :title, # T1, TI
10
+ :year, # Y1, PY
11
+ :abstract, # N2, AB
12
+ :type_of_work, # M3
13
+ :journal_full, # JF
14
+ :volume, # VL
15
+ :issue, # IS
16
+ :start_page, # SP
17
+ :end_page, # EP
18
+ :country, # CY
19
+ :isbn, # SN
20
+ :alternate_journal, # NL
21
+ :language, # LA
22
+ :publication_type, # PT
23
+ :authors, # A1, AU
24
+ :author_identifiers, # AI
25
+ :secondary_authors, # A2
26
+ :keywords, # KW
27
+ :publishers, # PB
28
+ :addresses, # AD
29
+ :miscellaneous_ones, # M1
30
+ :miscellaneous_twos, # M2
31
+ :urls # L2, UR
32
+ )
33
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rizzy
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable all
4
+ require_relative "reference"
5
+
6
+ # Rizzy writing logic
7
+ module Rizzy
8
+ FIELD_TO_TAG = {
9
+ type: { tag: "TY", multiple: false },
10
+ database: { tag: "DB", multiple: false },
11
+ id: { tag: "ID", multiple: false },
12
+ doi: { tag: "DO", multiple: false },
13
+ title: { tag: "T1", multiple: false },
14
+ year: { tag: "Y1", multiple: false },
15
+ abstract: { tag: "N2", multiple: false },
16
+ type_of_work: { tag: "M3", multiple: false },
17
+ journal_full: { tag: "JF", multiple: false },
18
+ volume: { tag: "VL", multiple: false },
19
+ issue: { tag: "IS", multiple: false },
20
+ start_page: { tag: "SP", multiple: false },
21
+ end_page: { tag: "EP", multiple: false },
22
+ country: { tag: "CY", multiple: false },
23
+ isbn: { tag: "SN", multiple: false },
24
+ alternate_journal: { tag: "NL", multiple: false },
25
+ language: { tag: "LA", multiple: false },
26
+ publication_type: { tag: "PT", multiple: false },
27
+ authors: { tag: "A1", multiple: true },
28
+ author_identifiers: { tag: "AI", multiple: true },
29
+ secondary_authors: { tag: "A2", multiple: true },
30
+ keywords: { tag: "KW", multiple: true },
31
+ publishers: { tag: "PB", multiple: true },
32
+ addresses: { tag: "AD", multiple: true },
33
+ miscellaneous_ones: { tag: "M1", multiple: true },
34
+ miscellaneous_twos: { tag: "M2", multiple: true },
35
+ urls: { tag: "L2", multiple: true }
36
+ }.freeze
37
+
38
+ def self.write(references)
39
+ references = [references] unless references.is_a?(Array)
40
+
41
+ output = []
42
+ references.each do |reference|
43
+ output << write_reference(reference)
44
+ end
45
+
46
+ output.join("\n")
47
+ end
48
+
49
+ def self.write_reference(reference)
50
+ lines = []
51
+
52
+ FIELD_TO_TAG.each do |field, config|
53
+ value = reference[field]
54
+ next if value.nil?
55
+
56
+ tag = config[:tag]
57
+
58
+ if config[:multiple]
59
+ next if value.empty?
60
+ value.each do |item|
61
+ lines << format_line(tag, item)
62
+ end
63
+ else
64
+ next if value.to_s.empty?
65
+ lines << format_line(tag, value)
66
+ end
67
+ end
68
+
69
+ lines << "ER -"
70
+ lines.join("\n")
71
+ end
72
+
73
+ def self.format_line(tag, value)
74
+ "#{tag} - #{value}"
75
+ end
76
+
77
+ private_class_method :write_reference, :format_line
78
+ end
data/lib/rizzy.rb ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "rizzy/version"
4
+ require_relative "rizzy/parser"
5
+ require_relative "rizzy/writer"
6
+
7
+ module Rizzy
8
+ class Error < StandardError; end
9
+ class EncodingError < StandardError; end
10
+ end
data/sig/rizzy.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Rizzy
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rizzy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Boeckh
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-10-25 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |-
14
+ The gem have a parse and writer method for easy interfacing with .ris files.
15
+ Currently only common .ris tags are implemented
16
+ email:
17
+ - boeckhandrew@gmail.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - ".rspec"
23
+ - ".rubocop.yml"
24
+ - ".vscode/launch.json"
25
+ - CHANGELOG.md
26
+ - CLAUDE.md
27
+ - LICENSE.txt
28
+ - README.md
29
+ - Rakefile
30
+ - lib/rizzy.rb
31
+ - lib/rizzy/parser.rb
32
+ - lib/rizzy/reference.rb
33
+ - lib/rizzy/version.rb
34
+ - lib/rizzy/writer.rb
35
+ - sig/rizzy.rbs
36
+ homepage: https://github.com/arboeckh/rizzy
37
+ licenses:
38
+ - MIT
39
+ metadata:
40
+ homepage_uri: https://github.com/arboeckh/rizzy
41
+ source_code_uri: https://github.com/arboeckh/rizzy
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 3.1.0
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubygems_version: 3.5.11
58
+ signing_key:
59
+ specification_version: 4
60
+ summary: A .ris file parser and writer for ruby
61
+ test_files: []