Top Level Namespace
Defined Under Namespace
Classes: Trocla
Instance Method Summary collapse
- #check_format(format_name) ⇒ Object
- #create(options) ⇒ Object
- #delete(options) ⇒ Object
- #formats(options) ⇒ Object
- #get(options) ⇒ Object
- #reset(options) ⇒ Object
- #set(options) ⇒ Object
Instance Method Details
#check_format(format_name) ⇒ Object
112 113 114 115 116 117 118 119 120 |
# File 'bin/trocla', line 112 def check_format(format_name) if format_name.nil? STDERR.puts 'Missing format, exiting...' exit 1 elsif !Trocla::Formats.available?(format_name) STDERR.puts "Error: The format #{format_name} is not available" exit 1 end end |
#create(options) ⇒ Object
49 50 51 52 53 54 55 |
# File 'bin/trocla', line 49 def create() [ Trocla.new(.delete(:config_file)).password( .delete(:trocla_key), .delete(:trocla_format), .merge(YAML.load(.delete(:other_options).shift.to_s)||{}) ) , 0 ] end |
#delete(options) ⇒ Object
101 102 103 104 105 106 |
# File 'bin/trocla', line 101 def delete() [ Trocla.new(.delete(:config_file)).delete_password( .delete(:trocla_key), .delete(:trocla_format) ), 0 ] end |
#formats(options) ⇒ Object
108 109 110 |
# File 'bin/trocla', line 108 def formats() "Available formats: #{Trocla::Formats.all.join(', ')}" end |
#get(options) ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'bin/trocla', line 57 def get() res = Trocla.new(.delete(:config_file)).get_password( .delete(:trocla_key), .delete(:trocla_format), .merge(YAML.load(.delete(:other_options).shift.to_s)||{}) ) [ res, res.nil? ? 1 : 0 ] end |
#reset(options) ⇒ Object
93 94 95 96 97 98 99 |
# File 'bin/trocla', line 93 def reset() [ Trocla.new(.delete(:config_file)).reset_password( .delete(:trocla_key), .delete(:trocla_format), .merge(YAML.load(.delete(:other_options).shift.to_s)||{}) ), 0 ] end |
#set(options) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'bin/trocla', line 65 def set() if .delete(:ask_password) require 'highline/import' password = ask('Enter your password: ') { |q| q.echo = 'x' }.to_s pwd2 = ask('Repeat password: ') { |q| q.echo = 'x' }.to_s unless password == pwd2 STDERR.puts 'Passwords did not match, exiting!' return [ nil, 1 ] end else password = .delete(:password) || STDIN.read.chomp end format = .delete(:trocla_format) no_format = .delete('no_format') trocla = Trocla.new(.delete(:config_file)) value = if no_format password else trocla.formats(format).format(password, (YAML.load(.delete(:other_options).shift.to_s)||{})) end trocla.set_password( .delete(:trocla_key), format, value ) [ '', 0 ] end |