jironimo 0.5.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 291b1b99136e1f84d299601e2f1b2a8dc7315d8f
4
+ data.tar.gz: 1ec46a9f0b2a1416685eb28272c67c323b966c6e
5
+ SHA512:
6
+ metadata.gz: fcfdbc2124b28e8d8e046555d98c3481071cda53dcd2290983f257bd43a9596c56f456bffae7981033616e7537dea4aeaa200237f5529feebfd45fbc23b35cdc
7
+ data.tar.gz: 19559507d1107c04da9f08ba981ce0cacd459c143ff9ea5adbc60867927fd49663f95b43a7d46d44364eb76018c9aff827744b10845e6535115f75afb6bebf89
@@ -0,0 +1,106 @@
1
+ require 'origen'
2
+ class JironimoApplication < Origen::Application
3
+
4
+ # These attributes should never be changed, the duplication here will be resolved in future
5
+ # by condensing these attributes that do similar things
6
+ self.name = "jironimo"
7
+ self.namespace = "Jironimo"
8
+ config.name = "jironimo"
9
+ config.initials = "Jironimo"
10
+ config.rc_url = "git@github.com:Origen-SDK/jironimo.git"
11
+ config.release_externally = true
12
+
13
+ config.web_directory = "git@github.com:Origen-SDK/Origen-SDK.github.io.git/jironimo"
14
+ config.web_domain = "http://origen-sdk.org/jironimo"
15
+
16
+ # When false Origen will be less strict about checking for some common coding errors,
17
+ # it is recommended that you leave this to true for better feedback and easier debug.
18
+ # This will be the default setting in Origen v3.
19
+ config.strict_errors = true
20
+
21
+ config.lint_test = {
22
+ # Require the lint tests to pass before allowing a release to proceed
23
+ run_on_tag: true,
24
+ # Auto correct violations where possible whenever 'origen lint' is run
25
+ auto_correct: true,
26
+ # Limit the testing for large legacy applications
27
+ #level: :easy,
28
+ # Run on these directories/files by default
29
+ #files: ["lib", "config/application.rb"],
30
+ }
31
+
32
+ config.semantically_version = true
33
+
34
+ # An example of how to set application specific LSF parameters
35
+ #config.lsf.project = "msg.te"
36
+
37
+ # An example of how to specify a prefix to add to all generated patterns
38
+ #config.pattern_prefix = "nvm"
39
+
40
+ # An example of how to add header comments to all generated patterns
41
+ #config.pattern_header do
42
+ # cc "This is a pattern created by the example origen application"
43
+ #end
44
+
45
+ # By default all generated output will end up in ./output.
46
+ # Here you can specify an alternative directory entirely, or make it dynamic such that
47
+ # the output ends up in a setup specific directory.
48
+ #config.output_directory do
49
+ # "#{Origen.root}/output/#{$dut.class}"
50
+ #end
51
+
52
+ # Similarly for the reference files, generally you want to setup the reference directory
53
+ # structure to mirror that of your output directory structure.
54
+ #config.reference_directory do
55
+ # "#{Origen.root}/.ref/#{$dut.class}"
56
+ #end
57
+
58
+ # This will automatically deploy your documentation after every tag
59
+ def after_release_email(tag, note, type, selector, options)
60
+ command = "origen web compile --remote --api --comment 'Release of #{Origen.app.name} #{Origen.app.version}'"
61
+ Dir.chdir Origen.root do
62
+ system command
63
+ end
64
+ end
65
+
66
+ # Ensure that all tests pass before allowing a release to continue
67
+ def validate_release
68
+ unless system("origen specs")
69
+ puts "Sorry but you can't release with failing tests, please fix them and try again."
70
+ exit 1
71
+ else
72
+ puts "All tests passing, proceeding with release process!"
73
+ end
74
+ end
75
+
76
+ def before_deploy_site
77
+ Dir.chdir Origen.root do
78
+ #system 'origen examples -c'
79
+ system 'origen specs -c'
80
+ dir = "#{Origen.root}/web/output/coverage"
81
+ FileUtils.remove_dir(dir, true) if File.exist?(dir)
82
+ system "mv #{Origen.root}/coverage #{dir}"
83
+ end
84
+ end
85
+
86
+ # To enabled source-less pattern generation create a class (for example PatternDispatcher)
87
+ # to generate the pattern. This should return false if the requested pattern has been
88
+ # dispatched, otherwise Origen will proceed with looking up a pattern source as normal.
89
+ #def before_pattern_lookup(requested_pattern)
90
+ # PatternDispatcher.new.dispatch_or_return(requested_pattern)
91
+ #end
92
+
93
+ # If you use pattern iterators you may come across the case where you request a pattern
94
+ # like this:
95
+ # origen g example_pat_b0.atp
96
+ #
97
+ # However it cannot be found by Origen since the pattern name is actually example_pat_bx.atp
98
+ # In the case where the pattern cannot be found Origen will pass the name to this translator
99
+ # if it exists, and here you can make any substitutions to help Origen find the file you
100
+ # want. In this example any instances of _b\d, where \d means a number, are replaced by
101
+ # _bx.
102
+ #config.pattern_name_translator do |name|
103
+ # name.gsub(/_b\d/, "_bx")
104
+ #end
105
+
106
+ end
data/config/boot.rb ADDED
@@ -0,0 +1,4 @@
1
+ # This file will be loaded by Origen to boot your application, just leave it as
2
+ # is and modify lib/jira.rb to load the additional resources that your
3
+ # application requires
4
+ require "jironimo"
@@ -0,0 +1,104 @@
1
+ # This file should be used to extend the origen command line tool with tasks
2
+ # specific to your application.
3
+ # The comments below should help to get started and you can also refer to
4
+ # lib/origen/commands.rb in your Origen core workspace for more examples and
5
+ # inspiration.
6
+
7
+ # Map any command aliases here, for example to allow 'origen ex' to refer to a
8
+ # command called execute you would add a reference as shown below:
9
+ aliases ={
10
+ # "ex" => "execute",
11
+ }
12
+
13
+ # The requested command is passed in here as @command, this checks it against
14
+ # the above alias table and should not be removed.
15
+ @command = aliases[@command] || @command
16
+
17
+ # Some helper methods to enable test coverage, these will eventually be
18
+ # added to Origen Core, but they need to be here for now and should generally
19
+ # not be modified
20
+ def path_to_coverage_report
21
+ require 'pathname'
22
+ Pathname.new("#{Origen.root}/coverage/index.html").relative_path_from(Pathname.pwd)
23
+ end
24
+
25
+ def enable_coverage(name, merge=true)
26
+ if ARGV.delete("-c") || ARGV.delete("--coverage")
27
+ require 'simplecov'
28
+ SimpleCov.start do
29
+ command_name name
30
+ add_filter "DO_NOT_HAND_MODIFY" # Exclude all imports
31
+
32
+ at_exit do
33
+ SimpleCov.result.format!
34
+ puts ""
35
+ puts "To view coverage report:"
36
+ puts " firefox #{path_to_coverage_report} &"
37
+ puts ""
38
+ end
39
+ end
40
+ yield
41
+ else
42
+ yield
43
+ end
44
+ end
45
+
46
+ # Now branch to the specific task code
47
+ case @command
48
+
49
+ when "tags"
50
+ Dir.chdir Origen.root do
51
+ system "ripper-tags --recursive lib"
52
+ end
53
+ exit 0
54
+
55
+ ## Example of how to make a command to run unit tests, this simply invokes RSpec on
56
+ ## the spec directory
57
+ when "specs"
58
+ enable_coverage("specs") do
59
+ ARGV.unshift "spec"
60
+ require "rspec"
61
+ require "rspec/autorun"
62
+ end
63
+ exit 0 # This will never be hit on a fail, RSpec will automatically exit 1
64
+
65
+ ## Example of how to make a command to run diff-based tests
66
+ #when "examples"
67
+ # Origen.load_application
68
+ # status = 0
69
+ # enable_coverage("examples") do
70
+ #
71
+ # # Compiler tests
72
+ # ARGV = %w(templates/example.txt.erb -t debug -r approved)
73
+ # load "origen/commands/compile.rb"
74
+ # # Pattern generator tests
75
+ # #ARGV = %w(some_pattern -t debug -r approved)
76
+ # #load "#{Origen.top}/lib/origen/commands/generate.rb"
77
+ #
78
+ # if Origen.app.stats.changed_files == 0 &&
79
+ # Origen.app.stats.new_files == 0 &&
80
+ # Origen.app.stats.changed_patterns == 0 &&
81
+ # Origen.app.stats.new_patterns == 0
82
+ #
83
+ # Origen.app.stats.report_pass
84
+ # else
85
+ # Origen.app.stats.report_fail
86
+ # status = 1
87
+ # end
88
+ # puts ""
89
+ # end
90
+ # exit status # Exit with a 1 on the event of a failure per std unix result codes
91
+
92
+ # Always leave an else clause to allow control to fall back through to the
93
+ # Origen command handler.
94
+ else
95
+ # You probably want to also add the your commands to the help shown via
96
+ # origen -h, you can do this be assigning the required text to @application_commands
97
+ # before handing control back to Origen. Un-comment the example below to get started.
98
+ @application_commands = <<-EOT
99
+ specs Run the specs (tests), -c will enable coverage
100
+ tags Generate ctags for this app
101
+ EOT
102
+ # examples Run the examples (tests), -c will enable coverage
103
+
104
+ end
data/config/version.rb ADDED
@@ -0,0 +1,8 @@
1
+ module Jironimo
2
+ MAJOR = 0
3
+ MINOR = 5
4
+ BUGFIX = 0
5
+ DEV = nil
6
+
7
+ VERSION = [MAJOR, MINOR, BUGFIX].join(".") + (DEV ? ".pre#{DEV}" : '')
8
+ end
data/lib/jironimo.rb ADDED
@@ -0,0 +1,489 @@
1
+ require 'origen'
2
+ require 'jira-ruby'
3
+ require_relative '../config/application.rb'
4
+
5
+ module Jironimo
6
+ # Hash of all projects
7
+ attr_accessor :projects
8
+
9
+ # Current project selected
10
+ attr_accessor :current_project
11
+
12
+ # JIRA client instance
13
+ attr_accessor :client
14
+
15
+ # JIRA site
16
+ attr_accessor :site
17
+
18
+ # All issues types found in the client instance
19
+ attr_accessor :issue_types
20
+
21
+ # Issues for the currently selected project
22
+ attr_accessor :issues
23
+
24
+ IssuesTableRow = Struct.new(:key, :assignee, :status, :summary)
25
+
26
+ MAX_ISSUES = 100_000
27
+
28
+ # Issue status types that can be passed as an argument
29
+ # DEPRECATED, this is project specific
30
+ STATUS_TYPES = ['Open', 'In Progress', 'Resolved', 'All', 'All Open']
31
+
32
+ # JQL events
33
+ EVENT_TYPES = %w(created resolved updated)
34
+
35
+ def self.initialize
36
+ @client ||= nil
37
+ @site ||= nil
38
+ @projects ||= {}
39
+ @issue_types ||= {}
40
+ @current_project ||= nil
41
+ @issues ||= {}
42
+ end
43
+
44
+ # JIRA sites
45
+ def self.site
46
+ @site
47
+ end
48
+
49
+ # JIRA client
50
+ def self.client
51
+ @client
52
+ end
53
+
54
+ def self.current_status_types(options = {})
55
+ options = {
56
+ project: @current_project.key
57
+ }.update(options)
58
+ if options[:project].nil?
59
+ Origen.log.error('Cannot find current status types, no project argument passed!')
60
+ fail
61
+ else
62
+ status_types_found = @projects[options[:project]].issues.map { |issue| issue.status.name }.uniq
63
+ end
64
+ end
65
+
66
+ # Allows filtering of @issue_types
67
+ def self.issue_types(filter_arg = nil)
68
+ if filter_arg.nil?
69
+ return @issue_types
70
+ else
71
+ issue_types_found = case filter_arg
72
+ when Regexp
73
+ @issue_types.filter(filter_arg)
74
+ when String
75
+ if @issue_types.include? filter_arg
76
+ @issue_types[filter_arg]
77
+ else
78
+ Origen.log.warn "Found no JIRA issue types using the argument '#{filter_arg}', refine your search!"
79
+ return nil
80
+ end
81
+ end
82
+ if issue_types_found.is_a? Hash
83
+ if issue_types_found.size > 1
84
+ issue_types_found
85
+ else
86
+ Origen.log.warn "Found no JIRA issue types using the argument '#{filter_arg}', refine your search!"
87
+ return nil
88
+ end
89
+ else
90
+ issue_types_found
91
+ end
92
+ end
93
+ end
94
+
95
+ # Allows filtering of @projects
96
+ def self.projects(filter_arg = nil)
97
+ if filter_arg.nil?
98
+ return @projects
99
+ else
100
+ projects_found = @projects.filter(filter_arg)
101
+ if projects_found.size == 1
102
+ return projects_found.values.first
103
+ elsif projects_found > 1
104
+ Origen.log.warn "Found more than one JIRA project using the argument '#{filter_arg}', refine your search from #{projects_found.keys.join(', ')}"
105
+ return projects_found.values
106
+ else
107
+ Origen.log.warn "Found no JIRA issue types using the argument '#{filter_arg}', refine your search from #{projects_found.keys.join(', ')}"
108
+ return nil
109
+ end
110
+ end
111
+ end
112
+
113
+ # Retrieve a project using a numeric ID or String key
114
+ def self.project(id)
115
+ # Try the project key first and then the ID
116
+ if id.is_a? String
117
+ return projects(id)
118
+ elsif id.is_a? Integer
119
+ # Try the ID
120
+ projects_found = @projects.select { |key, p| p.id.to_numeric == id }
121
+ if projects_found.size == 1
122
+ return projects_found.values.first
123
+ else
124
+ Origen.log.warn "Found more than one JIRA project using the argument '#{id}', refine your search from #{projects_found.keys.join(', ')}"
125
+ return projects_found.values
126
+ end
127
+ end
128
+ end
129
+
130
+ # Re-fresh the JIRA client and releated module accessors
131
+ # Useful after adding, deleting, ormodifying anythign on the JIRA server
132
+ def self.refresh(options = {})
133
+ query_options = {
134
+ fields: [],
135
+ start_at: 0,
136
+ max_results: MAX_ISSUES
137
+ }.update(options)
138
+ Origen.log.errpr 'Jironimo#refresh needs Jironimo.current_project to be set' if @current_project.nil?
139
+ Origen.log.error 'Jironimo#refresh needs to have Jironimo.client to be valid' if @client.nil?
140
+ @projects = create_projects_hash(@client.Project.all)
141
+ @issue_types = create_issue_types_hash(@client.Issuetype.all)
142
+ @issues = {}
143
+ @client.Issue.jql("project = #{@current_project.key}", query_options).each do |issue|
144
+ @issues[issue.key] = issue
145
+ end
146
+ end
147
+
148
+ # Set the current project, enables project specific accessors like @issues
149
+ def self.current_project=(id, options = {})
150
+ query_options = {
151
+ fields: [],
152
+ start_at: 0,
153
+ max_results: MAX_ISSUES
154
+ }.update(options)
155
+ project_search = project(id)
156
+ if project_search.is_a? JIRA::Resource::Project
157
+ @current_project = project_search
158
+ # Find all of the issues for this project
159
+ @issues = {} unless @issues.empty?
160
+ @client.Issue.jql("project = #{id}", query_options).each do |issue|
161
+ @issues[issue.key] = issue
162
+ end
163
+ # This code only returns 50 results max
164
+ # @current_project.issues.each do |issue|
165
+ # @issues[issue.key] = issue
166
+ # end
167
+ else
168
+ @current_project = nil
169
+ end
170
+ end
171
+
172
+ # Returns the curren project instance
173
+ def self.current_project
174
+ @current_project
175
+ end
176
+
177
+ # Returns a hash of JIRA issues assigned to the current user
178
+ # Defaults to 'Open' or 'In Progress' issue status
179
+ def self.my_issues(options = {})
180
+ query_options = {
181
+ verbose: false,
182
+ assignee: User.current.id,
183
+ project: @current_project.key,
184
+ fields: [],
185
+ start_at: 0,
186
+ max_results: MAX_ISSUES,
187
+ status: nil
188
+ }.update(options)
189
+ my_issues = {}
190
+ console_print = query_options.delete(:verbose)
191
+ Origen.log.error 'User option must be a String, exiting...' unless query_options[:assignee].is_a? String
192
+ assignee = query_options.delete(:assignee)
193
+ jql_str = "assignee = #{assignee.upcase}"
194
+ if query_options[:project].nil?
195
+ # Cannot search every project for issues, takes too long
196
+ Origen.log.error('No project passed, cannot fetch your issues!')
197
+ fail
198
+ else
199
+ jql_str += " AND project = #{query_options[:project]}"
200
+ end
201
+ # Check which issue status types to retrieve
202
+ valid_status_types = current_status_types(query_options)
203
+ begin
204
+ case query_options[:status]
205
+ # This can and should be expanded over time
206
+ when 'All', nil
207
+ jql_str = jql_str # Don't change naything as status doesn't need to be filtered
208
+ end
209
+ ensure
210
+ query_options.delete(:status)
211
+ end
212
+ if @client.nil?
213
+ Origen.log.error 'No JIRA client instantiated, cannot check for your issues, exiting...'
214
+ else
215
+ @client.Issue.jql(jql_str, query_options).each do |issue|
216
+ my_issues[issue.key] = issue
217
+ end
218
+ end
219
+ show_issues(my_issues) if console_print
220
+ my_issues
221
+ end
222
+
223
+ # Get the latest issues
224
+ def self.latest_issues(time, options = {})
225
+ query_options = {
226
+ verbose: false,
227
+ assignee: User.current.id,
228
+ fields: [],
229
+ start_at: 0,
230
+ max_results: MAX_ISSUES,
231
+ event: 'created'
232
+ }.update(options)
233
+ latest_issues = {}
234
+ console_print = query_options.delete(:verbose)
235
+ event = query_options.delete(:event)
236
+ assignee = query_options.delete(:assignee)
237
+ Origen.log.errpr 'Jironimo.current_project is not set, exiting...' if @current_project.nil?
238
+ Origen.log.error 'Jironimo.client is not set, exiting...' if @client.nil?
239
+ Origen.log.error "Event '#{event}' is not supported, choose from #{EVENT_TYPES.join(', ')}, exiting..." unless EVENT_TYPES.include? event
240
+ Origen.log.error "Could not get latest issues with argument '#{time}', exiting..." unless jql_time_ok?(time)
241
+ jql = "assignee = #{assignee} AND #{event} <= '#{time}'"
242
+ @client.Issue.jql(jql).each do |issue|
243
+ latest_issues[issue.key] = issue
244
+ end
245
+ latest_issues
246
+ end
247
+ # alias_method self(:latest, :latest_issues
248
+
249
+ # Allows filtering of @issues
250
+ def self.issues(id = nil)
251
+ if @current_project.nil?
252
+ return {}
253
+ elsif @current_project.is_a? JIRA::Resource::Project
254
+ if id.nil?
255
+ @issues
256
+ elsif @issues.include? id
257
+ @issues[id]
258
+ else
259
+ Origen.log.error("Jironimo: Issue '#{id}' is not found in project '#{@current_project.key}'!")
260
+ exit 0
261
+ end
262
+ else
263
+ Origen.log.error "Jironimo.current_project is of incorrect type '#{@current_project.class}', should be nil or JIRA::Resource::Project, exiting.."
264
+ exit 0
265
+ end
266
+ end
267
+
268
+ # Launches the JIRA interface client and initializes
269
+ # @projects and @issue_types
270
+ def self.launch(options = {})
271
+ options = {
272
+ username: User.current.id,
273
+ password: User.current.password,
274
+ site: 'http://jira.amd.com',
275
+ auth_type: :basic,
276
+ use_ssl: false,
277
+ context_path: ''
278
+ }.update(options)
279
+ initialize
280
+ @client = JIRA::Client.new(options)
281
+ @site = options[:site]
282
+ @projects = create_projects_hash(@client.Project.all)
283
+ @issue_types = create_issue_types_hash(@client.Issuetype.all)
284
+ @client
285
+ end
286
+
287
+ # Returns a hash of issue types with issue type name as key and
288
+ # issue type number as value
289
+ def self.issue_type_mapping
290
+ issue_type_names = {}
291
+ @issue_types.each do |type_name, issue_type|
292
+ issue_type_names[type_name] = issue_type.id
293
+ end
294
+ issue_type_names
295
+ end
296
+
297
+ def self.update_issue(issue_key)
298
+ options = {
299
+ type: nil,
300
+ summary: nil,
301
+ description: nil
302
+ }.merge(options)
303
+ Origen.log.error "Cannot update issue '#{issue_key}', please set the current project" if @issues.empty?
304
+ project_attr = 'key'
305
+ args_result, options = check_issue_args(options)
306
+ Origen.log.error "Updating JIRA issue '#{issue_key}' failed due to bad arguments, check previous log warnings, exiting..." unless args_result
307
+ issue = @issues[issue_key]
308
+ issue.save(assemble_issue_fields(options, project_attr))
309
+ issue
310
+ end
311
+
312
+ # Create anew JIRA issue for the current project or one passed as an argument
313
+ def self.new_issue(options = {})
314
+ options = {
315
+ project: nil,
316
+ type: nil,
317
+ summary: nil,
318
+ description: nil
319
+ }.merge(options)
320
+ project_attr = ''
321
+ args_result, options = check_issue_args(options)
322
+ Origen.log.jironimo 'Creating a new JIRA issue failed due to bad arguments, check previous log warnings, exiting...' unless args_result
323
+ if options[:project].numeric?
324
+ project_attr = 'id'
325
+ elsif options[:project].is_a? String
326
+ project_attr = 'key'
327
+ else
328
+ Origen.log.error 'options[:project] must be String (use project key) or Integer (use project ID), exiting...'
329
+ end
330
+ issue = @client.Issue.build
331
+ issue.save(assemble_issue_fields(options, project_attr))
332
+ if issue.respond_to?(:errors)
333
+ Origen.log.error('Jironimo: Cannot create Jira issue, here is why:')
334
+ issue.errors.each do |err|
335
+ Origen.log.error("Jironimo: #{err}")
336
+ end
337
+ exit 0
338
+ else
339
+ # Successfully created an issue
340
+ Origen.log.jironimo "Created issue for #{issue.key}"
341
+ end
342
+ issue
343
+ end
344
+
345
+ # Delete a JIRA issue
346
+ def self.delete_issue(issue_key)
347
+ Origen.log.error "Could not delete issue '#{issue_key}', exiting..." unless @issues.include? issue_key
348
+ @issues[issue_key].delete
349
+ end
350
+
351
+ private
352
+
353
+ def self.jql_time_ok?(time)
354
+ result = true
355
+ time.split(/\s+/).each do |time_arg|
356
+ if time_arg[/^[-|+]?\d+[d|h|m|w|y]$/].nil?
357
+ Origen.log.warn "Could not parse jql time argument #{time_arg}"
358
+ result = false
359
+ end
360
+ end
361
+ result
362
+ end
363
+
364
+ def self.assemble_issue_fields(options, project_attr)
365
+ Hash.new { |h, k| h[k] = {} }.tap do |issues_hash|
366
+ options.each do |attr, value|
367
+ case attr
368
+ when :summary, :description
369
+ issues_hash['fields'][attr.to_s] = value unless value.nil?
370
+ when :project
371
+ issues_hash['fields'][attr.to_s] = Hash[project_attr.to_s, value] unless value.nil?
372
+ when :type
373
+ issues_hash['fields']['issuetype'] = Hash['name', value] unless value.nil?
374
+ when :assignee
375
+ issues_hash['fields'][attr.to_s] = Hash['name', value] unless value.nil?
376
+ when :priority
377
+ issues_hash['fields'][attr.to_s] = Hash['id', value.to_s] unless value.nil?
378
+ when :components
379
+ value = [value] unless value.is_a? Array
380
+ component_array = []
381
+ value.each do |component|
382
+ component_key = ''
383
+ if component.is_a? String
384
+ if component.numeric?
385
+ component_key = 'id'
386
+ else
387
+ component_key = 'name'
388
+ end
389
+ elsif component.is_a? Integer
390
+ component_key = 'id'
391
+ else
392
+ Origen.log.error "Component option '#{component}' is not the correct type, choose from String or Integer, exiting..."
393
+ end
394
+ component_array << Hash[component_key, component.to_s]
395
+ end
396
+ issues_hash['fields'][attr.to_s] = component_array
397
+ else
398
+ issues_hash['fields'][attr.to_s] = value unless value.nil?
399
+ end
400
+ end
401
+ end
402
+ end
403
+
404
+ def self.check_issue_args(options)
405
+ result = true
406
+ if options[:project].nil?
407
+ if @current_project.nil?
408
+ Origen.log.warn 'options[:project] must be supplied or a current project be set with Jironimo#current_product='
409
+ result = false
410
+ else
411
+ options[:project] = @current_project.id
412
+ end
413
+ elsif options[:project].is_a?(Numeric)
414
+ # Convert the number to a String as jira requires a String argument
415
+ options[:project] = options[:project].to_s
416
+ end
417
+ string_options = options.reject { |k, v| [:project, :priority, :labels].include? k }
418
+ string_options.each do |_key, value|
419
+ unless value.is_a? String
420
+ Origen.log.warn "JIRA issue creation argument '#{value}' must be a String"
421
+ result = false
422
+ end
423
+ end
424
+ unless @issue_types.include?(options[:type])
425
+ Origen.log.warn "JIRA issue type argument '#{options[:type]}' is not valid, choose from:\n#{@issue_types.keys.sort.join("\n")}"
426
+ result = false
427
+ end
428
+ [result, options]
429
+ end
430
+
431
+ def self.show_issues(issues)
432
+ whitespace_padding, table_issues, column_widths, header, project_header, table = 3, [], {}, '', '', []
433
+ # Create a hash with key being the issue key and the value being the issue summary
434
+ issues.each do |key, issue|
435
+ assignee = ''
436
+ issue.assignee.nil? ? assignee = '' : assignee = issue.assignee.name
437
+ table_issues << IssuesTableRow.new(key, assignee, issue.status.name, issue.summary)
438
+ end
439
+ %w(Key Assignee Status Summary).each do |column|
440
+ sym = column.downcase.to_sym
441
+ if column.length > table_issues.map(&sym).max_by(&:length).length
442
+ column_widths[column] = column.length + whitespace_padding
443
+ else
444
+ column_widths[column] = table_issues.map(&sym).max_by(&:length).length + whitespace_padding
445
+ end
446
+ end
447
+ column_widths.each do |attr_name, column_width|
448
+ header += "| #{attr_name}".ljust(column_width)
449
+ end
450
+ project_header += "| #{@current_project.key}: #{@current_project.name}".ljust(header.length)
451
+ header += '|'
452
+ table << '-' * header.length
453
+ table << project_header += '|'
454
+ table << '=' * header.length
455
+ table << header
456
+ table << '=' * header.length
457
+ table_issues.each do |issue|
458
+ row = ''
459
+ row = "| #{issue.key}".ljust(column_widths['Key']) + "| #{issue.assignee}".ljust(column_widths['Assignee']) + "| #{issue.status}".ljust(column_widths['Status']) + "| #{issue.summary}".ljust(column_widths['Summary']) + '|'
460
+ table << row
461
+ end
462
+ table << '-' * header.length
463
+ puts table.flatten.join("\n")
464
+ end
465
+
466
+ def self.create_issue_types_hash(arr)
467
+ issue_types_hash = {}.tap do |new_h|
468
+ arr.each do |issue_type|
469
+ new_h[issue_type.name] = issue_type
470
+ end
471
+ end
472
+ end
473
+
474
+ def self.create_status_types_hash(arr)
475
+ status_types_hash = {}.tap do |new_h|
476
+ arr.each do |status_type|
477
+ new_h[status_type.name] = status_type
478
+ end
479
+ end
480
+ end
481
+
482
+ def self.create_projects_hash(arr)
483
+ project_hash = {}.tap do |new_h|
484
+ arr.each do |project|
485
+ new_h[project.key] = project
486
+ end
487
+ end
488
+ end
489
+ end
@@ -0,0 +1,69 @@
1
+ # You can define any Rake tasks to support your application here (or in any file
2
+ # ending in .rake in this directory).
3
+ #
4
+ # Rake (Ruby Make) is very useful for creating build scripts, see this short video
5
+ # for a quick introduction:
6
+ # http://railscasts.com/episodes/66-custom-rake-tasks
7
+
8
+ namespace :isc do
9
+ desc 'Remove back-up files recursively from the project'
10
+ task :clean do
11
+ backup_files = Dir.glob("#{Origen.root}/**/*~")
12
+ unless backup_files.empty?
13
+ puts 'Backup files removed:'
14
+ puts backup_files.join("\n")
15
+ File.delete(*backup_files)
16
+ end
17
+ end
18
+
19
+ desc 'Find unmanaged files'
20
+ task :find_unman do
21
+ root_path = Origen.root.to_s.split('/').drop(1)
22
+ Origen.app.rc.unmanaged.each do |f|
23
+ next if f =~ /\~/
24
+ path = f.split('/').drop(1)
25
+ proj_sub_dir = (path - root_path).first
26
+ next if proj_sub_dir =~ /^\.|^web$|^lbin$|^log$/
27
+ puts f
28
+ end
29
+ end
30
+
31
+ desc 'Find unmanaged files and commit to revision control'
32
+ task :commit_unman do
33
+ root_path = Origen.root.to_s.split('/').drop(1)
34
+ files = []
35
+ Origen.app.rc.unmanaged.each do |f|
36
+ next if f =~ /\~/
37
+ path = f.split('/').drop(1)
38
+ proj_sub_dir = (path - root_path).first
39
+ next if proj_sub_dir =~ /^\.|^web$|^lbin$|^log$/
40
+ files << f
41
+ end
42
+ commit_results = {}
43
+ files.each do |file|
44
+ commit_results[file] = system("origen rc new #{file}")
45
+ end
46
+ commit_results.each do |file, result|
47
+ puts "File #{file} commit result is #{result}"
48
+ end
49
+ end
50
+
51
+ desc 'Find modified files'
52
+ task :find_mods do
53
+ puts Origen.app.rc.local_modifications.join("\n")
54
+ end
55
+
56
+ desc 'Commit modified files'
57
+ task :commit_mods, [:comment] do |t, args|
58
+ args.with_defaults(comment: 'Mass file commit, code re-factor/cleanup or lint most likely cause')
59
+ results = `origen rc mods`.split("\n").select! { |f| f =~ /dssc diff/ }
60
+ results.map! { |f| f[/-ver\s+\S+\s+(\S+)/, 1] }
61
+ commit_results = {}
62
+ results.each do |file|
63
+ commit_results[file] = system("dssc ci -keep #{file} -com '#{args[:comment]}'")
64
+ end
65
+ commit_results.each do |file, result|
66
+ puts "File #{file} commit result is #{result}"
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,68 @@
1
+ # You can define any Rake tasks to support your application here (or in any file
2
+ # ending in .rake in this directory).
3
+ #
4
+ # Rake (Ruby Make) is very useful for creating build scripts, see this short video
5
+ # for a quick introduction:
6
+ # http://railscasts.com/episodes/66-custom-rake-tasks
7
+ namespace :jira do
8
+ desc 'Remove back-up files recursively from the project'
9
+ task :clean do
10
+ backup_files = Dir.glob("#{Origen.root}/**/*~")
11
+ unless backup_files.empty?
12
+ puts 'Backup files removed:'
13
+ puts backup_files.join("\n")
14
+ File.delete(*backup_files)
15
+ end
16
+ end
17
+
18
+ desc 'Find unmanaged files'
19
+ task :find_unman do
20
+ root_path = Origen.root.to_s.split('/').drop(1)
21
+ Origen.app.rc.unmanaged.each do |f|
22
+ next if f =~ /\~/
23
+ path = f.split('/').drop(1)
24
+ proj_sub_dir = (path - root_path).first
25
+ next if proj_sub_dir =~ /^\.|^web$|^lbin$|^log$/
26
+ puts f
27
+ end
28
+ end
29
+
30
+ desc 'Find unmanaged files and commit to revision control'
31
+ task :commit_unman do
32
+ root_path = Origen.root.to_s.split('/').drop(1)
33
+ files = []
34
+ Origen.app.rc.unmanaged.each do |f|
35
+ next if f =~ /\~/
36
+ path = f.split('/').drop(1)
37
+ proj_sub_dir = (path - root_path).first
38
+ next if proj_sub_dir =~ /^\.|^web$|^lbin$|^log$/
39
+ files << f
40
+ end
41
+ commit_results = {}
42
+ files.each do |file|
43
+ commit_results[file] = system("origen rc new #{file}")
44
+ end
45
+ commit_results.each do |file, result|
46
+ puts "File #{file} commit result is #{result}"
47
+ end
48
+ end
49
+
50
+ desc 'Find modified files'
51
+ task :find_mods do
52
+ puts Origen.app.rc.local_modifications.join("\n")
53
+ end
54
+
55
+ desc 'Commit modified files'
56
+ task :commit_mods, [:comment] do |t, args|
57
+ args.with_defaults(comment: 'Mass file commit, code re-factor/cleanup or lint most likely cause')
58
+ results = `origen rc mods`.split("\n").select! { |f| f =~ /dssc diff/ }
59
+ results.map! { |f| f[/-ver\s+\S+\s+(\S+)/, 1] }
60
+ commit_results = {}
61
+ results.each do |file|
62
+ commit_results[file] = system("dssc ci -keep #{file} -com '#{args[:comment]}'")
63
+ end
64
+ commit_results.each do |file, result|
65
+ puts "File #{file} commit result is #{result}"
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,95 @@
1
+ % render "layouts/basic.html" do
2
+
3
+ %# HTML tags can be embedded in mark down files if you want to do specific custom
4
+ %# formatting like this, but in most cases that is not required.
5
+ <h1><%= Origen.app.namespace %> <span style="font-size: 14px">(<%= Origen.app.version %>)</span></h1>
6
+
7
+ ### Purpose
8
+
9
+ This plugin provides interaction with the [JIRA issue tracking system](https://jira.atlassian.com/).
10
+ It provides some helpful high level methods while using the ruby-jira gem to do the heavy lifting.
11
+ If there isn't a canned method to do what you want do not despair, just go [here](https://github.com/sumoheavy/jira-ruby) and read up.
12
+
13
+ ### How To Import
14
+
15
+ ##### To use in an application:
16
+
17
+ Add the following to your application's <code>Gemfile</code>:
18
+
19
+ ~~~ruby
20
+ gem '<%= Origen.app.name %>', '<%= Origen.app.version %>'
21
+ ~~~
22
+
23
+ ##### To use in a plugin:
24
+
25
+ Add the following to your plugin's gemspec:
26
+
27
+ ~~~ruby
28
+ spec.add_runtime_dependency '<%= Origen.app.name %>', '~> <%= Origen.app.version.major %>', '>= <%= Origen.app.version %>'
29
+ ~~~
30
+
31
+ and require the gem in your code:
32
+
33
+ ~~~ruby
34
+ require '<%= Origen.app.name %>'
35
+ ~~~
36
+
37
+
38
+ ### How To Use
39
+
40
+ Give some quick start description here on how to use your plugin, providing
41
+ links to the API documents where necessary for further details.
42
+
43
+ Here is an example integration:
44
+
45
+ ~~~ruby
46
+ module MyJira
47
+ require 'jironimo'
48
+
49
+ my_jironimo_client = Jironimo.launch
50
+
51
+ # Set the current Jironimo project to 'ISC'
52
+ Jironimo.current_project = 'ISC'
53
+
54
+ unless Jironimo.issues['ISC-463'].assignee.nil?
55
+ Origen.log.info "Give him another issue!"
56
+ Origen.log.info "His email is #{Jironimo.issues['ISC-463'].assignee.emailAddress}"
57
+ end
58
+
59
+ # Print out current users issues to console
60
+ Jironimo.my_issues(verbose: true)
61
+
62
+ # Create a new ticket
63
+ project_issue_count = Jironimo.issues.size
64
+ new_issue = Jironimo.new_issue(type: 'Bug', summary: 'my summary', description: 'my description', priority: 1, assignee: 'B07507')
65
+
66
+ # Re-fresh the JIRA client database
67
+ Jironimo.refresh
68
+
69
+ new_project_issue_count = Jironimo.issues.size
70
+
71
+ # Make sure the database has one more ticket fo the current project
72
+ unless new_project_issue_count.should == (project_issue_count + 1)
73
+ Origen.log.error "Could not create new issue for project '#{@current_project.key}:#{@current_project.name}'"
74
+ end
75
+
76
+ # Delete the issue if needed
77
+ delete_issue(new_issue.key) # Method 1, useful when the user doesn't have an object instance
78
+ new_issue.delete # Method 2, suited for when the user does have an object instance
79
+
80
+ ~~~
81
+
82
+ ### How To Setup a Development Environment
83
+
84
+ ~~~text
85
+ mkdir <%= Origen.app.name %>
86
+ cd <%= Origen.app.name %>
87
+ dssc setvault <%= Origen.app.config.vault %> .
88
+ dssc pop -rec -get .
89
+ ~~~
90
+
91
+ Follow the instructions here if you want to make a 3rd party app
92
+ workspace use your development copy of the <%= Origen.app.name %> plugin:
93
+ [Setting up a Plugin Development Environment](http://origen-sdk.org/origen/guides/plugins/environment/)
94
+
95
+ % end
@@ -0,0 +1,15 @@
1
+ ---
2
+ title: <%= options[:title] || Origen.config.name %>
3
+ ---
4
+ <%= render "templates/web/partials/navbar.html", :tab => options[:tab] %>
5
+
6
+ <div class="row">
7
+ %# The markdown attribute is important if you are going to include content written
8
+ %# in markdown, without this is will be included verbatim
9
+ <div class="span12" markdown="1">
10
+ <%= yield %>
11
+
12
+ <%= disqus_comments %>
13
+
14
+ </div>
15
+ </div>
@@ -0,0 +1,21 @@
1
+ <nav class="navbar navbar-inverse navbar-fixed-top">
2
+ <div class="container">
3
+ <div class="navbar-header">
4
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
5
+ <span class="sr-only">Toggle navigation</span>
6
+ <span class="icon-bar"></span>
7
+ <span class="icon-bar"></span>
8
+ <span class="icon-bar"></span>
9
+ </button>
10
+ <a class="navbar-brand" href="<%= path "/" %>">Home</a>
11
+ </div>
12
+ <div id="navbar" class="collapse navbar-collapse">
13
+ <ul class="nav navbar-nav">
14
+ <li class="<%= options[:tab] == :api ? 'active' : '' %>"><a href="<%= path "/api/" %>">API</a></li>
15
+ <li class="<%= options[:tab] == :release ? 'active' : '' %>"><a href="<%= path "/release_notes" %>">Release Notes</a></li>
16
+ <li><a href="https://github.com/Origen-SDK/jironimo">Github</a></li>
17
+ </ul>
18
+ <%= import "origen/web/logo.html" %>
19
+ </div><!--/.nav-collapse -->
20
+ </div>
21
+ </nav>
@@ -0,0 +1,21 @@
1
+ % render "layouts/basic.html", tab: :release do
2
+
3
+ <%= render "#{Origen.root}/doc/history" %>
4
+
5
+ ### 0.5.0
6
+ * [OSDK-505](http://jira.amd.com/browse/OSDK-505): Add issue creation error checks to jironimo gem
7
+
8
+ ### 0.4.0
9
+ * [OSDK-491](http://jira.amd.com/browse/OSDK-491): Remove previous company-centric issue filters that prevented use across AMD Jira projects
10
+
11
+ ### 0.3.0
12
+ * [OSDK-438](http://jira.amd.com/browse/OSDK-438): Wrap project issues in method vs direct access to the Hash
13
+ * Moved to latest Github version of origen
14
+
15
+ ### 0.2.0
16
+ * unit level spec tests working within AMD, using the OSDK and ATEOBR projects
17
+
18
+ ### 0.1.0
19
+ * Initial release, not yet validated
20
+
21
+ % end
@@ -0,0 +1,21 @@
1
+ % render "layouts/basic.html", tab: :release do
2
+
3
+ <%= render "#{Origen.root}/doc/history" %>
4
+
5
+ ### 0.5.0
6
+ * [OSDK-505](http://jira.amd.com/browse/OSDK-505): Add issue creation error checks to jironimo gem
7
+
8
+ ### 0.4.0
9
+ * [OSDK-491](http://jira.amd.com/browse/OSDK-491): Remove previous company-centric issue filters that prevented use across AMD Jira projects
10
+
11
+ ### 0.3.0
12
+ * [OSDK-438](http://jira.amd.com/browse/OSDK-438): Wrap project issues in method vs direct access to the Hash
13
+ * Moved to latest Github version of origen
14
+
15
+ ### 0.2.0
16
+ * unit level spec tests working within AMD, using the OSDK and ATEOBR projects
17
+
18
+ ### 0.1.0
19
+ * Initial release, not yet validated
20
+
21
+ % end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jironimo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ platform: ruby
6
+ authors:
7
+ - Brian Caquelin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-01-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: origen
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.53.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.53.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: jira-ruby
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.7.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.7.1
41
+ description:
42
+ email:
43
+ - b07507@freescale.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - config/application.rb
49
+ - config/boot.rb
50
+ - config/commands.rb
51
+ - config/version.rb
52
+ - lib/jironimo.rb
53
+ - lib/tasks/isc.rake
54
+ - lib/tasks/jironimo.rake
55
+ - templates/web/index.md.erb
56
+ - templates/web/layouts/_basic.html.erb
57
+ - templates/web/partials/_navbar.html.erb
58
+ - templates/web/release_notes.md.erb
59
+ - templates/web/release_notes.md.erb~
60
+ homepage: http://origen-sdk.org/jironimo
61
+ licenses: []
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '2'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 1.8.11
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.6.12
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Top level wrapper for the gem jira-ruby that interacts with the JIRA issue
83
+ tracking system
84
+ test_files: []