-
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.
- Loading branch information
1 parent
99833ef
commit 3676d9e
Showing
8 changed files
with
114 additions
and
44 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,12 +1,13 @@ | ||
require_relative "redminep/version" | ||
require_relative "redminep/definition" | ||
require_relative "redminep/plugin" | ||
require_relative "redminep/theme" | ||
require_relative "redminep/commands/install" | ||
require_relative "redminep/source/base" | ||
require_relative "redminep/source/git" | ||
require_relative "redminep/cli" | ||
|
||
module Redminep | ||
class Error < StandardError; end | ||
Config = Data.define(:definition_file) | ||
|
||
def self.config | ||
@config ||= Config.new(definition_file: ".redminep.rb") | ||
end | ||
end | ||
|
||
require "zeitwerk" | ||
|
||
loader = Zeitwerk::Loader.for_gem | ||
loader.setup | ||
loader.eager_load |
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
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,26 @@ | ||
module Redminep | ||
module Commands | ||
class Uninstall | ||
def call | ||
definition = Definition.load_from_file | ||
|
||
uninsall_themes(definition.themes) | ||
uninstall_plugins(definition.plugins) | ||
end | ||
|
||
private | ||
|
||
def uninstall_plugins(plugins) | ||
plugins.each do | ||
Plugin::Uninstaller.new(_1).uninstall | ||
end | ||
end | ||
|
||
def uninsall_themes(themes) | ||
themes.each do | ||
Theme::Uninstaller.new(_1).uninstall | ||
end | ||
end | ||
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
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 |
---|---|---|
@@ -1,9 +1,58 @@ | ||
module Redminep | ||
module Theme | ||
class Installer | ||
def self.dir | ||
Pathname.pwd.join("themes") | ||
end | ||
|
||
class Uninstaller | ||
class Base | ||
def initialize(definition) | ||
@name = definition.name | ||
@source = definition.source | ||
@hooks = definition.hooks || {} | ||
end | ||
|
||
private | ||
|
||
attr_reader :name, :source, :hooks | ||
|
||
def theme_dir | ||
@theme_dir ||= Theme.dir.join(name.to_s) | ||
end | ||
|
||
def theme_exists? | ||
theme_dir.exist? && !theme_dir.empty? | ||
end | ||
end | ||
|
||
class Installer < Base | ||
def install | ||
return if theme_exists? | ||
|
||
load_from_source | ||
hooks[:installed]&.call | ||
end | ||
|
||
private | ||
|
||
def load_from_source | ||
src = Source.const_get(source.type.capitalize).new(**source.options) | ||
src.load(theme_dir.to_s) | ||
end | ||
end | ||
|
||
class Uninstaller < Base | ||
def uninstall | ||
return unless theme_exists? | ||
|
||
remove_theme | ||
hooks[:uninstalled]&.call | ||
end | ||
|
||
private | ||
|
||
def remove_theme | ||
theme_dir.rmtree | ||
end | ||
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