keystorage 0.3.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.1
data/keystorage.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{keystorage}
8
- s.version = "0.3.0"
8
+ s.version = "0.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Yoshihiro TAKAHARA"]
data/lib/keystorage.rb CHANGED
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # -*- coding: utf-8 -*-
3
3
  require 'keystorage/manager'
4
+ module Keystorage
5
+ DEFAULT_FILE = ENV["HOME"]+"/.keystore"
6
+ end
4
7
 
@@ -1,11 +1,12 @@
1
1
  require 'optparse'
2
+ require 'keystorage'
2
3
  require 'keystorage/commands'
3
4
 
4
5
  module Keystorage
5
6
  class CLI
6
7
  def initialize(argv)
7
8
  @options = Hash.new
8
- @options[:file] = ENV["HOME"]+"/.keystore"
9
+ @options[:file] = DEFAULT_FILE
9
10
  @argv = argv.clone
10
11
  @opt = OptionParser.new
11
12
  @opt.banner="Usage: keystorage [options] command [command options] args..."
@@ -2,22 +2,25 @@ require 'yaml'
2
2
  require 'openssl'
3
3
 
4
4
  module Keystorage
5
- def list(group=nil)
6
- Manager.new.list(group)
7
- end
8
-
9
- def set(group,key,value)
10
- Manager.new.set(group,key,value)
11
- end
12
-
13
- def get(group,name)
14
- Manager.new.get(group,name)
5
+ class << self
6
+ def list(group=nil,file=nil)
7
+ Manager.new(file).list(group)
8
+ end
9
+
10
+ def set(group,key,value,file=nil)
11
+ Manager.new(file).set(group,key,value)
12
+ end
13
+
14
+ def get(group,name,file=nil)
15
+ Manager.new(file).get(group,name)
16
+ end
15
17
  end
16
18
 
17
19
  class Manager
18
20
 
19
- def initialize(file)
20
- @file = file
21
+ def initialize(file=nil)
22
+ @file = DEFAULT_FILE
23
+ @file = file if file
21
24
  end
22
25
 
23
26
  def list(group=nil)
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: 19
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 3
9
- - 0
10
- version: 0.3.0
8
+ - 4
9
+ - 1
10
+ version: 0.4.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Yoshihiro TAKAHARA