Sha256: c0dae595c99a1e86044f09de0f170504c3241de87058ca125f47c236a3308941

Contents?: true

Size: 1.98 KB

Versions: 17

Compression:

Stored size: 1.98 KB

Contents

# frozen_string_literal: true

# MIT License
#
# Copyright (c) 2024 Zerocracy
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

require 'liquid'
require_relative '../fbe'

# A generator of policies/bylaws.
#
# Author:: Yegor Bugayenko (yegor256@gmail.com)
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
# License:: MIT
def Fbe.bylaws(anger: 2, love: 2, paranoia: 2)
  raise 'The "anger" must be in the [0..4] interval' unless !anger.negative? && anger < 5
  raise 'The "lover" must be in the [0..4] interval' unless !love.negative? && love < 5
  raise 'The "paranoia" must be in the [1..4] interval' unless paranoia.positive? && paranoia < 5
  home = File.join(__dir__, '../../assets/bylaws')
  raise "The directory with templates is absent '#{home}'" unless File.exist?(home)
  Dir[File.join(home, '*.liquid')].to_h do |f|
    formula = Liquid::Template.parse(File.read(f)).render(
      'anger' => anger, 'love' => love, 'paranoia' => paranoia
    )
    [File.basename(f).gsub(/\.liquid$/, ''), formula]
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
fbe-0.0.76 lib/fbe/bylaws.rb
fbe-0.0.75 lib/fbe/bylaws.rb
fbe-0.0.74 lib/fbe/bylaws.rb
fbe-0.0.73 lib/fbe/bylaws.rb
fbe-0.0.72 lib/fbe/bylaws.rb
fbe-0.0.71 lib/fbe/bylaws.rb
fbe-0.0.70 lib/fbe/bylaws.rb
fbe-0.0.69 lib/fbe/bylaws.rb
fbe-0.0.68 lib/fbe/bylaws.rb
fbe-0.0.67 lib/fbe/bylaws.rb
fbe-0.0.66 lib/fbe/bylaws.rb
fbe-0.0.65 lib/fbe/bylaws.rb
fbe-0.0.64 lib/fbe/bylaws.rb
fbe-0.0.63 lib/fbe/bylaws.rb
fbe-0.0.62 lib/fbe/bylaws.rb
fbe-0.0.61 lib/fbe/bylaws.rb
fbe-0.0.60 lib/fbe/bylaws.rb