keystorage 0.4.13 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 333b8e211ded44805b86648c854b2e26fa80c9d4
4
- data.tar.gz: e1084df108003dc4dba726139948fc9d27c168a9
3
+ metadata.gz: ad8f4fbc6eb42851fd6be0c507430a1715894da4
4
+ data.tar.gz: 31cd005dbc8e0c2c813d91e6d23b730911115c43
5
5
  SHA512:
6
- metadata.gz: e331f5856a149527bb56e93a554abfa85b27b66e64c5f34052fddf98e0d97cfd967b1030264f8d2b05da749a7ce83b5549c97ffbdeeedf941c586afb8e0f66e6
7
- data.tar.gz: dfe6ae96e6190f5060cc74ba2d62afdf3a443e3a804a68d36b7c806577f7d542e89fe3e788997df7a8f0af262df4892cb5b10069f16fd958d290e917d47b2e31
6
+ metadata.gz: 2af20459da3de9df711bd72f021ff74c011fed2a749903b85f2a35ff501a17b78a0e6f3ce0a2e8ad86ae42815bbc757843e7448cef06158f9de85256920eeb12
7
+ data.tar.gz: f46d937aa796ba6cf144e9127918d66c62b217fb7ab338d049e08fa0830c55a3d40bf9862d29fa53215b4631281308cf8074e2ad6a758e347c92d7236ecdb24e
@@ -0,0 +1,4 @@
1
+ pkg/*.gem
2
+ .c9revisions
3
+ Gemfile.lock
4
+ *~
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile CHANGED
@@ -1,13 +1,9 @@
1
1
  source "http://rubygems.org"
2
+ gemspec
3
+
2
4
  # Add dependencies required to use your gem here.
3
5
  # Example:
4
6
  # gem "activesupport", ">= 2.3.5"
5
7
 
6
8
  # Add dependencies to develop your gem here.
7
9
  # Include everything needed to run rake, tests, features, etc.
8
- group :development do
9
- gem "shoulda"
10
- gem "bundler"
11
- gem "jeweler", :git =>"git://github.com/emilsoman/jeweler.git"
12
- gem "simplecov"
13
- end
@@ -0,0 +1,73 @@
1
+ keystorage
2
+ ----------
3
+
4
+ Simple password storage.
5
+
6
+ ## Install
7
+
8
+ gem install keystorage
9
+
10
+ ## CLI Usage
11
+
12
+
13
+ -> % keystorage
14
+ Commands:
15
+ keystorage get # Get a encrypted value of the key of the group
16
+ keystorage groups # List groups
17
+ keystorage help [COMMAND] # Describe available commands or one specific command
18
+ keystorage keys # List keys of the group
19
+ keystorage password # Update storage secret
20
+ keystorage set # Set a value of the key of the group
21
+
22
+ Options:
23
+ -v, [--verbose], [--no-verbose]
24
+ -d, [--debug], [--no-debug]
25
+ -f, [--file=FILE]
26
+ -s, [--secret=SECRET]
27
+
28
+
29
+ ### File format
30
+
31
+ The file format of `Keystorage` is YAML format like belows:
32
+
33
+ ---
34
+ "@":
35
+ token: IUUo86G4494_BrNBs-N5vA
36
+ sig: 56b9b074d647a18fa06ecc172bdb46ff560d5b46dcc1b732add87f6283d47983499b8b67d2524d72f27ed2bf4fef4efba5662e8d55e2c8426a76be26196c0235
37
+ hoge:
38
+ fuga: 3bacfd9ef980ff4c7a80436ede540b6
39
+
40
+ The root-key "@" is reserved 'Keystorage' system. The other root keys, such as `hoge`, are `group names`.
41
+ The second level keys, such as `fuga` under `hoge`, are `key` of values.
42
+ The value of second level keys are encrypted values.
43
+
44
+
45
+ ## API
46
+
47
+ ### Load Library
48
+
49
+ ```
50
+ require 'keystone/manager'
51
+ ```
52
+
53
+ ### Use API
54
+
55
+ ```
56
+ Keystorage::Manager.new(:file=>"/path/to/file",:secret =>"P@ssword").set("mygroup","key","abc")
57
+ Keystorage::Manager.new(:file=>"/path/to/file",:secret =>"P@ssword").get("mygroup","key") # => abc
58
+ ```
59
+
60
+
61
+ ## Contributing to keystorage
62
+
63
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
64
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
65
+ * Fork the project
66
+ * Start a feature/bugfix branch
67
+ * Commit and push until you are happy with your contribution
68
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
69
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
70
+
71
+ ## Copyright
72
+
73
+ Copyright (c) 2011-2015 Yoshihiro TAKAHARA. See LICENSE.txt for further details.
data/Rakefile CHANGED
@@ -1,37 +1,7 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'rake'
1
+ require 'rake/version_task'
2
+ Rake::VersionTask.new
11
3
 
12
- require 'jeweler'
13
- Jeweler::Tasks.new do |gem|
14
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
- gem.name = "keystorage"
16
- gem.homepage = "http://github.com/tumf/keystorage"
17
- gem.license = "MIT"
18
- gem.summary = %Q{Simple password storage command}
19
- gem.description = %Q{This is a command to store and manage your passwords.}
20
- gem.email = "y.takahara@gmail.com"
21
- gem.authors = ["Yoshihiro TAKAHARA"]
22
- # Include your dependencies below. Runtime dependencies are required when using your gem,
23
- # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
- # gem.add_runtime_dependency 'jabber4r', '> 0.1'
25
- # gem.add_development_dependency 'rspec', '> 1.2.3'
26
- end
27
- Jeweler::RubygemsDotOrgTasks.new
28
-
29
- require 'rake/testtask'
30
- Rake::TestTask.new(:test) do |test|
31
- test.libs << 'lib' << 'test'
32
- test.pattern = 'test/**/test_*.rb'
33
- test.verbose = true
34
- end
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
35
6
 
36
7
  task :default => :test
37
-
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.13
1
+ 0.5.1
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- $:.unshift(File.dirname(__FILE__) + '/../lib')
2
+ $:.unshift(File.join(File.dirname(__FILE__),'..','lib'))
3
3
  require 'keystorage/cli'
4
-
5
- Keystorage::CLI::run(ARGV)
4
+ Keystorage::CLI.start(ARGV)
@@ -5,63 +5,30 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "keystorage"
8
- s.version = "0.4.13"
8
+ s.version = `cat VERSION`
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"]
12
12
  s.date = "2013-03-25"
13
13
  s.description = "This is a command to store and manage your passwords."
14
14
  s.email = "y.takahara@gmail.com"
15
- s.executables = ["keystorage"]
16
15
  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
- "keystorage.gemspec",
28
- "lib/keystorage.rb",
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"
16
+ "LICENSE.txt"
39
17
  ]
18
+ s.files = `git ls-files`.split($/)
19
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
21
+ s.require_paths = ["lib"]
22
+
40
23
  s.homepage = "http://github.com/tumf/keystorage"
41
24
  s.licenses = ["MIT"]
42
25
  s.require_paths = ["lib"]
43
26
  s.rubygems_version = "2.0.3"
44
- s.summary = "Simple password storage command"
27
+ s.summary = "Simple password storage"
45
28
 
46
- if s.respond_to? :specification_version then
47
- s.specification_version = 4
48
-
49
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
- s.add_development_dependency(%q<shoulda>, [">= 0"])
51
- s.add_development_dependency(%q<bundler>, [">= 0"])
52
- s.add_development_dependency(%q<jeweler>, [">= 0"])
53
- s.add_development_dependency(%q<simplecov>, [">= 0"])
54
- else
55
- s.add_dependency(%q<shoulda>, [">= 0"])
56
- s.add_dependency(%q<bundler>, [">= 0"])
57
- s.add_dependency(%q<jeweler>, [">= 0"])
58
- s.add_dependency(%q<simplecov>, [">= 0"])
59
- end
60
- else
61
- s.add_dependency(%q<shoulda>, [">= 0"])
62
- s.add_dependency(%q<bundler>, [">= 0"])
63
- s.add_dependency(%q<jeweler>, [">= 0"])
64
- s.add_dependency(%q<simplecov>, [">= 0"])
65
- end
29
+ s.add_dependency('thor')
30
+
31
+ s.add_development_dependency('rake')
32
+ s.add_development_dependency('rspec')
33
+ s.add_development_dependency('version')
66
34
  end
67
-
@@ -1,7 +1,91 @@
1
1
  #!/usr/bin/env ruby
2
2
  # -*- coding: utf-8 -*-
3
- require 'keystorage/manager'
3
+ require 'digest/md5'
4
+ require 'openssl'
5
+ require 'yaml'
6
+ require 'securerandom'
7
+
4
8
  module Keystorage
5
- DEFAULT_FILE = ENV["HOME"]+"/.keystorage"
6
- end
9
+ DEFAULT_SECRET="3Qw9EtWE"
10
+ DEFAULT_FILE = File.join(ENV["HOME"],".keystorage")
11
+
12
+ class NoRootGroup < StandardError; end
13
+ class RejectGroupName < StandardError; end
14
+ class SecretMissMatch < StandardError; end
15
+ class NoSecret < StandardError; end
16
+ class FormatNotSupport < StandardError; end
17
+
18
+ def sign message,secret=secret
19
+ raise NoSecret.new("set env KEYSTORAGE_SECRET") unless secret
20
+ OpenSSL::HMAC.hexdigest('sha512',secret, message)
21
+ end
22
+
23
+ def token
24
+ SecureRandom.urlsafe_base64(nil, false)
25
+ end
26
+
27
+ def root
28
+ raise NoRootGroup unless file.has_key?("@")
29
+ file["@"] || {}
30
+ end
31
+
32
+ def root! secret=secret,data=file
33
+ data["@"] = {}
34
+ data["@"]["token"] = token
35
+ data["@"]["sig"] = sign(data["@"]["token"],secret)
36
+ data
37
+ end
38
+
39
+ # file validation
40
+ def valid?
41
+ sign(root["token"]) == root["sig"]
42
+ rescue NoRootGroup
43
+ write root!
44
+ end
45
+
46
+ def encode(str,secret=secret)
47
+ enc = OpenSSL::Cipher::Cipher.new('aes256')
48
+ enc.encrypt.pkcs5_keyivgen(secret)
49
+ ((enc.update(str) + enc.final).unpack("H*")).first.to_s
50
+ end
7
51
 
52
+ def decode(str,secret=secret)
53
+ dec = OpenSSL::Cipher::Cipher.new('aes256')
54
+ dec.decrypt.pkcs5_keyivgen(secret)
55
+ (dec.update(Array.new([str]).pack("H*")) + dec.final)
56
+ end
57
+
58
+ def path
59
+ options[:file] || ENV['KEYSTORAGE_FILE'] || DEFAULT_FILE
60
+ end
61
+
62
+ def file
63
+ YAML.load(File.new(path)) || {}
64
+ end
65
+
66
+ def write data
67
+ File.open(path,'w',0600) { |f| YAML.dump(data,f) }
68
+ end
69
+
70
+ def secret
71
+ options[:secret] || ENV['KEYSTORAGE_SECRET'] || DEFAULT_SECRET
72
+ end
73
+
74
+ def render out,format =:text
75
+ case format
76
+ when :text then
77
+ render_text out
78
+ else
79
+ raise FormatNotSupport.new(format.to_s)
80
+ end
81
+ end
82
+
83
+ def render_text out
84
+ if out.kind_of?(Array)
85
+ out.join("\n")
86
+ else
87
+ out.to_s
88
+ end
89
+ end
90
+
91
+ end
@@ -1,44 +1,72 @@
1
- require 'optparse'
1
+ # coding: utf-8
2
2
  require 'keystorage'
3
- require 'keystorage/commands'
3
+ require 'keystorage/manager'
4
+ require 'thor'
5
+ require 'optparse'
4
6
 
5
7
  module Keystorage
6
- class CLI
7
- def initialize(argv)
8
- @options = Hash.new
9
- @options[:file] = DEFAULT_FILE
10
- @argv = argv.clone
11
- @opt = OptionParser.new
12
- @opt.banner="Usage: keystorage [options] command [command options] args..."
13
- @opt.on('--help', 'show this message') { usage; exit }
14
- @opt.on('-f FILE','--file=FILE', 'file to store password') { |v|
15
- @options[:file] = v;
16
- }
17
- end
18
-
19
- def usage
20
- puts @opt;
21
- puts "Commands:"
22
- @commands = ["list","set","get","help"]
23
- @commands.each do |m|
24
- puts " "+m
8
+ class CLI < Thor
9
+ include Keystorage
10
+
11
+ class <<self
12
+ def start(given_args = ARGV, config = {})
13
+ # parse global options: Thor is not support global-options.
14
+ # Like: command global-options subcommand options
15
+ global_options = []
16
+ OptionParser.new do |opt|
17
+ @global_options.each { |name,config|
18
+ case config[:type]
19
+ when :boolean then
20
+ opt.on(config[:aliases],"--#{name.to_s}") { |v| global_options << "--#{name.to_s}"}
21
+ opt.on(config[:aliases],"--no-#{name.to_s}") { |v| global_options << "--no-#{name.to_s}"}
22
+ when :string then
23
+ opt.on(config[:aliases],"--#{name.to_s}=VALUE") { |v| global_options << "--#{name.to_s}=#{v}"}
24
+ end
25
+ }
26
+ opt.parse!(given_args)
27
+ end
28
+ given_args+=global_options
29
+ super(given_args,config)
25
30
  end
26
- end
27
31
 
28
- def execute
29
- argv = @opt.parse(@argv)
30
- command = argv.shift
31
- unless command
32
- usage;exit
32
+ def global_option *params
33
+ @global_options ||= {}
34
+ @global_options[params[0]] = params[1]
35
+ class_option params[0],params[1]
33
36
  end
34
- Commands.send(command,argv,@options)
35
37
  end
36
38
 
37
- class << self
38
- def run(argv)
39
- self.new(argv).execute
40
- end
39
+ global_option :verbose, :aliases =>"-v", :type => :boolean
40
+ global_option :debug, :aliases =>"-d", :type => :boolean
41
+ global_option :file, :aliases =>"-f", :type => :string
42
+ global_option :secret, :aliases =>"-s",:type => :string
43
+
44
+ desc "groups", "List groups"
45
+ def groups
46
+ puts render(Manager.new(options).groups)
47
+ end
48
+
49
+ desc "keys", "List keys of the group"
50
+ def keys(group)
51
+ puts render(Manager.new(options).keys(group))
41
52
  end
53
+
54
+ desc "get", "Get a encrypted value of the key of the group"
55
+ def get(group,key)
56
+ puts render(Manager.new(options).get(group,key))
57
+ end
58
+
59
+ desc "set", "Set a value of the key of the group"
60
+ def set(group,key,value=nil)
61
+ #@todo: ask if value == nil
62
+ puts render Manager.new(options).set(group,key,value)
63
+ end
64
+
65
+ desc "password","Update storage secret"
66
+ def password new_secret=nil
67
+ #@todo: ask if new_secret == nil
68
+ Manager.new(options).password(new_secret)
69
+ end
70
+
42
71
  end
43
72
  end
44
-
@@ -1,104 +1,60 @@
1
- require 'yaml'
2
- require 'openssl'
3
-
1
+ # coding: utf-8
2
+ require 'keystorage'
4
3
  module Keystorage
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
17
-
18
- def delete(group,name=nil,file=nil)
19
- Manager.new(file).delete(group,name)
20
- end
21
-
22
- end
23
-
4
+ # ks = keystorage::Manager.new(:file =>"",:secret=> "P@ssword")
5
+ # ks.get("mygroup","mykey") # => "mysecret"
24
6
  class Manager
25
-
26
- def initialize(file=nil)
27
- @file = DEFAULT_FILE
28
- @file = file if file
7
+ include Keystorage
8
+ attr_reader :options
9
+ def initialize options = {}
10
+ @options = options
29
11
  end
30
12
 
31
- def list(group=nil)
32
- data = Hash.new
33
- if File::exist?(@file)
34
- File.open(@file,'r') do |f|
35
- data = YAML.load(f)
36
- return data.keys unless group
37
- return data[group].keys if data[group]
38
- end
39
- end
40
- Hash.new
13
+ def groups
14
+ file.keys.delete_if {|i| i == "@" }
41
15
  end
42
16
 
43
- def get(group,name)
44
- raise "missing group" unless group
45
- raise "missing name" unless name
46
-
47
- begin
48
- File.open(@file,'r') do |f|
49
- data=YAML.load(f)
50
- raise "missing keystorage" unless data
51
- raise "missing group "+group unless data.has_key?(group)
52
- raise "missing group "+group+" name "+name unless data[group].has_key?(name)
53
-
54
- return decode(data[group][name])
55
- end
56
- rescue =>e
57
- end
58
- false
17
+ def keys(group)
18
+ file[group].keys
59
19
  end
60
20
 
61
- def all
62
- return YAML.load_file(@file) if File.exist?(@file)
63
- Hash.new
21
+ def get(group,key)
22
+ raise SecretMissMatch unless valid?
23
+ decode(file[group][key])
64
24
  end
65
25
 
66
26
  def set(group,key,value)
67
- data=all
68
- data = Hash.new unless data
69
- data[group] = Hash.new unless data.has_key?(group)
70
- data[group][key.to_s] = encode(value.to_s)
27
+ raise RejectGroupName.new("Cannot use '@' for group name.") if group == "@"
28
+ raise SecretMissMatch unless valid?
29
+
30
+ data = file
31
+ data[group] = {} unless data.has_key?(group)
32
+ data[group][key] = {} unless data[group].has_key?(key)
33
+ data[group][key] = encode(value)
71
34
  write(data)
72
- end
73
35
 
74
- def write(data)
75
- File.open(@file,'w',0600) do |f|
76
- YAML.dump(data,f)
77
- end
36
+ data[group][key]
37
+ rescue Errno::ENOENT
38
+ write({})
39
+ retry
78
40
  end
79
41
 
80
- def delete(group,name = nil)
81
- data = all
82
- if name
83
- data[group].delete(name) if data[group]
84
- else
85
- data.delete(group) if data
86
- end
87
- write(data)
88
- end
42
+ def password new_secret
43
+ raise SecretMissMatch unless valid?
89
44
 
90
- def encode(str,salt="3Qw9EtWE")
91
- enc = OpenSSL::Cipher::Cipher.new('aes256')
92
- enc.encrypt.pkcs5_keyivgen(salt)
93
- ((enc.update(str) + enc.final).unpack("H*")).first.to_s
45
+ # update passwords
46
+ data = file.each { |name,keys|
47
+ next if name == "@"
48
+ keys.each { |key,value|
49
+ keys[key] = encode(decode(value),new_secret)
50
+ }
51
+ }
52
+ # update root group and write to file
53
+ write root!(new_secret,data)
54
+ rescue Errno::ENOENT
55
+ write({})
56
+ retry
94
57
  end
95
58
 
96
- def decode(str,salt="3Qw9EtWE")
97
- dec = OpenSSL::Cipher::Cipher.new('aes256')
98
- dec.decrypt.pkcs5_keyivgen(salt)
99
- (dec.update(Array.new([str]).pack("H*")) + dec.final)
100
- end
101
59
  end
102
-
103
-
104
60
  end
@@ -0,0 +1,7 @@
1
+ require 'keystorage/cli'
2
+ describe Keystorage::CLI do
3
+ subject { Keystorage::CLI::new(['-f','test.yml']).options[:file] }
4
+ it {
5
+ is_expected.to be ''
6
+ }
7
+ end
@@ -0,0 +1,13 @@
1
+ require 'keystorage/manager'
2
+ describe Keystorage::Manager do
3
+ before {
4
+ @ks = Keystorage::Manager.new
5
+ }
6
+ subject { @ks.get("mygroup","key") }
7
+ it {
8
+ is_expected.to be ""
9
+ }
10
+
11
+ end
12
+ # ks = keystorage::Manager.new(:file =>"",:secret=> "P@ssword")
13
+ # ks.get("mygroup","mykey") # => "mysecret"
@@ -0,0 +1,91 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # The `.rspec` file also contains a few flags that are not defaults but that
16
+ # users commonly want.
17
+ #
18
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
+ RSpec.configure do |config|
20
+ # rspec-expectations config goes here. You can use an alternate
21
+ # assertion/expectation library such as wrong or the stdlib/minitest
22
+ # assertions if you prefer.
23
+ config.expect_with :rspec do |expectations|
24
+ # This option will default to `true` in RSpec 4. It makes the `description`
25
+ # and `failure_message` of custom matchers include text for helper methods
26
+ # defined using `chain`, e.g.:
27
+ # be_bigger_than(2).and_smaller_than(4).description
28
+ # # => "be bigger than 2 and smaller than 4"
29
+ # ...rather than:
30
+ # # => "be bigger than 2"
31
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
32
+ end
33
+
34
+ # rspec-mocks config goes here. You can use an alternate test double
35
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
36
+ config.mock_with :rspec do |mocks|
37
+ # Prevents you from mocking or stubbing a method that does not exist on
38
+ # a real object. This is generally recommended, and will default to
39
+ # `true` in RSpec 4.
40
+ mocks.verify_partial_doubles = true
41
+ end
42
+
43
+ # The settings below are suggested to provide a good initial experience
44
+ # with RSpec, but feel free to customize to your heart's content.
45
+ =begin
46
+ # These two settings work together to allow you to limit a spec run
47
+ # to individual examples or groups you care about by tagging them with
48
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
49
+ # get run.
50
+ config.filter_run :focus
51
+ config.run_all_when_everything_filtered = true
52
+
53
+ # Limits the available syntax to the non-monkey patched syntax that is
54
+ # recommended. For more details, see:
55
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
56
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
57
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
58
+ config.disable_monkey_patching!
59
+
60
+ # This setting enables warnings. It's recommended, but in some cases may
61
+ # be too noisy due to issues in dependencies.
62
+ config.warnings = true
63
+
64
+ # Many RSpec users commonly either run the entire suite or an individual
65
+ # file, and it's useful to allow more verbose output when running an
66
+ # individual spec file.
67
+ if config.files_to_run.one?
68
+ # Use the documentation formatter for detailed output,
69
+ # unless a formatter has already been configured
70
+ # (e.g. via a command-line flag).
71
+ config.default_formatter = 'doc'
72
+ end
73
+
74
+ # Print the 10 slowest examples and example groups at the
75
+ # end of the spec run, to help surface which specs are running
76
+ # particularly slow.
77
+ config.profile_examples = 10
78
+
79
+ # Run specs in random order to surface order dependencies. If you find an
80
+ # order dependency and want to debug it, you can fix the order by providing
81
+ # the seed, which is printed after each run.
82
+ # --seed 1234
83
+ config.order = :random
84
+
85
+ # Seed global randomization in this process using the `--seed` CLI option.
86
+ # Setting this allows you to use `--seed` to deterministically reproduce
87
+ # test failures related to randomization by passing the same `--seed` value
88
+ # as the one that triggered the failure.
89
+ Kernel.srand config.seed
90
+ =end
91
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keystorage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.13
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoshihiro TAKAHARA
@@ -11,59 +11,59 @@ cert_chain: []
11
11
  date: 2013-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: shoulda
14
+ name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
- type: :development
20
+ type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: bundler
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: jeweler
42
+ name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: simplecov
56
+ name: version
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: This is a command to store and manage your passwords.
@@ -73,24 +73,22 @@ executables:
73
73
  extensions: []
74
74
  extra_rdoc_files:
75
75
  - LICENSE.txt
76
- - README.rdoc
77
76
  files:
77
+ - ".gitignore"
78
+ - ".rspec"
78
79
  - Gemfile
79
80
  - LICENSE.txt
80
- - README.rdoc
81
+ - README.md
81
82
  - Rakefile
82
83
  - VERSION
83
84
  - bin/keystorage
84
85
  - keystorage.gemspec
85
86
  - lib/keystorage.rb
86
87
  - lib/keystorage/cli.rb
87
- - lib/keystorage/command/base.rb
88
- - lib/keystorage/command/get.rb
89
- - lib/keystorage/command/help.rb
90
- - lib/keystorage/command/list.rb
91
- - lib/keystorage/command/set.rb
92
- - lib/keystorage/commands.rb
93
88
  - lib/keystorage/manager.rb
89
+ - spec/keystorage/cli_spec.rb
90
+ - spec/keystorage/manager_spec.rb
91
+ - spec/spec_helper.rb
94
92
  - test/helper.rb
95
93
  - test/test_keystorage.rb
96
94
  homepage: http://github.com/tumf/keystorage
@@ -103,18 +101,24 @@ require_paths:
103
101
  - lib
104
102
  required_ruby_version: !ruby/object:Gem::Requirement
105
103
  requirements:
106
- - - '>='
104
+ - - ">="
107
105
  - !ruby/object:Gem::Version
108
106
  version: '0'
109
107
  required_rubygems_version: !ruby/object:Gem::Requirement
110
108
  requirements:
111
- - - '>='
109
+ - - ">="
112
110
  - !ruby/object:Gem::Version
113
111
  version: '0'
114
112
  requirements: []
115
113
  rubyforge_project:
116
- rubygems_version: 2.0.3
114
+ rubygems_version: 2.4.6
117
115
  signing_key:
118
116
  specification_version: 4
119
- summary: Simple password storage command
120
- test_files: []
117
+ summary: Simple password storage
118
+ test_files:
119
+ - spec/keystorage/cli_spec.rb
120
+ - spec/keystorage/manager_spec.rb
121
+ - spec/spec_helper.rb
122
+ - test/helper.rb
123
+ - test/test_keystorage.rb
124
+ has_rdoc:
@@ -1,35 +0,0 @@
1
- = keystorage
2
-
3
- Simple password storage command.
4
-
5
- == Install
6
-
7
- sudo gem install keystrage
8
-
9
- == Usage
10
-
11
- Usage: keystorage [options] command [command options] args...
12
- --help show this message
13
- -f, --file=FILE file to store password
14
-
15
- === Commands
16
-
17
- * list [group]
18
- * set group name value
19
- * get group name
20
-
21
- == Contributing to keystorage
22
-
23
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
24
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
25
- * Fork the project
26
- * Start a feature/bugfix branch
27
- * Commit and push until you are happy with your contribution
28
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
29
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
30
-
31
- == Copyright
32
-
33
- Copyright (c) 2011 Yoshihiro TAKAHARA. See LICENSE.txt for
34
- further details.
35
-
@@ -1,26 +0,0 @@
1
- module Keystorage
2
- module Command
3
- class Base
4
-
5
- def initialize(options)
6
- @file = options[:file]
7
- end
8
-
9
- class << self
10
- def run(argv,options)
11
- begin
12
- self.new(options).execute(argv)
13
- rescue =>e
14
- puts "Error: \n %s\n\n" % e
15
- puts help
16
- end
17
- end
18
-
19
- def help
20
- "TODO: HELP IS NOT DESCRIBED YET."
21
- end
22
-
23
- end
24
- end
25
- end
26
- end
@@ -1,29 +0,0 @@
1
- require 'keystorage/command/base'
2
-
3
- module Keystorage
4
- module Command
5
- class Get < Base
6
- def execute(argv)
7
- group = argv.shift
8
- raise "missing parameter" unless group
9
-
10
- name = argv.shift
11
- ks = Manager.new(@file)
12
- data = ks.get(group,name)
13
- raise "missing %s " % [group] unless data
14
- puts data
15
- end
16
-
17
- class << self
18
- def help
19
- "Description:
20
- get key from file
21
-
22
- Usage:
23
- keystrage [options] get groups [name]
24
- "
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,14 +0,0 @@
1
- require 'keystorage/command/base'
2
-
3
- module Keystorage
4
- module Command
5
- class Help < Base
6
- class << self
7
- def run(argv,options)
8
- cmd = argv.shift
9
- puts Command.const_get(cmd.capitalize).help
10
- end
11
- end
12
- end
13
- end
14
- end
@@ -1,28 +0,0 @@
1
- require 'keystorage/command/base'
2
- require 'keystorage/manager'
3
-
4
- module Keystorage
5
- module Command
6
- class List < Base
7
- def execute(argv)
8
- site = argv.shift
9
- ks = Manager.new(@file)
10
- ks.list(site).each do |v|
11
- puts v
12
- end
13
- end
14
-
15
- class << self
16
- def help
17
- "Description:
18
- list in storage
19
-
20
- Usage:
21
- keystrage [options] list [group]
22
- "
23
- end
24
- end
25
-
26
- end
27
- end
28
- end
@@ -1,25 +0,0 @@
1
- require 'keystorage/command/base'
2
-
3
- module Keystorage
4
- module Command
5
- class Set < Base
6
- def execute(argv)
7
- group = argv.shift
8
- var = argv.shift
9
- val = argv.shift
10
- ks = Manager.new(@file)
11
- ks.set(group,var,val)
12
- end
13
- class << self
14
- def help
15
- "Description:
16
- store key to file
17
-
18
- Usage:
19
- keystrage [options] set group name key
20
- "
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,26 +0,0 @@
1
- require 'keystorage/command/help'
2
- require 'keystorage/command/list'
3
- require 'keystorage/command/set'
4
- require 'keystorage/command/get'
5
-
6
- module Keystorage
7
- class Commands
8
- class << self
9
- def help(argv,options)
10
- Command::Help.run(argv,options)
11
- end
12
-
13
- def list(argv,options)
14
- Command::List.run(argv,options)
15
- end
16
-
17
- def set(argv,options)
18
- Command::Set.run(argv,options)
19
- end
20
-
21
- def get(argv,options)
22
- Command::Get.run(argv,options)
23
- end
24
- end
25
- end
26
- end