gem-path 0.5.1 → 0.7.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.
- checksums.yaml +5 -5
- data/CHANGES.md +12 -0
- data/README.md +4 -5
- data/Rakefile +4 -4
- data/gem-path.gemspec +26 -25
- data/lib/rubygems/commands/path_command.rb +34 -12
- data/task/README.md +8 -8
- data/task/gemgem.rb +143 -71
- data/test/test.rb +7 -0
- metadata +14 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 15f18939d8e50af9c2fae87af1fe73ec1e05b286da7e0b2f025e978b96cf48a9
|
|
4
|
+
data.tar.gz: 02cf2bca584af9727c520ad61278c6fa3959422a57e0598cc611bf0a93719d0c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3e445e9f58fe8839b17885347ddc8b821967f20a012883c7f3ae976627a213d823edc30049c36a633f46043fa37a170bbdfeb7522bd822ff79a158581b6417a8
|
|
7
|
+
data.tar.gz: 5ed3e277e1ec364403613d58bd8b2eb2942ccff0cd6bd69263f9052ab14abea2308785f1d757e911c58f11a8ec1ef9f081b3a8913734e1f093492071d4282a95
|
data/CHANGES.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# CHANGES
|
|
2
2
|
|
|
3
|
+
## gem-path 0.6.2 -- 2017-03-23
|
|
4
|
+
|
|
5
|
+
* Fixed finding gems like google-protobuf which could have platform postfix.
|
|
6
|
+
|
|
7
|
+
## gem-path 0.6.1 -- 2014-10-27
|
|
8
|
+
|
|
9
|
+
* Updated that gem-beit could search against bundler installed gems.
|
|
10
|
+
|
|
11
|
+
## gem-path 0.6.0 -- 2014-10-27
|
|
12
|
+
|
|
13
|
+
* Internal cleanup and make find_gem_path a public method.
|
|
14
|
+
|
|
3
15
|
## gem-path 0.5.1 -- 2013-11-22
|
|
4
16
|
|
|
5
17
|
* Fixed a bug where it cannot find a gem if the version is not specified.
|
data/README.md
CHANGED
|
@@ -17,15 +17,14 @@ For examples, under [fish](http://fishshell.com/):
|
|
|
17
17
|
vim (gem path gem-path)
|
|
18
18
|
grep require -R (gem path gem-path)
|
|
19
19
|
|
|
20
|
-
Or checkout [gem-
|
|
20
|
+
Or checkout [gem-eit][], [gem-grep][] for shorthands.
|
|
21
21
|
|
|
22
|
-
[gem-cd]: https://github.com/godfat/gem-cd
|
|
23
22
|
[gem-eit]: https://github.com/godfat/gem-eit
|
|
24
23
|
[gem-grep]: https://github.com/godfat/gem-grep
|
|
25
24
|
|
|
26
25
|
## REQUIREMENTS:
|
|
27
26
|
|
|
28
|
-
* Tested with MRI (official CRuby)
|
|
27
|
+
* Tested with MRI (official CRuby), Rubinius and JRuby.
|
|
29
28
|
|
|
30
29
|
## INSTALLATION:
|
|
31
30
|
|
|
@@ -63,9 +62,9 @@ This was extracted from [eit-gem][].
|
|
|
63
62
|
|
|
64
63
|
## LICENSE:
|
|
65
64
|
|
|
66
|
-
Apache License 2.0
|
|
65
|
+
Apache License 2.0 (Apache-2.0)
|
|
67
66
|
|
|
68
|
-
Copyright (c) 2013, Lin Jen-Shin (godfat)
|
|
67
|
+
Copyright (c) 2013-2021, Lin Jen-Shin (godfat)
|
|
69
68
|
|
|
70
69
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
71
70
|
you may not use this file except in compliance with the License.
|
data/Rakefile
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
begin
|
|
3
|
-
require "#{
|
|
3
|
+
require "#{__dir__}/task/gemgem"
|
|
4
4
|
rescue LoadError
|
|
5
|
-
sh 'git submodule update --init'
|
|
5
|
+
sh 'git submodule update --init --recursive'
|
|
6
6
|
exec Gem.ruby, '-S', $PROGRAM_NAME, *ARGV
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
Gemgem.init(
|
|
9
|
+
Gemgem.init(__dir__) do |s|
|
|
10
10
|
s.name = 'gem-path'
|
|
11
|
-
s.version = '0.
|
|
11
|
+
s.version = '0.7.0'
|
|
12
12
|
end
|
data/gem-path.gemspec
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
# stub: gem-path 0.
|
|
2
|
+
# stub: gem-path 0.7.0 ruby lib
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
|
-
s.name = "gem-path"
|
|
6
|
-
s.version = "0.
|
|
5
|
+
s.name = "gem-path".freeze
|
|
6
|
+
s.version = "0.7.0"
|
|
7
7
|
|
|
8
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
9
|
-
s.
|
|
10
|
-
s.
|
|
11
|
-
s.
|
|
12
|
-
s.
|
|
8
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
|
9
|
+
s.require_paths = ["lib".freeze]
|
|
10
|
+
s.authors = ["Lin Jen-Shin (godfat)".freeze]
|
|
11
|
+
s.date = "2021-08-11"
|
|
12
|
+
s.description = "Find the path for a given gem or require path for editing or greping.\n\nFor examples, under [fish](http://fishshell.com/):\n\n cd (gem path gem-path)\n vim (gem path gem-path)\n grep require -R (gem path gem-path)\n\nOr checkout [gem-eit][], [gem-grep][] for shorthands.\n\n[gem-eit]: https://github.com/godfat/gem-eit\n[gem-grep]: https://github.com/godfat/gem-grep".freeze
|
|
13
|
+
s.email = ["godfat (XD) godfat.org".freeze]
|
|
13
14
|
s.files = [
|
|
14
|
-
".gitignore",
|
|
15
|
-
".gitmodules",
|
|
16
|
-
".travis.yml",
|
|
17
|
-
"CHANGES.md",
|
|
18
|
-
"LICENSE",
|
|
19
|
-
"README.md",
|
|
20
|
-
"Rakefile",
|
|
21
|
-
"gem-path.gemspec",
|
|
22
|
-
"lib/rubygems/commands/path_command.rb",
|
|
23
|
-
"lib/rubygems_plugin.rb",
|
|
24
|
-
"task/README.md",
|
|
25
|
-
"task/gemgem.rb"
|
|
26
|
-
|
|
27
|
-
s.
|
|
28
|
-
s.
|
|
29
|
-
s.rubygems_version = "2.
|
|
30
|
-
s.summary = "Find the path for a given gem or require path for editing or greping."
|
|
15
|
+
".gitignore".freeze,
|
|
16
|
+
".gitmodules".freeze,
|
|
17
|
+
".travis.yml".freeze,
|
|
18
|
+
"CHANGES.md".freeze,
|
|
19
|
+
"LICENSE".freeze,
|
|
20
|
+
"README.md".freeze,
|
|
21
|
+
"Rakefile".freeze,
|
|
22
|
+
"gem-path.gemspec".freeze,
|
|
23
|
+
"lib/rubygems/commands/path_command.rb".freeze,
|
|
24
|
+
"lib/rubygems_plugin.rb".freeze,
|
|
25
|
+
"task/README.md".freeze,
|
|
26
|
+
"task/gemgem.rb".freeze,
|
|
27
|
+
"test/test.rb".freeze]
|
|
28
|
+
s.homepage = "https://github.com/godfat/gem-path".freeze
|
|
29
|
+
s.licenses = ["Apache-2.0".freeze]
|
|
30
|
+
s.rubygems_version = "3.2.25".freeze
|
|
31
|
+
s.summary = "Find the path for a given gem or require path for editing or greping.".freeze
|
|
31
32
|
end
|
|
@@ -12,16 +12,16 @@ class Gem::Commands::PathCommand < Gem::Command
|
|
|
12
12
|
name, version = extract!(options[:args])
|
|
13
13
|
|
|
14
14
|
# find the exact gem
|
|
15
|
-
if
|
|
16
|
-
say(
|
|
15
|
+
if gem_path = find_gem_path(name)
|
|
16
|
+
say(gem_path)
|
|
17
17
|
|
|
18
18
|
# find the require file
|
|
19
19
|
elsif path = Gem.find_files("#{name}.rb").first
|
|
20
20
|
# favor gem first (e.g. rake gem)
|
|
21
|
-
if
|
|
21
|
+
if gem_path = Gem.path.find{ |p|
|
|
22
22
|
break $1 if path =~ %r{(#{p}(/[^/]+){2})}
|
|
23
23
|
}
|
|
24
|
-
say(
|
|
24
|
+
say(gem_path)
|
|
25
25
|
else
|
|
26
26
|
say(path)
|
|
27
27
|
end
|
|
@@ -31,6 +31,29 @@ class Gem::Commands::PathCommand < Gem::Command
|
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
def find_gem_path name
|
|
35
|
+
gem_path = Gem.path.find do |base|
|
|
36
|
+
gem_path = $LOAD_PATH.find do |path|
|
|
37
|
+
platforms = [
|
|
38
|
+
'ruby',
|
|
39
|
+
sitearch,
|
|
40
|
+
*univeral_darwin
|
|
41
|
+
].map(&Regexp.method(:escape)).join('|')
|
|
42
|
+
|
|
43
|
+
gem_path = path[
|
|
44
|
+
%r{\A#{base}/
|
|
45
|
+
(?:bundler/)?
|
|
46
|
+
gems/
|
|
47
|
+
#{name}\-[^/-]+(?:\-(?:#{platforms}))?/
|
|
48
|
+
}x
|
|
49
|
+
]
|
|
50
|
+
break gem_path if gem_path
|
|
51
|
+
end
|
|
52
|
+
break gem_path if gem_path
|
|
53
|
+
end
|
|
54
|
+
gem_path.chop if gem_path
|
|
55
|
+
end
|
|
56
|
+
|
|
34
57
|
private
|
|
35
58
|
def extract! args
|
|
36
59
|
gem(*args)
|
|
@@ -44,14 +67,13 @@ class Gem::Commands::PathCommand < Gem::Command
|
|
|
44
67
|
end
|
|
45
68
|
end
|
|
46
69
|
|
|
47
|
-
def
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
70
|
+
def sitearch
|
|
71
|
+
@sitearch ||= RbConfig::CONFIG['sitearch']
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def univeral_darwin
|
|
75
|
+
if sitearch.include?('darwin')
|
|
76
|
+
'universal-darwin'
|
|
54
77
|
end
|
|
55
|
-
path_gem[0...-1] if path_gem
|
|
56
78
|
end
|
|
57
79
|
end
|
data/task/README.md
CHANGED
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
Provided tasks:
|
|
6
6
|
|
|
7
|
-
rake clean #
|
|
7
|
+
rake clean # Trash ignored files
|
|
8
8
|
rake gem:build # Build gem
|
|
9
9
|
rake gem:install # Install gem
|
|
10
10
|
rake gem:release # Release gem
|
|
11
11
|
rake gem:spec # Generate gemspec
|
|
12
|
-
rake test # Run tests
|
|
12
|
+
rake test # Run tests
|
|
13
13
|
|
|
14
14
|
## REQUIREMENTS:
|
|
15
15
|
|
|
16
|
-
* Tested with MRI (official CRuby)
|
|
16
|
+
* Tested with MRI (official CRuby) and JRuby.
|
|
17
17
|
|
|
18
18
|
## INSTALLATION:
|
|
19
19
|
|
|
@@ -23,13 +23,13 @@ And in Rakefile:
|
|
|
23
23
|
|
|
24
24
|
``` ruby
|
|
25
25
|
begin
|
|
26
|
-
require "#{
|
|
26
|
+
require "#{__dir__}/task/gemgem"
|
|
27
27
|
rescue LoadError
|
|
28
|
-
sh 'git submodule update --init'
|
|
28
|
+
sh 'git submodule update --init --recursive'
|
|
29
29
|
exec Gem.ruby, '-S', $PROGRAM_NAME, *ARGV
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
Gemgem.init(
|
|
32
|
+
Gemgem.init(__dir__, :submodules => %w[your-dep]) do |s|
|
|
33
33
|
s.name = 'your-gem'
|
|
34
34
|
s.version = '0.1.0'
|
|
35
35
|
end
|
|
@@ -37,9 +37,9 @@ end
|
|
|
37
37
|
|
|
38
38
|
## LICENSE:
|
|
39
39
|
|
|
40
|
-
Apache License 2.0
|
|
40
|
+
Apache License 2.0 (Apache-2.0)
|
|
41
41
|
|
|
42
|
-
Copyright (c) 2011-
|
|
42
|
+
Copyright (c) 2011-2021, Lin Jen-Shin (godfat)
|
|
43
43
|
|
|
44
44
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
45
45
|
you may not use this file except in compliance with the License.
|
data/task/gemgem.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
module Gemgem
|
|
3
3
|
class << self
|
|
4
|
-
attr_accessor :dir, :spec, :spec_create
|
|
4
|
+
attr_accessor :dir, :spec, :submodules, :spec_create
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
module_function
|
|
@@ -11,12 +11,14 @@ module Gemgem
|
|
|
11
11
|
def pkg_dir ; "#{dir}/pkg" ; end
|
|
12
12
|
def escaped_dir; @escaped_dir ||= Regexp.escape(dir); end
|
|
13
13
|
|
|
14
|
-
def init dir, &block
|
|
14
|
+
def init dir, options={}, &block
|
|
15
15
|
self.dir = dir
|
|
16
|
-
$LOAD_PATH.unshift("#{dir}/lib")
|
|
17
16
|
ENV['RUBYLIB'] = "#{dir}/lib:#{ENV['RUBYLIB']}"
|
|
18
17
|
ENV['PATH'] = "#{dir}/bin:#{ENV['PATH']}"
|
|
18
|
+
self.submodules = options[:submodules] || []
|
|
19
19
|
self.spec_create = block
|
|
20
|
+
|
|
21
|
+
$LOAD_PATH.unshift("#{dir}/lib", *submodules_libs)
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
def create
|
|
@@ -26,7 +28,7 @@ module Gemgem
|
|
|
26
28
|
|
|
27
29
|
s.description = description.join
|
|
28
30
|
s.summary = description.first
|
|
29
|
-
s.license =
|
|
31
|
+
s.license = license
|
|
30
32
|
|
|
31
33
|
s.date = Time.now.strftime('%Y-%m-%d')
|
|
32
34
|
s.files = gem_files
|
|
@@ -34,10 +36,115 @@ module Gemgem
|
|
|
34
36
|
s.executables = bin_files
|
|
35
37
|
end
|
|
36
38
|
spec_create.call(spec)
|
|
37
|
-
spec.homepage
|
|
39
|
+
spec.homepage ||= "https://github.com/godfat/#{spec.name}"
|
|
38
40
|
self.spec = spec
|
|
39
41
|
end
|
|
40
42
|
|
|
43
|
+
def gem_install
|
|
44
|
+
require 'rubygems/commands/install_command'
|
|
45
|
+
require 'rubygems/package'
|
|
46
|
+
# read ~/.gemrc
|
|
47
|
+
Gem.use_paths(Gem.configuration[:gemhome], Gem.configuration[:gempath])
|
|
48
|
+
Gem::Command.extra_args = Gem.configuration[:gem]
|
|
49
|
+
|
|
50
|
+
# setup install options
|
|
51
|
+
cmd = Gem::Commands::InstallCommand.new
|
|
52
|
+
cmd.handle_options([])
|
|
53
|
+
|
|
54
|
+
# install
|
|
55
|
+
gem_package = Gem::Package.new(gem_path)
|
|
56
|
+
install = Gem::Installer.new(gem_package, cmd.options)
|
|
57
|
+
install.install
|
|
58
|
+
puts "\e[35mGem installed: \e[33m#{strip_path(install.gem_dir)}\e[0m"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def gem_spec
|
|
62
|
+
create
|
|
63
|
+
write
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def gem_build
|
|
67
|
+
require 'fileutils'
|
|
68
|
+
require 'rubygems/package'
|
|
69
|
+
gem = nil
|
|
70
|
+
Dir.chdir(dir) do
|
|
71
|
+
gem = Gem::Package.build(Gem::Specification.load(spec_path))
|
|
72
|
+
FileUtils.mkdir_p(pkg_dir)
|
|
73
|
+
FileUtils.mv(gem, pkg_dir) # gem is relative path, but might be ok
|
|
74
|
+
end
|
|
75
|
+
puts "\e[35mGem built: \e[33m#{strip_path("#{pkg_dir}/#{gem}")}\e[0m"
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def gem_release
|
|
79
|
+
sh_git('tag', gem_tag)
|
|
80
|
+
# sh_git('push')
|
|
81
|
+
# sh_git('push', '--tags')
|
|
82
|
+
sh_gem('push', gem_path)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def gem_check
|
|
86
|
+
unless git('status', '--porcelain').empty?
|
|
87
|
+
puts("\e[35mWorking copy is not clean.\e[0m")
|
|
88
|
+
exit(3)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
ver = spec.version.to_s
|
|
92
|
+
|
|
93
|
+
if ENV['VERSION'].nil?
|
|
94
|
+
puts("\e[35mExpected " \
|
|
95
|
+
"\e[33mVERSION\e[35m=\e[33m#{ver}\e[0m")
|
|
96
|
+
exit(1)
|
|
97
|
+
|
|
98
|
+
elsif ENV['VERSION'] != ver
|
|
99
|
+
puts("\e[35mExpected \e[33mVERSION\e[35m=\e[33m#{ver} " \
|
|
100
|
+
"\e[35mbut got\n " \
|
|
101
|
+
"\e[33mVERSION\e[35m=\e[33m#{ENV['VERSION']}\e[0m")
|
|
102
|
+
exit(2)
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def test
|
|
107
|
+
return if test_files.empty?
|
|
108
|
+
|
|
109
|
+
if ENV['COV'] || ENV['CI']
|
|
110
|
+
require 'simplecov'
|
|
111
|
+
if ENV['CI']
|
|
112
|
+
begin
|
|
113
|
+
require 'coveralls'
|
|
114
|
+
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
|
115
|
+
rescue LoadError => e
|
|
116
|
+
puts "Cannot load coveralls, skip: #{e}"
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
SimpleCov.start do
|
|
120
|
+
add_filter('test/')
|
|
121
|
+
add_filter('test.rb')
|
|
122
|
+
submodules_libs.each(&method(:add_filter))
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
test_files.each{ |file| require "#{dir}/#{file[0..-4]}" }
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def clean
|
|
130
|
+
return if ignored_files.empty?
|
|
131
|
+
|
|
132
|
+
require 'fileutils'
|
|
133
|
+
trash = File.expand_path("~/.Trash/#{spec.name}")
|
|
134
|
+
puts "Move the following files into: \e[35m#{strip_path(trash)}\e[33m"
|
|
135
|
+
|
|
136
|
+
ignored_files.each do |file|
|
|
137
|
+
from = "#{dir}/#{file}"
|
|
138
|
+
to = "#{trash}/#{File.dirname(file)}"
|
|
139
|
+
puts strip_path(from)
|
|
140
|
+
|
|
141
|
+
FileUtils.mkdir_p(to)
|
|
142
|
+
FileUtils.mv(from, to)
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
print "\e[0m"
|
|
146
|
+
end
|
|
147
|
+
|
|
41
148
|
def write
|
|
42
149
|
File.open(spec_path, 'w'){ |f| f << split_lines(spec.to_ruby) }
|
|
43
150
|
end
|
|
@@ -57,11 +164,15 @@ module Gemgem
|
|
|
57
164
|
end
|
|
58
165
|
|
|
59
166
|
def strip_home_path path
|
|
60
|
-
path.sub(ENV['HOME']
|
|
167
|
+
path.sub(/\A#{Regexp.escape(ENV['HOME'])}\//, '~/')
|
|
61
168
|
end
|
|
62
169
|
|
|
63
170
|
def strip_cwd_path path
|
|
64
|
-
path.sub(Dir.pwd
|
|
171
|
+
path.sub(/\A#{Regexp.escape(Dir.pwd)}\//, '')
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def submodules_libs
|
|
175
|
+
submodules.map{ |path| "#{dir}/#{path}/lib" }
|
|
65
176
|
end
|
|
66
177
|
|
|
67
178
|
def git *args
|
|
@@ -99,6 +210,11 @@ module Gemgem
|
|
|
99
210
|
@description ||= (readme['DESCRIPTION']||'').sub(/.+\n\n/, '').lines.to_a
|
|
100
211
|
end
|
|
101
212
|
|
|
213
|
+
def license
|
|
214
|
+
readme['LICENSE'].sub(/.+\n\n/, '').lines.first.
|
|
215
|
+
split(/[()]/).map(&:strip).reject(&:empty?).last
|
|
216
|
+
end
|
|
217
|
+
|
|
102
218
|
def all_files
|
|
103
219
|
@all_files ||= fold_files(glob).sort
|
|
104
220
|
end
|
|
@@ -119,7 +235,8 @@ module Gemgem
|
|
|
119
235
|
|
|
120
236
|
def gem_files
|
|
121
237
|
@gem_files ||= all_files.reject{ |f|
|
|
122
|
-
f =~
|
|
238
|
+
f =~ submodules_pattern ||
|
|
239
|
+
(f =~ ignored_pattern && !git_files.include?(f))
|
|
123
240
|
}
|
|
124
241
|
end
|
|
125
242
|
|
|
@@ -151,17 +268,20 @@ module Gemgem
|
|
|
151
268
|
end
|
|
152
269
|
end
|
|
153
270
|
|
|
271
|
+
def submodules_pattern
|
|
272
|
+
@submodules_pattern ||= if submodules.empty?
|
|
273
|
+
/^$/
|
|
274
|
+
else
|
|
275
|
+
Regexp.new(submodules.map{ |path|
|
|
276
|
+
"^#{Regexp.escape(path)}/" }.join('|'))
|
|
277
|
+
end
|
|
278
|
+
end
|
|
279
|
+
|
|
154
280
|
def expand_patterns pathes
|
|
155
281
|
# http://git-scm.com/docs/gitignore
|
|
156
282
|
pathes.flat_map{ |path|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
Regexp.escape(path).gsub(/\\\*/, '[^/]*')
|
|
160
|
-
when %r{^/}
|
|
161
|
-
"^#{Regexp.escape(path[1..-1])}"
|
|
162
|
-
else # we didn't implement negative pattern for now
|
|
163
|
-
Regexp.escape(path)
|
|
164
|
-
end
|
|
283
|
+
# we didn't implement negative pattern for now
|
|
284
|
+
Regexp.escape(path).sub(%r{^/}, '^').gsub(/\\\*/, '[^/]*')
|
|
165
285
|
}
|
|
166
286
|
end
|
|
167
287
|
|
|
@@ -179,86 +299,38 @@ namespace :gem do
|
|
|
179
299
|
|
|
180
300
|
desc 'Install gem'
|
|
181
301
|
task :install => [:build] do
|
|
182
|
-
Gemgem.
|
|
302
|
+
Gemgem.gem_install
|
|
183
303
|
end
|
|
184
304
|
|
|
185
305
|
desc 'Build gem'
|
|
186
306
|
task :build => [:spec] do
|
|
187
|
-
|
|
188
|
-
require 'rubygems/package'
|
|
189
|
-
gem = nil
|
|
190
|
-
Dir.chdir(Gemgem.dir) do
|
|
191
|
-
gem = Gem::Package.build(Gem::Specification.load(Gemgem.spec_path))
|
|
192
|
-
FileUtils.mkdir_p(Gemgem.pkg_dir)
|
|
193
|
-
FileUtils.mv(gem, Gemgem.pkg_dir) # gem is relative path, but might be ok
|
|
194
|
-
end
|
|
195
|
-
puts "\e[35mGem built: \e[33m" \
|
|
196
|
-
"#{Gemgem.strip_path("#{Gemgem.pkg_dir}/#{gem}")}\e[0m"
|
|
307
|
+
Gemgem.gem_build
|
|
197
308
|
end
|
|
198
309
|
|
|
199
310
|
desc 'Generate gemspec'
|
|
200
311
|
task :spec do
|
|
201
|
-
Gemgem.
|
|
202
|
-
Gemgem.write
|
|
312
|
+
Gemgem.gem_spec
|
|
203
313
|
end
|
|
204
314
|
|
|
205
315
|
desc 'Release gem'
|
|
206
316
|
task :release => [:spec, :check, :build] do
|
|
207
|
-
Gemgem.
|
|
208
|
-
sh_git('tag', Gemgem.gem_tag)
|
|
209
|
-
sh_git('push')
|
|
210
|
-
sh_git('push', '--tags')
|
|
211
|
-
sh_gem('push', Gemgem.gem_path)
|
|
212
|
-
end
|
|
317
|
+
Gemgem.gem_release
|
|
213
318
|
end
|
|
214
319
|
|
|
215
320
|
task :check do
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
if ENV['VERSION'].nil?
|
|
219
|
-
puts("\e[35mExpected " \
|
|
220
|
-
"\e[33mVERSION\e[35m=\e[33m#{ver}\e[0m")
|
|
221
|
-
exit(1)
|
|
222
|
-
|
|
223
|
-
elsif ENV['VERSION'] != ver
|
|
224
|
-
puts("\e[35mExpected \e[33mVERSION\e[35m=\e[33m#{ver} " \
|
|
225
|
-
"\e[35mbut got\n " \
|
|
226
|
-
"\e[33mVERSION\e[35m=\e[33m#{ENV['VERSION']}\e[0m")
|
|
227
|
-
exit(2)
|
|
228
|
-
end
|
|
321
|
+
# Gemgem.gem_check
|
|
229
322
|
end
|
|
230
323
|
|
|
231
324
|
end # of gem namespace
|
|
232
325
|
|
|
233
326
|
desc 'Run tests'
|
|
234
327
|
task :test do
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
require 'bacon'
|
|
238
|
-
Bacon.extend(Bacon::TestUnitOutput)
|
|
239
|
-
Bacon.summary_on_exit
|
|
240
|
-
Gemgem.test_files.each{ |file| require "#{Gemgem.dir}/#{file[0..-4]}" }
|
|
328
|
+
Gemgem.test
|
|
241
329
|
end
|
|
242
330
|
|
|
243
331
|
desc 'Trash ignored files'
|
|
244
332
|
task :clean => ['gem:spec'] do
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
require 'fileutils'
|
|
248
|
-
trash = File.expand_path("~/.Trash/#{Gemgem.spec.name}")
|
|
249
|
-
puts "Move the following files into:" \
|
|
250
|
-
" \e[35m#{Gemgem.strip_path(trash)}\e[33m"
|
|
251
|
-
|
|
252
|
-
Gemgem.ignored_files.each do |file|
|
|
253
|
-
from = "#{Gemgem.dir}/#{file}"
|
|
254
|
-
to = "#{trash}/#{File.dirname(file)}"
|
|
255
|
-
puts Gemgem.strip_path(from)
|
|
256
|
-
|
|
257
|
-
FileUtils.mkdir_p(to)
|
|
258
|
-
FileUtils.mv(from, to)
|
|
259
|
-
end
|
|
260
|
-
|
|
261
|
-
print "\e[0m"
|
|
333
|
+
Gemgem.clean
|
|
262
334
|
end
|
|
263
335
|
|
|
264
336
|
task :default do
|
data/test/test.rb
ADDED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gem-path
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Lin Jen-Shin (godfat)
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-08-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: |-
|
|
14
14
|
Find the path for a given gem or require path for editing or greping.
|
|
@@ -19,9 +19,8 @@ description: |-
|
|
|
19
19
|
vim (gem path gem-path)
|
|
20
20
|
grep require -R (gem path gem-path)
|
|
21
21
|
|
|
22
|
-
Or checkout [gem-
|
|
22
|
+
Or checkout [gem-eit][], [gem-grep][] for shorthands.
|
|
23
23
|
|
|
24
|
-
[gem-cd]: https://github.com/godfat/gem-cd
|
|
25
24
|
[gem-eit]: https://github.com/godfat/gem-eit
|
|
26
25
|
[gem-grep]: https://github.com/godfat/gem-grep
|
|
27
26
|
email:
|
|
@@ -30,9 +29,9 @@ executables: []
|
|
|
30
29
|
extensions: []
|
|
31
30
|
extra_rdoc_files: []
|
|
32
31
|
files:
|
|
33
|
-
- .gitignore
|
|
34
|
-
- .gitmodules
|
|
35
|
-
- .travis.yml
|
|
32
|
+
- ".gitignore"
|
|
33
|
+
- ".gitmodules"
|
|
34
|
+
- ".travis.yml"
|
|
36
35
|
- CHANGES.md
|
|
37
36
|
- LICENSE
|
|
38
37
|
- README.md
|
|
@@ -42,28 +41,28 @@ files:
|
|
|
42
41
|
- lib/rubygems_plugin.rb
|
|
43
42
|
- task/README.md
|
|
44
43
|
- task/gemgem.rb
|
|
44
|
+
- test/test.rb
|
|
45
45
|
homepage: https://github.com/godfat/gem-path
|
|
46
46
|
licenses:
|
|
47
|
-
- Apache
|
|
47
|
+
- Apache-2.0
|
|
48
48
|
metadata: {}
|
|
49
|
-
post_install_message:
|
|
49
|
+
post_install_message:
|
|
50
50
|
rdoc_options: []
|
|
51
51
|
require_paths:
|
|
52
52
|
- lib
|
|
53
53
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
54
54
|
requirements:
|
|
55
|
-
- -
|
|
55
|
+
- - ">="
|
|
56
56
|
- !ruby/object:Gem::Version
|
|
57
57
|
version: '0'
|
|
58
58
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
59
|
requirements:
|
|
60
|
-
- -
|
|
60
|
+
- - ">="
|
|
61
61
|
- !ruby/object:Gem::Version
|
|
62
62
|
version: '0'
|
|
63
63
|
requirements: []
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
signing_key:
|
|
64
|
+
rubygems_version: 3.2.25
|
|
65
|
+
signing_key:
|
|
67
66
|
specification_version: 4
|
|
68
67
|
summary: Find the path for a given gem or require path for editing or greping.
|
|
69
68
|
test_files: []
|