Sha256: 98158a838fa5498eed000de9a4332879fb9e48335c14792e0a00ba06a012f71b

Contents?: true

Size: 1.46 KB

Versions: 13

Compression:

Stored size: 1.46 KB

Contents

require 'bundler'

module IronWorkerNG
  module Feature
    module Ruby
      module MergeGemfile
        class Feature < IronWorkerNG::Feature::Base
          attr_reader :path
          attr_reader :groups

          def initialize(code, path, groups)
            super(code)

            @path = path
            @groups = groups
          end

          def hash_string
            Digest::MD5.hexdigest(@path + File.mtime(rebase(@path)).to_i.to_s + (File.exists?(rebase(@path) + '.lock') ? File.mtime(rebase(@path) + '.lock').to_i.to_s : '') + @groups.join)
          end
        end

        module InstanceMethods
          def merge_gemfile(path, *groups)
            groups = groups.map { |g| g.to_sym }
            groups << :default if groups.length == 0

            IronCore::Logger.info 'IronWorkerNG', "Adding ruby gems dependencies from #{groups.join(', ')} group#{groups.length > 1 ? 's' : ''} of #{path}"

            specs = Bundler::Definition.build(path, path + '.lock', nil).specs_for(groups)

            specs.each do |spec|
              merge_gem(spec.name, spec.version.to_s)
            end

            @features << IronWorkerNG::Feature::Ruby::MergeGemfile::Feature.new(self, path, groups)
          end

          alias :gemfile :merge_gemfile

          def self.included(base)
            IronWorkerNG::Code::Base.register_feature(:name => 'merge_gemfile', :for_klass => base, :args => 'PATH[,GROUP...]')
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
iron_worker_ng-0.7.4 lib/iron_worker_ng/feature/ruby/merge_gemfile.rb
iron_worker_ng-0.7.3 lib/iron_worker_ng/feature/ruby/merge_gemfile.rb
iron_worker_ng-0.7.2 lib/iron_worker_ng/feature/ruby/merge_gemfile.rb
iron_worker_ng-0.7.1 lib/iron_worker_ng/feature/ruby/merge_gemfile.rb
iron_worker_ng-0.7.0 lib/iron_worker_ng/feature/ruby/merge_gemfile.rb
iron_worker_ng-0.6.8 lib/iron_worker_ng/feature/ruby/merge_gemfile.rb
iron_worker_ng-0.6.7 lib/iron_worker_ng/feature/ruby/merge_gemfile.rb
iron_worker_ng-0.6.6 lib/iron_worker_ng/feature/ruby/merge_gemfile.rb
iron_worker_ng-0.6.5 lib/iron_worker_ng/feature/ruby/merge_gemfile.rb
iron_worker_ng-0.6.4 lib/iron_worker_ng/feature/ruby/merge_gemfile.rb
iron_worker_ng-0.6.3 lib/iron_worker_ng/feature/ruby/merge_gemfile.rb
iron_worker_ng-0.6.2 lib/iron_worker_ng/feature/ruby/merge_gemfile.rb
iron_worker_ng-0.6.1 lib/iron_worker_ng/feature/ruby/merge_gemfile.rb