Module: OnlyofficeTestrailWrapper::TestrailProjectMilestoneMethods
- Included in:
- TestrailProject
- Defined in:
- lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_milestone_methods.rb
Overview
Methods to perform operations on milestones
Instance Method Summary collapse
-
#create_new_milestone(name, description = '') ⇒ TestrailMilestone
Create new milestone.
-
#get_milestone_by_id(id) ⇒ TestrailMilestone
Get milestone by it’s id.
-
#get_milestone_by_name(name) ⇒ TestrailMilestone?
Get milestone data by it’s name.
-
#get_milestones ⇒ Array<TestrailMilestone>
Get list of all milestones.
-
#init_milestone_by_name(name) ⇒ TestrailMilestone
Get milestone data by it’s name Will create a new one if no one found.
-
#milestone(name_or_id) ⇒ TestrailMilestone
Get milestone data by parameter.
Instance Method Details
#create_new_milestone(name, description = '') ⇒ TestrailMilestone
Create new milestone
58 59 60 61 62 63 64 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_milestone_methods.rb', line 58 def create_new_milestone(name, description = '') new_milestone = TestrailMilestone.new.init_from_hash(Testrail2.http_post("index.php?/api/v2/add_milestone/#{@id}", :name => StringHelper.warnstrip!(name.to_s), description => description)) OnlyofficeLoggerHelper.log "Created new milestone: #{new_milestone.name}" new_milestone end |
#get_milestone_by_id(id) ⇒ TestrailMilestone
Get milestone by it’s id
32 33 34 35 36 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_milestone_methods.rb', line 32 def get_milestone_by_id(id) milestone = TestrailMilestone.new.init_from_hash(Testrail2.http_get("index.php?/api/v2/get_milestone/#{id}")) OnlyofficeLoggerHelper.log("Initialized milestone: #{milestone.name}") milestone end |
#get_milestone_by_name(name) ⇒ TestrailMilestone?
Get milestone data by it’s name
41 42 43 44 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_milestone_methods.rb', line 41 def get_milestone_by_name(name) get_milestones if @milestones_names.empty? @milestones_names[StringHelper.warnstrip!(name.to_s)].nil? ? nil : get_milestone_by_id(@milestones_names[name]) end |
#get_milestones ⇒ Array<TestrailMilestone>
Get list of all milestones
48 49 50 51 52 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_milestone_methods.rb', line 48 def get_milestones milestones = Testrail2.http_get("index.php?/api/v2/get_milestones/#{@id}") @milestones_names = name_id_pairs(milestones) if @milestones_names.empty? milestones end |
#init_milestone_by_name(name) ⇒ TestrailMilestone
Get milestone data by it’s name Will create a new one if no one found
24 25 26 27 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_milestone_methods.rb', line 24 def init_milestone_by_name(name) found_milestone = get_milestone_by_name name found_milestone.nil? ? create_new_milestone(name) : found_milestone end |
#milestone(name_or_id) ⇒ TestrailMilestone
Get milestone data by parameter
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_milestone_methods.rb', line 9 def milestone(name_or_id) case name_or_id.class.to_s when 'Fixnum', 'Integer' get_milestone_by_id name_or_id when 'String' init_milestone_by_name name_or_id else raise 'Wrong argument. Must be name [String] or id [Integer]' end end |