perfect_world 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # Perfect World Manager (pwm)
2
2
 
3
- ![build status](https://api.travis-ci.org/ushis/perfect_world.png)
3
+ [![Build Status](https://travis-ci.org/ushis/perfect_world.png)](https://travis-ci.org/ushis/perfect_world)
4
+ [![Dependency Status](https://gemnasium.com/ushis/perfect_world.png)](https://gemnasium.com/ushis/perfect_world)
5
+ [![Code Climate](https://codeclimate.com/github/ushis/perfect_world.png)](https://codeclimate.com/github/ushis/perfect_world)
4
6
 
5
- The perfect world manager is the attempt to build a simple but secure
7
+ The perfect world manager is an attempt to build a simple but secure
6
8
  password manager for the cli.
7
9
 
8
10
  This is work in progress and has not been audited by security experts.
@@ -29,9 +31,9 @@ Dropbox, but they should not get my passwords.)
29
31
 
30
32
  You need an installed and set up version of gnupg. It should be available
31
33
  in the package repo of your linux distribution. There are also several ways
32
- to install it on a Mac. I tested the code with version 2.0.19.
34
+ to install it on a Mac.
33
35
 
34
- In addition you will need at least Ruby 1.9.
36
+ In addition you will need at least Ruby 1.9.3.
35
37
 
36
38
  ## pwm
37
39
 
@@ -103,14 +105,14 @@ pwm looks for the config file at ```~/.pwmrc``` by default. This can be
103
105
  changed with the ```--config``` switch. It contains straight forward Yaml.
104
106
 
105
107
  ---
106
- owner: ushi@porkbox.net # Used as ecryption recipient by GPG.
108
+ owner: ushi@porkbox.net # Used as encryption recipient by GPG.
107
109
  length: 64 # Length of the generated password.
108
110
  gpgdir: /home/ushi/.gnupg # Path to the GnuPG home dir.
109
111
  database: /home/ushi/.pwm.yml.gpg # Path to the password database.
110
112
 
111
113
  # License (MIT)
112
114
 
113
- Copyright (c) 2013 ushi
115
+ Copyright (c) 2013 ushi <ushi@porkbox.net>
114
116
 
115
117
  Permission is hereby granted, free of charge, to any person obtaining a copy
116
118
  of this software and associated documentation files (the "Software"), to deal
@@ -1,9 +1,9 @@
1
1
  require 'gpgme'
2
- require 'clipboard'
3
2
 
4
3
  require 'perfect_world/db'
5
4
  require 'perfect_world/error'
6
5
  require 'perfect_world/storage'
6
+ require 'perfect_world/clipboard'
7
7
 
8
8
  module PerfectWorld
9
9
 
@@ -87,7 +87,7 @@ module PerfectWorld
87
87
  # Prints a password or copies it to the clipboard.
88
88
  def print_or_copy_to_clipboard(id, password)
89
89
  if @config.fetch('clipboard')
90
- Clipboard.copy(password)
90
+ Clipboard << password
91
91
  puts "Copied the password for '#{id}' to your clipboard."
92
92
  else
93
93
  print_password(id, password)
@@ -0,0 +1,57 @@
1
+ require 'perfect_world/error'
2
+
3
+ module PerfectWorld
4
+
5
+ # Writes/Reads data from/to the users clipboard.
6
+ #
7
+ # Works in graphical environments only. So it is not available
8
+ # via SSH and stuff.
9
+ class Clipboard
10
+ class << self
11
+
12
+ # Common clipboard tools.
13
+ COMMANDS = [{
14
+ read: 'xclip -selection clipboard -o',
15
+ write: 'xclip -selection clipboard'
16
+ }, {
17
+ read: 'xsel -b -o',
18
+ write: 'xsel -b'
19
+ }, {
20
+ read: 'pbpaste',
21
+ write: 'pbcopy'
22
+ }]
23
+
24
+ # Find a working clipboard tool.
25
+ CMD = COMMANDS.find { |c| system("#{c[:read]} &>/dev/null") }
26
+
27
+ # Returns true if the clipboard is available, else false.
28
+ def available?
29
+ ! CMD.nil?
30
+ end
31
+
32
+ # Writes a string to the clipboard.
33
+ def write(s)
34
+ run do
35
+ IO.popen(CMD[:write], 'w') { |io| io << s }
36
+ end
37
+ end
38
+
39
+ alias :<< :write
40
+
41
+ # Reads a string from the clipboard.
42
+ def read
43
+ run { `#{CMD[:read]}` }
44
+ end
45
+
46
+ private
47
+
48
+ # Wraps the system calls to catch errors.
49
+ def run
50
+ raise ClipboardNotAvailable unless available?
51
+ yield
52
+ rescue SystemCallError, IOError => e
53
+ raise Error, e
54
+ end
55
+ end
56
+ end
57
+ end
@@ -10,10 +10,17 @@ module PerfectWorld
10
10
  end
11
11
  end
12
12
 
13
- # Should be raised if a database corruption is detected.
13
+ # Should be raised, when a database corruption is detected.
14
14
  class CorruptedDatabase < Error
15
15
  def initialize(database)
16
16
  super("Database seems corrupted: #{database}")
17
17
  end
18
18
  end
19
+
20
+ # Should be raised, when no clipboard tool could be found.
21
+ class ClipboardNotAvailable < Error
22
+ def initialize
23
+ super("The clipboard is not available on this system.")
24
+ end
25
+ end
19
26
  end
@@ -1,3 +1,3 @@
1
1
  module PerfectWorld
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
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.0
4
+ version: 0.2.1
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-06 00:00:00.000000000 Z
39
+ date: 2013-02-07 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: gpgme
@@ -54,22 +54,6 @@ dependencies:
54
54
  - - ~>
55
55
  - !ruby/object:Gem::Version
56
56
  version: 2.0.1
57
- - !ruby/object:Gem::Dependency
58
- name: clipboard
59
- requirement: !ruby/object:Gem::Requirement
60
- none: false
61
- requirements:
62
- - - ~>
63
- - !ruby/object:Gem::Version
64
- version: 1.0.1
65
- type: :runtime
66
- prerelease: false
67
- version_requirements: !ruby/object:Gem::Requirement
68
- none: false
69
- requirements:
70
- - - ~>
71
- - !ruby/object:Gem::Version
72
- version: 1.0.1
73
57
  description: An attempt to build a simple but secure password manager.
74
58
  email:
75
59
  - ushi@porkbox.net
@@ -78,13 +62,14 @@ executables:
78
62
  extensions: []
79
63
  extra_rdoc_files: []
80
64
  files:
81
- - lib/perfect_world/cli.rb
82
- - lib/perfect_world/storage.rb
65
+ - lib/perfect_world.rb
83
66
  - lib/perfect_world/version.rb
84
- - lib/perfect_world/random.rb
85
- - lib/perfect_world/db.rb
67
+ - lib/perfect_world/storage.rb
68
+ - lib/perfect_world/clipboard.rb
86
69
  - lib/perfect_world/error.rb
87
- - lib/perfect_world.rb
70
+ - lib/perfect_world/db.rb
71
+ - lib/perfect_world/random.rb
72
+ - lib/perfect_world/cli.rb
88
73
  - bin/pwm
89
74
  - README.md
90
75
  homepage: http://github.com/ushis/perfect_world
@@ -99,7 +84,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
84
  requirements:
100
85
  - - ! '>='
101
86
  - !ruby/object:Gem::Version
102
- version: 1.9.0
87
+ version: 1.9.3
103
88
  required_rubygems_version: !ruby/object:Gem::Requirement
104
89
  none: false
105
90
  requirements:
metadata.gz.sig CHANGED
Binary file