Skip to content

Commit

Permalink
ignore abstract classes
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosgz committed Nov 4, 2024
1 parent 31d1e7a commit 5543d4b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/lepus/supervisor/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def consumers=(vals)
def consumers
@consumers ||= Dir[Lepus.config.consumers_directory.join("**/*.rb")].map { |path| Pathname.new(path) }.map do |path|
next unless path.extname == ".rb"
next if File.readlines(path.to_s).grep(/abstract_class\s*=\s*true/).any?

path.relative_path_from(Lepus.config.consumers_directory).to_s.sub(/\.rb$/, "").split("/").map do |part|
part.split("_").collect(&:capitalize).join
Expand Down
7 changes: 7 additions & 0 deletions spec/lepus/supervisor/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,16 @@
allow(Dir).to receive(:[]).and_return([
"/tmp/lepus/consumers/ignore.js",
"/tmp/lepus/consumers/exclude",
"/tmp/lepus/consumers/application_consumer.rb",
"/tmp/lepus/consumers/foo_consumer.rb",
"/tmp/lepus/consumers/namespaced/bar_consumer.rb"
])
allow(File).to receive(:readlines).and_return([""])
expect(File).to receive(:readlines).with("/tmp/lepus/consumers/application_consumer.rb").and_return([
"class ApplicationConsumer < Lepus::Consumer",
" self.abstract_class = true",
"end"
])
end

it "returns the list of consumers" do
Expand Down

0 comments on commit 5543d4b

Please sign in to comment.