Like PHP, Ruby ships as source, so the dongle earns its place when you install on customer hardware rather than hosting yourself.
KeyNub::Dongle.open do |dongle| # closed when the block ends
raise 'no genuine KeyNub' unless dongle.genuine?
dongle.session_open
license = dongle.record_read('license')
endCode language: Ruby (ruby)
The block form closes the device when the block exits, including when it exits by raising. The binding uses FFI, so there is no native gem to compile.
And the rule that matters in every language: do not branch on a boolean. Encrypt data your program genuinely needs with appEncrypt at build time and decrypt it through the dongle at run time, so removing the check leaves the program with nothing to compute rather than a working unlicensed copy.