Module: Rubyists::Opr
- Defined in:
- lib/rubyists::opr.rb,
lib/rubyists::opr/cli.rb,
lib/rubyists::opr/utils.rb,
lib/rubyists::opr/command.rb,
lib/rubyists::opr/version.rb,
lib/rubyists::opr/model/item.rb,
lib/rubyists::opr/commands/rm.rb,
lib/rubyists::opr/model/vault.rb,
lib/rubyists::opr/commands/gen.rb,
lib/rubyists::opr/commands/get.rb,
lib/rubyists::opr/commands/list.rb,
lib/rubyists::opr/commands/list/items.rb,
lib/rubyists::opr/commands/list/vaults.rb
Overview
Main namespace
Defined Under Namespace
Modules: Commands, Utils Classes: CLI, Command, Error, Item, Vault
Constant Summary collapse
- ROOT =
Pathname(__FILE__).dirname..join('..').
- LIBDIR =
ROOT.join('lib/rubyists::opr')
- MODEL_DIR =
LIBDIR.join('model')
- VERSION =
'0.3.0'.freeze
Class Method Summary collapse
-
.L(lib) ⇒ Object
rubocop:disable Naming/MethodName.
- .login! ⇒ Object
-
.M(model) ⇒ Object
rubocop:disable Naming/MethodName.
- .opbin(bin_name: 'op') ⇒ Object
-
.R(rbf) ⇒ Object
rubocop:disable Naming/MethodName.
-
.s_or_no(count) ⇒ Object
{{{.
- .with_login ⇒ Object
Class Method Details
.L(lib) ⇒ Object
rubocop:disable Naming/MethodName
46 47 48 |
# File 'lib/rubyists::opr.rb', line 46 def self.L(lib) # rubocop:disable Naming/MethodName require LIBDIR.join(lib.to_s).to_s end |
.login! ⇒ Object
23 24 25 26 27 28 29 30 31 |
# 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 |
.M(model) ⇒ Object
rubocop:disable Naming/MethodName
50 51 52 |
# 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 |
.opbin(bin_name: 'op') ⇒ Object
33 34 35 36 37 38 39 40 |
# 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 |
.R(rbf) ⇒ Object
rubocop:disable Naming/MethodName
42 43 44 |
# File 'lib/rubyists::opr.rb', line 42 def self.R(rbf) # rubocop:disable Naming/MethodName require ROOT.join(rbf.to_s).to_s end |
.s_or_no(count) ⇒ Object
{{{
7 8 9 |
# File 'lib/rubyists::opr/utils.rb', line 7 def self.s_or_no(count) # {{{ count == 1 ? '' : 's' end |
.with_login ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# 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 |