Class: Jars::Lock

Inherits:
Object
  • Object
show all
Defined in:
lib/jars/lock.rb

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Lock

Returns a new instance of Lock.



51
52
53
# File 'lib/jars/lock.rb', line 51

def initialize(file)
  @file = file
end

Instance Method Details

#process(scope) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/jars/lock.rb', line 55

def process(scope)
  scope ||= :runtime
  File.read(@file).each_line do |line|
    next unless /:.+:/.match?(line)

    jar = JarDetails.new(line.strip.sub(/:jar:/, ':').sub(/:$/, ': ').split(':'))
    case scope
    when :all, :test
      yield jar
    when :compile
      # jar.scope is maven scope
      yield jar if jar.scope != :test
    when :provided
      # jar.scope is maven scope
      yield jar if jar.scope == :provided
    when :runtime
      # jar.scope is maven scope
      yield jar if (jar.scope != :test) && (jar.scope != :provided)
    end
  end
end