Skip to content

Commit

Permalink
chore: add Bundler::GemBytes::Actions module to extend the API for ge…
Browse files Browse the repository at this point in the history
…mbytes scripts

This module (along with Thor::Actions) will make up the API for gembytes scripts.
  • Loading branch information
jcouball committed Oct 30, 2024
1 parent 6f7be90 commit 5d41e08
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/bundler/gem_bytes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module GemBytes
end

require 'active_support'
require 'thor'

require_relative 'gem_bytes/bundler_command'
require_relative 'gem_bytes/gemspec'
Expand Down
9 changes: 9 additions & 0 deletions lib/bundler/gem_bytes/actions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

module Bundler
module GemBytes
# The API for GemBytes templates
# @api public
module Actions; end
end
end
8 changes: 4 additions & 4 deletions lib/bundler/gem_bytes/script_executor.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# frozen_string_literal: true

# require 'pp'
require 'thor'
require 'uri'
require_relative 'actions'

module Bundler
module GemBytes
Expand All @@ -13,8 +12,9 @@ module GemBytes
# @example Executing a script from a file or URI
# executor = Bundler::GemBytes::ScriptExecutor.new
# executor.execute('path_or_uri_to_script')
class ScriptExecutor < Thor::Group
include Thor::Actions
class ScriptExecutor < ::Thor::Group
include ::Thor::Actions
include Bundler::GemBytes::Actions

# Set the source paths for Thor to use
# @return [Array<String>] the source paths
Expand Down
8 changes: 8 additions & 0 deletions spec/lib/bundler/gem_bytes/script_executor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
RSpec.describe Bundler::GemBytes::ScriptExecutor do
let(:instance) { described_class.new }

it 'is expected to include Thor actions' do
expect(described_class.ancestors).to include(Thor::Actions)
end

it 'is expected to include GemBytes actions' do
expect(described_class.ancestors).to include(Bundler::GemBytes::Actions)
end

describe '#execute' do
subject { instance.execute(path_or_uri) }

Expand Down

0 comments on commit 5d41e08

Please sign in to comment.