Class: JiraMetrics

Inherits:
Thor
  • Object
show all
Defined in:
lib/jirametrics.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/jirametrics.rb', line 10

def self.exit_on_failure?
  true
end

Instance Method Details

#__print_versionObject



17
18
19
# File 'lib/jirametrics.rb', line 17

def __print_version
  puts Gem.loaded_specs['jirametrics'].version
end

#downloadObject



32
33
34
35
# File 'lib/jirametrics.rb', line 32

def download
  load_config options[:config]
  Exporter.instance.download(name_filter: options[:name] || '*')
end

#exportObject



24
25
26
27
# File 'lib/jirametrics.rb', line 24

def export
  load_config options[:config]
  Exporter.instance.export(name_filter: options[:name] || '*')
end

#goObject



40
41
42
43
44
45
46
# File 'lib/jirametrics.rb', line 40

def go
  load_config options[:config]
  Exporter.instance.download(name_filter: options[:name] || '*')

  load_config options[:config]
  Exporter.instance.export(name_filter: options[:name] || '*')
end

#info(key) ⇒ Object



50
51
52
53
# File 'lib/jirametrics.rb', line 50

def info key
  load_config options[:config]
  Exporter.instance.info(key, name_filter: options[:name] || '*')
end

#mcpObject



58
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
# File 'lib/jirametrics.rb', line 58

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 options[:config]
  require 'jirametrics/mcp_server'

  Exporter.instance.file_system.log_only = true

  projects = {}
  aggregates = {}
  Exporter.instance.each_project_config(name_filter: options[: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.message.start_with? 'This is an aggregated project'
      names = project.aggregate_project_names
      aggregates[project.name] = names if names.any?
      next
    end
    next if e.message.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

#stitch(stitch_file = 'stitcher.erb') ⇒ Object



98
99
100
101
# File 'lib/jirametrics.rb', line 98

def stitch stitch_file = 'stitcher.erb'
  load_config options[:config]
  Exporter.instance.stitch stitch_file
end