Class: JiraMetrics
- Inherits:
-
Thor
- Object
- Thor
- JiraMetrics
- Defined in:
- lib/jirametrics.rb
Class Method Summary collapse
Instance Method Summary collapse
- #__print_version ⇒ Object
- #download ⇒ Object
- #export ⇒ Object
- #go ⇒ Object
- #info(key) ⇒ Object
- #mcp ⇒ Object
- #stitch(stitch_file = 'stitcher.erb') ⇒ 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
104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/jirametrics.rb', line 104 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 file_system.logfile.puts "#{exception.class}: #{exception.}" exception.backtrace&.each { |line| file_system.logfile.puts "\t#{line}" } rescue StandardError # Exporter may not be initialized, or the logfile may already be closed end 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 |
#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
51 52 53 54 |
# File 'lib/jirametrics.rb', line 51 def info key load_config [:config] Exporter.instance.info(key, name_filter: [:name] || '*') end |
#mcp ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/jirametrics.rb', line 59 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) load_config [:config] 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 } 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 |