{"payload":{"feedbackUrl":"https://github.com/orgs/community/discussions/53140","repo":{"id":933839,"defaultBranch":"main","name":"ruby-marc","ownerLogin":"ruby-marc","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2010-09-23T16:48:01.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/412970?v=4","public":true,"private":false,"isOrgOwned":true},"refInfo":{"name":"","listCacheKey":"v0:1715794714.0","currentOid":""},"activityList":{"items":[{"before":"2a8543e96252e26122a917550dd0eea8edb7bc9b","after":"09cdda998484be03997bb146f102bf767e3c39d2","ref":"refs/heads/record_as_factory","pushedAt":"2024-05-15T17:57:57.000Z","pushType":"force_push","commitsCount":0,"pusher":{"login":"billdueber","name":"Bill Dueber","path":"/billdueber","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/114006?s=80&v=4"},"commit":{"message":"Allow readers to take a custom Record class\n\nMost uses of a MARC record require extraction of things\nlike OCLC numbers, local identifiers, etc. The ruby-marc\nreader classes hard-code the use of MARC::Record, which\nmeans folks who want to do that either need to inline\ntheir code, wrap a MARC::Record object, or call\nthe reader.\n\nThis code allows the binary reader and the non-REXML\nXML readers to take a `record_class` option. The\nrequired interface is for the passed class is:\n\n* `#append_control_field(tag, value)`\n* `#append_data_field(tag, ind1, ind2, subfields)` where `subfields` is an array of [code, value] pairs\n* `#leader` and `#leader=`\n* `#new_from_hash(marc_hash)` which is used in the XML reader to avoid using specific field classes\n\nAll the rest of the code has been modified to use just those methods when building up a record.\n\nThe easiest way to take advantage of this would be to just subclass MARC::Record, e.g.\n\n```\nclass MyRecord < MARC::Record\n def isbns\n m = /[\\d\\-Xx]{10,15}/\n fields('020').map{|f| f['a'].scan(m).first.gsub('-', '').upcase}\n end\nend\n\nr = MARC::Reader.new(\"test/batch.dat\", record_class: MyRecord).first\nr.isbns #=> [\"0471383147\"]\n\n```","shortMessageHtmlLink":"Allow readers to take a custom Record class"}},{"before":null,"after":"2a8543e96252e26122a917550dd0eea8edb7bc9b","ref":"refs/heads/record_as_factory","pushedAt":"2024-05-15T17:38:34.000Z","pushType":"branch_creation","commitsCount":0,"pusher":{"login":"billdueber","name":"Bill Dueber","path":"/billdueber","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/114006?s=80&v=4"},"commit":{"message":"Allow readers to take a custom Record class\n\nMost uses of a MARC record require extraction of things\nlike OCLC numbers, local identifiers, etc. The ruby-marc\nreader classes hard-code the use of MARC::Record, which\nmeans folks who want to do that either need to inline\ntheir code, wrap a MARC::Record object, or call\nthe reader.\n\nThis code allows the binary reader and the non-REXML\nXML readers to take a `record_class` option. The\nrequired interface is for the passed class is:\n\n* `#append_control_field(tag, value)`\n* `#append_data_field(tag, ind1, ind2, subfields)` where `subfields` is an array of [code, value] pairs\n* `#leader` and `#leader=`\n* `#new_from_hash(marc_hash)` which is used in the XML reader to avoid using specific field classes\n\nAll the rest of the code has been modified to use just those methods when building up a record.\n\nThe easiest way to take advantage of this would be to just subclass MARC::Record, e.g.\n\n```\nclass MyRecord < MARC::Record\n def isbns\n m = /[\\d\\-Xx]{10,15}/\n fields('020').map{|f| f['a'].scan(m).first.gsub('-', '').upcase}\n end\nend\n\nr = MARC::Reader.new(\"test/batch.dat\", record_class: MyRecord).first\nr.isbns #=> [\"0471383147\"]\n\n```","shortMessageHtmlLink":"Allow readers to take a custom Record class"}},{"before":null,"after":"e729274053f0c07262cac5bd019f64ae51c952b7","ref":"refs/heads/allow_custom_record_class_for_readers","pushedAt":"2023-03-10T05:58:58.009Z","pushType":"branch_creation","commitsCount":0,"pusher":{"login":"billdueber","name":"Bill Dueber","path":"/billdueber","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/114006?s=80&v=4"},"commit":{"message":"Allow passing of custom MARC::Record-derived class to readers\n\nCurrently, the use of MARC::Record is hard-coded into the readers, when really any\nduck-typed alternative would be fine. This makes it hard for people to develop\nlocal customizations on the record (to, e.g., get the sublibraries that hold a monograph),\nthe only option being to build external methods/functions to extract the data\n(e.g., `get_oclcs(rec)`, instead of `rec.oclcs`)\n\nSimilarly, the current MARC::Record implementation is driven largely by the needs of\nthose of us who are more than willing to trade memory use and initialization time\nin order to make many reads from a record slightly faster. If anyone else would rather\nmake different tradeoffs they have no options at all.\n\nThis non-breaking change allows passing in a `record_class:` keyword argument\nto the readers, which will then use that class to build records instead of\na vanilla MARC::Record.\n\n```ruby\n\nclass MyMarc < MARC::Record\n include \"my_library_stuff\"\n include \"someone_elses_standard_identifier_stuff\"\nend\n\nreader = MARC::XMLReader.new(\"/path/to/file.xml\", record_class: MyMarc)\nreader.each do |rec|\n puts rec.oclcs.join(\"\\n\")\nend\n\n```","shortMessageHtmlLink":"Allow passing of custom MARC::Record-derived class to readers"}}],"hasNextPage":false,"hasPreviousPage":false,"activityType":"all","actor":null,"timePeriod":"all","sort":"DESC","perPage":30,"cursor":"djE6ks8AAAAEStcdnwA","startCursor":null,"endCursor":null}},"title":"Activity ยท ruby-marc/ruby-marc"}