module Rubyists::Opr
Main namespace
Main namespace
Main namespace
Main namespace
Main namespace
Constants
- LIBDIR
- MODEL_DIR
- ROOT
- VERSION
Public Class Methods
L(lib)
click to toggle source
# File lib/rubyists::opr.rb, line 46 def self.L(lib) # rubocop:disable Naming/MethodName require LIBDIR.join(lib.to_s).to_s end
M(model)
click to toggle source
# File lib/rubyists::opr.rb, line 50 def self.M(model) # rubocop:disable Naming/MethodName require MODEL_DIR.join(model.to_s).to_s end
R(rbf)
click to toggle source
# File lib/rubyists::opr.rb, line 42 def self.R(rbf) # rubocop:disable Naming/MethodName require ROOT.join(rbf.to_s).to_s end
login!()
click to toggle source
# File lib/rubyists::opr.rb, line 23 def self.login! out = `#{opbin} signin 2>&1` raise "Problem logging in #{out}" if out.match? '(ERROR)' firstline = out.split("\n").first.split('=') key = firstline.first.split.last val = JSON.parse(firstline.last) ENV[key] = val end
opbin(bin_name: 'op')
click to toggle source
# File lib/rubyists::opr.rb, line 33 def self.opbin(bin_name: 'op') raise Error, 'attribute bin_name cannot be nil' if bin_name.empty? @opbin ||= `which #{bin_name}`.chomp raise Error, '`op` binary not found' if @opbin.empty? @opbin end
s_or_no(count)
click to toggle source
# File lib/rubyists::opr/utils.rb, line 7 def self.s_or_no(count) # {{{ count == 1 ? '' : 's' end
with_login() { || ... }
click to toggle source
# File lib/rubyists::opr.rb, line 12 def self.with_login yield rescue TTY::Command::ExitError => e raise unless e.to_s.match?(/not currently signed in|401: Authentication/) warn 'You are not currently logged in to 1pass' warn 'Consider running `eval (op signin)` in your shell to avoid logging in for each opr command' Opr.login! retry end