moat 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -1
- data/bin/moat +61 -1
- data/lib/moat.rb +40 -2
- data/moat-0.0.1.gem +0 -0
- data/moat.gemspec +4 -1
- metadata +5 -5
data/History.txt
CHANGED
data/bin/moat
CHANGED
@@ -1,3 +1,63 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
# Almost everything here is stolen from Giles Bowkett's
|
4
|
+
# password gem. sudo gem install password for the original good shit.
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'optparse'
|
8
|
+
|
9
|
+
require "#{File.dirname(__FILE__)}/../lib/moat"
|
10
|
+
include Moat
|
11
|
+
|
12
|
+
load_passwords
|
13
|
+
|
14
|
+
option_parser = OptionParser.new do |option_parser|
|
15
|
+
option_parser.on("-?", "--grep query", String) do |query|
|
16
|
+
@query = query
|
17
|
+
@action = :grep
|
18
|
+
end
|
19
|
+
|
20
|
+
option_parser.on("-a") do
|
21
|
+
@action = :all
|
22
|
+
end
|
23
|
+
|
24
|
+
option_parser.on("-s", "--set site", String) do |site|
|
25
|
+
@site = site
|
26
|
+
@action = :set
|
27
|
+
end
|
28
|
+
|
29
|
+
option_parser.on("-l", "--length length") do |length|
|
30
|
+
@length = length.to_i
|
31
|
+
end
|
32
|
+
|
33
|
+
option_parser.on("-G", "--generating_set site") do |site|
|
34
|
+
@site = site
|
35
|
+
@action = :set
|
36
|
+
@length ||= 10
|
37
|
+
@generated = generate(@length)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
username, password = option_parser.parse(ARGV)
|
42
|
+
password ||= @generated
|
43
|
+
|
44
|
+
def show_credentials_for(site)
|
45
|
+
abort "No password stored for #{site}" unless Moat::SITES[site]
|
46
|
+
puts site
|
47
|
+
puts " username: #{Moat::SITES[site][:username]}"
|
48
|
+
puts " password: #{Moat::SITES[site][:password]}"
|
49
|
+
end
|
50
|
+
|
51
|
+
case @action
|
52
|
+
when :get
|
53
|
+
show_credentials_for(@site)
|
54
|
+
when :all
|
55
|
+
Moat::SITES.keys.each {|site| show_credentials_for(site)}
|
56
|
+
when :set
|
57
|
+
Moat::SITES[@site] = {:username => username, :password => password }
|
58
|
+
show_credentials_for(@site) if @generated
|
59
|
+
save_passwords
|
60
|
+
when :grep
|
61
|
+
Moat::SITES.keys.each {|site| show_credentials_for(site) if site =~ /#{@query}/ }
|
62
|
+
end
|
63
|
+
|
data/lib/moat.rb
CHANGED
@@ -1,3 +1,41 @@
|
|
1
|
-
|
2
|
-
VERSION = '
|
1
|
+
module Moat
|
2
|
+
VERSION = '0.0.1'
|
3
|
+
FILENAME = "#{ENV['HOME']}/.moatfile"
|
4
|
+
SITES = {}
|
5
|
+
|
6
|
+
def set(credentials)
|
7
|
+
SITES[credentials[:site]] = {
|
8
|
+
:username => credentials[:username],
|
9
|
+
:password => credentials[:password]
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
def username(site)
|
14
|
+
SITES[site][:username]
|
15
|
+
end
|
16
|
+
|
17
|
+
def password(site)
|
18
|
+
SITES[site][:password]
|
19
|
+
end
|
20
|
+
|
21
|
+
def save_passwords
|
22
|
+
File.open(FILENAME, "w") {|file| file.puts SITES.to_yaml }
|
23
|
+
end
|
24
|
+
|
25
|
+
def load_passwords
|
26
|
+
if File.exists?(FILENAME)
|
27
|
+
SITES.merge!(YAML::load(File.open(FILENAME)))
|
28
|
+
else
|
29
|
+
{}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def generate
|
34
|
+
letters = ('a'..'z').to_a
|
35
|
+
numbers = ('0'..'9').to_a
|
36
|
+
alphanumeric_array = letters + numbers
|
37
|
+
alphanumeric_array.shuffle[0..9].join
|
38
|
+
end
|
39
|
+
|
3
40
|
end
|
41
|
+
|
data/moat-0.0.1.gem
ADDED
Binary file
|
data/moat.gemspec
CHANGED
@@ -2,11 +2,14 @@ require 'rubygems'
|
|
2
2
|
|
3
3
|
SPEC = Gem::Specification.new do |s|
|
4
4
|
s.name = "moat"
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.2"
|
6
6
|
s.author = "Bryan Woods"
|
7
7
|
s.email = "bryanwoods4e@gmail.com"
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
|
+
s.description = "Brain-dead simple password storage. Improved."
|
9
10
|
s.summary = "Brain-dead simple password storage. Improved."
|
11
|
+
s.rubyforge_project = "moat"
|
12
|
+
s.homepage = "http://github.com/bryanwoods/moat"
|
10
13
|
s.files = Dir.glob("**/*")
|
11
14
|
s.executables << "moat"
|
12
15
|
s.require_path = "lib"
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Bryan Woods
|
@@ -18,7 +18,7 @@ date: 2010-04-01 00:00:00 -04:00
|
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
21
|
-
description:
|
21
|
+
description: Brain-dead simple password storage. Improved.
|
22
22
|
email: bryanwoods4e@gmail.com
|
23
23
|
executables:
|
24
24
|
- moat
|
@@ -37,7 +37,7 @@ files:
|
|
37
37
|
- README.txt
|
38
38
|
- test/test_moat.rb
|
39
39
|
has_rdoc: true
|
40
|
-
homepage:
|
40
|
+
homepage: http://github.com/bryanwoods/moat
|
41
41
|
licenses: []
|
42
42
|
|
43
43
|
post_install_message:
|
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
61
|
version: "0"
|
62
62
|
requirements: []
|
63
63
|
|
64
|
-
rubyforge_project:
|
64
|
+
rubyforge_project: moat
|
65
65
|
rubygems_version: 1.3.6
|
66
66
|
signing_key:
|
67
67
|
specification_version: 3
|