Class: Cucover::Cache

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

Direct Known Subclasses

SourceFileCache, StatusCache

Instance Method Summary collapse

Constructor Details

#initialize(feature_file) ⇒ Cache

Returns a new instance of Cache.



133
134
135
# File 'lib/cucover.rb', line 133

def initialize(feature_file)
  @feature_file = feature_file
end

Instance Method Details

#cache_filenameObject



141
142
143
# File 'lib/cucover.rb', line 141

def cache_filename
  @feature_file.gsub /([^\/]*\.feature)/, '.coverage/\1'
end

#exists?Boolean

Returns:

  • (Boolean)


137
138
139
# File 'lib/cucover.rb', line 137

def exists?
  File.exist?(cache_filename)
end

#timeObject



145
146
147
# File 'lib/cucover.rb', line 145

def time
  File.mtime(cache_filename)
end

#write_to_cacheObject



149
150
151
152
153
154
# File 'lib/cucover.rb', line 149

def write_to_cache
  FileUtils.mkdir_p File.dirname(cache_filename)
  File.open(cache_filename, "w") do |file|
    yield file
  end
end