perfect_world 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -30,10 +30,11 @@ Dropbox, but they should not get my passwords.)
30
30
  ## Dependencies
31
31
 
32
32
  You need an installed and set up version of gnupg. It should be available
33
- in the package repo of your linux distribution. There are also several ways
34
- to install it on a Mac.
33
+ in the package repo of your linux distribution. Check out the
34
+ [GPGTools](https://www.gpgtools.org/installer/index.html) project, if you
35
+ are on a Mac.
35
36
 
36
- In addition you will need at least Ruby 1.9.3.
37
+ In addition you need at least Ruby 1.9.3.
37
38
 
38
39
  ## pwm
39
40
 
@@ -60,6 +61,7 @@ Or clone the repo.
60
61
  -C, --clipboard Copies the password to the clipboard.
61
62
  -d, --delete ID Deletes the password.
62
63
  -D, --database [FILE] Prints or sets the used database.
64
+ -f, --force Override existing password.
63
65
  -g, --get ID Prints the password for an ID.
64
66
  -G, --generate ID Generates and stores a new passord.
65
67
  --gpgdir DIR Sets the path to the GPG directory.
@@ -94,6 +96,11 @@ Directly to the clipboard.
94
96
  $ pwm --clipboard --get google
95
97
  Copied the password for 'google' to your clipboard.
96
98
 
99
+ Override an existing password.
100
+
101
+ $ pwm --force --generate google
102
+ gi>VlHK<=m2D+}8X4P\( yB6(<Jk'/9^ JAwCjK|!j-$exDe83g8[CD.n^%cYxO7 google
103
+
97
104
  And delete one.
98
105
 
99
106
  $ pwm --delete google
@@ -110,6 +117,11 @@ changed with the ```--config``` switch. It contains straight forward Yaml.
110
117
  gpgdir: /home/ushi/.gnupg # Path to the GnuPG home dir.
111
118
  database: /home/ushi/.pwm.yml.gpg # Path to the password database.
112
119
 
120
+ ## Clipboard
121
+
122
+ The clipboard feature should work out of the box on Mac OS. If you are on a
123
+ Linux system you need to install ```xclip``` or ```xsel``` to make it work.
124
+
113
125
  # License (MIT)
114
126
 
115
127
  Copyright (c) 2013 ushi <ushi@porkbox.net>
data/bin/pwm CHANGED
@@ -34,7 +34,7 @@ parser = OptionParser.new do |parser|
34
34
  options[:config] = f
35
35
  end
36
36
 
37
- parser.on('-C', '--clipboard', "Copies the password to the clipboard.") do |c|
37
+ parser.on('-C', '--clipboard', 'Copies the password to the clipboard.') do |c|
38
38
  options[:clipboard] = c
39
39
  end
40
40
 
@@ -46,6 +46,10 @@ parser = OptionParser.new do |parser|
46
46
  options[:database] = f
47
47
  end
48
48
 
49
+ parser.on('-f', '--force', 'Override existing password.') do |f|
50
+ options[:force] = f
51
+ end
52
+
49
53
  parser.on('-g', '--get ID', 'Prints the password for an ID.') do |id|
50
54
  options[:get] = id
51
55
  end
@@ -98,7 +102,7 @@ rescue SystemCallError, Psych::Exception, Psych::SyntaxError => e
98
102
  end
99
103
 
100
104
  # Override config with command line options.
101
- [:clipboard, :database, :gpgdir, :length, :owner].each do |option|
105
+ [:clipboard, :database, :force, :gpgdir, :length, :owner].each do |option|
102
106
  config[option.to_s] = options.delete(option) unless options[option].nil?
103
107
  end
104
108
 
@@ -11,9 +11,10 @@ module PerfectWorld
11
11
 
12
12
  # Default config.
13
13
  CONFIG = {
14
- 'length' => 64,
14
+ 'clipboard' => false,
15
15
  'database' => File.expand_path('~/.pwm.yml.gpg'),
16
- 'clipboard' => false
16
+ 'force' => false,
17
+ 'length' => 64
17
18
  }
18
19
 
19
20
  # Sets the config.
@@ -52,7 +53,9 @@ module PerfectWorld
52
53
 
53
54
  # Generats a new password and sends it to stdout.
54
55
  def generate(db, id)
55
- print_or_copy_to_clipboard(id, db.generate(id, @config.fetch('length')))
56
+ len = @config.fetch('length')
57
+ pwd = @config['force'] ? db.generate!(id, len) : db.generate(id, len)
58
+ print_or_copy_to_clipboard(id, pwd)
56
59
  rescue Error => e
57
60
  raise Error, "Couldn't create password: #{e.message}"
58
61
  end
@@ -49,8 +49,18 @@ module PerfectWorld
49
49
  # store[:google]
50
50
  # #=> "B6m/![)A%fqw,\\ti-d`4\"&0>gl+>$0$Z"
51
51
  #
52
- # Returns the new password.
52
+ # Returns the new password or raises an error if the password is already
53
+ # in the database.
53
54
  def generate(id, len = 64)
55
+ if ! @passwords.key?(id)
56
+ generate!(id, len)
57
+ else
58
+ raise Error, "Password for '#{id}' is already in the database."
59
+ end
60
+ end
61
+
62
+ # Does the same as DB#generate, but overrides existing passwords.
63
+ def generate!(id, len = 64)
54
64
  @passwords[id] = Random.string(len)
55
65
  @changed = true
56
66
  @passwords[id]
@@ -1,3 +1,3 @@
1
1
  module PerfectWorld
2
- VERSION = '0.2.1'
2
+ VERSION = '0.3.0'
3
3
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perfect_world
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -36,7 +36,7 @@ cert_chain:
36
36
  bjRVQmxyeTVQVzB6ZzY0VEk5L1AzNEFHUXQ2SStUOHMKQnh0dUdkZ0YyMkpt
37
37
  M3ZYbGlySkJJSStvMDdIeDV3ZjJEUGRDMTRKRU1UUVZoRVFkc2ZwbU9ub2Q0
38
38
  SnpLdWRxNwpES1U9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
39
- date: 2013-02-07 00:00:00.000000000 Z
39
+ date: 2013-02-08 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: gpgme
@@ -62,14 +62,14 @@ executables:
62
62
  extensions: []
63
63
  extra_rdoc_files: []
64
64
  files:
65
- - lib/perfect_world.rb
66
- - lib/perfect_world/version.rb
65
+ - lib/perfect_world/cli.rb
67
66
  - lib/perfect_world/storage.rb
68
- - lib/perfect_world/clipboard.rb
69
- - lib/perfect_world/error.rb
70
- - lib/perfect_world/db.rb
67
+ - lib/perfect_world/version.rb
71
68
  - lib/perfect_world/random.rb
72
- - lib/perfect_world/cli.rb
69
+ - lib/perfect_world/db.rb
70
+ - lib/perfect_world/error.rb
71
+ - lib/perfect_world/clipboard.rb
72
+ - lib/perfect_world.rb
73
73
  - bin/pwm
74
74
  - README.md
75
75
  homepage: http://github.com/ushis/perfect_world
metadata.gz.sig CHANGED
Binary file