bundler-source-pathext 0.2.0 → 0.2.1

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
  SHA256:
3
- metadata.gz: fe992635560597c121fa90491f6501471dedddf344d497cfa87f4c512e51deb8
4
- data.tar.gz: afd9e49a4916dbf8b9ec52505ef19fee11de8052716d94411a15e3961f93e628
3
+ metadata.gz: cdeaf53514088b07fa6fa9f2855330f37bb35f267b22b91204e82825c1935244
4
+ data.tar.gz: 2bf8c27185fcfae260b11a35e0d19db9145e710a29354ac37e1860e47efcde17
5
5
  SHA512:
6
- metadata.gz: eafc5e0d6fd8e7ff002ed82cc766332ec1b9e371fa596bc20f9877625a8feb5afc28160f5a698eedc85d8c9c6281e9c52e7fbb78cf18d0727c5791fc7788265d
7
- data.tar.gz: c89d33b02882c2bb025e16a097cf48940ed86c7f0ce653bf4422e3bdf08d49db6dea1e885dc7c2062d261b8fab8932c0c0972d7d239f1712d58254a969c8b3ed
6
+ metadata.gz: 03d30d6b285753b0c0a094f2c452ba5df46e5ccbb304236c16a8ed8c772a6befea680f43d652627d6b4ea41e580bc4e694fe1a10e9bb1573f6535ac5606e0163
7
+ data.tar.gz: 38defcddfe6be5be21844a8bad420279bc761c85622e10c77e2b95686dfc38be910162b36ab0fabe607a79ae95342d8212256d6ad4894504779818ffa0fd24dc
@@ -1,8 +1,6 @@
1
- require_relative 'lib/bundler-source-pathext/version'
2
-
3
1
  Gem::Specification.new do |spec|
4
2
  spec.name = "bundler-source-pathext"
5
- spec.version = BundlerSourcePathext::VERSION
3
+ spec.version = "0.2.1"
6
4
  spec.authors = ["pganalyze Team"]
7
5
  spec.email = ["team@pganalyze.com"]
8
6
 
data/plugins.rb CHANGED
@@ -1,2 +1,164 @@
1
- require 'bundler-source-pathext'
1
+ class BundlerSourcePathext < Bundler::Plugin::API
2
+ class PathExtSource < Bundler::Source
3
+ def install(spec, opts)
4
+ print_using_message "Using #{spec.name} #{spec.version} from #{self}"
2
5
 
6
+ using_message = "Using #{version_message(spec, options[:previous_spec])} from #{self}"
7
+ using_message += " and installing its executables" unless spec.executables.empty?
8
+ print_using_message using_message
9
+ generate_bin(spec, disable_extensions: true) # Turned off!
10
+
11
+ build_local_extensions(spec)
12
+
13
+ nil # no post-install message
14
+ end
15
+
16
+ # Bundler plugin api, we need to return a Bundler::Index
17
+ def specs
18
+ files = Dir.glob(File.join(File.expand_path(uri), '*.gemspec'))
19
+
20
+ Bundler::Index.build do |index|
21
+ files.each do |file|
22
+ next unless spec = Bundler.load_gemspec(file)
23
+ spec.installed_by_version = Gem::VERSION
24
+ spec.source = self
25
+ spec.extension_dir = File.join(File.dirname(file), 'tmp', RUBY_PLATFORM, spec.name, RUBY_VERSION)
26
+ Bundler.rubygems.validate(spec)
27
+
28
+ index << spec
29
+ end
30
+ end
31
+ end
32
+
33
+ # Set internal representation to fetch the gems/specs locally.
34
+ #
35
+ # When this is called, the source should try to fetch the specs and
36
+ # install from the local system.
37
+ def local!
38
+ # not applicable
39
+ end
40
+
41
+ # Set internal representation to fetch the gems/specs from remote.
42
+ #
43
+ # When this is called, the source should try to fetch the specs and
44
+ # install from remote path.
45
+ def remote!
46
+ # not applicable
47
+ end
48
+
49
+ # Set internal representation to fetch the gems/specs from app cache.
50
+ #
51
+ # When this is called, the source should try to fetch the specs and
52
+ # install from the path provided by `app_cache_path`.
53
+ def cached!
54
+ # not applicable
55
+ end
56
+
57
+ # This is called to update the spec and installation.
58
+ #
59
+ # If the source plugin is loaded from lockfile or otherwise, it shall
60
+ # refresh the cache/specs (e.g. git sources can make a fresh clone).
61
+ def unlock!
62
+ # not applicable
63
+ end
64
+
65
+ private
66
+
67
+ def build_local_extensions(spec)
68
+ build_args = options[:build_args] || Bundler.rubygems.build_args || begin
69
+ require_relative "command"
70
+ Gem::Command.build_args
71
+ end
72
+
73
+ builder = Gem::Ext::Builder.new spec, build_args
74
+
75
+ build_extensions(spec, build_args, builder)
76
+ end
77
+
78
+ def build_extensions(spec, build_args, builder)
79
+ return if spec.extensions.empty?
80
+
81
+ if build_args.empty?
82
+ puts "Building native extensions for #{spec.name}. This could take a while..."
83
+ else
84
+ puts "Building native extensions for #{spec.name} with: '#{@build_args.join " "}'"
85
+ puts "This could take a while..."
86
+ end
87
+
88
+ dest_path = spec.extension_dir
89
+ start = Time.now
90
+ load_dir = File.dirname(spec.loaded_from)
91
+
92
+ success = true
93
+ spec.extensions.each do |extension|
94
+ if extension[/extconf/] && File.exist?(File.join(load_dir, 'Rakefile'))
95
+ rake_args = ['compile']
96
+ builder.class.run(rake + rake_args, [], 'rake compile (via ' + self.class.to_s + ')', load_dir) do |status, results|
97
+ unless status.success?
98
+ success = false
99
+ puts results
100
+ end
101
+ end
102
+ else
103
+ builder.build_extension extension, dest_path
104
+ end
105
+ end
106
+ puts format(' Finished after %0.2f seconds', Time.now - start)
107
+ FileUtils.touch(spec.gem_build_complete_path) if success
108
+ end
109
+
110
+ def rake
111
+ rake = ENV["rake"]
112
+
113
+ if rake
114
+ rake = Shellwords.split(rake)
115
+ else
116
+ begin
117
+ rake = Gem::Ext::Builder.ruby << "-rrubygems" << Gem.bin_path("rake", "rake")
118
+ rescue Gem::Exception
119
+ rake = [Gem.default_exec_format % "rake"]
120
+ end
121
+ end
122
+ rake
123
+ end
124
+
125
+ def generate_bin(spec, options = {})
126
+ gem_dir = Pathname.new(spec.full_gem_path)
127
+
128
+ # Some gem authors put absolute paths in their gemspec
129
+ # and we have to save them from themselves
130
+ spec.files = spec.files.filter_map do |path|
131
+ next path unless /\A#{Pathname::SEPARATOR_PAT}/o.match?(path)
132
+ next if File.directory?(path)
133
+ begin
134
+ Pathname.new(path).relative_path_from(gem_dir).to_s
135
+ rescue ArgumentError
136
+ path
137
+ end
138
+ end
139
+
140
+ installer = Path::Installer.new(
141
+ spec,
142
+ env_shebang: false,
143
+ disable_extensions: options[:disable_extensions],
144
+ build_args: options[:build_args],
145
+ bundler_extension_cache_path: extension_cache_path(spec)
146
+ )
147
+ installer.post_install
148
+ rescue Gem::InvalidSpecificationException => e
149
+ Bundler.ui.warn "\n#{spec.name} at #{spec.full_gem_path} did not have a valid gemspec.\n" \
150
+ "This prevents bundler from installing bins or native extensions, but " \
151
+ "that may not affect its functionality."
152
+
153
+ if !spec.extensions.empty? && !spec.email.empty?
154
+ Bundler.ui.warn "If you need to use this package without installing it from a gem " \
155
+ "repository, please contact #{spec.email} and ask them " \
156
+ "to modify their .gemspec so it can work with `gem build`."
157
+ end
158
+
159
+ Bundler.ui.warn "The validation message from RubyGems was:\n #{e.message}"
160
+ end
161
+ end
162
+
163
+ source 'pathext', PathExtSource
164
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler-source-pathext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - pganalyze Team
@@ -24,8 +24,6 @@ files:
24
24
  - README.md
25
25
  - Rakefile
26
26
  - bundler-source-pathext.gemspec
27
- - lib/bundler-source-pathext.rb
28
- - lib/bundler-source-pathext/version.rb
29
27
  - plugins.rb
30
28
  homepage:
31
29
  licenses: []
@@ -1,3 +0,0 @@
1
- class BundlerSourcePathext < Bundler::Plugin::API
2
- VERSION = "0.2.0"
3
- end
@@ -1,166 +0,0 @@
1
- require "bundler-source-pathext/version"
2
-
3
- class BundlerSourcePathext < Bundler::Plugin::API
4
- class PathExtSource < Bundler::Source#Bundler::Source::Path
5
- def install(spec, opts)
6
- print_using_message "Using #{spec.name} #{spec.version} from #{self}"
7
-
8
- using_message = "Using #{version_message(spec, options[:previous_spec])} from #{self}"
9
- using_message += " and installing its executables" unless spec.executables.empty?
10
- print_using_message using_message
11
- generate_bin(spec, disable_extensions: true) # Turned off!
12
-
13
- build_local_extensions(spec)
14
-
15
- nil # no post-install message
16
- end
17
-
18
- # Bundler plugin api, we need to return a Bundler::Index
19
- def specs
20
- files = Dir.glob(File.join(File.expand_path(uri), '*.gemspec'))
21
-
22
- Bundler::Index.build do |index|
23
- files.each do |file|
24
- next unless spec = Bundler.load_gemspec(file)
25
- spec.installed_by_version = Gem::VERSION
26
- spec.source = self
27
- spec.extension_dir = File.join(File.dirname(file), 'tmp', RUBY_PLATFORM, spec.name, RUBY_VERSION)
28
- Bundler.rubygems.validate(spec)
29
-
30
- index << spec
31
- end
32
- end
33
- end
34
-
35
- # Set internal representation to fetch the gems/specs locally.
36
- #
37
- # When this is called, the source should try to fetch the specs and
38
- # install from the local system.
39
- def local!
40
- # not applicable
41
- end
42
-
43
- # Set internal representation to fetch the gems/specs from remote.
44
- #
45
- # When this is called, the source should try to fetch the specs and
46
- # install from remote path.
47
- def remote!
48
- # not applicable
49
- end
50
-
51
- # Set internal representation to fetch the gems/specs from app cache.
52
- #
53
- # When this is called, the source should try to fetch the specs and
54
- # install from the path provided by `app_cache_path`.
55
- def cached!
56
- # not applicable
57
- end
58
-
59
- # This is called to update the spec and installation.
60
- #
61
- # If the source plugin is loaded from lockfile or otherwise, it shall
62
- # refresh the cache/specs (e.g. git sources can make a fresh clone).
63
- def unlock!
64
- # not applicable
65
- end
66
-
67
- private
68
-
69
- def build_local_extensions(spec)
70
- build_args = options[:build_args] || Bundler.rubygems.build_args || begin
71
- require_relative "command"
72
- Gem::Command.build_args
73
- end
74
-
75
- builder = Gem::Ext::Builder.new spec, build_args
76
-
77
- build_extensions(spec, build_args, builder)
78
- end
79
-
80
- def build_extensions(spec, build_args, builder)
81
- return if spec.extensions.empty?
82
-
83
- if build_args.empty?
84
- puts "Building native extensions for #{spec.name}. This could take a while..."
85
- else
86
- puts "Building native extensions for #{spec.name} with: '#{@build_args.join " "}'"
87
- puts "This could take a while..."
88
- end
89
-
90
- dest_path = spec.extension_dir
91
- start = Time.now
92
- load_dir = File.dirname(spec.loaded_from)
93
-
94
- success = true
95
- spec.extensions.each do |extension|
96
- if extension[/extconf/] && File.exist?(File.join(load_dir, 'Rakefile'))
97
- rake_args = ['compile']
98
- builder.class.run(rake + rake_args, [], 'rake compile (via ' + self.class.to_s + ')', load_dir) do |status, results|
99
- unless status.success?
100
- success = false
101
- puts results
102
- end
103
- end
104
- else
105
- builder.build_extension extension, dest_path
106
- end
107
- end
108
- puts format(' Finished after %0.2f seconds', Time.now - start)
109
- FileUtils.touch(spec.gem_build_complete_path) if success
110
- end
111
-
112
- def rake
113
- rake = ENV["rake"]
114
-
115
- if rake
116
- rake = Shellwords.split(rake)
117
- else
118
- begin
119
- rake = Gem::Ext::Builder.ruby << "-rrubygems" << Gem.bin_path("rake", "rake")
120
- rescue Gem::Exception
121
- rake = [Gem.default_exec_format % "rake"]
122
- end
123
- end
124
- rake
125
- end
126
-
127
- def generate_bin(spec, options = {})
128
- gem_dir = Pathname.new(spec.full_gem_path)
129
-
130
- # Some gem authors put absolute paths in their gemspec
131
- # and we have to save them from themselves
132
- spec.files = spec.files.filter_map do |path|
133
- next path unless /\A#{Pathname::SEPARATOR_PAT}/o.match?(path)
134
- next if File.directory?(path)
135
- begin
136
- Pathname.new(path).relative_path_from(gem_dir).to_s
137
- rescue ArgumentError
138
- path
139
- end
140
- end
141
-
142
- installer = Path::Installer.new(
143
- spec,
144
- env_shebang: false,
145
- disable_extensions: options[:disable_extensions],
146
- build_args: options[:build_args],
147
- bundler_extension_cache_path: extension_cache_path(spec)
148
- )
149
- installer.post_install
150
- rescue Gem::InvalidSpecificationException => e
151
- Bundler.ui.warn "\n#{spec.name} at #{spec.full_gem_path} did not have a valid gemspec.\n" \
152
- "This prevents bundler from installing bins or native extensions, but " \
153
- "that may not affect its functionality."
154
-
155
- if !spec.extensions.empty? && !spec.email.empty?
156
- Bundler.ui.warn "If you need to use this package without installing it from a gem " \
157
- "repository, please contact #{spec.email} and ask them " \
158
- "to modify their .gemspec so it can work with `gem build`."
159
- end
160
-
161
- Bundler.ui.warn "The validation message from RubyGems was:\n #{e.message}"
162
- end
163
- end
164
-
165
- source 'pathext', PathExtSource
166
- end