ueno / ruby-gpgme

a ruby interface to GnuPG Made Easy (GPGME).
GNU Lesser General Public License v2.1
232 stars 99 forks source link

Add the `ignore_mdc_error` flag setter and getter #180

Closed Verseth closed 10 months ago

Verseth commented 11 months ago

This fixes https://github.com/ueno/ruby-gpgme/issues/141.

I added a setter and getter for the ignore-mdc-error flag.

Example usage:

ctx = GPGME::Ctx.new
ctx.ignore_mdc_error #=> false

ctx.ignore_mdc_error = true
ctx.ignore_mdc_error #=> true

ctx = GPGME::Ctx.new(ignore_mdc_error: true)
ctx.ignore_mdc_error #=> true

I also added a generic pair of getter/setter methods that can be used to set ctx flags that have not been exposed through getters and setters in Ruby.

Example usage:

ctx = GPGME::Ctx.new
ctx.get_ctx_flag("ignore-mdc-error") #=> ""

ctx.ignore_mdc_error = true
ctx.ignore_mdc_error #=> true
ctx.get_ctx_flag("ignore-mdc-error") #=> "1"

ctx.set_ctx_flag("ignore-mdc-error", "0")
ctx.ignore_mdc_error #=> false
ctx.get_ctx_flag("ignore-mdc-error") #=> ""

ctx.set_ctx_flag("ignore-mdc-error", "1")
ctx.ignore_mdc_error #=> true
ctx.get_ctx_flag("ignore-mdc-error") #=> "1"

These two methods make it possible to use features that are available in GPGME but haven't been defined in the Ruby bindings, like the ignore-mdc-error flag prior to this PR.