keystorage 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -14,9 +14,9 @@ Simple password storage command.
14
14
 
15
15
  === Commands
16
16
 
17
- * list [group]
18
- * set group name value
19
- * get group name
17
+ * list [group]
18
+ * set group name value
19
+ * get group name
20
20
 
21
21
  == Contributing to keystorage
22
22
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -0,0 +1,71 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{keystorage}
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Yoshihiro TAKAHARA"]
12
+ s.date = %q{2011-01-16}
13
+ s.description = %q{This is a command to store and manage your passwords.}
14
+ s.email = %q{y.takahara@gmail.com}
15
+ s.executables = ["keystorage", "keystorage.rb"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE.txt",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ "Gemfile",
22
+ "LICENSE.txt",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "bin/keystorage",
27
+ "bin/keystorage.rb",
28
+ "keystorage.gemspec",
29
+ "lib/keystorage/cli.rb",
30
+ "lib/keystorage/command/base.rb",
31
+ "lib/keystorage/command/get.rb",
32
+ "lib/keystorage/command/help.rb",
33
+ "lib/keystorage/command/list.rb",
34
+ "lib/keystorage/command/set.rb",
35
+ "lib/keystorage/commands.rb",
36
+ "lib/keystorage/manager.rb",
37
+ "test/helper.rb",
38
+ "test/test_keystorage.rb"
39
+ ]
40
+ s.homepage = %q{http://github.com/tumf/keystorage}
41
+ s.licenses = ["MIT"]
42
+ s.require_paths = ["lib"]
43
+ s.rubygems_version = %q{1.4.2}
44
+ s.summary = %q{Simple password storage command}
45
+ s.test_files = [
46
+ "test/helper.rb",
47
+ "test/test_keystorage.rb"
48
+ ]
49
+
50
+ if s.respond_to? :specification_version then
51
+ s.specification_version = 3
52
+
53
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
54
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
55
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
56
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
57
+ s.add_development_dependency(%q<rcov>, [">= 0"])
58
+ else
59
+ s.add_dependency(%q<shoulda>, [">= 0"])
60
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
61
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
62
+ s.add_dependency(%q<rcov>, [">= 0"])
63
+ end
64
+ else
65
+ s.add_dependency(%q<shoulda>, [">= 0"])
66
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
67
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
68
+ s.add_dependency(%q<rcov>, [">= 0"])
69
+ end
70
+ end
71
+
@@ -1,63 +1,77 @@
1
1
  require 'yaml'
2
2
  require 'openssl'
3
3
 
4
- class Manager
4
+ module Keystorage
5
+ def list(group=nil)
6
+ Manager.new.list(group)
7
+ end
5
8
 
6
- def initialize(file)
7
- @file = file
9
+ def set(group,key,value)
10
+ Manager.new.set(group,key,value)
8
11
  end
9
12
 
10
- def list(group=null)
11
- data = Hash.new
12
- if File::exist?(@file)
13
- File.open(@file,'r') do |f|
14
- data = YAML.load(f)
15
- return data.keys unless group
16
- return data[group].keys
13
+ def get(group,name)
14
+ Manager.new.get(group,name)
15
+ end
16
+
17
+ class Manager
18
+
19
+ def initialize(file)
20
+ @file = file
21
+ end
22
+
23
+ def list(group=nil)
24
+ data = Hash.new
25
+ if File::exist?(@file)
26
+ File.open(@file,'r') do |f|
27
+ data = YAML.load(f)
28
+ return data.keys unless group
29
+ return data[group].keys
30
+ end
17
31
  end
32
+ Hash.new
18
33
  end
19
- Hash.new
20
- end
21
34
 
22
- def get(group,name)
23
- raise "missing group" unless group
24
- raise "missing name" unless name
35
+ def get(group,name)
36
+ raise "missing group" unless group
37
+ raise "missing name" unless name
25
38
 
26
- File.open(@file,'r') do |f|
27
- data=YAML.load(f)
28
- raise "missing key" unless data[group][name]
29
- return decode(data[group][name])
39
+ File.open(@file,'r') do |f|
40
+ data=YAML.load(f)
41
+ raise "missing key" unless data[group][name]
42
+ return decode(data[group][name])
43
+ end
44
+ false
30
45
  end
31
- false
32
- end
33
46
 
34
- def all
35
- return YAML.load_file(@file) if File.exist?(@file)
36
- Hash.new
37
- end
47
+ def all
48
+ return YAML.load_file(@file) if File.exist?(@file)
49
+ Hash.new
50
+ end
38
51
 
39
- def set(group,key,value)
40
- data=all
41
- data = Hash.new unless data
42
- data[group] = Hash.new unless data.has_key?(group)
43
- data[group][key] = encode(value)
52
+ def set(group,key,value)
53
+ data=all
54
+ data = Hash.new unless data
55
+ data[group] = Hash.new unless data.has_key?(group)
56
+ data[group][key] = encode(value)
44
57
 
45
- File.open(@file,'w',0600) do |f|
46
- YAML.dump(data,f)
58
+ File.open(@file,'w',0600) do |f|
59
+ YAML.dump(data,f)
60
+ end
47
61
  end
48
- end
49
62
 
50
- def encode(str,salt="3Qw9EtWE")
51
- enc = OpenSSL::Cipher::Cipher.new('aes256')
52
- enc.encrypt.pkcs5_keyivgen(salt)
53
- ((enc.update(str) + enc.final).unpack("H*")).to_s
54
- end
63
+ def encode(str,salt="3Qw9EtWE")
64
+ enc = OpenSSL::Cipher::Cipher.new('aes256')
65
+ enc.encrypt.pkcs5_keyivgen(salt)
66
+ ((enc.update(str) + enc.final).unpack("H*")).to_s
67
+ end
55
68
 
56
- def decode(str,salt="3Qw9EtWE")
57
- dec = OpenSSL::Cipher::Cipher.new('aes256')
58
- dec.decrypt.pkcs5_keyivgen(salt)
59
- (dec.update(Array.new([str]).pack("H*")) + dec.final)
69
+ def decode(str,salt="3Qw9EtWE")
70
+ dec = OpenSSL::Cipher::Cipher.new('aes256')
71
+ dec.decrypt.pkcs5_keyivgen(salt)
72
+ (dec.update(Array.new([str]).pack("H*")) + dec.final)
73
+ end
60
74
  end
61
- end
62
75
 
63
76
 
77
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keystorage
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Yoshihiro TAKAHARA
@@ -15,10 +15,11 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-15 00:00:00 +09:00
18
+ date: 2011-01-16 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
+ type: :development
22
23
  version_requirements: &id001 !ruby/object:Gem::Requirement
23
24
  none: false
24
25
  requirements:
@@ -31,8 +32,8 @@ dependencies:
31
32
  requirement: *id001
32
33
  prerelease: false
33
34
  name: shoulda
34
- type: :development
35
35
  - !ruby/object:Gem::Dependency
36
+ type: :development
36
37
  version_requirements: &id002 !ruby/object:Gem::Requirement
37
38
  none: false
38
39
  requirements:
@@ -47,8 +48,8 @@ dependencies:
47
48
  requirement: *id002
48
49
  prerelease: false
49
50
  name: bundler
50
- type: :development
51
51
  - !ruby/object:Gem::Dependency
52
+ type: :development
52
53
  version_requirements: &id003 !ruby/object:Gem::Requirement
53
54
  none: false
54
55
  requirements:
@@ -63,8 +64,8 @@ dependencies:
63
64
  requirement: *id003
64
65
  prerelease: false
65
66
  name: jeweler
66
- type: :development
67
67
  - !ruby/object:Gem::Dependency
68
+ type: :development
68
69
  version_requirements: &id004 !ruby/object:Gem::Requirement
69
70
  none: false
70
71
  requirements:
@@ -77,7 +78,6 @@ dependencies:
77
78
  requirement: *id004
78
79
  prerelease: false
79
80
  name: rcov
80
- type: :development
81
81
  description: This is a command to store and manage your passwords.
82
82
  email: y.takahara@gmail.com
83
83
  executables:
@@ -96,6 +96,7 @@ files:
96
96
  - VERSION
97
97
  - bin/keystorage
98
98
  - bin/keystorage.rb
99
+ - keystorage.gemspec
99
100
  - lib/keystorage/cli.rb
100
101
  - lib/keystorage/command/base.rb
101
102
  - lib/keystorage/command/get.rb
@@ -136,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
137
  requirements: []
137
138
 
138
139
  rubyforge_project:
139
- rubygems_version: 1.4.1
140
+ rubygems_version: 1.4.2
140
141
  signing_key:
141
142
  specification_version: 3
142
143
  summary: Simple password storage command