Class: HttpLockrInit

Inherits:
Object
  • Object
show all
Defined in:
lib/lockr/http/httplockrinit.rb

Instance Method Summary collapse

Instance Method Details

#getLoadBrowserObject



30
31
32
# File 'lib/lockr/http/httplockrinit.rb', line 30

def getLoadBrowser
  return @load_browser
end

#getPwdMgrObject



26
27
28
# File 'lib/lockr/http/httplockrinit.rb', line 26

def getPwdMgr
  return @pwdmgr
end

#parse_optionsObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/lockr/http/httplockrinit.rb', line 34

def parse_options()
  options = {}
  
  optparse = OptionParser.new do|opts|
  # Set a banner, displayed at the top
  # of the help screen.
    opts.banner = "Usage: httplockr [options]"
  
    options[:keyfile] = nil
    opts.on( '-k', '--keyfile FILE', 'the FILE to use as key for the password encryption') do |file|
      options[:keyfile] = File.expand_path(file)
    end
    
    options[:vault] = 'vault.yaml'
    opts.on( '-v', '--vault FILE', 'FILE is the name of the vault to store the password sets') do |file|
      options[:vault] = File.expand_path(file)
    end
    
    options[:browser] = false
    opts.on( '-b', '--browser', 'open browser windows for lockr') do |d|
      options[:browser] = true
    end
    
    # This displays the help screen, all programs are
    # assumed to have this option.
    opts.on( '-h', '--help', 'Display this screen' ) do
      puts opts
      exit
    end
    
    opts.on('--version', 'Show version') do
      puts "HttpLockr #{LockrVer::VERSION} (#{LockrVer::DATE})"
      exit
    end
    
    opts.separator ""
    opts.separator "For detailed instructions on how to use HttpLockr, please visit http://lockr.byteblues.com"
  end
  
  # Parse the command-line. Remember there are two forms
  # of the parse method. The 'parse' method simply parses
  # ARGV, while the 'parse!' method parses ARGV and removes
  # any options found there, as well as any parameters for
  # the options. What's left is the list of files to resize.
  optparse.parse!

  options
end

#startObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/lockr/http/httplockrinit.rb', line 7

def start()
  options = parse_options()
  
  unless options[:keyfile]
    puts 'Please provide a keyfile'
    raise ArgumentError
  end
  
  configfile = Configuration.new()
  cfg = nil
  if configfile.config
    cfg = configfile.config[:lockr]
  end
  options[:vault] = File.expand_path(cfg[:vault]) if options[:vault] == 'vault.yaml' and cfg != nil
  
  @pwdmgr = PasswordManager.new( options[:keyfile], options[:vault])
  @load_browser = options[:browser]
end