-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Framework / spec: refactored author info
* Improved the API. * Extracted `Gem::Author` into Magic Support. * Replaced `Magic::Presenter::AUTHORS` with `Magic::Presenter::Author`.
- Loading branch information
1 parent
2855cf5
commit 8cfedd0
Showing
6 changed files
with
36 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
## [1.1.0] — UNRELEASED | ||
|
||
|
||
## [1.0.0] — 2024-11-23 | ||
|
||
This release marks the gem to be stable enough. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ gem 'puma' | |
|
||
gem 'sqlite3' | ||
gem 'combustion' | ||
gem 'magic-support' | ||
|
||
group :test do | ||
gem 'rspec' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
Gem::Author ||= Struct.new( | ||
:name, | ||
:email, | ||
:github, | ||
) do | ||
def github_url = github && "https://github.com/#{github}" | ||
begin | ||
gem_original_require lib = 'rubygems/author' | ||
rescue LoadError => error # HACK: install magic-support | ||
raise unless error.path == lib | ||
|
||
`gem install #{name = 'magic-support'} --ignore-dependencies --no-document` | ||
.match(/^Successfully installed (?<full_name>#{name}-.*)$/) | ||
&.match(:full_name) | ||
&.then { Bundler.bundle_path.join 'gems', _1, 'lib' } | ||
&.then { $LOAD_PATH << _1 } | ||
|
||
require error.path # retry | ||
end | ||
|
||
module Magic | ||
module Presenter # :nodoc: | ||
AUTHORS = [ # rubocop:disable Style/MutableConstant | ||
Gem::Author.new( | ||
name: 'Alexander Senko', | ||
email: 'Alexander.Senko@gmail.com', | ||
github: 'Alexander-Senko', | ||
), | ||
] | ||
|
||
class << AUTHORS | ||
def names = filter_map &:name | ||
def emails = filter_map &:email | ||
def github_url = filter_map(&:github_url).first | ||
module Presenter | ||
class Author < Gem::Author # :nodoc: | ||
new( | ||
name: 'Alexander Senko', | ||
email: 'Alexander.Senko@gmail.com', | ||
github: 'Alexander-Senko', | ||
) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,6 @@ | |
|
||
module Magic | ||
module Presenter | ||
VERSION = '1.0.0' | ||
VERSION = '1.1.0.alpha' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Magic | ||
module Presenter | ||
class Author < Gem::Author | ||
extend Gem::Author::ClassMethods | ||
|
||
attr_reader self.all: Array[self] | ||
end | ||
end | ||
end |