Class: KPM::Sha1Checker

Inherits:
Object
  • Object
show all
Defined in:
lib/kpm/sha1_checker.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sha1_file, logger = nil) ⇒ Sha1Checker

Returns a new instance of Sha1Checker.



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/kpm/sha1_checker.rb', line 12

def initialize(sha1_file, logger=nil)
  @sha1_file = sha1_file
  init!

  if logger.nil?
    @logger       = Logger.new(STDOUT)
    @logger.level = Logger::INFO
  else
    @logger = logger
  end
end

Class Method Details

.from_file(sha1_file, logger = nil) ⇒ Object



8
9
10
# File 'lib/kpm/sha1_checker.rb', line 8

def self.from_file(sha1_file, logger=nil)
  Sha1Checker.new(sha1_file, logger)
end

Instance Method Details

#add_or_modify_entry!(coordinates, remote_sha1) ⇒ Object



32
33
34
35
# File 'lib/kpm/sha1_checker.rb', line 32

def add_or_modify_entry!(coordinates, remote_sha1)
  @sha1_config['sha1'][coordinates] = remote_sha1
  save!
end

#all_sha1Object



28
29
30
# File 'lib/kpm/sha1_checker.rb', line 28

def all_sha1()
  @sha1_config['sha1']
end

#remove_entry!(coordinates) ⇒ Object



37
38
39
40
# File 'lib/kpm/sha1_checker.rb', line 37

def remove_entry!(coordinates)
  @sha1_config['sha1'].delete(coordinates)
  save!
end

#sha1(coordinates) ⇒ Object



24
25
26
# File 'lib/kpm/sha1_checker.rb', line 24

def sha1(coordinates)
  @sha1_config['sha1'][coordinates]
end