Class: JiraMetrics
- Inherits:
-
Thor
- Object
- Thor
- JiraMetrics
- Defined in:
- lib/jirametrics.rb
Class Method Summary collapse
- .exit_on_failure? ⇒ Boolean
- .log_uncaught_exception(exception, file_system: nil) ⇒ Object
- .write_exception_to_logfile(logfile, exception) ⇒ Object
Instance Method Summary collapse
- #__print_version ⇒ Object
- #boards(board_id = nil) ⇒ Object
- #download ⇒ Object
- #export ⇒ Object
- #go ⇒ Object
- #info(key) ⇒ Object
- #mcp ⇒ Object
- #stitch(stitch_file = 'stitcher.erb') ⇒ Object
- #verify ⇒ Object
Class Method Details
.exit_on_failure? ⇒ Boolean
11 12 13 |
# File 'lib/jirametrics.rb', line 11 def self.exit_on_failure? true end |
.log_uncaught_exception(exception, file_system: nil) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/jirametrics.rb', line 127 def self.log_uncaught_exception exception, file_system: nil return unless exception && !exception.is_a?(SystemExit) begin file_system ||= Exporter.instance.file_system return if file_system.logfile == $stdout write_exception_to_logfile file_system.logfile, exception rescue StandardError # Exporter may not be initialized, or the logfile may already be closed end end |
.write_exception_to_logfile(logfile, exception) ⇒ Object
140 141 142 143 |
# File 'lib/jirametrics.rb', line 140 def self.write_exception_to_logfile logfile, exception logfile.puts "#{exception.class}: #{exception.}" exception.backtrace&.each { |line| logfile.puts "\t#{line}" } end |
Instance Method Details
#__print_version ⇒ Object
18 19 20 |
# File 'lib/jirametrics.rb', line 18 def __print_version puts Gem.loaded_specs['jirametrics'].version end |
#boards(board_id = nil) ⇒ Object
61 62 63 64 |
# File 'lib/jirametrics.rb', line 61 def boards board_id = nil load_config [:config] exit 1 unless Exporter.instance.boards(board_id: board_id, name_filter: [:name]) end |
#download ⇒ Object
33 34 35 36 |
# File 'lib/jirametrics.rb', line 33 def download load_config [:config] Exporter.instance.download(name_filter: [:name] || '*') end |
#export ⇒ Object
25 26 27 28 |
# File 'lib/jirametrics.rb', line 25 def export load_config [:config] Exporter.instance.export(name_filter: [:name] || '*') end |
#go ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/jirametrics.rb', line 41 def go load_config [:config] Exporter.instance.download(name_filter: [:name] || '*') load_config [:config] Exporter.instance.export(name_filter: [:name] || '*') end |
#info(key) ⇒ Object
68 69 70 71 |
# File 'lib/jirametrics.rb', line 68 def info key load_config [:config] Exporter.instance.info(key, name_filter: [:name] || '*') end |
#mcp ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/jirametrics.rb', line 76 def mcp # Redirect stdout to stderr for the entire startup phase so that any # incidental output (from config files, gem loading, etc.) does not # corrupt the JSON-RPC channel before the MCP transport takes over. original_stdout = $stdout.dup $stdout.reopen($stderr) # Log to a separate file so that starting the MCP server doesn't truncate jirametrics.log, which # someone may be relying on to debug a preceding export run. load_config [:config], logfile_name: 'jirametrics-mcp.log' require 'jirametrics/mcp_server' Exporter.instance.file_system.log_only = true projects = {} aggregates = {} Exporter.instance.each_project_config(name_filter: [:name] || '*') do |project| project.evaluate_next_level project.run load_only: true projects[project.name || 'default'] = { issues: project.issues, today: project.time_range.end.to_date, end_time: project.time_range.end } # Fabrication is lazy, so force every historical status to resolve now and then emit the single # consolidated warning into jirametrics-mcp.log (file_system is log_only here). project.resolve_all_status_changes project.report_fabricated_statuses rescue StandardError => e if e..start_with? 'This is an aggregated project' names = project.aggregate_project_names aggregates[project.name] = names if names.any? next end next if e..start_with? 'No data found' raise end $stdout.reopen(original_stdout) original_stdout.close McpServer.new(projects: projects, aggregates: aggregates, timezone_offset: Exporter.instance.timezone_offset).run end |