Class: ActiveBugzilla::Field

Inherits:
Base
  • Object
show all
Defined in:
lib/active_bugzilla/field.rb

Constant Summary collapse

KNOWN_TIMESTAMPS =
%w(creation_time last_change_time)
FIELD_ALIASES =

List of field aliases. Maps old style RHBZ parameter names to actual upstream values. Used for createbug() and query include_fields at least.

{
  # old               => current
  'short_desc'        => 'summary',
  'comment'           => 'description',
  'rep_platform'      => 'platform',
  'bug_severity'      => 'severity',
  'bug_status'        => 'status',
  'bug_id'            => 'id',
  'blockedby'         => 'blocks',
  'blocked'           => 'blocks',
  'dependson'         => 'depends_on',
  'reporter'          => 'creator',
  'bug_file_loc'      => 'url',
  'dupe_id'           => 'dupe_of',
  'dup_id'            => 'dupe_of',
  'longdescs'         => 'comments',
  'opendate'          => 'creation_time',
  'creation_ts'       => 'creation_time',
  'status_whiteboard' => 'whiteboard',
  'delta_ts'          => 'last_change_time',
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

service, service=

Constructor Details

#initialize(attributes = {}) ⇒ Field

Returns a new instance of Field.



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/active_bugzilla/field.rb', line 36

def initialize(attributes = {})
  @display_name      = attributes["display_name"]
  @id                = attributes["id"]
  @name              = self.class.field_alias(attributes["name"])
  @original_name     = attributes["name"]
  @type              = attributes["type"]
  @values            = attributes["values"]
  @visibility_field  = attributes["visibility_field"]
  @visibility_values = attributes["visibility_values"]
  @is_custom         = attributes["is_custom"]
  @is_mandatory      = attributes["is_mandatory"]
  @is_on_bug_entry   = attributes["is_on_bug_entry"]
end

Instance Attribute Details

#display_nameObject (readonly)

Returns the value of attribute display_name.



3
4
5
# File 'lib/active_bugzilla/field.rb', line 3

def display_name
  @display_name
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/active_bugzilla/field.rb', line 3

def id
  @id
end

#is_customObject (readonly) Also known as: custom?

Returns the value of attribute is_custom.



4
5
6
# File 'lib/active_bugzilla/field.rb', line 4

def is_custom
  @is_custom
end

#is_mandatoryObject (readonly) Also known as: mandatory?

Returns the value of attribute is_mandatory.



4
5
6
# File 'lib/active_bugzilla/field.rb', line 4

def is_mandatory
  @is_mandatory
end

#is_on_bug_entryObject (readonly) Also known as: on_bug_entry?

Returns the value of attribute is_on_bug_entry.



4
5
6
# File 'lib/active_bugzilla/field.rb', line 4

def is_on_bug_entry
  @is_on_bug_entry
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/active_bugzilla/field.rb', line 3

def name
  @name
end

#original_nameObject (readonly)

Returns the value of attribute original_name.



3
4
5
# File 'lib/active_bugzilla/field.rb', line 3

def original_name
  @original_name
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/active_bugzilla/field.rb', line 3

def type
  @type
end

#valuesObject (readonly)

Returns the value of attribute values.



3
4
5
# File 'lib/active_bugzilla/field.rb', line 3

def values
  @values
end

#visibility_fieldObject (readonly)

Returns the value of attribute visibility_field.



3
4
5
# File 'lib/active_bugzilla/field.rb', line 3

def visibility_field
  @visibility_field
end

#visibility_valuesObject (readonly)

Returns the value of attribute visibility_values.



3
4
5
# File 'lib/active_bugzilla/field.rb', line 3

def visibility_values
  @visibility_values
end

Class Method Details

.instantiate_from_raw_data(data) ⇒ Object



54
55
56
57
58
59
60
# File 'lib/active_bugzilla/field.rb', line 54

def self.instantiate_from_raw_data(data)
  data.delete_if { |hash| hash["name"] == "longdesc" } # Another way to specify comment[0]
  data.delete_if { |hash| hash["name"].include?(".") } # Remove things like longdescs.count
  data.collect do |field_hash|
    new(field_hash)
  end
end

Instance Method Details

#timestamp?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/active_bugzilla/field.rb', line 50

def timestamp?
  (type == 5) || KNOWN_TIMESTAMPS.include?(name)
end