Class: NewIssue
- Inherits:
-
Object
- Object
- NewIssue
- Defined in:
- lib/jirarest2/newissue.rb
Overview
class to handle new issues (building them up, changing fields, persistence)
Instance Attribute Summary collapse
-
#issuekey ⇒ Object
readonly
The issue numer if we got it somehow.
-
#issuetype ⇒ Object
readonly
issue type of the issue.
-
#project ⇒ Object
readonly
project the issue belongs to.
Instance Method Summary collapse
-
#add_watchers(connection, watchers) ⇒ Boolean
Set the watchers for this Ticket.
-
#fieldtype(fieldname) ⇒ String
Return the fieldtype (Multitype as “array” nostly for backwards compability).
-
#get_field(field) ⇒ String
Value of the field.
-
#get_fieldnames ⇒ Array
Names of all fields.
-
#get_requireds ⇒ Array
Names of required fields.
-
#initialize(project, type, connection) ⇒ NewIssue
constructor
A new instance of NewIssue.
-
#jirahash ⇒ Hash
deprecated
Deprecated.
@see Issuetype#new_ticket_hash does the same now
-
#persist(connection) ⇒ Jirarest2::Result
persitence of this Issue object instance.
- #set_field(key, value) ⇒ Object
Constructor Details
#initialize(project, type, connection) ⇒ NewIssue
Returns a new instance of NewIssue.
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/jirarest2/newissue.rb', line 34 def initialize (project,type,connection) query = {:projectKeys => project, :issuetypeNames => type, :expand => "projects.issuetypes.fields" } answer = connection.execute("Get","issue/createmeta/",query) jhash = answer.result begin @project = jhash["projects"][0]["key"] rescue NoMethodError raise Jirarest2::WrongProjectException, project end @issue = Issuetype.new @issue.(jhash["projects"][0]["issuetypes"][0]) @issuetype = @issue.name end |
Instance Attribute Details
#issuekey ⇒ Object (readonly)
The issue numer if we got it somehow
28 29 30 |
# File 'lib/jirarest2/newissue.rb', line 28 def issuekey @issuekey end |
#issuetype ⇒ Object (readonly)
issue type of the issue
24 25 26 |
# File 'lib/jirarest2/newissue.rb', line 24 def issuetype @issuetype end |
#project ⇒ Object (readonly)
project the issue belongs to
26 27 28 |
# File 'lib/jirarest2/newissue.rb', line 26 def project @project end |
Instance Method Details
#add_watchers(connection, watchers) ⇒ Boolean
Set the watchers for this Ticket
99 100 101 102 103 104 105 106 |
# File 'lib/jirarest2/newissue.rb', line 99 def add_watchers(connection,watchers) success = false # Return whether we were successful with the watchers watch = Watcher.new(connection,@issuekey) watchers.each { |person| success = watch.add_watcher(person) } return success end |
#fieldtype(fieldname) ⇒ String
Return the fieldtype (Multitype as “array” nostly for backwards compability)
111 112 113 |
# File 'lib/jirarest2/newissue.rb', line 111 def fieldtype(fieldname) return @issue.fieldtype(fieldname) end |
#get_field(field) ⇒ String
Returns value of the field.
79 80 81 |
# File 'lib/jirarest2/newissue.rb', line 79 def get_field(field) @issue.get_value(field,:name) end |
#get_fieldnames ⇒ Array
Returns Names of all fields.
54 55 56 57 58 59 60 |
# File 'lib/jirarest2/newissue.rb', line 54 def get_fieldnames names = Array.new @issue.fields.each {|id,field| names << field.name } return names end |
#get_requireds ⇒ Array
Returns Names of required fields.
49 50 51 |
# File 'lib/jirarest2/newissue.rb', line 49 def get_requireds return @issue.required_by_name end |
#jirahash ⇒ Hash
@see Issuetype#new_ticket_hash does the same now
take this classes representation of an issue and make it presentable to JIRA(tm)
65 66 67 |
# File 'lib/jirarest2/newissue.rb', line 65 def jirahash return @issue.new_ticket_hash end |
#persist(connection) ⇒ Jirarest2::Result
persitence of this Issue object instance
86 87 88 89 90 91 92 93 |
# File 'lib/jirarest2/newissue.rb', line 86 def persist(connection) hash = @issue.new_ticket_hash ret = connection.execute("Post","issue/",hash) if ret.code == "201" then # Ticket sucessfully created @issuekey = ret.result["key"] end return ret end |
#set_field(key, value) ⇒ Object
check if the allowed Values are working now too and if they might throw an exception
73 74 75 |
# File 'lib/jirarest2/newissue.rb', line 73 def set_field(key, value) @issue.set_value(key,value,:name) end |