Skip to content

Commit

Permalink
theft from basiccache; fixes #8, fixes #13
Browse files Browse the repository at this point in the history
  • Loading branch information
akerl committed Nov 23, 2013
1 parent 4c55a0b commit b11b2a0
Show file tree
Hide file tree
Showing 44 changed files with 155 additions and 35 deletions.
4 changes: 3 additions & 1 deletion .gitignore
@@ -1,2 +1,4 @@
pkg/*.gem
coverage/
.coveralls.yml
config.yml
*.gem
2 changes: 2 additions & 0 deletions .rspec
@@ -0,0 +1,2 @@
--format Fuubar
--color
2 changes: 2 additions & 0 deletions .rubocop.yml
@@ -0,0 +1,2 @@
Encoding:
Enabled: false
15 changes: 15 additions & 0 deletions .travis.yml
@@ -0,0 +1,15 @@
language: ruby
cache: bundler
rvm:
- ruby-head
- 2.0.0
- 1.9.3
- jruby-19mode
notifications:
email: false
irc:
channels:
- ircs://irc.oftc.net:6697#akerl
channel_key: sekrit
template:
- '%{repository}/%{branch}/%{build_number}: %{message} -- %{build_url}'
3 changes: 3 additions & 0 deletions Gemfile
@@ -0,0 +1,3 @@
source 'https://rubygems.org'

gemspec
71 changes: 71 additions & 0 deletions Gemfile.lock
@@ -0,0 +1,71 @@
PATH
remote: .
specs:
hss (0.2.5)

GEM
remote: https://rubygems.org/
specs:
ast (1.1.0)
coveralls (0.7.0)
multi_json (~> 1.3)
rest-client
simplecov (>= 0.7)
term-ansicolor
thor
diff-lcs (1.2.5)
docile (1.1.0)
fuubar (1.2.1)
rspec (~> 2.0)
rspec-instafail (~> 0.2.0)
ruby-progressbar (~> 1.0)
hashr (0.0.22)
mime-types (2.0)
multi_json (1.8.2)
parser (2.1.0.pre1)
ast (~> 1.1)
slop (~> 3.4, >= 3.4.5)
powerpack (0.0.9)
rainbow (1.1.4)
rake (10.1.0)
rest-client (1.6.7)
mime-types (>= 1.16)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.7)
rspec-expectations (2.14.4)
diff-lcs (>= 1.1.3, < 2.0)
rspec-instafail (0.2.4)
rspec-mocks (2.14.4)
rubocop (0.15.0)
parser (~> 2.0)
powerpack (~> 0.0.6)
rainbow (>= 1.1.4)
ruby-progressbar (1.2.0)
simplecov (0.8.2)
docile (~> 1.1.0)
multi_json
simplecov-html (~> 0.8.0)
simplecov-html (0.8.0)
slop (3.4.7)
term-ansicolor (1.2.2)
tins (~> 0.8)
thor (0.18.1)
tins (0.13.1)
travis-lint (1.7.0)
hashr (~> 0.0.22)

PLATFORMS
ruby

DEPENDENCIES
coveralls
fuubar
hss!
parser (~> 2.1.0.pre1)
rake
rspec
rubocop
travis-lint
20 changes: 19 additions & 1 deletion Rakefile
@@ -1,2 +1,20 @@
require "bundler/gem_tasks"
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'

desc 'Run tests'
RSpec::Core::RakeTask.new(:spec)

desc 'Run Rubocop on the gem'
Rubocop::RakeTask.new(:rubocop) do |task|
task.patterns = ['lib/**/*.rb', 'spec/**/*.rb', 'bin/*']
task.fail_on_error = true
end

desc 'Run travis-lint on .travis.yml'
task :travislint do
fail 'There is an issue with your .travis.yml' unless system('travis-lint')
end

task default: [:spec, :travislint, :rubocop, :build, :install]

13 changes: 6 additions & 7 deletions bin/hss
Expand Up @@ -14,12 +14,11 @@ elsif ARGV == ['help'] || ARGV.empty?
exit
end

Short_Host = ARGV.delete_at(ARGV.find_index { |x| x[0, 1] != '-' } || 0)
Args = ARGV.reduce('') { |a, e| a + " '" + e.gsub(/([$"])/, '\1') + "'" }
Command = ENV.include?('HSS_DEBUG') ? 'echo ssh' : 'ssh'
short_host = ARGV.delete_at(ARGV.find_index { |x| x[0, 1] != '-' } || 0)
args = ARGV.reduce('') { |a, e| a + " '" + e.gsub(/([$"])/, '\1') + "'" }
command = ENV.include?('HSS_DEBUG') ? 'echo ssh' : 'ssh'

Long_Host = My_Handler.handle Short_Host

$stdout.syswrite "\033]0;#{Short_Host}\007" if $stdout.tty? and $stdin.tty?
exec "#{Command} #{Long_Host} #{Args}"
long_host = My_Handler.handle Short_Host

$stdout.syswrite "\033]0;#{short_host}\007" if $stdout.tty? && $stdin.tty?
exec "#{command} #{long_host} #{args}"
9 changes: 8 additions & 1 deletion hss.gemspec
@@ -1,4 +1,5 @@
require File.join(Dir.pwd, 'lib/hss.rb')
$:.unshift File.expand_path('../lib/', __FILE__)
require 'hss.rb'

Gem::Specification.new do |s|
s.name = 'hss'
Expand All @@ -9,8 +10,14 @@ Gem::Specification.new do |s|
s.authors = ['Les Aker']
s.email = 'me@lesaker.org'
s.files = `git ls-files`.split
s.test_files = `git ls-files spec/*`.split
s.executables = ['hss']
s.homepage = 'https://github.com/akerl/hss'
s.license = 'MIT'

%w(rubocop travis-lint rake coveralls rspec fuubar).each do |gem|
s.add_development_dependency gem
end
s.add_development_dependency 'parser', '~> 2.1.0.pre1'
end

4 changes: 3 additions & 1 deletion lib/helpers/command.rb
@@ -1,6 +1,8 @@
##
# Runs a shell command and returns the output

class HSS::Parser
def command(input)
IO.popen(input) { |cmd| cmd.read }
end
end

4 changes: 3 additions & 1 deletion lib/helpers/default.rb
@@ -1,6 +1,8 @@
##
# Provides a helper to have default values

class HSS::Parser
def default(a, b)
a.nil? || a.empty? ? b : a
end
end

4 changes: 3 additions & 1 deletion lib/helpers/expand.rb
@@ -1,3 +1,6 @@
##
# Expand a shortcode based the config hash

class HSS::Parser
def expand(input)
@config['expansions'].each do |long, shorts|
Expand All @@ -6,4 +9,3 @@ def expand(input)
fail NameError, "No expansion found for: #{input}"
end
end

10 changes: 8 additions & 2 deletions lib/helpers/external.rb
@@ -1,5 +1,11 @@
require 'yaml'

##
# Load values from an external YAML hash

class HSS::Parser
def external(cmd)
IO.popen(cmd).read
def external(source, key)
config = open(File.expand_path(source)) { |f| YAML.load f.read }
key.split('.').reduce(nil) { |a, e| config[e] }
end
end
4 changes: 3 additions & 1 deletion lib/helpers/shortcut.rb
@@ -1,6 +1,8 @@
##
# Allow shortcut expansion from the config

class HSS::Parser
def shortcut(input)
@config['shortcuts'][input]
end
end

3 changes: 1 addition & 2 deletions lib/hss.rb
Expand Up @@ -95,8 +95,7 @@ def check(input, short_form)
# Evaluate the long_form using the stored context

def parse(long_form)
eval '"' + long_form + '"', @match_data
eval '"' + long_form + '"', @match_data # rubocop:disable Eval
end
end
end

5 changes: 5 additions & 0 deletions spec/spec_helper.rb
@@ -0,0 +1,5 @@
require 'coveralls'
Coveralls.wear!

require 'rspec'
require 'basiccache'
17 changes: 0 additions & 17 deletions test.conf

This file was deleted.

Binary file added vendor/cache/ast-1.1.0.gem
Binary file not shown.
Binary file added vendor/cache/coveralls-0.7.0.gem
Binary file not shown.
Binary file added vendor/cache/diff-lcs-1.2.5.gem
Binary file not shown.
Binary file added vendor/cache/docile-1.1.0.gem
Binary file not shown.
Binary file added vendor/cache/fuubar-1.2.1.gem
Binary file not shown.
Binary file added vendor/cache/hashr-0.0.22.gem
Binary file not shown.
Binary file added vendor/cache/mime-types-2.0.gem
Binary file not shown.
Binary file added vendor/cache/multi_json-1.8.2.gem
Binary file not shown.
Binary file added vendor/cache/parser-2.1.0.pre1.gem
Binary file not shown.
Binary file added vendor/cache/powerpack-0.0.9.gem
Binary file not shown.
Binary file added vendor/cache/rainbow-1.1.4.gem
Binary file not shown.
Binary file added vendor/cache/rake-10.1.0.gem
Binary file not shown.
Binary file added vendor/cache/rest-client-1.6.7.gem
Binary file not shown.
Binary file added vendor/cache/rspec-2.14.1.gem
Binary file not shown.
Binary file added vendor/cache/rspec-core-2.14.7.gem
Binary file not shown.
Binary file added vendor/cache/rspec-expectations-2.14.4.gem
Binary file not shown.
Binary file added vendor/cache/rspec-instafail-0.2.4.gem
Binary file not shown.
Binary file added vendor/cache/rspec-mocks-2.14.4.gem
Binary file not shown.
Binary file added vendor/cache/rubocop-0.15.0.gem
Binary file not shown.
Binary file added vendor/cache/ruby-progressbar-1.2.0.gem
Binary file not shown.
Binary file added vendor/cache/simplecov-0.8.2.gem
Binary file not shown.
Binary file added vendor/cache/simplecov-html-0.8.0.gem
Binary file not shown.
Binary file added vendor/cache/slop-3.4.7.gem
Binary file not shown.
Binary file added vendor/cache/term-ansicolor-1.2.2.gem
Binary file not shown.
Binary file added vendor/cache/thor-0.18.1.gem
Binary file not shown.
Binary file added vendor/cache/tins-0.13.1.gem
Binary file not shown.
Binary file added vendor/cache/travis-lint-1.7.0.gem
Binary file not shown.

0 comments on commit b11b2a0

Please sign in to comment.