Sha256: df0ef6c4e362ded645b748d1d5c33eae398646d776b8343d703aefca3554497a

Contents?: true

Size: 1.87 KB

Versions: 2

Compression:

Stored size: 1.87 KB

Contents

module IronWorkerNG
  module Feature
    module Ruby
      module MergeGem
        def self.merge_binary?
          @merge_binary ||= false
        end

        def self.merge_binary=(merge_binary)
          @merge_binary = merge_binary
        end

        class Feature < IronWorkerNG::Feature::Base
          attr_reader :spec

          def initialize(code, spec)
            super(code)

            @spec = spec
          end

          def gem_path
            path = @spec.full_gem_path

            # bundler fix

            ['/gems/' + @spec.full_name, '/gems'].each do |bad_part|
              path.gsub!(bad_part + bad_part, bad_part)
            end

            path
          end

          def hash_string
            Digest::MD5.hexdigest(@spec.full_name)
          end

          def bundle(container)
            if @spec.extensions.length == 0 || IronWorkerNG::Feature::Ruby::MergeGem.merge_binary?
              IronCore::Logger.debug 'IronWorkerNG', "Bundling ruby gem with name='#{@spec.name}' and version='#{@spec.version}'"

              if File.exists? @spec.full_gem_path
                container_add(container, '__gems__/gems/' + @spec.full_name, gem_path)
              else # local gem
                from_dir = File.dirname @spec.loaded_from
                @spec.files.each do |fname|
                  to = '__gems__/gems/' + @spec.full_name + '/' + fname
                  from = from_dir + '/' + fname
                  container_add(container, to, from) if File.file? from
                end
              end
              container_add(container, "__gems__/specifications/#{@spec.full_name}.gemspec", @spec.loaded_from)
            else
              IronCore::Logger.warn 'IronWorkerNG', "Skipping ruby gem with name='#{@spec.name}' and version='#{@spec.version}' as it contains native extensions"
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
iron_worker_ng-0.10.4 lib/iron_worker_ng/feature/ruby/merge_gem.rb
iron_worker_ng-0.10.3 lib/iron_worker_ng/feature/ruby/merge_gem.rb