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.



53
54
55
# File 'lib/jars/lock.rb', line 53

def initialize( file )
  @file = file
end

Instance Method Details

#process(scope) ⇒ Object



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

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 :runtime
      # jar.scope is maven scope
      yield jar if jar.scope != :test and jar.scope != :provided
    when :test
      yield jar
    end
  end
end