lightning 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'rubygems' unless Object.const_defined?(:Gem)
3
+ require File.dirname(__FILE__) + "/lib/lightning/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "lightning"
7
+ s.version = Lightning::VERSION
8
+ s.authors = ["Gabriel Horner"]
9
+ s.email = "gabriel.horner@gmail.com"
10
+ s.homepage = "http://tagaholic.me/lightning/"
11
+ s.summary = "Lightning is a commandline framework that generates shell functions which wrap around commands to autocomplete and translate full paths by their basenames."
12
+ s.description = "Lightning is a commandline framework that lets users wrap commands with shell functions that are able to refer to any filesystem path by its basename. To achieve this, a group of paths to be translated are defined with shell globs. These shell globs, known as a lightning _bolt_, are then applied to commands to produce functions. In addition to translating basenames to full paths, lightning _functions_ can autocomplete these basenames, resolve conflicts if they have the same name, leave any non-basename arguments untouched, and autocomplete directories above and below a basename. To make bolts shareable between users and functions easier to create, lightning has _generators_. A _generator_ generates filesystem-specific globs for a bolt. Lightning comes with some default generators. Users can make their own generators with generator plugins placed under ~/.lightning/generators/."
13
+ s.required_rubygems_version = ">= 1.3.6"
14
+ s.rubyforge_project = 'tagaholic'
15
+ s.executables = %w{lightning lightning-complete lightning-translate}
16
+ s.has_rdoc = 'yard'
17
+ s.rdoc_options = ['--title', "Lightning #{Lightning::VERSION} Documentation"]
18
+ s.add_development_dependency 'bacon', '>= 1.1.0'
19
+ s.add_development_dependency 'rr', '>= 1.0'
20
+ s.add_development_dependency 'bacon-bits'
21
+ s.add_development_dependency 'bacon-rr'
22
+ s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec}
23
+ s.files += Dir.glob(['test/*.yml', 'man/*'])
24
+ s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
25
+ s.license = 'MIT'
26
+ end
@@ -1,3 +1,7 @@
1
+ == 0.3.3
2
+ * Disallow arbitrary methods to pass as commands to lightning
3
+ * Remove jeweler from Rakefile
4
+
1
5
  == 0.3.2
2
6
  * Better tests
3
7
  * Added a manpage
@@ -1,6 +1,6 @@
1
1
  The MIT LICENSE
2
2
 
3
- Copyright (c) 2009 Gabriel Horner
3
+ Copyright (c) 2010 Gabriel Horner
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
@@ -1,5 +1,14 @@
1
1
  == Description
2
- Lightning is a commandline framework that lets users wrap commands with shell functions that are able to refer to any filesystem path by its basename. To achieve this, a group of paths to be translated are defined with shell globs. These shell globs, known as a lightning _bolt_, are then applied to commands to produce functions. In addition to translating basenames to full paths, lightning _functions_ can autocomplete these basenames, resolve conflicts if they have the same name, leave any non-basename arguments untouched, and autocomplete directories above and below a basename. To make bolts shareable between users and functions easier to create, lightning has _generators_. A _generator_ generates filesystem-specific globs for a bolt. Lightning comes with some default generators. Users can make their own generators with generator plugins placed under ~/.lightning/generators/.
2
+ Lightning is a commandline framework that lets users wrap commands with shell functions that are
3
+ able to refer to any filesystem path by its basename. To achieve this, a group of paths to be
4
+ translated are defined with shell globs. These shell globs, known as a lightning _bolt_, are then
5
+ applied to commands to produce functions. In addition to translating basenames to full paths,
6
+ lightning _functions_ can autocomplete these basenames, resolve conflicts if they have the same
7
+ name, leave any non-basename arguments untouched, and autocomplete directories above and below a
8
+ basename. To make bolts shareable between users and functions easier to create, lightning has
9
+ _generators_. A _generator_ generates filesystem-specific globs for a bolt. Lightning comes with
10
+ some default generators. Users can make their own generators with generator plugins placed under
11
+ ~/.lightning/generators/.
3
12
 
4
13
  == Intro
5
14
  Lightning generates shell functions which can interpret paths by their basenames. So instead of carpal-typing
@@ -10,7 +19,8 @@ just type
10
19
 
11
20
  $ less-ruby irb.rb
12
21
 
13
- less-ruby is a lightning function which wraps `less` with the ability to refer to system ruby files by their basenames. Being a lightning function, it can also autocomplete system ruby files:
22
+ less-ruby is a lightning function which wraps `less` with the ability to refer to system ruby files
23
+ by their basenames. Being a lightning function, it can also autocomplete system ruby files:
14
24
 
15
25
  # 1112 available system ruby files
16
26
  $ less-ruby [TAB]
@@ -37,12 +47,14 @@ And here's the one-liner that creates this function:
37
47
  == Install
38
48
 
39
49
  Install with either rip or rubygems:
40
- $ rip install git://github.com/cldwalker/lightning.git
50
+ $ rip install lightning
41
51
  # OR
42
- $ sudo gem install yard # if you want lightning's documentation generated correctly
43
- $ sudo gem install lightning
52
+ $ gem install yard # if you want lightning's documentation generated correctly
53
+ $ gem install lightning
44
54
 
45
- If you've installed with rubygems and `time lightning` takes longer than 0.05 seconds, I *strongly recommend* installing with rip. Your startup time directly effects your autocompletion speed with lightning.
55
+ If you've installed with rubygems and `time lightning` takes longer than 0.05 seconds, I *strongly
56
+ recommend* installing with rip. Your startup time directly effects your autocompletion speed with
57
+ lightning.
46
58
 
47
59
  Once lightning is installed, we need to do a one-time setup:
48
60
 
@@ -51,7 +63,7 @@ Once lightning is installed, we need to do a one-time setup:
51
63
 
52
64
  # Installs lightning's core files and sources the needed lightning functions
53
65
  $ lightning install && source ~/.lightning/functions.sh
54
- Created ~/.lightning_yml
66
+ Created ~/.lightningrc
55
67
  Created ~/.lightning/functions.sh
56
68
 
57
69
  # To have lightning's functionality loaded when your shell starts up
@@ -61,10 +73,7 @@ Once lightning is installed, we need to do a one-time setup:
61
73
 
62
74
  To install and view lightning's man page:
63
75
 
64
- # If installed with rip
65
- $ LDIR=`ruby -rrip -e 'puts Rip::PackageManager.new.package("lightning").cache_path'`
66
- # Assumes /usr/local/man is in $MANPATH
67
- $ cp $LDIR/man/lightning.1 /usr/local/man/man1/
76
+ # If installed with rip, man pages are automatically installed
68
77
  $ man lightning
69
78
 
70
79
  # If installed with rubygems
@@ -79,7 +88,8 @@ Please report them {on github}[http://github.com/cldwalker/lightning/issues].
79
88
  * Only bash and zsh shells are supported. Patches are welcome to support other shells.
80
89
 
81
90
  == Credits
82
- * ryanb's dotfiles inspired tinkering with autocompletion in ruby: http://github.com/ryanb/dotfiles/blob/master/bash/completion_scripts/project_completion
91
+ * ryanb's dotfiles inspired tinkering with autocompletion in ruby:
92
+ http://github.com/ryanb/dotfiles/blob/master/bash/completion_scripts/project_completion
83
93
  * defunkt's rip, http://github.com/defunkt/rip, was influential in designing plugins
84
94
  * Bug fixes: ljsc
85
95
 
data/Rakefile CHANGED
@@ -1,43 +1,35 @@
1
1
  require 'rake'
2
- begin
3
- require 'rcov/rcovtask'
2
+ require 'fileutils'
4
3
 
5
- Rcov::RcovTask.new do |t|
6
- t.libs << 'test'
7
- t.test_files = FileList['test/**/*_test.rb']
8
- t.rcov_opts = ["-T -x '/Library/Ruby/*'"]
9
- t.verbose = true
10
- end
11
- rescue LoadError
4
+ def gemspec
5
+ @gemspec ||= eval(File.read('.gemspec'), binding, '.gemspec')
12
6
  end
13
7
 
14
- begin
15
- require 'jeweler'
16
- require File.dirname(__FILE__) + "/lib/lightning/version"
8
+ desc "Build the gem"
9
+ task :gem=>:gemspec do
10
+ sh "gem build .gemspec"
11
+ FileUtils.mkdir_p 'pkg'
12
+ FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
13
+ end
17
14
 
18
- Jeweler::Tasks.new do |s|
19
- s.name = "lightning"
20
- s.version = Lightning::VERSION
21
- s.executables = ['lightning', 'lightning-complete', 'lightning-translate']
22
- s.summary = "Lightning is a commandline framework that generates shell functions which wrap around commands to autocomplete and translate full paths by their basenames."
23
- s.description = "Lightning is a commandline framework that lets users wrap commands with shell functions that are able to refer to any filesystem path by its basename. To achieve this, a group of paths to be translated are defined with shell globs. These shell globs, known as a lightning _bolt_, are then applied to commands to produce functions. In addition to translating basenames to full paths, lightning _functions_ can autocomplete these basenames, resolve conflicts if they have the same name, leave any non-basename arguments untouched, and autocomplete directories above and below a basename."
24
- s.email = "gabriel.horner@gmail.com"
25
- s.homepage = "http://tagaholic.me/lightning"
26
- s.authors = ["Gabriel Horner"]
27
- s.files = FileList["CHANGELOG.rdoc", "Rakefile","README.rdoc", "LICENSE.txt", "{bin,lib,test,man}/**/*"]
28
- s.has_rdoc = 'yard'
29
- s.rdoc_options = ['--title', "Lightning #{Lightning::VERSION} Documentation"]
30
- s.rubyforge_project = 'tagaholic'
31
- s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
32
- end
15
+ desc "Install the gem locally"
16
+ task :install => :gem do
17
+ sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}}
18
+ end
33
19
 
34
- rescue LoadError
35
- puts "Jeweler not available. Install it for jeweler-related tasks with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
20
+ desc "Generate the gemspec"
21
+ task :generate do
22
+ puts gemspec.to_ruby
36
23
  end
37
24
 
38
- task :default => :test
25
+ desc "Validate the gemspec"
26
+ task :gemspec do
27
+ gemspec.validate
28
+ end
39
29
 
40
- desc 'Run specs with unit test style output'
30
+ desc 'Run tests'
41
31
  task :test do |t|
42
- sh 'bacon -q -Ilib test/*_test.rb'
32
+ sh 'bacon -q -Ilib -I. test/*_test.rb'
43
33
  end
34
+
35
+ task :default => :test
@@ -34,7 +34,7 @@ module Lightning
34
34
  def run(argv=ARGV)
35
35
  if (command = argv.shift) && (actual_command = unalias_command(command))
36
36
  run_command(actual_command, argv)
37
- elsif command && respond_to?(command)
37
+ elsif command && commands.include?(command)
38
38
  run_command(command, argv)
39
39
  elsif %w{-v --version}.include?(command)
40
40
  puts "lightning #{VERSION}"
@@ -112,4 +112,4 @@ module Lightning
112
112
  end
113
113
  end
114
114
 
115
- Lightning::Util.load_plugins File.dirname(__FILE__), 'commands'
115
+ Lightning::Util.load_plugins File.dirname(__FILE__), 'commands'
@@ -1,3 +1,3 @@
1
1
  module Lightning
2
- VERSION = '0.3.2'
2
+ VERSION = '0.3.3'
3
3
  end
@@ -58,7 +58,7 @@ context "Commands:" do
58
58
 
59
59
  test "with invalid command prints messaged and usage" do
60
60
  mock(Commands).print_help
61
- capture_stdout { Commands.run ['blah'] }.should =~ /Command 'blah'/
61
+ capture_stdout { Commands.run ['to_s'] }.should =~ /Command 'to_s'/
62
62
  end
63
63
 
64
64
  test "passes -h as command argument" do
@@ -67,4 +67,4 @@ context "Commands:" do
67
67
  Commands.run(['complete', 'blah', '-h'])
68
68
  end
69
69
  end
70
- end
70
+ end
@@ -0,0 +1,4 @@
1
+ bacon >=1.1.0
2
+ rr >=1.0
3
+ bacon-bits >=0
4
+ bacon-rr >=0
@@ -1,5 +1,7 @@
1
1
  require 'bacon'
2
+ require 'bacon/bits'
2
3
  require 'rr'
4
+ require 'bacon/rr'
3
5
  require 'lightning'
4
6
  #set up valid global config file
5
7
  Lightning::Config.config_file = File.join(File.dirname(__FILE__), 'lightning.yml')
@@ -35,59 +37,15 @@ module Helpers
35
37
  end
36
38
  end
37
39
 
38
- module BaconExtensions
39
- def self.included(mod)
40
- mod.module_eval do
41
- # nested context methods automatically inherit methods from parent contexts
42
- def describe(*args, &block)
43
- context = Bacon::Context.new(args.join(' '), &block)
44
- (parent_context = self).methods(false).each {|e|
45
- class<<context; self end.send(:define_method, e) {|*args| parent_context.send(e, *args)}
46
- }
47
- @before.each { |b| context.before(&b) }
48
- @after.each { |b| context.after(&b) }
49
- context.run
50
- end
51
- end
52
- end
53
-
54
- def xtest(*args); end
55
- def xcontext(*args); end
56
- def before_all; yield; end
57
- def after_all; yield; end
58
- def assert(description, &block)
59
- it(description) do
60
- block.call.should == true
61
- end
62
- end
63
- end
64
-
65
40
  class Bacon::Context
66
41
  include Helpers
67
- include BaconExtensions
68
-
69
- # RR adapter
70
- def self.silent?
71
- @silent ||= class << Bacon; self; end.ancestors.include?(Bacon::TestUnitOutput)
72
- end
73
- include RR::Adapters::RRMethods
74
- RR.trim_backtrace = true
75
- alias_method :old_it, :it
76
- def it(description)
77
- old_it(description) do
78
- # Add at least one requirement to ensure mock-only tests don't fail
79
- Bacon::Counter[:requirements] += 1
80
- yield
81
- Bacon::Counter[:requirements] -= 1 if RR.double_injections.size.zero?
82
- RR.verify unless self.class.silent?
83
- RR.reset
84
- end
85
- end
86
42
 
43
+ def xtest(*args); end
44
+ def xcontext(*args); end
87
45
  alias_method :test, :it
88
46
  alias_method :context, :describe
89
47
  end
90
48
 
91
49
  class <<self
92
50
  alias_method :context, :describe
93
- end
51
+ end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lightning
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 21
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 3
8
- - 2
9
- version: 0.3.2
9
+ - 3
10
+ version: 0.3.3
10
11
  platform: ruby
11
12
  authors:
12
13
  - Gabriel Horner
@@ -14,11 +15,69 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-04-13 00:00:00 -04:00
18
+ date: 2011-02-08 00:00:00 -05:00
18
19
  default_executable:
19
- dependencies: []
20
-
21
- description: Lightning is a commandline framework that lets users wrap commands with shell functions that are able to refer to any filesystem path by its basename. To achieve this, a group of paths to be translated are defined with shell globs. These shell globs, known as a lightning _bolt_, are then applied to commands to produce functions. In addition to translating basenames to full paths, lightning _functions_ can autocomplete these basenames, resolve conflicts if they have the same name, leave any non-basename arguments untouched, and autocomplete directories above and below a basename.
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: bacon
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 19
30
+ segments:
31
+ - 1
32
+ - 1
33
+ - 0
34
+ version: 1.1.0
35
+ type: :development
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: rr
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 15
46
+ segments:
47
+ - 1
48
+ - 0
49
+ version: "1.0"
50
+ type: :development
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: bacon-bits
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ type: :development
65
+ version_requirements: *id003
66
+ - !ruby/object:Gem::Dependency
67
+ name: bacon-rr
68
+ prerelease: false
69
+ requirement: &id004 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ type: :development
79
+ version_requirements: *id004
80
+ description: Lightning is a commandline framework that lets users wrap commands with shell functions that are able to refer to any filesystem path by its basename. To achieve this, a group of paths to be translated are defined with shell globs. These shell globs, known as a lightning _bolt_, are then applied to commands to produce functions. In addition to translating basenames to full paths, lightning _functions_ can autocomplete these basenames, resolve conflicts if they have the same name, leave any non-basename arguments untouched, and autocomplete directories above and below a basename. To make bolts shareable between users and functions easier to create, lightning has _generators_. A _generator_ generates filesystem-specific globs for a bolt. Lightning comes with some default generators. Users can make their own generators with generator plugins placed under ~/.lightning/generators/.
22
81
  email: gabriel.horner@gmail.com
23
82
  executables:
24
83
  - lightning
@@ -27,37 +86,28 @@ executables:
27
86
  extensions: []
28
87
 
29
88
  extra_rdoc_files:
30
- - LICENSE.txt
31
89
  - README.rdoc
32
- files:
33
- - CHANGELOG.rdoc
34
90
  - LICENSE.txt
35
- - README.rdoc
36
- - Rakefile
37
- - bin/lightning
38
- - bin/lightning-complete
39
- - bin/lightning-translate
40
- - lib/lightning.rb
91
+ files:
41
92
  - lib/lightning/bolt.rb
42
93
  - lib/lightning/builder.rb
43
- - lib/lightning/commands.rb
44
94
  - lib/lightning/commands/bolt.rb
45
95
  - lib/lightning/commands/core.rb
46
96
  - lib/lightning/commands/function.rb
47
97
  - lib/lightning/commands/shell_command.rb
98
+ - lib/lightning/commands.rb
48
99
  - lib/lightning/commands_util.rb
49
100
  - lib/lightning/completion.rb
50
101
  - lib/lightning/completion_map.rb
51
102
  - lib/lightning/config.rb
52
103
  - lib/lightning/function.rb
53
104
  - lib/lightning/generator.rb
54
- - lib/lightning/generators.rb
55
105
  - lib/lightning/generators/misc.rb
56
106
  - lib/lightning/generators/ruby.rb
107
+ - lib/lightning/generators.rb
57
108
  - lib/lightning/util.rb
58
109
  - lib/lightning/version.rb
59
- - man/lightning.1
60
- - man/lightning.1.ronn
110
+ - lib/lightning.rb
61
111
  - test/bolt_commands_test.rb
62
112
  - test/bolt_test.rb
63
113
  - test/builder_test.rb
@@ -69,51 +119,56 @@ files:
69
119
  - test/function_commands_test.rb
70
120
  - test/function_test.rb
71
121
  - test/generator_test.rb
72
- - test/lightning.yml
73
122
  - test/shell_command_commands_test.rb
74
123
  - test/test_helper.rb
75
- has_rdoc: yard
76
- homepage: http://tagaholic.me/lightning
77
- licenses: []
78
-
124
+ - bin/lightning
125
+ - bin/lightning-complete
126
+ - bin/lightning-translate
127
+ - LICENSE.txt
128
+ - CHANGELOG.rdoc
129
+ - README.rdoc
130
+ - test/deps.rip
131
+ - Rakefile
132
+ - .gemspec
133
+ - test/lightning.yml
134
+ - man/lightning.1
135
+ - man/lightning.1.ronn
136
+ has_rdoc: true
137
+ homepage: http://tagaholic.me/lightning/
138
+ licenses:
139
+ - MIT
79
140
  post_install_message:
80
141
  rdoc_options:
81
142
  - --title
82
- - Lightning 0.3.2 Documentation
143
+ - Lightning 0.3.3 Documentation
83
144
  require_paths:
84
145
  - lib
85
146
  required_ruby_version: !ruby/object:Gem::Requirement
147
+ none: false
86
148
  requirements:
87
149
  - - ">="
88
150
  - !ruby/object:Gem::Version
151
+ hash: 3
89
152
  segments:
90
153
  - 0
91
154
  version: "0"
92
155
  required_rubygems_version: !ruby/object:Gem::Requirement
156
+ none: false
93
157
  requirements:
94
158
  - - ">="
95
159
  - !ruby/object:Gem::Version
160
+ hash: 23
96
161
  segments:
97
- - 0
98
- version: "0"
162
+ - 1
163
+ - 3
164
+ - 6
165
+ version: 1.3.6
99
166
  requirements: []
100
167
 
101
168
  rubyforge_project: tagaholic
102
- rubygems_version: 1.3.6
169
+ rubygems_version: 1.3.7
103
170
  signing_key:
104
171
  specification_version: 3
105
172
  summary: Lightning is a commandline framework that generates shell functions which wrap around commands to autocomplete and translate full paths by their basenames.
106
- test_files:
107
- - test/bolt_commands_test.rb
108
- - test/bolt_test.rb
109
- - test/builder_test.rb
110
- - test/commands_test.rb
111
- - test/completion_map_test.rb
112
- - test/completion_test.rb
113
- - test/config_test.rb
114
- - test/core_commands_test.rb
115
- - test/function_commands_test.rb
116
- - test/function_test.rb
117
- - test/generator_test.rb
118
- - test/shell_command_commands_test.rb
119
- - test/test_helper.rb
173
+ test_files: []
174
+