Class: Prebake::PlatformGemBuilder
- Inherits:
-
Object
- Object
- Prebake::PlatformGemBuilder
- Defined in:
- lib/prebake/platform_gem_builder.rb
Instance Attribute Summary collapse
-
#checksum ⇒ Object
readonly
Returns the value of attribute checksum.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(spec) ⇒ PlatformGemBuilder
constructor
A new instance of PlatformGemBuilder.
Constructor Details
#initialize(spec) ⇒ PlatformGemBuilder
Returns a new instance of PlatformGemBuilder.
15 16 17 18 |
# File 'lib/prebake/platform_gem_builder.rb', line 15 def initialize(spec) @spec = spec @checksum = nil end |
Instance Attribute Details
#checksum ⇒ Object (readonly)
Returns the value of attribute checksum.
13 14 15 |
# File 'lib/prebake/platform_gem_builder.rb', line 13 def checksum @checksum end |
Instance Method Details
#build ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/prebake/platform_gem_builder.rb', line 20 def build # Build in a temp directory; Dir.chdir is scoped to it to # isolate from Bundler's working directory. Dir.mktmpdir("prebake-build") do |build_dir| FileUtils.cp_r(File.join(@spec.gem_dir, "."), build_dir) platform_spec = build_platform_spec(build_dir) gem_file = nil Dir.chdir(build_dir) do gem_file = Gem::Package.build(platform_spec) end built_path = File.join(build_dir, gem_file) final = File.join(Dir.tmpdir, "prebake-built-#{SecureRandom.hex(16)}.gem") FileUtils.cp(built_path, final) @checksum = Digest::SHA256.file(final).hexdigest Logger.debug "Built #{gem_file} (SHA256: #{@checksum})" final end end |