Class: Bug

Inherits:
ActiveRecord::Base show all
Extended by:
Generic_Table::ClassMethods
Includes:
Generic_Table
Defined in:
app/models/bug.rb

Constant Summary

Constants included from ColumnGroup::ClassMethods

ColumnGroup::ClassMethods::History_columns

Constants included from GenericGrep::ClassMethods

GenericGrep::ClassMethods::ASSOCIATION_MACRO_LETTERS, GenericGrep::ClassMethods::ASSOCIATION_MACRO_PATTERN

Constants included from GenericTableAssociation::Examples

GenericTableAssociation::Examples::First_stream_method

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Generic_Table::ClassMethods

is_active_record_method?, model_file_name, nesting, one_pass_statistics, sample, sample_burst

Methods included from ColumnGroup::ClassMethods

#attribute_ddl, #attribute_rails_type, #attribute_ruby_type, #candidate_logical_keys_from_indexes, #categorical?, #column_symbols, #default_logical_primary_key, #defaulted_primary_logical_key?, #history_type?, #is_logical_primary_key?, #logical_attributes, #logical_primary_key, #logical_primary_key_recursive, #numerical?, #probably_categorical?, #probably_numerical?, #sequential_id?

Methods included from GenericGrep::ClassMethods

#all_associations, #association_grep, #association_grep_pattern, #association_macro_type, #association_type, #belongs_to_association?, #grep_all_associations_command, #grep_command, #has_many_association?, #has_one_association?, #model_grep, #model_grep_command

Methods included from GenericTableHtml::ClassMethods

#column_order, #header_html, #table_html

Methods included from Generic_Table

activeRecordTableNotCreatedYet?, classDefiniton, classReference, class_of_name, eval_constant, is_ActiveRecord_table?, is_generic_table?, is_generic_table_name?, is_table?, rails_MVC_class?, rubyClassName, table_exists?

Methods included from GenericTableAssociation

#associated_foreign_key_records, #associated_to_s, #association_class, #association_has_data, #association_state, #foreign_key_points_to_me?, #foreign_key_to_association, #foreign_key_value, #logical_primary_key_recursive_value, #logical_primary_key_value, #name_to_association

Methods included from GenericTableAssociation::Assertions::ClassMethods

#assert_foreign_keys_not_nil, #assert_invariant, #assert_post_conditions, #assert_pre_conditions

Methods included from GenericTableAssociation::Assertions

#assert_associated_foreign_key, #assert_associated_foreign_key_name, #assert_association, #assert_association_methods, #assert_association_to_many, #assert_association_to_one, #assert_foreign_key_association_names, #assert_foreign_key_name, #assert_foreign_key_not_nil, #assert_foreign_keys_not_nil, #assert_invariant, #assert_post_conditions, #assert_pre_conditions

Methods included from GenericTableHtml

#column_html, #rails_route, #row_html

Methods included from GenericTableAssociation::ClassMethods

#associated_foreign_key_name, #association_arity, #association_class, #association_default_class_name?, #association_method_plurality, #association_method_symbol, #association_methods, #association_names, #association_names_to_many, #association_names_to_one, #association_patterns, #foreign_key_association_names, #foreign_key_names, #foreign_key_to_association_name, #is_association?, #is_association_patterns?, #is_association_to_many?, #is_association_to_one?, #is_foreign_key_name?, #is_matching_association?, #is_polymorphic_association?, #match_association_patterns?, #name_symbol

Constructor Details

#initialize(test_type = nil, table = nil, error = nil) ⇒ Bug

def


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/models/bug.rb', line 11

def initialize(test_type=nil,table=nil,error=nil)
	if test_type==nil then
		super(nil)
		return
	elsif test_type.instance_of?(Hash) || test_type.instance_of?(ActiveSupport::HashWithIndifferentAccess) then
		puts "hash parameter=#{test_type}"
		super(test_type) # actually hash of attributes
#		attributes=testType 
	else
		puts "not hash, not empty: test_type.class=#{test_type.class}, test_type=#{test_type.inspect}, table=#{table}, error='#{error}'"
		super(nil)
		raise "not hash, not empty:  test_type.class=#{test_type.class}, test_type=#{test_type.inspect}, table=#{table}, error=#{error}" if error.nil?
	error.scan(/  ([0-9]+)[)] ([A-Za-z]+):\n(test_[a-z_]*)[(]([a-zA-Z]+)[)]:?\n(.*)$/m) do |number,error_type,test,klass,report|
		#~ puts "number=#{number.inspect}"
		#~ puts "error_type=#{error_type}"
		#~ puts "test=#{test.inspect}"
		#~ puts "klass=#{klass.inspect}"
		#~ puts "report=#{report.inspect}"
		self.url="rake testing:#{test_type}_test TABLE=#{table} TEST=#{test}"
		if error_type=='Error' then
			report.scan(/^([^\n]*)\n(.*)$/m) do |error,trace|
				self[:context]=trace.split("\n")
				puts "error='#{error.inspect}'"
				puts "trace='#{trace.inspect}'"
				puts "context=#{context.inspect}"
				open('db/bugs.sql',"a" ) {|f| f.write("insert into bugs(url,error,context,created_at,updated_at) values('#{url}','#{error.tr("'",'`')}','#{context}','#{Time.now.rfc2822}','#{Time.now.rfc2822}');\n") }						
			end #scan
		elsif error_type=='Failure' then
			report.scan(/^\s*[\[]([^\]]+)[\]]:\n(.*)$/m) do |trace,error|
				self[:context]=trace.split("\n")
				self[:error]=error.slice(0,50)
				puts "error='#{error.inspect}'"
				puts "trace='#{trace.inspect}'"
				puts "context='#{context.inspect}'"
				open('db/bugs.sql',"a" ) {|f| f.write("insert into bugs(url,error,context,created_at,updated_at) values('#{url}','#{error.tr("'",'`')}','#{context}','#{Time.now.rfc2822}','#{Time.now.rfc2822}');\n") }						
			end #scan
		else
			puts "pre_match=#{s.pre_match}"
			puts "post_match=#{s.post_match}"
			puts "before #{s.rest}"
		end #if
	end #scan
	end #if
end

Class Method Details

.logical_primary_keyObject


8
9
10
# File 'app/models/bug.rb', line 8

def self.logical_primary_key
	return [:created_at]
end

Instance Method Details

#short_contextObject

parse_bug


55
56
57
# File 'app/models/bug.rb', line 55

def short_context
	return self.context.reverse[1..-1].collect{|t| t.slice(/`([a-zA-Z_]+)'/,1)}.join(', ')
end