Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Oct 13, 2024
1 parent f47a915 commit 94c45d2
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
6 changes: 6 additions & 0 deletions lib/fbe/iterate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
require_relative 'unmask_repos'

# Creates an instance of {Fbe::Iterate}.
#
# @param [Factbase] fb The global factbase provided by the +judges+ tool
# @param [Judges::Options] options The options coming from the +judges+ tool
# @param [Hash] global The hash for global caching
# @param [Loog] loog The logging facility
# @return [Fbe::Iterate] The instance of the class
def Fbe.iterate(fb: Fbe.fb, loog: $loog, options: $options, global: $global, &)
c = Fbe::Iterate.new(fb:, loog:, options:, global:)
c.instance_eval(&)
Expand Down
4 changes: 4 additions & 0 deletions lib/fbe/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
require_relative '../fbe'

# The module.
#
# Author:: Yegor Bugayenko (yegor256@gmail.com)
# Copyright:: Copyright (c) 2024 Zerocracy
# License:: MIT
module Fbe::Middleware
# empty
end
4 changes: 4 additions & 0 deletions lib/fbe/middleware/quota.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
require 'faraday'

# Faraday Middleware that monitors GitHub API rate limits.
#
# Author:: Yegor Bugayenko (yegor256@gmail.com)
# Copyright:: Copyright (c) 2024 Zerocracy
# License:: MIT
class Fbe::Middleware::Quota < Faraday::Middleware
def initialize(app, loog: Loog::NULL, pause: 60, limit: 100, rate: 5)
super(app)
Expand Down
12 changes: 7 additions & 5 deletions lib/fbe/overwrite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,19 @@
require_relative '../fbe'
require_relative 'fb'

# Overwrite a property in the fact.
# Overwrites a property in the fact.
#
# If the property doesn't exist in the fact, it will be added. If it does
# exist, it will be removed (the entire fact will be destroyed, new fact
# created, and property set).
# exist, it will be re-set (the entire fact will be destroyed, new fact
# created, and property set with the new value).
#
# It is important that the fact has +_id+ property. If it doesn't, an exception
# will be raised.
# It is important that the fact has the +_id+ property. If it doesn't,
# an exception will be raised.
#
# @param [Factbase::Fact] fact The fact to modify
# @param [String] property The name of the property to set
# @param [Any] value The value to set
# @return [nil] Nothing
def Fbe.overwrite(fact, property, value, fb: Fbe.fb)
raise 'The fact is nil' if fact.nil?
raise "The property is not a String but #{property.class} (#{property})" unless property.is_a?(String)
Expand All @@ -56,4 +57,5 @@ def Fbe.overwrite(fact, property, value, fb: Fbe.fb)
n.send("#{k}=", v)
end
end
nil
end
2 changes: 2 additions & 0 deletions lib/fbe/regularly.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
# @param [Factbase] fb The factbase
# @param [String] judge The name of the judge, from the +judges+ tool
# @param [Loog] loog The logging facility
# @return [nil] Nothing
def Fbe.regularly(area, p_every_days, p_since_days = nil, fb: Fbe.fb, judge: $judge, loog: $loog, &)
pmp = fb.query("(and (eq what 'pmp') (eq area '#{area}') (exists #{p_every_days}))").each.to_a.first
interval = pmp.nil? ? 7 : pmp[p_every_days].first
Expand All @@ -53,4 +54,5 @@ def Fbe.regularly(area, p_every_days, p_since_days = nil, fb: Fbe.fb, judge: $ju
f.since = since
end
yield f
nil
end
2 changes: 2 additions & 0 deletions lib/fbe/repeatedly.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
# @param [Factbase] fb The factbase
# @param [String] judge The name of the judge, from the +judges+ tool
# @param [Loog] loog The logging facility
# @return [nil] Nothing
def Fbe.repeatedly(area, p_every_hours, fb: Fbe.fb, judge: $judge, loog: $loog, &)
pmp = fb.query("(and (eq what 'pmp') (eq area '#{area}') (exists #{p_every_hours}))").each.to_a.first
hours = pmp.nil? ? 24 : pmp[p_every_hours].first
Expand All @@ -51,4 +52,5 @@ def Fbe.repeatedly(area, p_every_hours, fb: Fbe.fb, judge: $judge, loog: $loog,
end
Fbe.overwrite(f, 'when', Time.now)
yield fb.query("(and (eq what '#{judge}'))").each.to_a.first
nil
end

0 comments on commit 94c45d2

Please sign in to comment.