aka 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ .DS_Store
2
+ results.html
3
+ pkg
4
+ html
5
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in aka.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,42 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ aka (0.4.5)
5
+ methadone (~> 1.2.4)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ aruba (0.5.1)
11
+ childprocess (~> 0.3.6)
12
+ cucumber (>= 1.1.1)
13
+ rspec-expectations (>= 2.7.0)
14
+ builder (3.1.4)
15
+ childprocess (0.3.7)
16
+ ffi (~> 1.0, >= 1.0.6)
17
+ cucumber (1.2.1)
18
+ builder (>= 2.1.2)
19
+ diff-lcs (>= 1.1.3)
20
+ gherkin (~> 2.11.0)
21
+ json (>= 1.4.6)
22
+ diff-lcs (1.1.3)
23
+ ffi (1.3.1)
24
+ gherkin (2.11.6)
25
+ json (>= 1.7.6)
26
+ json (1.7.6)
27
+ methadone (1.2.4)
28
+ bundler
29
+ rake (0.9.6)
30
+ rdoc (3.12)
31
+ json (~> 1.4)
32
+ rspec-expectations (2.12.1)
33
+ diff-lcs (~> 1.1.3)
34
+
35
+ PLATFORMS
36
+ ruby
37
+
38
+ DEPENDENCIES
39
+ aka!
40
+ aruba
41
+ rake (~> 0.9.2)
42
+ rdoc
data/LICENSE.txt ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2013 YOUR NAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Aka
2
+
3
+ AKA is an alias manager. keep tabs on all of your alias'ed commands, shortcuts, and more without hand-editing dot files.
4
+
5
+ ## Installation
6
+
7
+ For now (meaning, until I get this into [RubyGems]) use these steps
8
+
9
+ $ cd /path/to/aka
10
+
11
+ Then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install /path/to/aka
18
+
19
+ ## Usage
20
+
21
+ 1. add the line `source ~/.alias` to your `.bash_profile` or `.profile` or `.bashrc`… basically whatever profile file you use on your system.
22
+ 2. run `aka -a hi "echo Hi There!"`
23
+ 3. type `source ~/.alias` to reload the aliases in your current session (or restart your session)
24
+ 4. type `hi`
25
+ 1. Enjoy having your command line say `hi there` back to you
26
+ 5. run `aka -h` to see a full list of features.
27
+
28
+ ## Contributing
29
+
30
+ Pull requests and issues are very welcome. If you have time, please include a solution or a test with any issues you submit.
31
+
32
+
33
+ [RubyGems]:https://rubygems.org/
data/README.rdoc ADDED
@@ -0,0 +1,30 @@
1
+ = aka - Manage your Aliases with style.
2
+
3
+ Author:: Nate Dickson (nate at natedickson dot com)
4
+ Copyright:: Copyright (c) 2013 Nate Dickson
5
+
6
+
7
+ License:: mit, see LICENSE.txt
8
+
9
+ aka lets you store all of your unix-style aliases in a single file.
10
+
11
+ Add <code>source ~/.alias</code> to your profile.
12
+
13
+
14
+ == Links
15
+
16
+ * {https://github.com/PogiNate/A.K.A.}[LINK TO GITHUB]
17
+ * RDoc[LINK TO RDOC.INFO]
18
+
19
+ == Install
20
+
21
+ <code>gem install aka</code>
22
+
23
+ == Examples
24
+
25
+ * To add a new alias enter <code>aka -n hi "echo "hi there!"</code>
26
+ * enter <code>aka -h</code> to see the other available commands.
27
+
28
+ == Contributing
29
+
30
+ I welcome pull requests and errors on GitHub.
data/Rakefile ADDED
@@ -0,0 +1,61 @@
1
+ def dump_load_path
2
+ puts $LOAD_PATH.join("\n")
3
+ found = nil
4
+ $LOAD_PATH.each do |path|
5
+ if File.exists?(File.join(path,"rspec"))
6
+ puts "Found rspec in #{path}"
7
+ if File.exists?(File.join(path,"rspec","core"))
8
+ puts "Found core"
9
+ if File.exists?(File.join(path,"rspec","core","rake_task"))
10
+ puts "Found rake_task"
11
+ found = path
12
+ else
13
+ puts "!! no rake_task"
14
+ end
15
+ else
16
+ puts "!!! no core"
17
+ end
18
+ end
19
+ end
20
+ if found.nil?
21
+ puts "Didn't find rspec/core/rake_task anywhere"
22
+ else
23
+ puts "Found in #{path}"
24
+ end
25
+ end
26
+ require 'bundler'
27
+ require 'rake/clean'
28
+
29
+ require 'rake/testtask'
30
+
31
+ require 'cucumber'
32
+ require 'cucumber/rake/task'
33
+ gem 'rdoc' # we need the installed RDoc gem, not the system one
34
+ require 'rdoc/task'
35
+
36
+ include Rake::DSL
37
+
38
+ Bundler::GemHelper.install_tasks
39
+
40
+
41
+ Rake::TestTask.new do |t|
42
+ t.pattern = 'test/tc_*.rb'
43
+ end
44
+
45
+
46
+ CUKE_RESULTS = 'results.html'
47
+ CLEAN << CUKE_RESULTS
48
+ Cucumber::Rake::Task.new(:features) do |t|
49
+ t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty --no-source -x"
50
+ t.fork = false
51
+ end
52
+
53
+ Rake::RDocTask.new do |rd|
54
+
55
+ rd.main = "README.rdoc"
56
+
57
+ rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
58
+ end
59
+
60
+ task :default => [:test,:features]
61
+
data/aka.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'aka/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "aka"
8
+ gem.version = Aka::VERSION
9
+ gem.authors = ["Nate Dickson"]
10
+ gem.email = ["nate@natedickson.com"]
11
+ gem.description = %q{Manage your aliases with style}
12
+ gem.summary = %q{Manages your list of aliases from an easy and friendly command line interface.}
13
+ gem.homepage = "https://github.com/PogiNate/A.K.A."
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ gem.add_development_dependency('rdoc')
20
+ gem.add_development_dependency('aruba')
21
+ gem.add_development_dependency('rake', '~> 0.9.2')
22
+ gem.add_dependency('methadone', '~> 1.2.4')
23
+ end
data/bin/aka ADDED
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'methadone'
5
+ require 'aka'
6
+ require 'fileutils'
7
+
8
+ class App
9
+ include Methadone::Main
10
+ include Methadone::CLILogging
11
+ include Aka
12
+
13
+ main do |aliasString,value|
14
+ al = AliasList.new
15
+ options.each do |key, value|
16
+ debug("#{key} : #{value}")
17
+ end
18
+ al.backup if options[:backup]
19
+ al.list if options[:list]
20
+ if options[:show]
21
+ if aliasString == nil
22
+ fatal("Needs an alias string to show the related command!")
23
+ exit 64
24
+ end
25
+ al.show aliasString
26
+ end
27
+
28
+ if options[:delete]
29
+ al.empty
30
+ elsif options[:add]
31
+ if aliasString == nil || value == nil
32
+ fatal("Both an alias and a value are required!")
33
+ exit 64
34
+ end
35
+ al.add(aliasString,value)
36
+ elsif options[:remove]
37
+ if aliasString == nil
38
+ fatal("Alias is required for the remove operation!")
39
+ exit 64
40
+ end
41
+ al.remove(aliasString)
42
+ end
43
+ end
44
+
45
+ # supplemental methods here
46
+
47
+ # Declare command-line interface here
48
+
49
+ description "Manage your aliases without editing dot files."
50
+
51
+ on("-a", "--add", "Add a new alias")
52
+ on("-l", "--list", "List all current aliases")
53
+ on("-r", "--remove", "Remove the specified alias")
54
+ on("-s", "--show", "Show what the specified alias does")
55
+ on("-b", "--backup", "Create a backup copy of your alias file")
56
+ on("-d", "--delete", "Delete all keys from your alias file")
57
+
58
+ arg :alias, :optional
59
+ arg :value, :optional
60
+ version Aka::VERSION
61
+
62
+ use_log_level_option
63
+
64
+ go!
65
+ end
@@ -0,0 +1,11 @@
1
+ Feature: Adding a new alias
2
+ In order to navigate and control my system quickly
3
+ I can add new aliases to the system's alias file
4
+
5
+ Scenario: Short Form
6
+ When I run `aka -a second "echo second"`
7
+ Then the alias "second" should be in the alias file.
8
+
9
+ Scenario: Long Form
10
+ When I run `aka -add third "echo third"`
11
+ Then the alias "third" should be in the alias file.
@@ -0,0 +1,28 @@
1
+ Feature: Help method is complete
2
+ In order to understand how this app works
3
+ I can access the help function
4
+ and get a complete and understandable set of instructions for using the app.
5
+
6
+ Scenario: App just runs
7
+ When I get help for "aka"
8
+ Then the exit status should be 0
9
+ And the banner should be present
10
+ And there should be a one line summary of what the app does
11
+ And the banner should document that this app takes options
12
+ And the following options should be documented:
13
+ |--version|
14
+ |-a |
15
+ |--add |
16
+ |-l |
17
+ |--list |
18
+ |-r |
19
+ |--remove |
20
+ |-s |
21
+ |--show |
22
+ |-b |
23
+ |--backup |
24
+ |-d |
25
+ |--delete |
26
+ Then the banner should document that this app's arguments are:
27
+ |alias|which is optional|
28
+ |value|which is optional|
@@ -0,0 +1,8 @@
1
+ Feature: Create a backup file
2
+ In order to ensure that I can keep my awesome list of aliases safe
3
+ I can create a backup file
4
+ So that I can restore it if things go wrong.
5
+
6
+ Scenario: Create a backup.
7
+ When I run `aka -b`
8
+ Then a file named "/tmp/akaTest/.alias.bak" should exist
@@ -0,0 +1,7 @@
1
+ Feature: Delete the entire file
2
+ In order to get a fresh start on things
3
+ I can delete my alias file entirely
4
+
5
+ Scenario: short code
6
+ When I run `aka -d`
7
+ Then the alias file should be empty.
@@ -0,0 +1,15 @@
1
+ Feature: Aliases are listed
2
+ In order to know what aliases are available to me
3
+ I want to ask for a list of aliases
4
+ So I can confidently use them.
5
+
6
+
7
+ Scenario: Use Short Code
8
+ When I run `aka -l`
9
+ Then the exit status should be 0
10
+ And the output should contain "test"
11
+
12
+ Scenario: Use Long code
13
+ When I run `aka --list`
14
+ Then the exit status should be 0
15
+ And the output should contain "test"
@@ -0,0 +1,7 @@
1
+ Feature: Remove an alias
2
+ In order to get rid of aliases that I no longer use
3
+ I can remove an alias from my system.
4
+
5
+ Scenario: Drop an alias
6
+ When I run `aka -r test`
7
+ Then the alias "test" should no longer be in the alias file.
@@ -0,0 +1,7 @@
1
+ Feature: Show an alias
2
+
3
+ Scenario: display an alias
4
+ When I run `aka -a test "echo this is a test"`
5
+ And I run `aka -s test`
6
+ Then the exit status should be 0
7
+ And the output should contain "echo this is a test"
@@ -0,0 +1,19 @@
1
+ # Put your step definitions here
2
+
3
+ Then /^the alias file should be empty\.$/ do
4
+ File.zero? "#{ENV['HOME']}/.alias"
5
+ end
6
+
7
+ Then /^the alias "(.*?)" should be in the alias file\.$/ do |arg1|
8
+ worked = false
9
+ File.foreach("#{ENV['HOME']}/.alias") do |line|
10
+ worked = true if line.start_with? "alias #{arg1}"
11
+ end
12
+ end
13
+
14
+ Then /^the alias "(.*?)" should no longer be in the alias file\.$/ do |arg1|
15
+ worked = true
16
+ File.foreach("#{ENV['HOME']}/.alias") do |line|
17
+ worked = false if line.start_with? "alias #{arg1}"
18
+ end
19
+ end
@@ -0,0 +1,23 @@
1
+ require 'aruba/cucumber'
2
+ require 'methadone/cucumber'
3
+ require 'fileutils'
4
+
5
+ ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
6
+ LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
7
+
8
+ Before do
9
+ # Using "announce" causes massive warnings on 1.9.2
10
+ @puts = true
11
+ @original_rubylib = ENV['RUBYLIB']
12
+ @original_home = ENV['HOME']
13
+ FileUtils.rm_rf("/tmp/akaTest")
14
+ FileUtils.mkdir("/tmp/akaTest")
15
+ ENV['HOME'] = "/tmp/akaTest"
16
+ File.open("#{ENV['HOME']}/.alias", "w") { |file| file.puts 'alias test="echo this is a test"' }
17
+ ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
18
+ end
19
+
20
+ After do
21
+ ENV['RUBYLIB'] = @original_rubylib
22
+ ENV['HOME'] = @original_home
23
+ end
@@ -0,0 +1,3 @@
1
+ module Aka
2
+ VERSION = "0.5.1"
3
+ end
data/lib/aka.rb ADDED
@@ -0,0 +1,68 @@
1
+ require "aka/version"
2
+ require "fileutils"
3
+ require "methadone"
4
+ module Aka
5
+
6
+ class AliasList
7
+ include Methadone::CLILogging
8
+
9
+ def initialize
10
+ @aliasPattern = /alias (\S+)="(.+)"/
11
+ @aliases = {}
12
+ @fileName = "#{ENV["HOME"]}/.alias"
13
+ debug ("made it to the class. filenName is #{@fileName}, aliasPattern is #{@aliasPattern}.")
14
+ #Open the alias list
15
+ File.foreach(@fileName) do |line|
16
+ @aliasPattern.match(line)do |match|
17
+ #read them all into an array
18
+ @aliases[match[1]] = match[2]
19
+ end
20
+ end
21
+ end
22
+
23
+ def add string, command
24
+ debug "string: #{string} command: #{command}"
25
+ #add a new alias to the list
26
+ @aliases[string] = command
27
+ writeOut
28
+ end
29
+
30
+ def remove string
31
+ #remove the alias from the list.
32
+ @aliases.delete string
33
+ writeOut
34
+ end
35
+
36
+ def list
37
+ #return the list of aliases.
38
+ keyList = ""
39
+ @aliases.keys.each{|key| keyList = keyList+" #{key}" }
40
+ info(keyList)
41
+ end
42
+
43
+ def show string
44
+ #return the command of a single alias.
45
+ info(@aliases[string])
46
+ end
47
+
48
+ def empty
49
+ #empty out the file.
50
+ backup # So we don't have deleter's remorse.
51
+ @aliases = {}
52
+ writeOut
53
+ end
54
+
55
+ def backup
56
+ FileUtils.copy(@fileName,"#{@fileName}.bak")
57
+ end
58
+
59
+ def writeOut
60
+ filestring = ""
61
+ @aliases.each { |key, value| filestring = filestring + "alias #{key}=\"#{value}\"\n" }
62
+
63
+ File.open(@fileName, "w") { |file| file.write filestring }
64
+
65
+ #write out the list. This will be called after any method that changes something.
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,7 @@
1
+ require 'test/unit'
2
+
3
+ class TestSomething < Test::Unit::TestCase
4
+ def test_truth
5
+ assert true
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aka
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Nate Dickson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rdoc
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: aruba
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.9.2
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.2
62
+ - !ruby/object:Gem::Dependency
63
+ name: methadone
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 1.2.4
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.2.4
78
+ description: Manage your aliases with style
79
+ email:
80
+ - nate@natedickson.com
81
+ executables:
82
+ - aka
83
+ extensions: []
84
+ extra_rdoc_files: []
85
+ files:
86
+ - .gitignore
87
+ - Gemfile
88
+ - Gemfile.lock
89
+ - LICENSE.txt
90
+ - README.md
91
+ - README.rdoc
92
+ - Rakefile
93
+ - aka.gemspec
94
+ - bin/aka
95
+ - features/add.feature
96
+ - features/aka.feature
97
+ - features/backup.feature
98
+ - features/delete.feature
99
+ - features/list.feature
100
+ - features/remove.feature
101
+ - features/show.feature
102
+ - features/step_definitions/aka_steps.rb
103
+ - features/support/env.rb
104
+ - lib/aka.rb
105
+ - lib/aka/version.rb
106
+ - test/tc_something.rb
107
+ homepage: https://github.com/PogiNate/A.K.A.
108
+ licenses: []
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 1.8.25
128
+ signing_key:
129
+ specification_version: 3
130
+ summary: Manages your list of aliases from an easy and friendly command line interface.
131
+ test_files:
132
+ - features/add.feature
133
+ - features/aka.feature
134
+ - features/backup.feature
135
+ - features/delete.feature
136
+ - features/list.feature
137
+ - features/remove.feature
138
+ - features/show.feature
139
+ - features/step_definitions/aka_steps.rb
140
+ - features/support/env.rb
141
+ - test/tc_something.rb