Sha256: 60f154647b6fbf845aec8084b6ecddf937db1b17cabf4264191cb8338f04929f
Contents?: true
Size: 1.34 KB
Versions: 1
Compression:
Stored size: 1.34 KB
Contents
# frozen_string_literal: true module Gem # :nodoc: # # Gem Author # # This class holds authors info to be used primarily in gem specs. # # ## Usage # # 1. Inherit +Gem::Author+ inside your gem and add the authors’ info. # # Example: # # module MyLib # class Author < Gem::Author # new( # name: 'Your Name', # email: 'Your.Name@email.service', # github: 'Your-GitHub-Username', # ) # end # end # # 2. You can call some helper methods now. # # Example: # # Gem::Specification.new do |spec| # spec.name = 'my_lib' # spec.version = MyLib::VERSION # spec.authors = MyLib::Author.names # spec.email = MyLib::Author.emails # spec.homepage = "#{MyLib::Author.github_url}/#{spec.name}" # end # Author ||= Struct.new( :name, :email, :github, ) do def self.inherited child super child.class_eval do class << self attr_reader :all include Author::ClassMethods end end end module self::ClassMethods # rubocop:disable Lint, Style def new(...) = (@all ||= []) << super def names = all.filter_map &:name def emails = all.filter_map &:email def github_url = all.filter_map(&:github_url).first end def github_url = github && "https://github.com/#{github}" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
magic-support-0.1.0 | lib/rubygems/author.rb |