{"id":18650259,"url":"https://github.com/zuki/jpmarc","last_synced_at":"2025-06-20T12:13:21.436Z","repository":{"id":149401843,"uuid":"81175966","full_name":"zuki/jpmarc","owner":"zuki","description":null,"archived":false,"fork":false,"pushed_at":"2017-04-08T00:07:10.000Z","size":83,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-27T13:10:21.256Z","etag":null,"topics":["elixir","marc"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zuki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-07T06:45:32.000Z","updated_at":"2017-02-16T05:13:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"f443fa36-0f13-42d7-885b-e2b18599fc8c","html_url":"https://github.com/zuki/jpmarc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuki%2Fjpmarc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuki%2Fjpmarc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuki%2Fjpmarc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuki%2Fjpmarc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zuki","download_url":"https://codeload.github.com/zuki/jpmarc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239457662,"owners_count":19642092,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","marc"],"created_at":"2024-11-07T06:43:05.233Z","updated_at":"2025-02-18T10:43:49.586Z","avatar_url":"https://github.com/zuki.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JPMarc\n\nA library for using JPMARC in Elixir\n\n## Installation\n\nAdd `jpmarc` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [{:jpmarc, github: \"zuki/jpmarc\"}]\nend\n```\n\n## Usage\n\n````elixir\nalias JPMarc.Record\nalias JPMarc.Leader\nalias JPMarc.ControlField, as: CF\nalias JPMarc.DataField, as: DF\nalias JPMarc.SubField, as: SF\nimport JPMarc.MarkSigil\n\n# Read MARC file and process every MARC record\n\nfor record \u003c- JPMarc.parse_file(\"marc.dat\") do\n  # Print a value of field 245, subfield a\n  IO.puts Record.subfield_value(record, \"245\", \"a\")\nend\n\n# Construct a JPMarc.Record\n\nleader = %Leader{}\nt001 = %CF{tag: \"001\", value: \"1234\"}\nt003 = %CF{tag: \"003\", value: \"JTNDL\"}\nt245a = %SF{code: \"a\", value: \"Book title /\"}\nt245c = %SF{code: \"c\", value: \"Yamada, Taro.\"}\nt245 = %DF{tag: \"245\", ind1: \"0\", ind2: \"0\", subfields: [t245a, t245c]}\nrecord = %Record{leader: leader, fields: [t001, t003, t245]}\n\n# Construct a JPMarc.Record with ~m sigil\nrecord = %Record{leader: %Leader{}, fields: [~m\"001 1234\", ~m\"003 JTNDL\", ~m\"245 00 $a Book title / $b Yamada, Taro.\"]}\n\n# Write records in MARC format\nFile.write(\"marc.dat\", JPMarc.to_marc(record))\n\n# Write records in MARCXML format\nFile.write(\"marc.xml\", JPMarc.to_xml(record))\n\n# Write records in Mark-in-json format\nFile.write(\"marc.json\", JPMarc.to_json(record))\n\n# Write records in Text format\nFile.write(\"marc.txt\", Record.to_text(record))\n````\n\n## ~m Sigil\n\nCovert string in Text MARC format to JPMarc.Record.\n\n````elixir\n# Record\nrecord = ~m\"\"\"\n00276nam a2200109zi 4500\n001 123456789012\n003 JTNDL\n005 20170209103923.0\n007 ta\n008 170209s2017    ja ||||g |||| |||||||jpn\n020    $c 2000 $z 978-4-123456-01-0\n245 00 $a Book title : $b subtitle / $c Yamada Taro.\n\"\"\"\n\nIO.puts Record.subfield_value(record, \"245\", \"a\") # -\u003e \"Book title : \"\n\n# Leader\nleader = ~m\"00276nam a2200109zi 4500\"\n\n# Control field\ncf = ~m\"001 123456789012\"\n\n# Data field\ndf = ~m\"245 00 $a Book title : $b subtitle / $c Yamada Taro.\"\n\n# fields\nfields = ~m\"\"\"\n001 123456789012\n245 00 $a Book title : $b subtitle / $c Yamada Taro.\n\"\"\"\n\nlength(fields) # -\u003e 2\nJPMarc.is_controlfield(Enum.at(fields, 0)) # -\u003e true\nJPMarc.is_datafield(Enum.at(fields, 1)) # -\u003e true\n````\n\n## API documents\n\n````elixir\nmix docs\n\nopen \"doc/index.html\"\n````\n\n## License\n\nThis software released under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzuki%2Fjpmarc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzuki%2Fjpmarc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzuki%2Fjpmarc/lists"}