fbe 0.0.76 → 0.0.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +1 -1
- data/Gemfile.lock +31 -30
- data/fbe.gemspec +15 -14
- data/lib/fbe/bylaws.rb +12 -8
- data/lib/fbe/conclude.rb +73 -11
- data/lib/fbe/copy.rb +8 -1
- data/lib/fbe/enter.rb +39 -0
- data/lib/fbe/fb.rb +5 -0
- data/lib/fbe/github_graph.rb +8 -3
- data/lib/fbe/if_absent.rb +23 -2
- data/lib/fbe/issue.rb +7 -0
- data/lib/fbe/iterate.rb +46 -7
- data/lib/fbe/just_one.rb +14 -0
- data/lib/fbe/middleware/quota.rb +4 -0
- data/lib/fbe/middleware.rb +4 -0
- data/lib/fbe/octo.rb +9 -8
- data/lib/fbe/overwrite.rb +7 -5
- data/lib/fbe/pmp.rb +14 -4
- data/lib/fbe/regularly.rb +2 -0
- data/lib/fbe/repeatedly.rb +2 -0
- data/lib/fbe/sec.rb +9 -2
- data/lib/fbe/unmask_repos.rb +44 -30
- data/lib/fbe/who.rb +8 -1
- data/lib/fbe.rb +3 -3
- data/test/fbe/test_conclude.rb +0 -20
- data/test/fbe/test_enter.rb +50 -0
- metadata +56 -40
    
        data/lib/fbe/middleware.rb
    CHANGED
    
    
    
        data/lib/fbe/octo.rb
    CHANGED
    
    | @@ -22,27 +22,28 @@ | |
| 22 22 | 
             
            # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         | 
| 23 23 | 
             
            # SOFTWARE.
         | 
| 24 24 |  | 
| 25 | 
            -
            require 'loog'
         | 
| 26 25 | 
             
            require 'decoor'
         | 
| 26 | 
            +
            require 'faraday/http_cache'
         | 
| 27 | 
            +
            require 'faraday/retry'
         | 
| 28 | 
            +
            require 'loog'
         | 
| 27 29 | 
             
            require 'obk'
         | 
| 28 30 | 
             
            require 'octokit'
         | 
| 29 31 | 
             
            require 'verbose'
         | 
| 30 | 
            -
            require 'faraday/http_cache'
         | 
| 31 | 
            -
            require 'faraday/retry'
         | 
| 32 32 | 
             
            require_relative '../fbe'
         | 
| 33 33 | 
             
            require_relative 'middleware'
         | 
| 34 | 
            -
            require_relative 'middleware/quota'
         | 
| 35 34 | 
             
            require_relative 'middleware/logging_formatter'
         | 
| 35 | 
            +
            require_relative 'middleware/quota'
         | 
| 36 36 |  | 
| 37 | 
            -
            #  | 
| 37 | 
            +
            # Makes a call to the GitHub API.
         | 
| 38 38 | 
             
            #
         | 
| 39 | 
            -
            # It is supposed to be used instead of Octokit  | 
| 40 | 
            -
            # is pre-configured and enables additional  | 
| 39 | 
            +
            # It is supposed to be used instead of +Octokit::Client+, because it
         | 
| 40 | 
            +
            # is pre-configured and enables additional features, such as retrying,
         | 
| 41 41 | 
             
            # logging, and caching.
         | 
| 42 42 | 
             
            #
         | 
| 43 43 | 
             
            # @param [Judges::Options] options The options available globally
         | 
| 44 44 | 
             
            # @param [Hash] global Hash of global options
         | 
| 45 45 | 
             
            # @param [Loog] loog Logging facility
         | 
| 46 | 
            +
            # @return [Hash] Usually returns a JSON, as it comes from the GitHub API
         | 
| 46 47 | 
             
            def Fbe.octo(options: $options, global: $global, loog: $loog)
         | 
| 47 48 | 
             
              raise 'The $global is not set' if global.nil?
         | 
| 48 49 | 
             
              global[:octo] ||=
         | 
| @@ -132,7 +133,7 @@ def Fbe.octo(options: $options, global: $global, loog: $loog) | |
| 132 133 | 
             
                    def repo_id_by_name(name)
         | 
| 133 134 | 
             
                      json = @origin.repository(name)
         | 
| 134 135 | 
             
                      id = json[:id]
         | 
| 135 | 
            -
                      @loog.debug("GitHub repository #{name} has an ID: ##{id}")
         | 
| 136 | 
            +
                      @loog.debug("GitHub repository #{name.inspect} has an ID: ##{id}")
         | 
| 136 137 | 
             
                      id
         | 
| 137 138 | 
             
                    end
         | 
| 138 139 |  | 
    
        data/lib/fbe/overwrite.rb
    CHANGED
    
    | @@ -25,18 +25,19 @@ | |
| 25 25 | 
             
            require_relative '../fbe'
         | 
| 26 26 | 
             
            require_relative 'fb'
         | 
| 27 27 |  | 
| 28 | 
            -
            #  | 
| 28 | 
            +
            # Overwrites a property in the fact.
         | 
| 29 29 | 
             
            #
         | 
| 30 30 | 
             
            # If the property doesn't exist in the fact, it will be added. If it does
         | 
| 31 | 
            -
            # exist, it will be  | 
| 32 | 
            -
            # created, and property set).
         | 
| 31 | 
            +
            # exist, it will be re-set (the entire fact will be destroyed, new fact
         | 
| 32 | 
            +
            # created, and property set with the new value).
         | 
| 33 33 | 
             
            #
         | 
| 34 | 
            -
            # It is important that the fact has +_id+ property. If it doesn't, | 
| 35 | 
            -
            # will be raised.
         | 
| 34 | 
            +
            # It is important that the fact has the +_id+ property. If it doesn't,
         | 
| 35 | 
            +
            # an exception will be raised.
         | 
| 36 36 | 
             
            #
         | 
| 37 37 | 
             
            # @param [Factbase::Fact] fact The fact to modify
         | 
| 38 38 | 
             
            # @param [String] property The name of the property to set
         | 
| 39 39 | 
             
            # @param [Any] value The value to set
         | 
| 40 | 
            +
            # @return [nil] Nothing
         | 
| 40 41 | 
             
            def Fbe.overwrite(fact, property, value, fb: Fbe.fb)
         | 
| 41 42 | 
             
              raise 'The fact is nil' if fact.nil?
         | 
| 42 43 | 
             
              raise "The property is not a String but #{property.class} (#{property})" unless property.is_a?(String)
         | 
| @@ -56,4 +57,5 @@ def Fbe.overwrite(fact, property, value, fb: Fbe.fb) | |
| 56 57 | 
             
                  n.send("#{k}=", v)
         | 
| 57 58 | 
             
                end
         | 
| 58 59 | 
             
              end
         | 
| 60 | 
            +
              nil
         | 
| 59 61 | 
             
            end
         | 
    
        data/lib/fbe/pmp.rb
    CHANGED
    
    | @@ -23,24 +23,34 @@ | |
| 23 23 | 
             
            # SOFTWARE.
         | 
| 24 24 |  | 
| 25 25 | 
             
            require 'others'
         | 
| 26 | 
            -
            require_relative 'fb'
         | 
| 27 26 | 
             
            require_relative '../fbe'
         | 
| 27 | 
            +
            require_relative 'fb'
         | 
| 28 28 |  | 
| 29 | 
            -
            #  | 
| 29 | 
            +
            # Takes configuration parameter from the "PMP" fact.
         | 
| 30 | 
            +
            #
         | 
| 31 | 
            +
            # The factbase may have a few facts with the +what+ set to +pmp+ (stands for
         | 
| 32 | 
            +
            # "project management plan"). These facts contain information that configure
         | 
| 33 | 
            +
            # the project. It is expected that every fact with the +what+ set to +pmp+ also
         | 
| 34 | 
            +
            # contains the +area+ property, which is set to one of nine values: +scope+,
         | 
| 35 | 
            +
            # +time+, +cost+, etc. (by nine process areas in the PMBOK).
         | 
| 30 36 | 
             
            #
         | 
| 31 37 | 
             
            # @param [Factbase] fb The factbase
         | 
| 32 38 | 
             
            # @param [Hash] global The hash for global caching
         | 
| 33 39 | 
             
            # @param [Judges::Options] options The options coming from the +judges+ tool
         | 
| 34 40 | 
             
            # @param [Loog] loog The logging facility
         | 
| 41 | 
            +
            # @return [String|Integer] The value of the property found
         | 
| 35 42 | 
             
            def Fbe.pmp(fb: Fbe.fb, global: $global, options: $options, loog: $loog)
         | 
| 36 43 | 
             
              others do |*args1|
         | 
| 37 44 | 
             
                area = args1.first
         | 
| 45 | 
            +
                unless %w[cost scope hr time procurement risk integration quality communication].include?(area.to_s)
         | 
| 46 | 
            +
                  raise "Invalid area #{area.inspect} (not part of PMBOK)"
         | 
| 47 | 
            +
                end
         | 
| 38 48 | 
             
                others do |*args2|
         | 
| 39 49 | 
             
                  param = args2.first
         | 
| 40 50 | 
             
                  f = Fbe.fb(global:, fb:, options:, loog:).query("(and (eq what 'pmp') (eq area '#{area}'))").each.to_a.first
         | 
| 41 | 
            -
                  raise "Unknown area  | 
| 51 | 
            +
                  raise "Unknown area #{area.inspect}" if f.nil?
         | 
| 42 52 | 
             
                  r = f[param]
         | 
| 43 | 
            -
                  raise "Unknown property  | 
| 53 | 
            +
                  raise "Unknown property #{param.inspect} in the #{area.inspect} area" if r.nil?
         | 
| 44 54 | 
             
                  r.first
         | 
| 45 55 | 
             
                end
         | 
| 46 56 | 
             
              end
         | 
    
        data/lib/fbe/regularly.rb
    CHANGED
    
    | @@ -33,6 +33,7 @@ require_relative 'fb' | |
| 33 33 | 
             
            # @param [Factbase] fb The factbase
         | 
| 34 34 | 
             
            # @param [String] judge The name of the judge, from the +judges+ tool
         | 
| 35 35 | 
             
            # @param [Loog] loog The logging facility
         | 
| 36 | 
            +
            # @return [nil] Nothing
         | 
| 36 37 | 
             
            def Fbe.regularly(area, p_every_days, p_since_days = nil, fb: Fbe.fb, judge: $judge, loog: $loog, &)
         | 
| 37 38 | 
             
              pmp = fb.query("(and (eq what 'pmp') (eq area '#{area}') (exists #{p_every_days}))").each.to_a.first
         | 
| 38 39 | 
             
              interval = pmp.nil? ? 7 : pmp[p_every_days].first
         | 
| @@ -53,4 +54,5 @@ def Fbe.regularly(area, p_every_days, p_since_days = nil, fb: Fbe.fb, judge: $ju | |
| 53 54 | 
             
                f.since = since
         | 
| 54 55 | 
             
              end
         | 
| 55 56 | 
             
              yield f
         | 
| 57 | 
            +
              nil
         | 
| 56 58 | 
             
            end
         | 
    
        data/lib/fbe/repeatedly.rb
    CHANGED
    
    | @@ -33,6 +33,7 @@ require_relative 'overwrite' | |
| 33 33 | 
             
            # @param [Factbase] fb The factbase
         | 
| 34 34 | 
             
            # @param [String] judge The name of the judge, from the +judges+ tool
         | 
| 35 35 | 
             
            # @param [Loog] loog The logging facility
         | 
| 36 | 
            +
            # @return [nil] Nothing
         | 
| 36 37 | 
             
            def Fbe.repeatedly(area, p_every_hours, fb: Fbe.fb, judge: $judge, loog: $loog, &)
         | 
| 37 38 | 
             
              pmp = fb.query("(and (eq what 'pmp') (eq area '#{area}') (exists #{p_every_hours}))").each.to_a.first
         | 
| 38 39 | 
             
              hours = pmp.nil? ? 24 : pmp[p_every_hours].first
         | 
| @@ -51,4 +52,5 @@ def Fbe.repeatedly(area, p_every_hours, fb: Fbe.fb, judge: $judge, loog: $loog, | |
| 51 52 | 
             
              end
         | 
| 52 53 | 
             
              Fbe.overwrite(f, 'when', Time.now)
         | 
| 53 54 | 
             
              yield fb.query("(and (eq what '#{judge}'))").each.to_a.first
         | 
| 55 | 
            +
              nil
         | 
| 54 56 | 
             
            end
         | 
    
        data/lib/fbe/sec.rb
    CHANGED
    
    | @@ -26,11 +26,16 @@ require_relative '../fbe' | |
| 26 26 |  | 
| 27 27 | 
             
            # Converts number of seconds into text.
         | 
| 28 28 | 
             
            #
         | 
| 29 | 
            +
            # THe number of seconds is taken from the +fact+ provided, usually stored
         | 
| 30 | 
            +
            # there in the +seconds+ property. The seconds are formatted to hours,
         | 
| 31 | 
            +
            # days, or weeks.
         | 
| 32 | 
            +
            #
         | 
| 29 33 | 
             
            # @param [Factbase::Fact] fact The fact, where to get the number of seconds
         | 
| 30 34 | 
             
            # @param [String] prop The property in the fact, with the seconds
         | 
| 35 | 
            +
            # @return [String] Time interval as a text
         | 
| 31 36 | 
             
            def Fbe.sec(fact, prop = :seconds)
         | 
| 32 37 | 
             
              s = fact[prop.to_s]
         | 
| 33 | 
            -
              raise "There is no #{prop} property" if s.nil?
         | 
| 38 | 
            +
              raise "There is no #{prop.inspect} property" if s.nil?
         | 
| 34 39 | 
             
              s = s.first.to_i
         | 
| 35 40 | 
             
              if s < 60
         | 
| 36 41 | 
             
                format('%d seconds', s)
         | 
| @@ -38,7 +43,9 @@ def Fbe.sec(fact, prop = :seconds) | |
| 38 43 | 
             
                format('%d minutes', s / 60)
         | 
| 39 44 | 
             
              elsif s < 60 * 60 * 24
         | 
| 40 45 | 
             
                format('%d hours', s / (60 * 60))
         | 
| 41 | 
            -
               | 
| 46 | 
            +
              elsif s < 7 * 60 * 60 * 24
         | 
| 42 47 | 
             
                format('%d days', s / (60 * 60 * 24))
         | 
| 48 | 
            +
              else
         | 
| 49 | 
            +
                format('%d weeks', s / (7 * 60 * 60 * 24))
         | 
| 43 50 | 
             
              end
         | 
| 44 51 | 
             
            end
         | 
    
        data/lib/fbe/unmask_repos.rb
    CHANGED
    
    | @@ -22,40 +22,54 @@ | |
| 22 22 | 
             
            # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         | 
| 23 23 | 
             
            # SOFTWARE.
         | 
| 24 24 |  | 
| 25 | 
            +
            require_relative '../fbe'
         | 
| 25 26 | 
             
            require_relative 'octo'
         | 
| 26 27 |  | 
| 27 | 
            -
            #  | 
| 28 | 
            -
            # | 
| 29 | 
            -
            #  | 
| 30 | 
            -
            #  | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
               | 
| 28 | 
            +
            # Converts mask to repository name.
         | 
| 29 | 
            +
            #
         | 
| 30 | 
            +
            # This function takes something like +"zerocracy/*"+ as an input and returns
         | 
| 31 | 
            +
            # a regular expression that may match repositories defined by this mask, which
         | 
| 32 | 
            +
            # is +/zerocracy\/.*+ in this particular case.
         | 
| 33 | 
            +
            #
         | 
| 34 | 
            +
            # @param [String] mask The mask
         | 
| 35 | 
            +
            # @return [Regex] Regular expression
         | 
| 36 | 
            +
            def Fbe.mask_to_regex(mask)
         | 
| 37 | 
            +
              org, repo = mask.split('/')
         | 
| 38 | 
            +
              raise "Org '#{org}' can't have an asterisk" if org.include?('*')
         | 
| 39 | 
            +
              Regexp.compile("#{org}/#{repo.gsub('*', '.*')}")
         | 
| 40 | 
            +
            end
         | 
| 37 41 |  | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
             | 
| 43 | 
            -
             | 
| 44 | 
            -
             | 
| 45 | 
            -
             | 
| 46 | 
            -
             | 
| 47 | 
            -
             | 
| 48 | 
            -
             | 
| 49 | 
            -
             | 
| 50 | 
            -
             | 
| 42 | 
            +
            # Builds a list of repositories required by the +repositories+ option.
         | 
| 43 | 
            +
            #
         | 
| 44 | 
            +
            # The +repositories+ option defined in the +$options+ must contain something
         | 
| 45 | 
            +
            # like "zerocracy/fbe,zerocracy/ab*" (comma-separated list of masks). This
         | 
| 46 | 
            +
            # function will go to the GitHub API and fetch all available repositories
         | 
| 47 | 
            +
            # by these masks.
         | 
| 48 | 
            +
            #
         | 
| 49 | 
            +
            # @param [Judges::Options] options The options coming from the +judges+ tool
         | 
| 50 | 
            +
            # @param [Hash] global The hash for global caching
         | 
| 51 | 
            +
            # @param [Loog] loog The logging facility
         | 
| 52 | 
            +
            # @return [Array<String>] List of repository full names
         | 
| 53 | 
            +
            def Fbe.unmask_repos(options: $options, global: $global, loog: $loog)
         | 
| 54 | 
            +
              repos = []
         | 
| 55 | 
            +
              octo = Fbe.octo(loog:, global:, options:)
         | 
| 56 | 
            +
              masks = (options.repositories || '').split(',')
         | 
| 57 | 
            +
              masks.reject { |m| m.start_with?('-') }.each do |mask|
         | 
| 58 | 
            +
                unless mask.include?('*')
         | 
| 59 | 
            +
                  repos << mask
         | 
| 60 | 
            +
                  next
         | 
| 51 61 | 
             
                end
         | 
| 52 | 
            -
                 | 
| 53 | 
            -
             | 
| 54 | 
            -
                  repos | 
| 62 | 
            +
                re = Fbe.mask_to_regex(mask)
         | 
| 63 | 
            +
                octo.repositories(mask.split('/')[0]).each do |r|
         | 
| 64 | 
            +
                  repos << r[:full_name] if re.match?(r[:full_name])
         | 
| 55 65 | 
             
                end
         | 
| 56 | 
            -
                repos.reject! { |repo| octo.repository(repo)[:archived] }
         | 
| 57 | 
            -
                raise "No repos found matching: #{options.repositories}" if repos.empty?
         | 
| 58 | 
            -
                loog.debug("Scanning #{repos.size} repositories: #{repos.join(', ')}...")
         | 
| 59 | 
            -
                repos
         | 
| 60 66 | 
             
              end
         | 
| 67 | 
            +
              masks.select { |m| m.start_with?('-') }.each do |mask|
         | 
| 68 | 
            +
                re = Fbe.mask_to_regex(mask[1..])
         | 
| 69 | 
            +
                repos.reject! { |r| re.match?(r) }
         | 
| 70 | 
            +
              end
         | 
| 71 | 
            +
              repos.reject! { |repo| octo.repository(repo)[:archived] }
         | 
| 72 | 
            +
              raise "No repos found matching: #{options.repositories}" if repos.empty?
         | 
| 73 | 
            +
              loog.debug("Scanning #{repos.size} repositories: #{repos.join(', ')}...")
         | 
| 74 | 
            +
              repos
         | 
| 61 75 | 
             
            end
         | 
    
        data/lib/fbe/who.rb
    CHANGED
    
    | @@ -23,17 +23,24 @@ | |
| 23 23 | 
             
            # SOFTWARE.
         | 
| 24 24 |  | 
| 25 25 | 
             
            require_relative '../fbe'
         | 
| 26 | 
            +
            require_relative 'octo'
         | 
| 26 27 |  | 
| 27 28 | 
             
            # Converts an ID of GitHub user into a nicely formatting string with his name.
         | 
| 28 29 | 
             
            #
         | 
| 30 | 
            +
            # The ID of the user (integer) is expected to be stored in the +who+ property of the
         | 
| 31 | 
            +
            # provided +fact+. This function makes a live request to GitHub API in order
         | 
| 32 | 
            +
            # to find out what is the name of the user. For example, the ID +526301+
         | 
| 33 | 
            +
            # will be converted to the +"@yegor256"+ string.
         | 
| 34 | 
            +
            #
         | 
| 29 35 | 
             
            # @param [Factbase::Fact] fact The fact, where to get the ID of GitHub user
         | 
| 30 36 | 
             
            # @param [String] prop The property in the fact, with the ID
         | 
| 31 37 | 
             
            # @param [Judges::Options] options The options coming from the +judges+ tool
         | 
| 32 38 | 
             
            # @param [Hash] global The hash for global caching
         | 
| 33 39 | 
             
            # @param [Loog] loog The logging facility
         | 
| 40 | 
            +
            # @return [String] Full name of the user
         | 
| 34 41 | 
             
            def Fbe.who(fact, prop = :who, options: $options, global: $global, loog: $loog)
         | 
| 35 42 | 
             
              id = fact[prop.to_s]
         | 
| 36 | 
            -
              raise "There is no #{prop} property" if id.nil?
         | 
| 43 | 
            +
              raise "There is no #{prop.inspect} property" if id.nil?
         | 
| 37 44 | 
             
              id = id.first.to_i
         | 
| 38 45 | 
             
              "@#{Fbe.octo(options:, global:, loog:).user_name_by_id(id)}"
         | 
| 39 46 | 
             
            end
         | 
    
        data/lib/fbe.rb
    CHANGED
    
    | @@ -20,12 +20,12 @@ | |
| 20 20 | 
             
            # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         | 
| 21 21 | 
             
            # SOFTWARE.
         | 
| 22 22 |  | 
| 23 | 
            -
            # The module.
         | 
| 23 | 
            +
            # The main and only module of this gem.
         | 
| 24 24 | 
             
            #
         | 
| 25 25 | 
             
            # Author:: Yegor Bugayenko (yegor256@gmail.com)
         | 
| 26 26 | 
             
            # Copyright:: Copyright (c) 2024 Zerocracy
         | 
| 27 27 | 
             
            # License:: MIT
         | 
| 28 28 | 
             
            module Fbe
         | 
| 29 | 
            -
              # Current version of the gem (changed by  | 
| 30 | 
            -
              VERSION = '0.0. | 
| 29 | 
            +
              # Current version of the gem (changed by +.rultor.yml+ on every release)
         | 
| 30 | 
            +
              VERSION = '0.0.78'
         | 
| 31 31 | 
             
            end
         | 
    
        data/test/fbe/test_conclude.rb
    CHANGED
    
    | @@ -64,26 +64,6 @@ class TestConclude < Minitest::Test | |
| 64 64 | 
             
                assert_equal('something funny', f.details)
         | 
| 65 65 | 
             
              end
         | 
| 66 66 |  | 
| 67 | 
            -
              def test_maybe
         | 
| 68 | 
            -
                options = Judges::Options.new
         | 
| 69 | 
            -
                fb = Fbe.fb(fb: Factbase.new, global: {}, options:, loog: Loog::NULL)
         | 
| 70 | 
            -
                fb.insert.foo = 1
         | 
| 71 | 
            -
                Fbe.conclude(fb:, judge: 'issue-was-opened', loog: Loog::NULL, options:, global: {}) do
         | 
| 72 | 
            -
                  on '(exists foo)'
         | 
| 73 | 
            -
                  maybe do |n, prev|
         | 
| 74 | 
            -
                    n.repository = 111
         | 
| 75 | 
            -
                    n.where = 'github'
         | 
| 76 | 
            -
                    n.issue = prev.foo
         | 
| 77 | 
            -
                    n.who = 777
         | 
| 78 | 
            -
                    n.when = Time.now
         | 
| 79 | 
            -
                    "it's a test." * 20
         | 
| 80 | 
            -
                  end
         | 
| 81 | 
            -
                end
         | 
| 82 | 
            -
                f = fb.query('(exists issue)').each.to_a[0]
         | 
| 83 | 
            -
                assert_equal(1, f.issue)
         | 
| 84 | 
            -
                assert(f._id.positive?)
         | 
| 85 | 
            -
              end
         | 
| 86 | 
            -
             | 
| 87 67 | 
             
              def test_consider
         | 
| 88 68 | 
             
                fb = Factbase.new
         | 
| 89 69 | 
             
                fb.insert.foo = 1
         | 
| @@ -0,0 +1,50 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # MIT License
         | 
| 4 | 
            +
            #
         | 
| 5 | 
            +
            # Copyright (c) 2024 Zerocracy
         | 
| 6 | 
            +
            #
         | 
| 7 | 
            +
            # Permission is hereby granted, free of charge, to any person obtaining a copy
         | 
| 8 | 
            +
            # of this software and associated documentation files (the "Software"), to deal
         | 
| 9 | 
            +
            # in the Software without restriction, including without limitation the rights
         | 
| 10 | 
            +
            # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         | 
| 11 | 
            +
            # copies of the Software, and to permit persons to whom the Software is
         | 
| 12 | 
            +
            # furnished to do so, subject to the following conditions:
         | 
| 13 | 
            +
            #
         | 
| 14 | 
            +
            # The above copyright notice and this permission notice shall be included in all
         | 
| 15 | 
            +
            # copies or substantial portions of the Software.
         | 
| 16 | 
            +
            #
         | 
| 17 | 
            +
            # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         | 
| 18 | 
            +
            # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         | 
| 19 | 
            +
            # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         | 
| 20 | 
            +
            # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         | 
| 21 | 
            +
            # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         | 
| 22 | 
            +
            # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         | 
| 23 | 
            +
            # SOFTWARE.
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            require 'minitest/autorun'
         | 
| 26 | 
            +
            require 'loog'
         | 
| 27 | 
            +
            require_relative '../test__helper'
         | 
| 28 | 
            +
            require_relative '../../lib/fbe/enter'
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            # Test.
         | 
| 31 | 
            +
            # Author:: Yegor Bugayenko (yegor256@gmail.com)
         | 
| 32 | 
            +
            # Copyright:: Copyright (c) 2024 Zerocracy
         | 
| 33 | 
            +
            # License:: MIT
         | 
| 34 | 
            +
            class TestEnter < Minitest::Test
         | 
| 35 | 
            +
              def test_simple
         | 
| 36 | 
            +
                WebMock.disable_net_connect!
         | 
| 37 | 
            +
                options = Judges::Options.new({ 'zerocracy_token' => '00000-0000-0000-00000' })
         | 
| 38 | 
            +
                stub_request(:get, 'https://api.zerocracy.com/valves/result?badge=foo')
         | 
| 39 | 
            +
                  .to_return(status: 204)
         | 
| 40 | 
            +
                stub_request(:post, 'https://api.zerocracy.com/valves/add?badge=foo&job=0&result=hi&why=no%20reason')
         | 
| 41 | 
            +
                  .to_return(status: 302)
         | 
| 42 | 
            +
                assert_equal('hi', Fbe.enter('foo', 'no reason', options:, loog: Loog::NULL) { 'hi' })
         | 
| 43 | 
            +
              end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
              def test_in_testing_mode
         | 
| 46 | 
            +
                WebMock.enable_net_connect!
         | 
| 47 | 
            +
                options = Judges::Options.new({ 'testing' => true })
         | 
| 48 | 
            +
                assert_equal('hi', Fbe.enter('foo', 'no reason', options:, loog: Loog::NULL) { 'hi' })
         | 
| 49 | 
            +
              end
         | 
| 50 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,139 +1,153 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: fbe
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.78
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Yegor Bugayenko
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2024-10- | 
| 11 | 
            +
            date: 2024-10-14 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: backtrace
         | 
| 15 15 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 16 | 
             
                requirements:
         | 
| 17 | 
            -
                - - " | 
| 17 | 
            +
                - - "~>"
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 19 | 
             
                    version: '0'
         | 
| 20 20 | 
             
              type: :runtime
         | 
| 21 21 | 
             
              prerelease: false
         | 
| 22 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 23 | 
             
                requirements:
         | 
| 24 | 
            -
                - - " | 
| 24 | 
            +
                - - "~>"
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '0'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: baza.rb
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - "~>"
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '0'
         | 
| 34 | 
            +
              type: :runtime
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - "~>"
         | 
| 25 39 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 40 | 
             
                    version: '0'
         | 
| 27 41 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 42 | 
             
              name: decoor
         | 
| 29 43 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 44 | 
             
                requirements:
         | 
| 31 | 
            -
                - - " | 
| 45 | 
            +
                - - "~>"
         | 
| 32 46 | 
             
                  - !ruby/object:Gem::Version
         | 
| 33 47 | 
             
                    version: '0'
         | 
| 34 48 | 
             
              type: :runtime
         | 
| 35 49 | 
             
              prerelease: false
         | 
| 36 50 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 51 | 
             
                requirements:
         | 
| 38 | 
            -
                - - " | 
| 52 | 
            +
                - - "~>"
         | 
| 39 53 | 
             
                  - !ruby/object:Gem::Version
         | 
| 40 54 | 
             
                    version: '0'
         | 
| 41 55 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 42 56 | 
             
              name: factbase
         | 
| 43 57 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 58 | 
             
                requirements:
         | 
| 45 | 
            -
                - - " | 
| 59 | 
            +
                - - "~>"
         | 
| 46 60 | 
             
                  - !ruby/object:Gem::Version
         | 
| 47 61 | 
             
                    version: '0'
         | 
| 48 62 | 
             
              type: :runtime
         | 
| 49 63 | 
             
              prerelease: false
         | 
| 50 64 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 65 | 
             
                requirements:
         | 
| 52 | 
            -
                - - " | 
| 66 | 
            +
                - - "~>"
         | 
| 53 67 | 
             
                  - !ruby/object:Gem::Version
         | 
| 54 68 | 
             
                    version: '0'
         | 
| 55 69 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 56 70 | 
             
              name: faraday
         | 
| 57 71 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 72 | 
             
                requirements:
         | 
| 59 | 
            -
                - - " | 
| 73 | 
            +
                - - "~>"
         | 
| 60 74 | 
             
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            -
                    version: ' | 
| 75 | 
            +
                    version: '2'
         | 
| 62 76 | 
             
              type: :runtime
         | 
| 63 77 | 
             
              prerelease: false
         | 
| 64 78 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 79 | 
             
                requirements:
         | 
| 66 | 
            -
                - - " | 
| 80 | 
            +
                - - "~>"
         | 
| 67 81 | 
             
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            -
                    version: ' | 
| 82 | 
            +
                    version: '2'
         | 
| 69 83 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 70 84 | 
             
              name: faraday-http-cache
         | 
| 71 85 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 86 | 
             
                requirements:
         | 
| 73 | 
            -
                - - " | 
| 87 | 
            +
                - - "~>"
         | 
| 74 88 | 
             
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            -
                    version: ' | 
| 89 | 
            +
                    version: '2'
         | 
| 76 90 | 
             
              type: :runtime
         | 
| 77 91 | 
             
              prerelease: false
         | 
| 78 92 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 93 | 
             
                requirements:
         | 
| 80 | 
            -
                - - " | 
| 94 | 
            +
                - - "~>"
         | 
| 81 95 | 
             
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            -
                    version: ' | 
| 96 | 
            +
                    version: '2'
         | 
| 83 97 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 84 98 | 
             
              name: faraday-multipart
         | 
| 85 99 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 86 100 | 
             
                requirements:
         | 
| 87 | 
            -
                - - " | 
| 101 | 
            +
                - - "~>"
         | 
| 88 102 | 
             
                  - !ruby/object:Gem::Version
         | 
| 89 | 
            -
                    version: ' | 
| 103 | 
            +
                    version: '1'
         | 
| 90 104 | 
             
              type: :runtime
         | 
| 91 105 | 
             
              prerelease: false
         | 
| 92 106 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 93 107 | 
             
                requirements:
         | 
| 94 | 
            -
                - - " | 
| 108 | 
            +
                - - "~>"
         | 
| 95 109 | 
             
                  - !ruby/object:Gem::Version
         | 
| 96 | 
            -
                    version: ' | 
| 110 | 
            +
                    version: '1'
         | 
| 97 111 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 98 112 | 
             
              name: faraday-retry
         | 
| 99 113 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 100 114 | 
             
                requirements:
         | 
| 101 | 
            -
                - - " | 
| 115 | 
            +
                - - "~>"
         | 
| 102 116 | 
             
                  - !ruby/object:Gem::Version
         | 
| 103 | 
            -
                    version: ' | 
| 117 | 
            +
                    version: '2'
         | 
| 104 118 | 
             
              type: :runtime
         | 
| 105 119 | 
             
              prerelease: false
         | 
| 106 120 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 107 121 | 
             
                requirements:
         | 
| 108 | 
            -
                - - " | 
| 122 | 
            +
                - - "~>"
         | 
| 109 123 | 
             
                  - !ruby/object:Gem::Version
         | 
| 110 | 
            -
                    version: ' | 
| 124 | 
            +
                    version: '2'
         | 
| 111 125 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 112 126 | 
             
              name: graphql-client
         | 
| 113 127 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 114 128 | 
             
                requirements:
         | 
| 115 | 
            -
                - - " | 
| 129 | 
            +
                - - "~>"
         | 
| 116 130 | 
             
                  - !ruby/object:Gem::Version
         | 
| 117 131 | 
             
                    version: '0'
         | 
| 118 132 | 
             
              type: :runtime
         | 
| 119 133 | 
             
              prerelease: false
         | 
| 120 134 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 121 135 | 
             
                requirements:
         | 
| 122 | 
            -
                - - " | 
| 136 | 
            +
                - - "~>"
         | 
| 123 137 | 
             
                  - !ruby/object:Gem::Version
         | 
| 124 138 | 
             
                    version: '0'
         | 
| 125 139 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 126 140 | 
             
              name: judges
         | 
| 127 141 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 128 142 | 
             
                requirements:
         | 
| 129 | 
            -
                - - " | 
| 143 | 
            +
                - - "~>"
         | 
| 130 144 | 
             
                  - !ruby/object:Gem::Version
         | 
| 131 145 | 
             
                    version: '0'
         | 
| 132 146 | 
             
              type: :runtime
         | 
| 133 147 | 
             
              prerelease: false
         | 
| 134 148 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 135 149 | 
             
                requirements:
         | 
| 136 | 
            -
                - - " | 
| 150 | 
            +
                - - "~>"
         | 
| 137 151 | 
             
                  - !ruby/object:Gem::Version
         | 
| 138 152 | 
             
                    version: '0'
         | 
| 139 153 | 
             
            - !ruby/object:Gem::Dependency
         | 
| @@ -154,70 +168,70 @@ dependencies: | |
| 154 168 | 
             
              name: loog
         | 
| 155 169 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 156 170 | 
             
                requirements:
         | 
| 157 | 
            -
                - - " | 
| 171 | 
            +
                - - "~>"
         | 
| 158 172 | 
             
                  - !ruby/object:Gem::Version
         | 
| 159 173 | 
             
                    version: '0'
         | 
| 160 174 | 
             
              type: :runtime
         | 
| 161 175 | 
             
              prerelease: false
         | 
| 162 176 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 163 177 | 
             
                requirements:
         | 
| 164 | 
            -
                - - " | 
| 178 | 
            +
                - - "~>"
         | 
| 165 179 | 
             
                  - !ruby/object:Gem::Version
         | 
| 166 180 | 
             
                    version: '0'
         | 
| 167 181 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 168 182 | 
             
              name: obk
         | 
| 169 183 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 170 184 | 
             
                requirements:
         | 
| 171 | 
            -
                - - " | 
| 185 | 
            +
                - - "~>"
         | 
| 172 186 | 
             
                  - !ruby/object:Gem::Version
         | 
| 173 187 | 
             
                    version: '0'
         | 
| 174 188 | 
             
              type: :runtime
         | 
| 175 189 | 
             
              prerelease: false
         | 
| 176 190 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 177 191 | 
             
                requirements:
         | 
| 178 | 
            -
                - - " | 
| 192 | 
            +
                - - "~>"
         | 
| 179 193 | 
             
                  - !ruby/object:Gem::Version
         | 
| 180 194 | 
             
                    version: '0'
         | 
| 181 195 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 182 196 | 
             
              name: octokit
         | 
| 183 197 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 184 198 | 
             
                requirements:
         | 
| 185 | 
            -
                - - " | 
| 199 | 
            +
                - - "~>"
         | 
| 186 200 | 
             
                  - !ruby/object:Gem::Version
         | 
| 187 | 
            -
                    version: ' | 
| 201 | 
            +
                    version: '9'
         | 
| 188 202 | 
             
              type: :runtime
         | 
| 189 203 | 
             
              prerelease: false
         | 
| 190 204 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 191 205 | 
             
                requirements:
         | 
| 192 | 
            -
                - - " | 
| 206 | 
            +
                - - "~>"
         | 
| 193 207 | 
             
                  - !ruby/object:Gem::Version
         | 
| 194 | 
            -
                    version: ' | 
| 208 | 
            +
                    version: '9'
         | 
| 195 209 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 196 210 | 
             
              name: others
         | 
| 197 211 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 198 212 | 
             
                requirements:
         | 
| 199 | 
            -
                - - " | 
| 213 | 
            +
                - - "~>"
         | 
| 200 214 | 
             
                  - !ruby/object:Gem::Version
         | 
| 201 215 | 
             
                    version: '0'
         | 
| 202 216 | 
             
              type: :runtime
         | 
| 203 217 | 
             
              prerelease: false
         | 
| 204 218 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 205 219 | 
             
                requirements:
         | 
| 206 | 
            -
                - - " | 
| 220 | 
            +
                - - "~>"
         | 
| 207 221 | 
             
                  - !ruby/object:Gem::Version
         | 
| 208 222 | 
             
                    version: '0'
         | 
| 209 223 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 210 224 | 
             
              name: verbose
         | 
| 211 225 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 212 226 | 
             
                requirements:
         | 
| 213 | 
            -
                - - " | 
| 227 | 
            +
                - - "~>"
         | 
| 214 228 | 
             
                  - !ruby/object:Gem::Version
         | 
| 215 229 | 
             
                    version: '0'
         | 
| 216 230 | 
             
              type: :runtime
         | 
| 217 231 | 
             
              prerelease: false
         | 
| 218 232 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 219 233 | 
             
                requirements:
         | 
| 220 | 
            -
                - - " | 
| 234 | 
            +
                - - "~>"
         | 
| 221 235 | 
             
                  - !ruby/object:Gem::Version
         | 
| 222 236 | 
             
                    version: '0'
         | 
| 223 237 | 
             
            description: A collection of extensions for a factbase, helping the judges of Zerocracy
         | 
| @@ -265,6 +279,7 @@ files: | |
| 265 279 | 
             
            - lib/fbe/bylaws.rb
         | 
| 266 280 | 
             
            - lib/fbe/conclude.rb
         | 
| 267 281 | 
             
            - lib/fbe/copy.rb
         | 
| 282 | 
            +
            - lib/fbe/enter.rb
         | 
| 268 283 | 
             
            - lib/fbe/fb.rb
         | 
| 269 284 | 
             
            - lib/fbe/github_graph.rb
         | 
| 270 285 | 
             
            - lib/fbe/if_absent.rb
         | 
| @@ -290,6 +305,7 @@ files: | |
| 290 305 | 
             
            - test/fbe/test_bylaws.rb
         | 
| 291 306 | 
             
            - test/fbe/test_conclude.rb
         | 
| 292 307 | 
             
            - test/fbe/test_copy.rb
         | 
| 308 | 
            +
            - test/fbe/test_enter.rb
         | 
| 293 309 | 
             
            - test/fbe/test_fb.rb
         | 
| 294 310 | 
             
            - test/fbe/test_github_graph.rb
         | 
| 295 311 | 
             
            - test/fbe/test_if_absent.rb
         |