Module: Shhh::App

Defined in:
lib/shhh/app.rb,
lib/shhh/app/cli.rb,
lib/shhh/app/nlp.rb,
lib/shhh/app/args.rb,
lib/shhh/app/cache.rb,
lib/shhh/app/output.rb,
lib/shhh/app/commands.rb,
lib/shhh/app/keychain.rb,
lib/shhh/app/nlp/usage.rb,
lib/shhh/app/short_name.rb,
lib/shhh/app/output/base.rb,
lib/shhh/app/output/file.rb,
lib/shhh/app/output/noop.rb,
lib/shhh/app/input/handler.rb,
lib/shhh/app/nlp/constants.rb,
lib/shhh/app/output/stdout.rb,
lib/shhh/app/nlp/translator.rb,
lib/shhh/app/commands/command.rb,
lib/shhh/app/commands/print_key.rb,
lib/shhh/app/commands/show_help.rb,
lib/shhh/app/private_key/handler.rb,
lib/shhh/app/commands/open_editor.rb,
lib/shhh/app/private_key/detector.rb,
lib/shhh/app/commands/generate_key.rb,
lib/shhh/app/commands/show_version.rb,
lib/shhh/app/private_key/decryptor.rb,
lib/shhh/app/commands/show_examples.rb,
lib/shhh/app/commands/encrypt_decrypt.rb,
lib/shhh/app/private_key/base64_decoder.rb,
lib/shhh/app/commands/delete_keychain_item.rb,
lib/shhh/app/commands/show_language_examples.rb

Overview

The App Module is responsible for handing user input and executing commands. Central class in this module is the CLI class.

Methods in this module are responsible for reporting errors and maintaining the future exit code class-global variable.

It also contains several helpers that enable some additional functionality on Mac OS-X (such as using KeyChain for storing encryption keys).

Defined Under Namespace

Modules: Commands, Input, NLP, Output, PrivateKey, ShortName Classes: Args, CLI, Cache, KeyChain

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.exit_codeObject

Returns the value of attribute exit_code.



16
17
18
# File 'lib/shhh/app.rb', line 16

def exit_code
  @exit_code
end

Class Method Details

.error(config: {}, exception: nil, type: nil, details: nil, reason: nil, comments: nil) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/shhh/app.rb', line 25

def self.error(
  config: {},
  exception: nil,
  type: nil,
  details: nil,
  reason: nil,
  comments: nil)

  self.out.puts([\
                "#{(type || exception.class.name).titleize}:".red.bold.underlined +
                (sprintf '  %s', details || exception.message).red.italic,
                (reason ? "\n#{reason.blue.bold.italic}" : nil),
                (comments ? "\n\n#{comments}" : nil)].compact.join("\n"))
  self.out.puts "\n" + exception.backtrace.join("\n").bold.red if exception && config && config[:trace]
  self.exit_code = 1
end

.is_osx?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/shhh/app.rb', line 42

def self.is_osx?
  Gem::Platform.local.os.eql?('darwin')
end

.outObject



21
22
23
# File 'lib/shhh/app.rb', line 21

def self.out
  STDERR
end

.this_osObject



45
46
47
# File 'lib/shhh/app.rb', line 45

def self.this_os
  Gem::Platform.local.os
end