Sha256: dee2b340ba928ec1c127c2362a9f03564e7c44fd9b8cbd940656ea8644f0d662

Contents?: true

Size: 1023 Bytes

Versions: 7

Compression:

Stored size: 1023 Bytes

Contents

module IronWorkerNG
  module Feature
    module Python
      module MergeRequirements
        module InstanceMethods

          def merge_requirements(path)
            feature = IronWorkerNG::Feature::Base.new(self)
            IronWorkerNG::Fetcher.fetch_to_file(feature.rebase(path)) do |requirements|
              specs = parse_requirements(requirements)
              specs.each {|spec| merge_pip(spec[:name], spec[:version])}
            end
            @features << feature
          end

          alias :requirements :merge_requirements

          private
          def parse_requirements(file)
            specs = []
            File.readlines(file).each do |line|
              line = line.strip
              next if line.to_s.empty? || line.start_with?('#')
              spec = line.split(/(==|>=|<=|<|>)/, 2)
              version = spec[1]? spec[1]+spec[2]: ''
              specs << {name: spec[0], version:version}
            end
            specs
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
iron_worker_ng-1.6.10 lib/iron_worker_ng/feature/python/merge_requirements.rb
iron_worker_ng-1.6.9 lib/iron_worker_ng/feature/python/merge_requirements.rb
iron_worker_ng-1.6.8 lib/iron_worker_ng/feature/python/merge_requirements.rb
iron_worker_ng-1.6.7 lib/iron_worker_ng/feature/python/merge_requirements.rb
iron_worker_ng-1.6.6 lib/iron_worker_ng/feature/python/merge_requirements.rb
iron_worker_ng-1.6.5 lib/iron_worker_ng/feature/python/merge_requirements.rb
iron_worker_ng-1.6.4 lib/iron_worker_ng/feature/python/merge_requirements.rb