Sha256: 3b4f01b46e9488974dcdd5a71e1ef4ed01589681124576e1f5ee74ced990e129
Contents?: true
Size: 1.79 KB
Versions: 2
Compression:
Stored size: 1.79 KB
Contents
require "pathname" module Licensed class Configuration < Hash attr_accessor :ui def initialize(options = {}) super() self.path = options["license-dir"] if options["license-dir"] update config_path.exist? ? YAML.load_file(config_path) : {} self["sources"] ||= {} self["reviewed"] ||= {} self["ignored"] ||= {} self["whitelist"] ||= [] @ui = Licensed::UI::Shell.new end def path @path ||= Pathname.new("vendor/licenses") end def path=(value) @path = Pathname.new(value) end def config_path path.join("config.yml") end def pwd Pathname.new(Dir.pwd) end def sources @sources ||= [ Source::Bundler.new(self), Source::Bower.new(self), Source::Cabal.new(self), Source::Go.new(self), Source::Manifest.new(self), Source::NPM.new(self), Source::Stack.new(self) ].select(&:enabled?) end def enabled?(source_type) self["sources"].fetch(source_type, true) end # Is the given dependency approved? def reviewed?(dependency) Array(self["reviewed"][dependency["type"]]).include?(dependency["name"]) end # Is the given dependency ignored? def ignored?(dependency) Array(self["ignored"][dependency["type"]]).include?(dependency["name"]) end # Is the license of the dependency whitelisted? def whitelisted?(dependency) Array(self["whitelist"]).include?(dependency["license"]) end def ignore(dependency) (self["ignored"][dependency["type"]] ||= []) << dependency["name"] end def review(dependency) (self["reviewed"][dependency["type"]] ||= []) << dependency["name"] end def whitelist(license) self["whitelist"] << license end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
licensed-0.11.1 | lib/licensed/configuration.rb |
licensed-0.11.0 | lib/licensed/configuration.rb |