class Granify::Model::Data
Attributes
branch[RW]
browser[RW]
files_with_errors[RW]
identifier[RW]
Public Class Methods
new()
click to toggle source
# File lib/model_data.rb, line 6 def initialize() @d = Hash.new([]) # setup defaults defaults = { :issues => {:errors => 0, :warnings => 0}, :status => {:success => 0, :error => 0, :total => 0, :errors_per_file => 0}, :success_rate => {:int => 0, :str => "0%"}, :log => '', :below_acceptable_limit => false } @branch = Command::Exec.git_current_branch @files_with_errors = [] @d.merge! defaults end
Public Instance Methods
add_to_error_list(file)
click to toggle source
# File lib/model_data.rb, line 65 def add_to_error_list(file) @files_with_errors << file end
below_acceptable_limit=(val)
click to toggle source
# File lib/model_data.rb, line 80 def below_acceptable_limit=(val) set(:below_acceptable_limit, val) end
below_acceptable_limit?()
click to toggle source
# File lib/model_data.rb, line 76 def below_acceptable_limit? get(:below_acceptable_limit) == true end
bind!(seed_data)
click to toggle source
# File lib/model_data.rb, line 84 def bind!(seed_data) @d = seed_data end
get(key, default = @d.default)
click to toggle source
# File lib/model_data.rb, line 88 def get(key, default = @d.default) @d[key] || default end
identifier=(val)
click to toggle source
# File lib/model_data.rb, line 69 def identifier=(val) @identifier = val # create the log file now @d[:log] = Log.new(@branch, Time.now, @identifier) end
increment_issues(key, val)
click to toggle source
# File lib/model_data.rb, line 45 def increment_issues(key, val) @d[:issues][key.to_sym] += val end
increment_status(key, val)
click to toggle source
# File lib/model_data.rb, line 49 def increment_status(key, val) @d[:status][key.to_sym] += val end
instance_var(key, val = nil)
click to toggle source
# File lib/model_data.rb, line 28 def instance_var(key, val = nil) self.class.__send__(:attr_accessor, key) instance_variable_set("@#{key}", val) end
issues()
click to toggle source
# File lib/model_data.rb, line 53 def issues get(:issues) end
issues=(val)
click to toggle source
# File lib/model_data.rb, line 57 def issues=(val) set(:issues, val) end
log()
click to toggle source
# File lib/model_data.rb, line 61 def log get(:log, Granify::DEFAULT_LOG) end
serialize()
click to toggle source
# File lib/model_data.rb, line 33 def serialize @d.to_json end
set(key, val = nil)
click to toggle source
# File lib/model_data.rb, line 92 def set(key, val = nil) @d[key] = val end
status()
click to toggle source
# File lib/model_data.rb, line 37 def status get(:status) end
success_rate()
click to toggle source
# File lib/model_data.rb, line 41 def success_rate get(:success_rate) end
unset(key)
click to toggle source
# File lib/model_data.rb, line 24 def unset(key) @d.delete(key.to_sym) end