From 1e20c77318708f697aaef18727d44f3910197447 Mon Sep 17 00:00:00 2001 From: Andy Hartford Date: Wed, 25 Apr 2012 11:13:26 -0700 Subject: [PATCH] Rename to hush --- .rspec | 2 ++ .rvmrc | 2 +- Gemfile | 2 +- README.markdown | 14 +++++----- README.md | 6 ++--- bin/hush | 48 +++++++++++++++++++++++++++++++++ bin/secret | 11 -------- secret.gemspec => hush.gemspec | 8 +++--- lib/hush.rb | 5 ++++ lib/{secret => hush}/version.rb | 2 +- lib/secret.rb | 5 ---- spec/configuration_spec.rb | 6 +++++ spec/hush_spec.rb | 7 +++++ spec/spec_helper.rb | 11 ++++++++ 14 files changed, 96 insertions(+), 33 deletions(-) create mode 100644 .rspec create mode 100755 bin/hush delete mode 100755 bin/secret rename secret.gemspec => hush.gemspec (72%) create mode 100644 lib/hush.rb rename lib/{secret => hush}/version.rb (63%) delete mode 100644 lib/secret.rb create mode 100644 spec/configuration_spec.rb create mode 100644 spec/hush_spec.rb create mode 100644 spec/spec_helper.rb diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..5f16476 --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--color +--format progress diff --git a/.rvmrc b/.rvmrc index 1b44ca1..a001a82 100644 --- a/.rvmrc +++ b/.rvmrc @@ -6,7 +6,7 @@ # First we specify our desired [@], the @gemset name is optional, # Only full ruby name is supported here, for short names use: # echo "rvm use 1.9.2" > .rvmrc -environment_id="ruby-1.9.2-p318@secret" +environment_id="ruby-1.9.2-p318@hush" # Uncomment the following lines if you want to verify rvm version per project # rvmrc_rvm_version="1.11.6" # 1.10.1 seams as a safe start diff --git a/Gemfile b/Gemfile index 3e31dae..cd8a564 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ source 'https://rubygems.org' -# Specify your gem's dependencies in secret.gemspec +# Specify your gem's dependencies in hush.gemspec gemspec diff --git a/README.markdown b/README.markdown index e5caff8..646e4e5 100644 --- a/README.markdown +++ b/README.markdown @@ -1,22 +1,22 @@ -Secret unix utility +Hush unix utility =================== -This gem provides a command line utility called 'secret' which can -manage secret info. This was built to solve my problem of not wanting to +This gem provides a command line utility called 'hush' which can +manage hush info. This was built to solve my problem of not wanting to store email addresses and other sensitive info in my github managed dotfiles project. -The secrets are not meant to be cryptographically secure. They are -stored in a yaml file (~/.secret.yml) and are protected by unix +The hushs are not meant to be cryptographically secure. They are +stored in a yaml file (~/.hush.yml) and are protected by unix file permissions. This is similar to how ssh private keys are stored in an ~/.ssh directory. Examples ========== -git config user.email ${secret my_email} +git config user.email ${hush my_email} This will store the value of *my_email* in your git config. If -*my_email* is not known to secret, you will be prompted to supply it and +*my_email* is not known to hush, you will be prompted to supply it and it will be remembered from then on. diff --git a/README.md b/README.md index bb45d2c..5318c09 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Secret +# Hush TODO: Write a gem description @@ -6,7 +6,7 @@ TODO: Write a gem description Add this line to your application's Gemfile: - gem 'secret' + gem 'hush' And then execute: @@ -14,7 +14,7 @@ And then execute: Or install it yourself as: - $ gem install secret + $ gem install hush ## Usage diff --git a/bin/hush b/bin/hush new file mode 100755 index 0000000..d022742 --- /dev/null +++ b/bin/hush @@ -0,0 +1,48 @@ +#!/usr/bin/env ruby + +require "rubygems" +require "thor" +require "yaml" +require "pathname" + +class HushCommand < Thor + include Thor::Actions + + desc "foo", "Prints foo" + def foo; puts "foo"; end + + desc "add NAME VALUE", "Adds a field to storage" + def add(name, value) + storage = load_storage + storage[name] = value + save_storage storage + end + + desc "take NAME", "Prints the value of the field with named NAME. If NAME is unknown, the value can be provided at the prompt" + def take(name) + storage = load_storage + + if !storage.key?(name) + storage[name] = ask "#{name} is undefined. Enter a value to add it to storage:" + save_storage storage + end + + puts storage[name] + end + + private + + # returns hash from storage + def load_storage + path = Pathname.new("#{ENV['HOME']}/.hush.yml") + path.file? ? YAML.load(path) : {} + end + + # saves hash from storage + def save_storage(hash) + path = Pathname.new("#{ENV['HOME']}/.hush.yml") + path.open('w') {|io| io << YAML.dump(hash) } + end +end + +HushCommand.start diff --git a/bin/secret b/bin/secret deleted file mode 100755 index 3e44fae..0000000 --- a/bin/secret +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env ruby - -require "rubygems" -require "thor" - -class SecretCommand < Thor - desc "foo", "Prints foo" - def foo; puts "foo"; end -end - -SecretCommand.start diff --git a/secret.gemspec b/hush.gemspec similarity index 72% rename from secret.gemspec rename to hush.gemspec index 79e6a89..a9fe8ee 100644 --- a/secret.gemspec +++ b/hush.gemspec @@ -1,5 +1,5 @@ # -*- encoding: utf-8 -*- -require File.expand_path('../lib/secret/version', __FILE__) +require File.expand_path('../lib/hush/version', __FILE__) Gem::Specification.new do |gem| gem.authors = ["Andy Hartford"] @@ -11,12 +11,12 @@ Gem::Specification.new do |gem| gem.files = `git ls-files`.split($\) gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) - gem.name = "secret" + gem.name = "hush" gem.require_paths = ["lib"] - gem.version = Secret::VERSION + gem.version = Hush::VERSION gem.add_runtime_dependency 'thor' - gem.post_install_message = "Shush - you've installed secret. See 'secret -h' for more info." + gem.post_install_message = "You've installed hush. See 'hush -h' for more info." gem.add_development_dependency 'rspec', '~> 2' end diff --git a/lib/hush.rb b/lib/hush.rb new file mode 100644 index 0000000..b8f41bd --- /dev/null +++ b/lib/hush.rb @@ -0,0 +1,5 @@ +require "hush/version" + +module Hush + # Your code goes here... +end diff --git a/lib/secret/version.rb b/lib/hush/version.rb similarity index 63% rename from lib/secret/version.rb rename to lib/hush/version.rb index 60ebf91..70f009a 100644 --- a/lib/secret/version.rb +++ b/lib/hush/version.rb @@ -1,3 +1,3 @@ -module Secret +module Hush VERSION = "0.0.1" end diff --git a/lib/secret.rb b/lib/secret.rb deleted file mode 100644 index 84d974a..0000000 --- a/lib/secret.rb +++ /dev/null @@ -1,5 +0,0 @@ -require "secret/version" - -module Secret - # Your code goes here... -end diff --git a/spec/configuration_spec.rb b/spec/configuration_spec.rb new file mode 100644 index 0000000..020d142 --- /dev/null +++ b/spec/configuration_spec.rb @@ -0,0 +1,6 @@ +require 'spec_helper' + +describe "configuration" do + it "should look for configuration file in home dir by default" + it "should accept option to choose configuration path" +end diff --git a/spec/hush_spec.rb b/spec/hush_spec.rb new file mode 100644 index 0000000..35bf90d --- /dev/null +++ b/spec/hush_spec.rb @@ -0,0 +1,7 @@ +require 'spec_helper' + +describe "hush" do + + +end + diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..2bd441c --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,11 @@ +# This file was generated by the `rspec --init` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# Require this file using `require "spec_helper.rb"` to ensure that it is only +# loaded once. +# +# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + config.treat_symbols_as_metadata_keys_with_true_values = true + config.run_all_when_everything_filtered = true + config.filter_run :focus +end