Class: Rubu::State
- Inherits:
-
Object
- Object
- Rubu::State
- Defined in:
- lib/rubu.rb
Constant Summary
- @@md5 =
{}
- @@state_file =
".rubu_state.yml"
Class Method Summary (collapse)
Class Method Details
+ (Object) load
19 20 21 22 23 |
# File 'lib/rubu.rb', line 19 def State.load if File.exist?( @@state_file ) @@md5 = YAML.load_file( @@state_file ) end end |
+ (Boolean) md5_check_and_update?(file)
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rubu.rb', line 29 def State.md5_check_and_update?( file ) if @@md5[ file ] md5 = State.md5_gen( file ) if md5 != @@md5[ file ] @@md5[ file ] = md5 return true end return false else @@md5[ file ] = State.md5_gen( file ) return true end end |
+ (Object) md5_gen(file)
25 26 27 |
# File 'lib/rubu.rb', line 25 def State.md5_gen( file ) Digest::MD5.hexdigest( File.read( file ) ) end |
+ (Object) save
13 14 15 16 17 |
# File 'lib/rubu.rb', line 13 def State.save if @@md5.any? IO.write( @@state_file, YAML.dump( @@md5 ) ) end end |