Class: Rubyzilla::Bug

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id = nil) ⇒ Bug

Returns a new instance of Bug.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rubyzilla/bug.rb', line 18

def initialize id=nil
  unless id.nil?
    result = Bugzilla.server.call("Bug.get_bugs", {:ids => [id]})
    
    @product_id   = result["bugs"][0]["internals"]["product_id"]
    @product      = product
    @id           = result["bugs"][0]["id"]
    @component_id = result["bugs"][0]["internals"]["component_id"]
    @summary      = result["bugs"][0]["summary"]
    @version      = result["bugs"][0]["internals"]["version"]
    @op_sys       = result["bugs"][0]["internals"]["op_sys"]
    @platform     = result["bugs"][0]["internals"]["rep_platform"]
    @priority     = result["bugs"][0]["internals"]["priority"]
    @description  = result["bugs"][0]["internals"]["short_desc"]
    @alias        = result["bugs"][0]["alias"]
    @qa_contact   = result["bugs"][0]["internals"]["qa_contact"]
    @status       = result["bugs"][0]["internals"]["status_whiteboard"]
    @target_milestone = result["bugs"][0]["internals"]["target_milestone"]
    @severity     = result["bugs"][0]["internals"]["bug_severity"]
  end
  return self
end

Instance Attribute Details

#aliasObject

Optional create parameters



15
16
17
# File 'lib/rubyzilla/bug.rb', line 15

def alias
  @alias
end

#assigned_toObject

Optional create parameters



15
16
17
# File 'lib/rubyzilla/bug.rb', line 15

def assigned_to
  @assigned_to
end

#ccObject

Optional create parameters



15
16
17
# File 'lib/rubyzilla/bug.rb', line 15

def cc
  @cc
end

#componentObject

String value component for creation



7
8
9
# File 'lib/rubyzilla/bug.rb', line 7

def component
  @component
end

#component_idObject

Required create parameters



6
7
8
# File 'lib/rubyzilla/bug.rb', line 6

def component_id
  @component_id
end

#descriptionObject

Returns the value of attribute description.



12
13
14
# File 'lib/rubyzilla/bug.rb', line 12

def description
  @description
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/rubyzilla/bug.rb', line 3

def id
  @id
end

#op_sysObject

Defaulted create parameters



11
12
13
# File 'lib/rubyzilla/bug.rb', line 11

def op_sys
  @op_sys
end

#platformObject

Defaulted create parameters



11
12
13
# File 'lib/rubyzilla/bug.rb', line 11

def platform
  @platform
end

#priorityObject

Defaulted create parameters



11
12
13
# File 'lib/rubyzilla/bug.rb', line 11

def priority
  @priority
end

#product_idObject

Required create parameters



6
7
8
# File 'lib/rubyzilla/bug.rb', line 6

def product_id
  @product_id
end

#qa_contactObject

Optional create parameters



15
16
17
# File 'lib/rubyzilla/bug.rb', line 15

def qa_contact
  @qa_contact
end

#severityObject

Defaulted create parameters



11
12
13
# File 'lib/rubyzilla/bug.rb', line 11

def severity
  @severity
end

#statusObject

Optional create parameters



15
16
17
# File 'lib/rubyzilla/bug.rb', line 15

def status
  @status
end

#summaryObject

Required create parameters



6
7
8
# File 'lib/rubyzilla/bug.rb', line 6

def summary
  @summary
end

#target_milestoneObject

Returns the value of attribute target_milestone.



16
17
18
# File 'lib/rubyzilla/bug.rb', line 16

def target_milestone
  @target_milestone
end

#versionObject

Required create parameters



6
7
8
# File 'lib/rubyzilla/bug.rb', line 6

def version
  @version
end

Instance Method Details

#add_comment(comment) ⇒ Object



79
80
81
82
83
# File 'lib/rubyzilla/bug.rb', line 79

def add_comment(comment)
  if Bugzilla.logged_in?
    Bugzilla.server.call("Bug.add_comment", {:id => id, :comment => comment}) 
  end
end

#createObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/rubyzilla/bug.rb', line 50

def create
  if Bugzilla.logged_in?
    parameters = {
      :product => @product,
      :component => @component,
      :summary => @summary || "",
      :version => @version || "unspecified",
      :op_sys => @op_sys || "Windows",
      :platform => @platform || "PC",
      :priority => @priority || "P5",
    }
  
    parameters.merge!({:severity => @severity}) if @severity
    parameters.merge!({:description => @description}) if @description
    parameters.merge!({:alias => @alias}) if @alias && @alias != ""
    parameters.merge!({:assigned_to => @assigned_to}) if @assigned_to
    parameters.merge!({:cc => @cc}) if @cc
    parameters.merge!({:qa_contact => @qa_contact}) if @qa_contact
    parameters.merge!({:status => @status}) if @status
    parameters.merge!({:target_milestone => @target_milestone}) if
      @target_milestone

    result = Bugzilla.server.call("Bug.create", parameters)
    
    @id = result["id"].to_i
  end
  return self
end

#productObject



41
42
43
# File 'lib/rubyzilla/bug.rb', line 41

def product
  Product.new(@product_id)
end

#product=(_product) ⇒ Object



45
46
47
48
# File 'lib/rubyzilla/bug.rb', line 45

def product= _product
  @product_id = _product.id
  @product = _product.name
end