adamsanderson-open_gem 1.0.0
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/README.markdown +12 -0
- data/Rakefile +30 -0
- data/VERSION.yml +4 -0
- data/lib/rubygems/commands/open_command.rb +63 -0
- data/lib/rubygems_plugin.rb +3 -0
- metadata +57 -0
data/README.markdown
ADDED
data/Rakefile
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'rake'
|
|
2
|
+
require 'rake/testtask'
|
|
3
|
+
require 'rake/rdoctask'
|
|
4
|
+
|
|
5
|
+
begin
|
|
6
|
+
require 'jeweler'
|
|
7
|
+
Jeweler::Tasks.new do |s|
|
|
8
|
+
s.name = "open_gem"
|
|
9
|
+
s.summary = "Gem Command to easily open a ruby gem with the editor of your choice."
|
|
10
|
+
s.description = <<-DESC
|
|
11
|
+
Open a gem's source directory with either the default editor, or a specified command.
|
|
12
|
+
DESC
|
|
13
|
+
s.email = "netghost@gmail.com"
|
|
14
|
+
s.homepage = "http://github.com/adamsanderson/open_gem"
|
|
15
|
+
s.authors = ["Adam Sanderson"]
|
|
16
|
+
s.has_rdoc = false
|
|
17
|
+
s.files = FileList["[A-Z]*", "{bin,lib,test}/**/*"]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
rescue LoadError
|
|
21
|
+
puts "Jeweler not available. Install it for jeweler-related tasks with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
Rake::TestTask.new do |t|
|
|
25
|
+
t.libs << 'lib'
|
|
26
|
+
t.pattern = 'test/**/*_test.rb'
|
|
27
|
+
t.verbose = false
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
task :default => :install
|
data/VERSION.yml
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
require 'rubygems/command'
|
|
2
|
+
require 'rubygems/dependency'
|
|
3
|
+
require 'rubygems/version_option'
|
|
4
|
+
|
|
5
|
+
# OpenCommand will open a gem's source path
|
|
6
|
+
class Gem::Commands::OpenCommand < Gem::Command
|
|
7
|
+
include Gem::VersionOption
|
|
8
|
+
|
|
9
|
+
def initialize
|
|
10
|
+
super 'open', "Opens the gem's source directory with $EDITOR",
|
|
11
|
+
:command => nil,
|
|
12
|
+
:version=> Gem::Requirement.default,
|
|
13
|
+
:latest=> false
|
|
14
|
+
|
|
15
|
+
add_option('-c', '--command COMMAND',
|
|
16
|
+
'Execute command at path of the rubygem') do |value, options|
|
|
17
|
+
options[:command] = value
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
add_option('-l', '--latest',
|
|
21
|
+
'If there are multiple versions, open the latest') do |value, options|
|
|
22
|
+
options[:latest] = true
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
add_version_option
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def arguments # :nodoc:
|
|
29
|
+
"GEMNAME gem to open"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def execute
|
|
33
|
+
name = get_one_gem_name
|
|
34
|
+
|
|
35
|
+
dep = Gem::Dependency.new name, options[:version]
|
|
36
|
+
specs = Gem.source_index.search dep
|
|
37
|
+
|
|
38
|
+
if specs.length == 0
|
|
39
|
+
say "Could not find '#{name}'"
|
|
40
|
+
|
|
41
|
+
elsif specs.length == 1 || options[:latest]
|
|
42
|
+
path = specs.last.full_gem_path
|
|
43
|
+
|
|
44
|
+
else
|
|
45
|
+
choices = specs.map{|s|"#{s.name} #{s.version}"}
|
|
46
|
+
c,i = choose_from_list "Open which gem?", choices
|
|
47
|
+
path = specs[i].full_gem_path if i
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
open_gem(path) if path
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
private
|
|
55
|
+
def open_gem(path)
|
|
56
|
+
editor = options[:command] || ENV['EDITOR']
|
|
57
|
+
if !editor
|
|
58
|
+
say "Either set $EDITOR, or use -c <command_name>"
|
|
59
|
+
else
|
|
60
|
+
system(editor, path)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: adamsanderson-open_gem
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Adam Sanderson
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2009-04-26 00:00:00 -07:00
|
|
13
|
+
default_executable:
|
|
14
|
+
dependencies: []
|
|
15
|
+
|
|
16
|
+
description: Open a gem's source directory with either the default editor, or a specified command.
|
|
17
|
+
email: netghost@gmail.com
|
|
18
|
+
executables: []
|
|
19
|
+
|
|
20
|
+
extensions: []
|
|
21
|
+
|
|
22
|
+
extra_rdoc_files:
|
|
23
|
+
- README.markdown
|
|
24
|
+
files:
|
|
25
|
+
- README.markdown
|
|
26
|
+
- Rakefile
|
|
27
|
+
- VERSION.yml
|
|
28
|
+
- lib/rubygems/commands/open_command.rb
|
|
29
|
+
- lib/rubygems_plugin.rb
|
|
30
|
+
has_rdoc: false
|
|
31
|
+
homepage: http://github.com/adamsanderson/open_gem
|
|
32
|
+
post_install_message:
|
|
33
|
+
rdoc_options:
|
|
34
|
+
- --charset=UTF-8
|
|
35
|
+
require_paths:
|
|
36
|
+
- lib
|
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - ">="
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: "0"
|
|
42
|
+
version:
|
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: "0"
|
|
48
|
+
version:
|
|
49
|
+
requirements: []
|
|
50
|
+
|
|
51
|
+
rubyforge_project:
|
|
52
|
+
rubygems_version: 1.2.0
|
|
53
|
+
signing_key:
|
|
54
|
+
specification_version: 3
|
|
55
|
+
summary: Gem Command to easily open a ruby gem with the editor of your choice.
|
|
56
|
+
test_files: []
|
|
57
|
+
|