gem-edit 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,58 +1,4 @@
1
1
  gem-edit
2
2
  ========
3
3
 
4
- Open a library file you can require in your editor. That's it.
5
-
6
- gem edit active_support/all
7
- gem edit rake/task thor/task
8
- gem edit -e mvim fileutils
9
-
10
- Actually that's not it. You can also open a gem by name:
11
-
12
- gem open bundler
13
-
14
- Your editor's current working directory will be the root of the gem.
15
-
16
- I almost forgot. You can also clone a gem from GitHub.
17
-
18
- gem clone rails
19
- gem clone -d ~/src capybara
20
-
21
- And tell it to open the gem in your editor afterwards:
22
-
23
- gem clone -o rack
24
- gem clone -oe mvim -d /tmp gem-edit
25
-
26
- This one doesn't work if the neither the homepage nor the source code
27
- URL points back at GitHub.
28
-
29
- Installation
30
- ------------
31
-
32
- RubyGems 1.8 is required to use `gem edit` itself, but the other
33
- commands will work on any version that supports RubyGems plugins.
34
-
35
- gem install gem-edit
36
-
37
- If you're using RVM, you can put it in the global gemset (relax, it has
38
- no dependencies):
39
-
40
- echo gem-edit >> ~/.rvm/gemsets/global.gems
41
- rvm @global gem install gem-edit
42
-
43
- Protip: Install [gem-ctags](https://github.com/tpope/gem-ctags) to
44
- automatically invoke [Ctags](http://ctags.sourceforge.net/) on gems as
45
- they are installed.
46
-
47
- Contributing
48
- ------------
49
-
50
- Don't submit a pull request with [an ugly commit
51
- message](http://stopwritingramblingcommitmessages.com) or I will ignore
52
- your patch until I have the energy to politely explain my zero tolerance
53
- policy.
54
-
55
- License
56
- -------
57
-
58
- Copyright (c) Tim Pope. MIT License.
4
+ Replaced by [gem-browse](https://github.com/tpope/gem-browse).
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem-edit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-28 00:00:00.000000000Z
12
+ date: 2011-08-29 00:00:00.000000000Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: gem-browse
16
+ requirement: &74267740 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *74267740
14
25
  - !ruby/object:Gem::Dependency
15
26
  name: rake
16
- requirement: &70672910 !ruby/object:Gem::Requirement
27
+ requirement: &74267480 !ruby/object:Gem::Requirement
17
28
  none: false
18
29
  requirements:
19
30
  - - ~>
@@ -21,32 +32,16 @@ dependencies:
21
32
  version: '0.8'
22
33
  type: :development
23
34
  prerelease: false
24
- version_requirements: *70672910
25
- description: ! 'gem edit: Open a library file you can require
26
-
27
- gem open: Open a gem by name
28
-
29
- gem clone: Clone a gem from GitHub
30
-
31
- '
35
+ version_requirements: *74267480
36
+ description:
32
37
  email:
33
38
  - ruby@tpope.org
34
39
  executables: []
35
40
  extensions: []
36
41
  extra_rdoc_files: []
37
42
  files:
38
- - .gitignore
39
- - Gemfile
40
- - MIT-LICENSE
41
43
  - README.markdown
42
- - Rakefile
43
- - gem-edit.gemspec
44
- - lib/rubygems/commands/clone_command.rb
45
- - lib/rubygems/commands/edit_command.rb
46
- - lib/rubygems/commands/open_command.rb
47
- - lib/rubygems/edit/command.rb
48
- - lib/rubygems_plugin.rb
49
- homepage: https://github.com/tpope/gem-edit
44
+ homepage: https://github.com/tpope/gem-browse
50
45
  licenses: []
51
46
  post_install_message:
52
47
  rdoc_options: []
@@ -69,5 +64,5 @@ rubyforge_project:
69
64
  rubygems_version: 1.8.6
70
65
  signing_key:
71
66
  specification_version: 3
72
- summary: gem edit, gem open, gem clone
67
+ summary: Superseded by gem-browse
73
68
  test_files: []
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- pkg/*
data/Gemfile DELETED
@@ -1,2 +0,0 @@
1
- source "http://rubygems.org"
2
- gemspec
@@ -1,20 +0,0 @@
1
- Copyright (c) Tim Pope
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/Rakefile DELETED
@@ -1 +0,0 @@
1
- require "bundler/gem_tasks"
@@ -1,23 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
-
4
- Gem::Specification.new do |s|
5
- s.name = "gem-edit"
6
- s.version = "1.0.0"
7
- s.authors = ["Tim Pope"]
8
- s.email = ["ruby@tpop"+'e.org']
9
- s.homepage = "https://github.com/tpope/gem-edit"
10
- s.summary = %q{gem edit, gem open, gem clone}
11
- s.description = <<-EOS
12
- gem edit: Open a library file you can require
13
- gem open: Open a gem by name
14
- gem clone: Clone a gem from GitHub
15
- EOS
16
-
17
- s.files = `git ls-files`.split("\n")
18
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
- s.require_paths = ["lib"]
21
-
22
- s.add_development_dependency('rake', '~> 0.8')
23
- end
@@ -1,81 +0,0 @@
1
- require 'rubygems/edit/command'
2
-
3
- class Gem::Commands::CloneCommand < Gem::Edit::Command
4
-
5
- def description
6
- <<-EOF
7
- The clone command performs a Git clone of a gem's upstream repository.
8
- It looks for this repository by checking the homepage field of the gemspec
9
- and the source code URL field at rubygems.org. Currently, only GitHub
10
- repositories are recognized.
11
- EOF
12
- end
13
-
14
- def initialize
15
- super 'clone', "Clone a gem's source from GitHub"
16
- add_editor_option
17
- add_option('-o', '--[no-]open', 'Open in editor afterwards') do |open, options|
18
- options[:open] = open
19
- end
20
- add_option('-d', '--directory DIR', 'Parent directory to clone into') do |directory, options|
21
- options[:directory] = directory
22
- end
23
- end
24
-
25
- def execute
26
- name = get_one_gem_name
27
- json = nil
28
-
29
- homepage =
30
- begin
31
- if Gem::Specification.respond_to?(:find_by_name)
32
- Gem::Specification.find_by_name(name)
33
- else
34
- Gem.source_index.find_name(name).last or raise Gem::LoadError
35
- end.homepage
36
- rescue Gem::LoadError
37
- json = get_json(name)
38
- json[/"homepage_uri":\s*([^"]*)"/, 1]
39
- end
40
-
41
- unless url = repo(homepage)
42
- json ||= get_json(name)
43
- unless url = repo(json[/"source_code_uri":\s*"([^"]*)"/, 1])
44
- alert_error "Could not find a GitHub URL for #{name}"
45
- terminate_interaction 1
46
- end
47
- end
48
-
49
- target = File.join(*[options[:directory], url[/([^\/]*)\.git$/, 1]].compact)
50
- unless system('git', 'clone', url, target)
51
- alert_error "Failed to clone #{url}"
52
- terminate_interaction 1
53
- end
54
-
55
- if options[:open]
56
- Dir.chdir(target) do
57
- edit('.')
58
- end
59
- end
60
- end
61
-
62
- def get_json(name)
63
- require 'open-uri'
64
- begin
65
- open("http://rubygems.org/api/v1/gems/#{name}.json").read
66
- rescue OpenURI::HTTPError
67
- alert_error "Cannot retrieve gem information for #{name} from rubygems.org."
68
- terminate_interaction 1
69
- end
70
- end
71
-
72
- def repo(url)
73
- case url.to_s
74
- when %r{://(?:wiki\.)?github\.com/([^/]*/[^/]*)}
75
- "git://github.com/#$1.git"
76
- when %r{://([^./]*)\.github\.com/([^/]*)}
77
- "git://github.com/#$1/#$2.git"
78
- end
79
- end
80
-
81
- end
@@ -1,64 +0,0 @@
1
- require 'rubygems/edit/command'
2
-
3
- class Gem::Commands::EditCommand < Gem::Edit::Command
4
-
5
- def description
6
- <<-EOF
7
- The edit command looks through the require paths of each gem for the
8
- specified library file and loads said file in your editor. If no file is
9
- found, $LOAD_PATH is searched before giving up.
10
- EOF
11
- end
12
-
13
- def initialize
14
- super 'edit', 'Edit a library file you can require'
15
- add_editor_option
16
- end
17
-
18
- def execute
19
- unless Gem::Specification.respond_to?(:find_by_path)
20
- $stderr.puts "RubyGems >= 1.8.0 is required to use gem edit."
21
- terminate_interaction 1
22
- end
23
-
24
- specs = options[:args].map do |lib|
25
- [lib, Gem::Specification.find_by_path(lib)]
26
- end
27
-
28
- paths = specs.map do |(lib, spec)|
29
- if spec
30
- find(lib, spec.require_paths.map {|p| File.join(spec.full_gem_path, p)})
31
- else
32
- find(lib, $LOAD_PATH)
33
- end
34
- end.compact
35
-
36
- gemspecs = specs.map {|s| s.last}.compact.uniq
37
- dir = if gemspecs.size == 1
38
- gemspecs.first.full_gem_path
39
- else
40
- File.join(Gem.dir, 'gems')
41
- end
42
-
43
- unless paths.empty?
44
- Dir.chdir(dir) do
45
- edit(*paths)
46
- end
47
- end
48
- end
49
-
50
- # Adapted from Gem::Commands::WhichCommand
51
- def find(lib, paths)
52
- paths.each do |path|
53
- Gem.suffixes.each do |ext|
54
- full_path = File.join(path, "#{lib}#{ext}")
55
- if File.exist?(full_path) && !File.directory?(full_path)
56
- return full_path
57
- end
58
- end
59
- end
60
-
61
- alert_warning("Could not find #{lib.inspect} in any require path.")
62
- end
63
-
64
- end
@@ -1,30 +0,0 @@
1
- require 'rubygems/edit/command'
2
- require 'rubygems/version_option'
3
-
4
- class Gem::Commands::OpenCommand < Gem::Edit::Command
5
- include Gem::VersionOption
6
-
7
- def initialize
8
- super 'open', 'Open a gem in your editor', :version => '>= 0'
9
- add_editor_option
10
- add_version_option
11
- end
12
-
13
- def execute
14
- name = get_one_gem_name
15
- gemspec =
16
- if Gem::Specification.respond_to?(:find_by_name)
17
- Gem::Specification.find_by_name(name, options[:version])
18
- else
19
- Gem.source_index.find_name(name, options[:version]).last or
20
- raise Gem::LoadError
21
- end
22
- Dir.chdir(gemspec.full_gem_path) do
23
- edit(gemspec.full_gem_path)
24
- end
25
- rescue Gem::LoadError
26
- alert_error "Could not find a valid gem #{name} (#{options[:version]})"
27
- terminate_interaction 1
28
- end
29
-
30
- end
@@ -1,28 +0,0 @@
1
- require 'rubygems/command'
2
-
3
- module Gem::Edit
4
- class Command < Gem::Command
5
-
6
- def add_editor_option
7
- add_option('-e', '--editor EDITOR', 'Specify editor to invoke') do |editor, options|
8
- options[:editor] = editor
9
- end
10
- end
11
-
12
- def editor
13
- options[:editor] ||
14
- ENV['GEM_EDITOR'] ||
15
- ENV['VISUAL'] ||
16
- ENV['EDITOR'] ||
17
- 'vi'
18
- end
19
-
20
- def edit(*args)
21
- unless system(*editor.split(/\s+/) + args)
22
- alert_error "Problem with editor #{editor}"
23
- terminate_interaction 1
24
- end
25
- end
26
-
27
- end
28
- end
@@ -1,5 +0,0 @@
1
- require 'rubygems/command_manager'
2
-
3
- Gem::CommandManager.instance.register_command :edit
4
- Gem::CommandManager.instance.register_command :open
5
- Gem::CommandManager.instance.register_command :clone