Class: Jiralicious::Version

Inherits:
Field
  • Object
show all
Defined in:
lib/jiralicious/versions.rb

Instance Attribute Summary

Attributes inherited from Base

#loaded

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Field

#initialize

Methods inherited from Base

#all, #endpoint_name, endpoint_name, fetch, find, find_all, handler, issueKey_test, #loaded?, #method_missing, #numeric?, parent_name, #parent_name, #properties_from_hash, #reload

Methods included from Parsers::FieldParser

#parse!

Constructor Details

This class inherits a constructor from Jiralicious::Field

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Jiralicious::Base

Class Method Details

.create(details) ⇒ Object

Creates a new version

Arguments

:details (required) Version details to be created



16
17
18
19
# File 'lib/jiralicious/versions.rb', line 16

def create(details)
  response = fetch({:method => :post, :body => details})
  new(response.parsed_response)
end

.move(key, options = {}) ⇒ Object

Moves the version to a new position

Arguments

:key (required) Version key

:options (optional) Hash of options

position

An absolute position, which may have a value of 'First', 'Last', 'Earlier' or 'Later'

after

A version to place this version after. The value should be the self link of another version


34
35
36
37
38
39
# File 'lib/jiralicious/versions.rb', line 34

def move(key, options = {})
  if options.include?(:position)
    options[:position] = options[:position].downcase.capitalize
  end
  fetch({:method => :post, :key => "#{key}/move", :body => options})
end

Returns the number of Issues associated with the Version

Arguments

:id (required) Version to count



59
60
61
62
63
# File 'lib/jiralicious/versions.rb', line 59

def related_issue_counts(id)
  response = fetch({:key => "#{id}/relatedIssueCounts"})
  response.parsed_response['key'] = id
  Field.new(response.parsed_response)
end

.remove(key, options = {}) ⇒ Object

Removes/Deletes a Version from the Issue

Arguments

:key (required) Version key

:options (optional) Hash of options



49
50
51
# File 'lib/jiralicious/versions.rb', line 49

def remove(key, options = {})
  fetch({:method => :delete, :key => key, :body_to_params => true, :body => options}).parsed_response
end

.unresolved_issue_count(id) ⇒ Object

Returns the number of Unresolved Issues associated with the Version

Arguments

:id (required) Version to count



84
85
86
87
88
# File 'lib/jiralicious/versions.rb', line 84

def unresolved_issue_count(id)
  response = fetch({:key => "#{id}/unresolvedIssueCount"})
  response.parsed_response['key'] = id
  Field.new(response.parsed_response)
end

.update(id, details) ⇒ Object

Updates a version

Arguments

:id (required) Version to be updated

:details (required) Details of the version to be updated



73
74
75
76
# File 'lib/jiralicious/versions.rb', line 73

def update(id, details)
  response = fetch({:method => :put, :key => id, :body => details})
  new(response.parsed_response)
end

Instance Method Details

#findObject

Finds all versions based on the provided Issue Key



94
95
96
# File 'lib/jiralicious/versions.rb', line 94

def find
  self.class.find(self.version_key)
end

#move(options = {}) ⇒ Object

Moves the version to a new position

Arguments

:options (optional) Hash of options

position

An absolute position, which may have a value of 'First', 'Last', 'Earlier' or 'Later'

after

A version to place this version after. The value should be the self link of another version


109
110
111
# File 'lib/jiralicious/versions.rb', line 109

def move(options = {})
  self.class.move(self.version_key, options)
end

Returns the number of Issues associated with the Version



126
127
128
# File 'lib/jiralicious/versions.rb', line 126

def related_issue_counts
  self.class.related_issue_counts(self.version_key)
end

#remove(options = {}) ⇒ Object

Removes/Deletes a Version from the Issue

Arguments

:options (optional) Hash of options



119
120
121
# File 'lib/jiralicious/versions.rb', line 119

def remove(options = {})
  self.class.remove(self.version_key, options)
end

#unresolved_issue_countObject

Returns the number of Unresolved Issues associated with the Version



146
147
148
# File 'lib/jiralicious/versions.rb', line 146

def unresolved_issue_count
  self.class.unresolved_issue_count(self.version_key).issuesUnresolvedCount
end

#update(details) ⇒ Object

Updates a version

Arguments

:details (required) Details of the version to be updated



136
137
138
139
140
141
# File 'lib/jiralicious/versions.rb', line 136

def update(details)
  details.each do |k, v|
    self.send("#{k.to_s}=", v)
  end
  self.class.update(self.version_key, details)
end

#version_keyObject

Holds the version Key



7
# File 'lib/jiralicious/versions.rb', line 7

property :version_key, :from => :id