Gem Version Build Status Code Climate Pull Requests Commits since latest

Installation

gem install paneron-register

Usage

require "paneron/register"
include Paneron::Register

# Initialize a new data set
# This example uses a working copy of Paneron's data set.
# => Raw::DataSet
raw_data_set = Raw::DataSet.new(
  "/Users/username/Library/Application Support/Electron/working_copies/00000000-0001-0000-0000-000000000001",
  "data_set_name-1"
)

# => DataSet < Lutaml::Model::Serializable
data_set = raw_data_set.to_lutaml

# Alternatively, initialize a new register:
# => Paneron::Register::Raw::Register
raw_register = Raw::Register.new(
  "/Users/username/Library/Application Support/Electron/working_copies/00000000-0001-0000-0000-000000000001",
)

# This example uses a Git URL
# => Raw::Register
raw_register = Raw::Register.from_git(
  "https://github.com/isogr/registry",

  # optional.  For previously cloned repos, pulls from repo iff true.
  # update: true,
)

# => Raw::DataSet
raw_data_set = raw_register.data_sets("data_set_name-1")

# => DataSet < Lutaml::Model::Serializable
data_set = raw_data_set.to_lutaml

# Get all item class objects
# => { item-class-name: Raw::ItemClass }
raw_data_set.item_classes

# => [ ItemClass ]
data_set.item_classes

# Get a specific item class object
# => Raw::ItemClass
raw_item_class = raw_data_set.item_classes("item-class-1")

# => ItemClass < Lutaml::Model::Serializable
item_class = raw_item_class.to_lutaml

# Get all item objects in Ruby Hash format
# => { item-uuid: Raw::Item }
raw_item_class.items

# => [ Item ]
item_class.items

# Get a specific item property, using normal Ruby Hash methods
# => Raw::Item
raw_item = raw_item_class.items["00000000-0000-0000-0000-000000000001"]
id = raw_item["id"]
blob1 = raw_item["data"]["blob1"]

# Get a specific item property, from a Lutaml object
# => Item < Lutaml::Model::Serializable
item = raw_item.to_lutaml
id = item.to_h["id"]
blob1 = item.to_h["data"]["blob1"]

For more usage examples, see Examples and related spec/worked_examples_spec.rb.

Development

Git clone this repository, then install dependencies.

git clone https://github.com/paneron/ruby-paneron-register
cd ruby-paneron-register
bundle install

Without Nix

Open development shell (irb) with:

bundle exec irb

Open development shell (pry) with:

bundle exec pry

Run tests with:

bundle exec rspec
# or
bundle exec rake spec

Run lint with:

bundle exec rubocop

Run lint with autocorrect with:

bundle exec rubocop -a

Release to Rubygem (adds a Git tag, pushes to GitHub and releases to Rubygem) with:

bundle exec rake release

With Nix

If your system is using Nix, run the following to gain access to shell aliases:

nix develop

Open development shell (irb) with:

irb
# or
console

Open development shell (pry) with:

pry

Run tests with:

rspec

Run lint with:

lint
# or
rubocop

Run lint with autocorrect with:

lint -a
# or
rubocop -a

Release to Rubygem (adds a Git tag, pushes to GitHub and releases to Rubygem) with:

release

Update Nix flakes with:

update-flakes

Release workflow

When actually creating a new version for release, do the following:

  1. Update the VERSION in file lib/paneron/register/version.rb.

  2. git add lib/paneron/register/version.rb
    git commit -m 'chore: Release vX.Y.Z' # change X.Y.Z to actual version
    git push
    
    # Run rake release
    bundle exec rake release

License