Class: Hookalist::File

Inherits:
Object
  • Object
show all
Defined in:
lib/hookalist/file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_name, start_time, commit_time) ⇒ File

Returns a new instance of File.



5
6
7
8
9
# File 'lib/hookalist/file.rb', line 5

def initialize(file_name, start_time, commit_time)
  @file_name = file_name
  @start_time = start_time.clone
  @commit_time = commit_time.clone
end

Instance Attribute Details

#commit_timeObject (readonly)

Returns the value of attribute commit_time.



3
4
5
# File 'lib/hookalist/file.rb', line 3

def commit_time
  @commit_time
end

#file_nameObject (readonly)

Returns the value of attribute file_name.



3
4
5
# File 'lib/hookalist/file.rb', line 3

def file_name
  @file_name
end

#start_timeObject (readonly)

Returns the value of attribute start_time.



3
4
5
# File 'lib/hookalist/file.rb', line 3

def start_time
  @start_time
end

Instance Method Details

#file_pathObject



11
12
13
# File 'lib/hookalist/file.rb', line 11

def file_path
  @file_path ||= Dir.pwd + "/#{file_name}"
end

#touch_commandObject



15
16
17
18
19
20
21
# File 'lib/hookalist/file.rb', line 15

def touch_command
  c_time = rand(start_time...commit_time)
  seconds = (Time.now - c_time).to_i
  command = "touch -d \"#{seconds} seconds ago\" #{file_path}"
  puts "#{command}"
  command
end