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.



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

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



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

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

Instance Method Details

#add_or_modify_entry!(coordinates, sha1) ⇒ Object



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

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

#all_sha1Object



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

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

#remove_entry!(coordinates) ⇒ Object



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

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

#sha1(coordinates) ⇒ Object



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

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