mantis_ruby 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mantis_ruby.rb +161 -135
  3. metadata +2 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c8dc43f406e5ef19933489ed0df7a527e904a852
4
- data.tar.gz: 33e258c5540af7b8deb4bafafc4f9a20e0c34e1f
3
+ metadata.gz: f5e2d89fd0388c35e9024e85bf8a529838bf08ab
4
+ data.tar.gz: 66821a29e20664d941ec60cf84b373bd62c5d2c6
5
5
  SHA512:
6
- metadata.gz: 23a32dcc4cbf4d069c617fb7e399e446cbf23ac73db63b165dbcea197d95457db33d75b7569a4547f04c7aaf1b68105e0d02e532239c8034d400c4d4e0746f0f
7
- data.tar.gz: 9ddaed3d3a9307237db7839295d0cb9cad31775f06b34e1c673009936ea99e45aa3eee4b3d93fc30d90fd900172c12f0f88b25891ae26b2b07b84fb97209ce10
6
+ metadata.gz: b5b31a514447693a99430ab4676764f5368f0b347e182feadd90ea3ba4fef555d175331b175470e19b72d0cf72e0d8fc89d7c9897e5970c7be5e662062674c1e
7
+ data.tar.gz: 0c364ffc94d319e68c69f42fc056dc16c927e5db9845949b2ec0fb1e2922b3b7ba2f8f10516c58128bb1322900761d75a748550b33d629bc6ec37167a2e32015
data/lib/mantis_ruby.rb CHANGED
@@ -2,150 +2,176 @@ require 'httpclient'
2
2
  require 'savon'
3
3
 
4
4
  class MantisRuby
5
- def self.hi
6
- puts "Hello world!"
7
- end
5
+ def self.issue_in_format(issue={})
6
+ ({id: 1,
7
+ status: "new",
8
+ summary: "First issue",
9
+ actual: "Actual result",
10
+ expected: "Expected Result",
11
+ screenresolution: "Give if possible",
12
+ description: ("Description \r\n ---------------- \r\n Actual Result: \r\n Your actual desult will be shown here. \r\n ---------------- \r\n Expected Result:\r\n Expected Result will be shown here \r\n ---------------- \r\n Screen Resolution:\r\n Screen resolution will come here."),
13
+ :steps_to_reproduce => "Step to reproduce",
14
+ :additional_information => "additional_information",
15
+ category: "General" ,
16
+ :add_note=> "bug note",
17
+ resolution: "screenresolution",
18
+ severity: "10",
19
+ reproducibility: "Reproducibility",
20
+ priority: "10",
21
+ file_location: 'http://dimomohit.com/assets/logo-a40f75aaa7c1d5a2a3f99e8da5e8159c353e407ffdc1c29dfabe43e4c7e8bd41.png',
22
+ content_type: 'png',
23
+ project: {id: "project_id",
24
+ name: "project_name"
25
+ }
26
+ }).merge(issue)
27
+ end
28
+ def self.hi
29
+ puts "Hello developer! Welcome to Mantis Ruby Gem."
30
+ puts "You can use MantisRuby.help any time to get the help."
31
+ end
8
32
 
9
- def initialize(username,password,wsdl)
10
- @username=username
11
- @password=password
12
- @wsdl=wsdl
13
- puts connect_to_tracker
14
- end
33
+ def self.help
34
+
35
+ end
15
36
 
16
- def connect_to_tracker
17
- @client = Savon.client(wsdl: "#{self.wsdl}/api/soap/mantisconnect.php?wsdl" )
18
- end
37
+ def initialize(username,password,wsdl)
38
+ @username=username
39
+ @password=password
40
+ @wsdl=wsdl
41
+ connect_to_tracker
42
+ end
19
43
 
20
- def check_version
21
- client=connect_to_tracker
22
- @response=client.call(:mc_version)
23
- end
44
+ def connect_to_tracker
45
+ @client = Savon.client(wsdl: "#{@wsdl}/api/soap/mantisconnect.php?wsdl" )
46
+ end
24
47
 
25
- def projects_get_user_accessible
26
- client=connect_to_tracker
27
- @response=client.call(:mc_projects_get_user_accessible,message: {username: self.client_id,
28
- password: self.client_key})
29
- JSON.parse(@response.to_json)["mc_projects_get_user_accessible_response"]["return"]
30
- end
48
+ def check_version
49
+ client=connect_to_tracker
50
+ client.call(:mc_version).to_hash[:mc_version_response][:return]
51
+ end
31
52
 
32
- def push_all_bugs
33
- client=connect_to_tracker
34
- # self.is_busy = true
35
- # self.save
36
- get_cycle_bugs.each do |bug|
37
- puts "Bug"
38
- push_bug(bug)
39
- set_attachment(bug)
40
- set_priority(bug)
41
- end
42
- # self.is_busy = false
43
- # self.save
44
- end
53
+ def get_user_accessible_projects
54
+ client=connect_to_tracker
55
+ @response=client.call(:mc_projects_get_user_accessible,message: {username: @username,
56
+ password: @password})
57
+ (@response.to_hash)[:mc_projects_get_user_accessible_response][:return]
58
+ end
45
59
 
46
- def push_bug(bug)
47
- client=connect_to_tracker
48
- @response = client.call(:mc_issue_add, message: {username: self.client_id,
49
- password: self.client_key,
50
- issue: {status: bug.status,
51
- summary: bug.title,
52
- description: ("#{bug.description} \r\n ---------------- \r\n Actual Result: \r\n #{bug.actual} \r\n ---------------- \r\n Expected Result:\r\n #{bug.expected} \r\n ---------------- \r\n Screen Resolution:\r\n #{bug.screenresolution}"),
53
- "steps_to_reproduce" => "#{bug.description}",
54
- "additional_information" => "Actual Result: \r\n #{bug.actual} \r\n ---------------- \r\n Expected Result:\r\n #{bug.expected} \r\n ---------------- \r\n Screen Resolution:\r\n #{bug.screenresolution}",
55
- category: "General" ,
56
- "add_note"=> ((bug.enterprisecyclecomponent.nil?) ? "" : bug.enterprisecyclecomponent.name ),
57
- resolution: bug.screenresolution,
58
- severity: ((bug.btype=="Feature") ? "10" : ((bug.btype=="Technical") ? "60" : ((bug.btype=="GUI") ? "40" : ((bug.btype=="Functional") ? "60" : "50") ))),
59
- reproducibility: ((bug.freq == "Every Time") ? "10" : ((bug.freq == "Frequently") ? "10" : ((bug.freq == "Rarely") ? "50" : ((bug.freq == "Once") ? "30" : "N/A" )))),
60
- priority: ((bug.priority==1) ? "50" : ((bug.priority==2) ? "40" : ((bug.priority==3) ? "30" : ((bug.priority==4) ? "20" : "10" ) ))),
61
- project: {id: self.project_id,
62
- name: self.project_name
63
- }
64
- }
65
- }
66
- )
67
- return_id=JSON.parse(@response.to_json)["mc_issue_add_response"]["return"]
68
- @response
69
- end
60
+ def push_all_bugs(bugs)
61
+ client=connect_to_tracker
62
+ bugs.each do |bug|
63
+ push_bug(bug)
64
+ begin
65
+ set_attachment(bug)
66
+ rescue
67
+ end
68
+ # set_priority(bug)
69
+ end
70
+ end
70
71
 
71
- def update_bug(bug_id)
72
- client=connect_to_tracker
73
- @response = client.call(:mc_issue_update, message: {username: self.client_id,
74
- password: self.client_key,
75
- "issueId" => map_bug_id,
76
- issue: {status: bug.status,
77
- summary: bug.title,
78
- description: ("#{bug.description} \r\n ---------------- \r\n Actual Result: \r\n #{bug.actual} \r\n ---------------- \r\n Expected Result:\r\n #{bug.expected} \r\n ---------------- \r\n Screen Resolution:\r\n #{bug.screenresolution}"),
79
- "steps_to_reproduce" => "#{bug.description}",
80
- "additional_information" => "Actual Result: \r\n #{bug.actual} \r\n ---------------- \r\n Expected Result:\r\n #{bug.expected} \r\n ---------------- \r\n Screen Resolution:\r\n #{bug.screenresolution}",
81
- category: "General" ,
82
- "add_note"=> ((bug.enterprisecyclecomponent.nil?) ? "" : bug.enterprisecyclecomponent.name ),
83
- resolution: bug.screenresolution,
84
- severity: ((bug.btype=="Feature") ? "10" : ((bug.btype=="Technical") ? "60" : ((bug.btype=="GUI") ? "40" : ((bug.btype=="Functional") ? "60" : "50") ))),
85
- reproducibility: ((bug.freq == "Every Time") ? "10" : ((bug.freq == "Frequently") ? "10" : ((bug.freq == "Rarely") ? "50" : ((bug.freq == "Once") ? "30" : "N/A" )))),
86
- priority: ((bug.priority==1) ? "50" : ((bug.priority==2) ? "40" : ((bug.priority==3) ? "30" : ((bug.priority==4) ? "20" : "10" ) ))),
87
- project: {id: self.project_id,
88
- name: self.project_name}}})
89
- set_attachment(bug)
90
- set_priority(bug)
91
- @response
92
- end
72
+ def push_bug(bug,project_id,project_name)
73
+ client=connect_to_tracker
74
+ @response = client.call(:mc_issue_add, message: {username: @username,
75
+ password: @password,
76
+ issue: {status: "#{bug[:status].blank? ? 'new' : bug[:status]}",
77
+ summary: bug[:summary],
78
+ description: ("#{bug[:description]} \r\n ---------------- \r\n Actual Result: \r\n #{bug[:actual]} \r\n ---------------- \r\n Expected Result:\r\n #{bug[:expected]} \r\n ---------------- \r\n Screen Resolution:\r\n #{bug[:screenresolution]}"),
79
+ "steps_to_reproduce" => "#{bug[:description]}",
80
+ "additional_information" => "Actual Result: \r\n #{bug[:actual]} \r\n ---------------- \r\n Expected Result:\r\n #{bug[:expected]} \r\n ---------------- \r\n Screen Resolution:\r\n #{bug[:screenresolution]}",
81
+ category: "#{bug[:category].blank? ? 'General' : bug[:category]}" ,
82
+ "add_note"=> bug[:add_note],
83
+ resolution: bug[:screenresolution],
84
+ severity: "#{bug[:severity].blank? ? '10' : bug[:severity]}",
85
+ reproducibility: "#{bug[:reproducibility].blank? ? '10' : bug[:reproducibility]}",
86
+ priority: "#{bug[:priority].blank? ? '10' : bug[:priority]}",
87
+ project: {id: project_id,
88
+ name: project_name
89
+ }
90
+ }
91
+ }
92
+ )
93
+ (@response.to_hash)[:mc_issue_add_response][:return]
94
+ end
93
95
 
94
- def set_note(bug) ########Working
95
- client=connect_to_tracker
96
- @response = client.call(:mc_issue_note_add,
97
- message: {username: self.client_id,
98
- password: self.client_key,
99
- "issue_id"=>map_bug_id,
100
- note: {text: bug.enterprisecyclecomponent.name }
101
- }
102
- )
103
- end
96
+ def update_bug(bug,project_id,project_name)
97
+ client=connect_to_tracker
98
+ @response = client.call(:mc_issue_update, message: {username: @username,
99
+ password: @password,
100
+ "issueId" => bug[:id],
101
+ issue: {status: "#{bug[:status].blank? ? 'new' : bug[:status]}",
102
+ summary: bug[:summary],
103
+ description: ("#{bug[:description]} \r\n ---------------- \r\n Actual Result: \r\n #{bug[:actual]} \r\n ---------------- \r\n Expected Result:\r\n #{bug[:expected]} \r\n ---------------- \r\n Screen Resolution:\r\n #{bug[:screenresolution]}"),
104
+ "steps_to_reproduce" => "#{bug[:description]}",
105
+ "additional_information" => "Actual Result: \r\n #{bug[:actual]} \r\n ---------------- \r\n Expected Result:\r\n #{bug[:expected]} \r\n ---------------- \r\n Screen Resolution:\r\n #{bug[:screenresolution]}",
106
+ category: "#{bug[:category].blank? ? 'General' : bug[:category]}" ,
107
+ "add_note"=> bug[:add_note],
108
+ resolution: bug[:screenresolution],
109
+ severity: "#{bug[:severity].blank? ? '10' : bug[:severity]}",
110
+ reproducibility: "#{bug[:reproducibility].blank? ? '10' : bug[:reproducibility]}",
111
+ priority: "#{bug[:priority].blank? ? '10' : bug[:priority]}",
112
+ project: {id: project_id,
113
+ name: project_name}}})
114
+ begin
115
+ set_attachment(bug)
116
+ rescue
117
+ end
118
+ # set_priority(bug)
119
+ @response.to_hash
120
+ end
104
121
 
105
- def set_tag(bug)
106
- client=connect_to_tracker
107
- @response = client.call(:mc_issue_set_tags,
108
- message: {username: self.client_id,
109
- password: self.client_key,
110
- "issue_id"=>map_bug_id,
111
- tags: [""] ##Array of tags
112
- }
113
- )
114
- return_id=JSON.parse(@response.to_json)
115
- puts return_id
116
- @response
117
- end
122
+ def set_note(bug,map_bug_id) ########Working
123
+ client=connect_to_tracker
124
+ client.call(:mc_issue_note_add,
125
+ message: {username: @username,
126
+ password: @password,
127
+ "issue_id"=>map_bug_id,
128
+ note: {text: bug.add_note }
129
+ }
130
+ ).to_hash
131
+ end
118
132
 
119
- def set_priority(bug) ########Working
120
- client=connect_to_tracker
121
- @response = client.call(:mc_issue_note_add,
122
- message: {username: self.client_id,
123
- password: self.client_key,
124
- "issue_id"=>map_bug_id,
125
- note: {text: bug.enterprisecyclecomponent.name }
126
- }
127
- )
128
- end
133
+ def set_tag(bug,map_bug_id,tags=[])
134
+ client=connect_to_tracker
135
+ client.call(:mc_issue_set_tags,
136
+ message: {username: @username,
137
+ password: @password,
138
+ "issue_id"=>map_bug_id,
139
+ tags: tags ##Array of tags
140
+ }
141
+ ).to_hash
142
+ end
129
143
 
130
- def set_attachment(bug)
131
- client=connect_to_tracker
132
- begin
133
- file_name="bug_#{Time.now.to_i}.#{bug.ext}"
134
- file_location = bug.cdn_url("enterprisebug_#{bug.id}_#{bug.created_at.to_i}.#{bug.ext}")
135
- sf = open(file_location, 'rb') { |io| io.read }
136
- sfile=Base64::encode64(sf)
137
- @response = client.call(:mc_issue_attachment_add,
138
- message: {username: self.client_id,
139
- password: self.client_key,
140
- "issue_id"=> map_bug_id,
141
- name: file_name,
142
- "file_type" => bug.content_type,
143
- "content"=> sfile
144
- }
145
- )
146
- rescue Exception => e
147
- puts "File not submitted : #{e}"
148
- end
149
- end
150
-
144
+ def set_priority(bug,map_bug_id,comment) ########Working
145
+ client=connect_to_tracker
146
+ client.call(:mc_issue_note_add,
147
+ message: {username: @username,
148
+ password: @password,
149
+ "issue_id"=>map_bug_id,
150
+ note: {text: comment }
151
+ }
152
+ ).to_hash
153
+ end
154
+
155
+ def set_attachment(bug,map_bug_id=bug[:id],file_location=bug[:file_location])
156
+ unless file_location.blank?
157
+ client=connect_to_tracker
158
+ begin
159
+ file_name="bug_#{Time.now.to_i}.#{bug[:content_type]}"
160
+ sf = open(file_location, 'rb') { |io| io.read }
161
+ sfile=Base64::encode64(sf)
162
+ client.call(:mc_issue_attachment_add,
163
+ message: {username: @username,
164
+ password: @password,
165
+ "issue_id"=> map_bug_id,
166
+ name: file_name,
167
+ "file_type" => bug[:content_type],
168
+ "content"=> sfile
169
+ }
170
+ ).to_hash
171
+ rescue Exception => e
172
+ puts "File not submitted : #{e}"
173
+ end
174
+ end
175
+ end
176
+
151
177
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mantis_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimo Mohit
@@ -37,9 +37,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
37
37
  version: '0'
38
38
  requirements: []
39
39
  rubyforge_project:
40
- rubygems_version: 2.4.5
40
+ rubygems_version: 2.4.8
41
41
  signing_key:
42
42
  specification_version: 4
43
43
  summary: Mantis Testing tool with Ruby
44
44
  test_files: []
45
- has_rdoc: