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.



49
50
51
# File 'lib/jars/lock.rb', line 49

def initialize( file )
  @file = file
end

Instance Method Details

#process(scope) ⇒ Object



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

def process( scope )
  scope ||= :runtime
  File.read( @file ).each_line do |line|
    next if not line =~ /:.+:/
    jar = JarDetails.new( line.strip.sub( /:jar:/, ':' ).sub( /:$/, ': ' ).split( /:/ ) )
    case scope
    when :all
      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 and jar.scope != :provided
    when :test
      yield jar
    end
  end
end