Class: Commenter::GitHubIssueCreator

Inherits:
Object
  • Object
show all
Defined in:
lib/commenter/github_integration.rb

Instance Method Summary collapse

Constructor Details

#initialize(config_path, title_template_path = nil, body_template_path = nil) ⇒ GitHubIssueCreator

Returns a new instance of GitHubIssueCreator.



10
11
12
13
14
15
16
17
18
19
# File 'lib/commenter/github_integration.rb', line 10

def initialize(config_path, title_template_path = nil, body_template_path = nil)
  @config = load_config(config_path)
  @github_client = create_github_client
  @repo = @config.dig("github", "repository")

  raise "GitHub repository not specified in config" unless @repo

  @title_template = load_liquid_template(title_template_path || default_title_template_path)
  @body_template = load_liquid_template(body_template_path || default_body_template_path)
end

Instance Method Details

#create_issues_from_yaml(yaml_file, options = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/commenter/github_integration.rb', line 21

def create_issues_from_yaml(yaml_file, options = {})
  data = YAML.load_file(yaml_file)
  comment_sheet = CommentSheet.from_hash(data)

  # Override stage if provided
  comment_sheet.stage = options[:stage] if options[:stage]

  results = []
  comment_sheet.comments.each do |comment|
    results << if options[:dry_run]
                 preview_issue(comment, comment_sheet)
               else
                 create_issue(comment, comment_sheet, options)
               end
  end

  # Update YAML with GitHub info after creation (unless dry run)
  update_yaml_with_github_info(yaml_file, comment_sheet, results, options) unless options[:dry_run]

  results
end