gem-path 0.6.1 → 0.6.2

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