Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement chronicle-etl plugins:show NAME #62

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions chronicle-etl.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "activesupport", "~> 7.0"
spec.add_dependency "chronic_duration", "~> 0.10.6"
spec.add_dependency "colorize", "~> 0.8.1"
spec.add_dependency "faraday"
spec.add_dependency "gems", ">= 1"
spec.add_dependency "launchy"
spec.add_dependency "marcel", "~> 1.0.2"
Expand All @@ -54,6 +55,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "tty-progressbar", "~> 0.17"
spec.add_dependency "tty-prompt", "~> 0.23"
spec.add_dependency "tty-spinner"
spec.add_dependency "tty-markdown"
spec.add_dependency "tty-table", "~> 0.11"
spec.add_dependency "xdg", ">= 4.0"

Expand Down
9 changes: 9 additions & 0 deletions lib/chronicle/etl/cli/plugins.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require "faraday"
require "tty-markdown"
require "tty-prompt"
require "tty-spinner"

Expand All @@ -11,6 +13,13 @@ class Plugins < SubcommandBase
default_task 'list'
namespace :plugins

desc "show", "Show information about a plugin"
def show(plugin)
readme = Chronicle::ETL::Registry::Plugins.readme(plugin)
parsed = TTY::Markdown.parse(readme, mode: 16)
puts parsed
end

desc "install", "Install a plugin"
def install(*plugins)
cli_fail(message: "Please specify a plugin to install") unless plugins.any?
Expand Down
9 changes: 9 additions & 0 deletions lib/chronicle/etl/registry/plugins.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'faraday'
require 'rubygems'
require 'rubygems/command'
require 'rubygems/commands/install_command'
Expand Down Expand Up @@ -89,6 +90,14 @@ def self.gem_info(name)
Gems.info(gem_name)
end

# Return readme for a given plugin
# @todo make this a responsibility of a Plugin instance
def self.readme(name)
conn = Faraday.new(url: 'https://raw.githubusercontent.com')
response = conn.get("/chronicle-app/chronicle-#{name}/main/README.md")
response.body
end

# Union of installed gems (latest version) + available gems
def self.all
(installed + available)
Expand Down