gemedit 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/License.txt +20 -0
- data/README.txt +20 -0
- data/bin/gemedit +86 -0
- data/lib/gemedit.rb +5 -0
- data/lib/gemedit/version.rb +9 -0
- metadata +62 -0
data/History.txt
ADDED
data/License.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Lee Marlow
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
gemedit
|
2
|
+
http://gemedit.rubyforge.org/
|
3
|
+
by Lee Marlow
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Gemedit lets you quickly open up the source for a gem in your favorite editor.
|
8
|
+
|
9
|
+
== INSTALLATION:
|
10
|
+
|
11
|
+
Gemedit can be installed via RubyGems:
|
12
|
+
|
13
|
+
$ sudo gem install gemedit
|
14
|
+
|
15
|
+
If you would like some basic command completion for installed gems add the following to your ~/.bashrc or ~/.profile:
|
16
|
+
complete -C "/usr/bin/gemedit --complete" gemedit
|
17
|
+
|
18
|
+
== USAGE:
|
19
|
+
|
20
|
+
$ gemedit gemedit
|
data/bin/gemedit
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Created on 2008-2-27.
|
4
|
+
# Copyright (c) 2008. All rights reserved.
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'rubygems'
|
8
|
+
rescue LoadError
|
9
|
+
# no rubygems to load, so we fail silently
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'optparse'
|
13
|
+
|
14
|
+
OPTIONS = {
|
15
|
+
:verbose => false,
|
16
|
+
:editor => ENV['VISUAL'] || ENV['EDITOR'] || 'vi'
|
17
|
+
}
|
18
|
+
|
19
|
+
parser = OptionParser.new do |opts|
|
20
|
+
opts.banner = <<BANNER
|
21
|
+
Open the source of installed gems in your favorite editor
|
22
|
+
|
23
|
+
Usage: #{File.basename($0)} GEM_NAME...
|
24
|
+
|
25
|
+
Options are:
|
26
|
+
BANNER
|
27
|
+
opts.separator ""
|
28
|
+
opts.on("-e", "--editor=EDITOR", String,
|
29
|
+
"The editor to open the gems with", "Default: #{OPTIONS[:editor]}") { |editor| OPTIONS[:editor] = editor }
|
30
|
+
opts.on("-v", "--verbose",
|
31
|
+
"Enable verbose logging", "Default: #{OPTIONS[:verbose]}") { |verbose| OPTIONS[:verbose] = true }
|
32
|
+
opts.on("-h", "--help",
|
33
|
+
"Show this help message.") { puts opts; exit }
|
34
|
+
end
|
35
|
+
|
36
|
+
if ARGV.include?('--complete')
|
37
|
+
exit 0 unless /\b#{Regexp.escape(File.basename($0))}\b/ =~ ENV["COMP_LINE"]
|
38
|
+
after_match = $'
|
39
|
+
complete_term = (after_match.empty? || after_match =~ /\s$/) ? nil : after_match.split.last
|
40
|
+
completions = if complete_term =~ /\A-/
|
41
|
+
parser.top.list.select { |opt| OptionParser::Switch === opt }.inject([]) { |ary, opt|
|
42
|
+
ary + opt.short + opt.long
|
43
|
+
}.select { |opt_string| opt_string =~ /\A#{Regexp.escape(complete_term)}/ }
|
44
|
+
elsif complete_term
|
45
|
+
Gem.source_index.inject([]) { |ary, (full_name, spec)| ary << full_name if /^#{Regexp.escape(complete_term)}/i =~ full_name; ary }
|
46
|
+
else
|
47
|
+
Gem.source_index.map { |full_name, spec| full_name }
|
48
|
+
end
|
49
|
+
puts completions
|
50
|
+
exit 0
|
51
|
+
end
|
52
|
+
|
53
|
+
parser.parse!(ARGV)
|
54
|
+
|
55
|
+
def get_gem(gem_name)
|
56
|
+
possible_gems = Gem.source_index.inject([]) { |ary, (name, spec)| ary << spec if /^#{Regexp.escape(gem_name)}/i =~ spec.full_name; ary }.sort_by { |gem| gem.version }.reverse
|
57
|
+
if possible_gems.size < 1
|
58
|
+
puts "No gems found for #{gem_name}... skipping"
|
59
|
+
end
|
60
|
+
gem = possible_gems.first if possible_gems.map { |g| g.name }.uniq.size == 1
|
61
|
+
gem ||= begin
|
62
|
+
require 'rubygems/user_interaction'
|
63
|
+
include Gem::DefaultUserInteraction
|
64
|
+
list = possible_gems.map { |g| "#{g.name} #{g.version}" }
|
65
|
+
list << 'None of the above'
|
66
|
+
name, index = ui.choose_from_list("Choose which gem to view for '#{gem_name}':", list)
|
67
|
+
possible_gems[index] if (0...possible_gems.size).include?(index)
|
68
|
+
end
|
69
|
+
gem
|
70
|
+
end
|
71
|
+
|
72
|
+
gems = ARGV.reject { |arg| arg.empty? }.map { |gem_name| get_gem(gem_name) }.compact
|
73
|
+
|
74
|
+
if gems.size > 0
|
75
|
+
puts "Opening the following gems with #{OPTIONS[:editor]}:" if OPTIONS[:verbose]
|
76
|
+
paths = gems.map do |gem|
|
77
|
+
puts " #{gem.full_name}: #{gem.full_gem_path}" if OPTIONS[:verbose]
|
78
|
+
%Q{"#{gem.full_gem_path}"}
|
79
|
+
end
|
80
|
+
cmd = "#{OPTIONS[:editor]} #{paths.join(' ')}"
|
81
|
+
puts "Running `#{cmd}`" if OPTIONS[:verbose]
|
82
|
+
exec cmd
|
83
|
+
else
|
84
|
+
puts "No gems found for editing"
|
85
|
+
end
|
86
|
+
exit 0
|
data/lib/gemedit.rb
ADDED
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gemedit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lee Marlow
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-02-28 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: A utility to view a gem's source in your favorite editor
|
17
|
+
email:
|
18
|
+
- lmarlow@rubyforge.org
|
19
|
+
executables:
|
20
|
+
- gemedit
|
21
|
+
extensions: []
|
22
|
+
|
23
|
+
extra_rdoc_files:
|
24
|
+
- History.txt
|
25
|
+
- License.txt
|
26
|
+
- README.txt
|
27
|
+
files:
|
28
|
+
- History.txt
|
29
|
+
- License.txt
|
30
|
+
- README.txt
|
31
|
+
- bin/gemedit
|
32
|
+
- lib/gemedit.rb
|
33
|
+
- lib/gemedit/version.rb
|
34
|
+
has_rdoc: true
|
35
|
+
homepage: http://gemedit.rubyforge.org
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options:
|
38
|
+
- --main
|
39
|
+
- README.txt
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
version:
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: "0"
|
53
|
+
version:
|
54
|
+
requirements: []
|
55
|
+
|
56
|
+
rubyforge_project: gemedit
|
57
|
+
rubygems_version: 1.0.1
|
58
|
+
signing_key:
|
59
|
+
specification_version: 2
|
60
|
+
summary: A utility to view a gem's source in your favorite editor
|
61
|
+
test_files: []
|
62
|
+
|