gempath 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in gempath.gemspec
4
+ gemspec
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,44 @@
1
+ # gempath
2
+
3
+ A simple script used to print the path to a given gem.
4
+
5
+ ## Why
6
+
7
+ A lot of times when I'm working on a project, I want to quickly view the source of a certain gem. Since I use Bundler, I can usually do:
8
+ ```bash
9
+ vim $(bundle show GEMNAME)
10
+ ```
11
+
12
+ But, other times, when I want to examine random gems, but don't want to to add it to my Gemfile, I end up doing something like:
13
+ ```bash
14
+ gem list -d GEMNAME
15
+ # look for gem path, copy/paste/cd to path
16
+ # cd GEMNAME-x.x.x
17
+ ```
18
+
19
+ That takes too long. Hence, gempath.
20
+
21
+ ## Usage
22
+
23
+ The most basic scenario:
24
+ ```bash
25
+ $ gempath rails
26
+ > /Users/xxxx/.rvm/gems/ruby-1.9.3-head/gems/rails-3.2.3
27
+ ```
28
+
29
+ But what if you have multiple versions of the rails gem installed. gempath supports version strings just like Gemfiles
30
+ ```bash
31
+ $ gempath rails -v '=3.2.1'
32
+ > /Users/xxxx/.rvm/gems/ruby-1.9.3-head/gems/rails-3.2.1
33
+ ```
34
+
35
+ Once I have the path, it's a simple cd, and I'm off and reading code:
36
+ ```bash
37
+ $ cd $(gempath rails -v '=3.2.1')
38
+ ```
39
+
40
+ or even quicker
41
+ ```bash
42
+ $ vim $(gempath rails -v '=3.2.1')
43
+ ```
44
+
@@ -0,0 +1,40 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ VERSION = "0.1.0"
4
+
5
+ require "optparse"
6
+ require "gempath"
7
+
8
+ options = {}
9
+ optparse = OptionParser.new do |opts|
10
+ opts.banner = "Usage: #{File.basename($0)} TARGET [options]"
11
+
12
+ opts.on('-v VERSION', 'Specify the gem version') do |version|
13
+ options[:v] = version
14
+ end
15
+
16
+ opts.on('--version', 'Display version') do
17
+ puts VERSION
18
+ exit
19
+ end
20
+
21
+ opts.on('-h', '--help', 'Display this screen') do
22
+ puts opts
23
+ exit
24
+ end
25
+ end
26
+
27
+ begin
28
+ optparse.parse!
29
+ Gempath.find(ARGV[0], options)
30
+ exit 0
31
+
32
+ rescue Gempath::NoTargetSpecifiedError
33
+ puts "error: no target specified"
34
+
35
+ rescue
36
+ puts "error: bad argument"
37
+ end
38
+
39
+ puts optparse
40
+ exit 1
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "gempath/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "gempath"
7
+ s.version = Gempath::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Micah Koga"]
10
+ s.email = ["m@mkoga.com"]
11
+ s.homepage = "http://github.com/mkoga/gempath"
12
+ s.summary = %q{echo a gem's path}
13
+ s.description = %q{A script that echo's out the path to a specified gem.}
14
+
15
+ s.rubyforge_project = "gempath"
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
+ # specify any dependencies here; for example:
23
+ # s.add_development_dependency "rake"
24
+ # s.add_runtime_dependency "rest-client"
25
+ end
@@ -0,0 +1,24 @@
1
+ require "gempath/version"
2
+
3
+ module Gempath
4
+
5
+ class NoTargetSpecifiedError < StandardError; end
6
+
7
+ def self.find(target, options = {})
8
+ raise NoTargetSpecifiedError unless target
9
+
10
+ begin
11
+ args = [ target ]
12
+ args << options[:v] if options[:v]
13
+ gem *args
14
+
15
+ puts Gem::Specification.find_by_name(target).gem_dir
16
+ exit 0
17
+
18
+ rescue LoadError
19
+ puts "'#{target}' not found in #{Gem.path.join(' or ')}"
20
+ exit 1
21
+ end
22
+ end
23
+
24
+ end
@@ -0,0 +1,3 @@
1
+ module Gempath
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gempath
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Micah Koga
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-30 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: A script that echo's out the path to a specified gem.
15
+ email:
16
+ - m@mkoga.com
17
+ executables:
18
+ - gempath
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - Rakefile
25
+ - Readme.md
26
+ - bin/gempath
27
+ - gempath.gemspec
28
+ - lib/gempath.rb
29
+ - lib/gempath/version.rb
30
+ homepage: http://github.com/mkoga/gempath
31
+ licenses: []
32
+ post_install_message:
33
+ rdoc_options: []
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubyforge_project: gempath
50
+ rubygems_version: 1.8.10
51
+ signing_key:
52
+ specification_version: 3
53
+ summary: echo a gem's path
54
+ test_files: []
55
+ has_rdoc: