<commit_before>module ::Concerns::Skill::GithubApiMethods
  extend ActiveSupport::Concern

  # ---------
  # CALLBACKS
  # ---------

  included do
    after_create :create_gist
    after_update :update_gist
  end

  def create_gist
    gist = self.creator.github_api.gists.create(
      description: self.title,
      public: false,
      files: files_for_gist
    )

    self.update_columns(gist_id: gist.id)
  rescue
    false
  end

  def update_gist
    self.creator.github_api.gists.find(self.gist_id)

    self.creator.github_api.gists.edit(
      self.gist_id,
      files: files_for_gist
    )
  rescue
    false
  end

  # --------------
  # SHARED METHODS
  # --------------

  def files_for_gist
    {
      "presentation.md" => {
        content: self.presentation
      }
    }
  end

  # ------------------
  # VIRTUAL ATTRIBUTES
  # ------------------

  def gist_url
    create_gist if self.gist_id.blank?
    "https://gist.github.com/#{self.gist_id}"
  end

end<commit_msg>updated skill gist integration<commit_after>module ::Concerns::Skill::GithubApiMethods
  extend ActiveSupport::Concern

  # ---------
  # CALLBACKS
  # ---------

  included do
    after_save :update_gist
  end

  def update_gist
    return create_gist if self.gist_id.blank?

    self.creator.github_api.gists.find(self.gist_id)

    self.creator.github_api.gists.edit(
      self.gist_id,
      files: files_for_gist
    )
  rescue
    false
  end

  def create_gist
    gist = self.creator.github_api.gists.create(
      description: self.title,
      public: false,
      files: files_for_gist
    )

    self.update_columns(gist_id: gist.id)
  rescue
    false
  end

  # --------------
  # SHARED METHODS
  # --------------

  def files_for_gist
    {
      "presentation.md" => {
        content: self.presentation
      }
    }
  end

  # ------------------
  # VIRTUAL ATTRIBUTES
  # ------------------

  def gist_url
    create_gist if self.gist_id.blank?
    "https://gist.github.com/#{self.gist_id}"
  end

end
{'fraction_non_alphanumeric': 0.16385302879841113, 'fraction_numerical': 0.0, 'mean_word_length': 1.8662873399715505, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5992924', 'n_tokens_mistral': 747, 'n_tokens_neox': 707, 'n_words': 114}