class Licensee::Rule

Constants

HASH_METHODS

Attributes

description[R]
group[R]
label[R]
tag[R]

Public Class Methods

all() click to toggle source
# File lib/licensee/rule.rb, line 22
def all
  @all ||= raw_rules.map do |group, rules|
    rules.map do |rule|
      Rule.new(
        tag:         rule['tag'],
        label:       rule['label'],
        description: rule['description'],
        group:       group
      )
    end
  end.flatten
end
file_path() click to toggle source
# File lib/licensee/rule.rb, line 40
def file_path
  dir = File.dirname(__FILE__)
  File.expand_path '../../vendor/choosealicense.com/_data/rules.yml', dir
end
find_by_tag(tag, group = nil)
find_by_tag_and_group(tag, group = nil) click to toggle source
# File lib/licensee/rule.rb, line 35
def find_by_tag_and_group(tag, group = nil)
  Rule.all.find { |r| r.tag == tag && (group.nil? || r.group == group) }
end
Also aliased as: find_by_tag
groups() click to toggle source
# File lib/licensee/rule.rb, line 49
def groups
  Rule.raw_rules.keys
end
new(tag: nil, label: nil, description: nil, group: nil) click to toggle source
# File lib/licensee/rule.rb, line 10
def initialize(tag: nil, label: nil, description: nil, group: nil)
  @tag = tag
  @label = label
  @description = description
  @group = group
end
raw_rules() click to toggle source
# File lib/licensee/rule.rb, line 45
def raw_rules
  YAML.safe_load File.read(Rule.file_path)
end

Public Instance Methods

inspect() click to toggle source
# File lib/licensee/rule.rb, line 17
def inspect
  "#<Licensee::Rule @tag=\"#{tag}\">"
end