Skip to content

Commit

Permalink
Refactor find_gem_files into scanning_gemfile and find_gem_files methods
Browse files Browse the repository at this point in the history
- Separated the find_gem_files method into two distinct methods: scanning_gemfile and find_gem_files. This change was made to reduce the coupling between two unrelated processes that were sharing variables.
- Updated the comments for the find_gem_files method to align with the capabilities of modern Ruby versions. Ocran no longer supports Ruby 1.8 or 1.9.
  • Loading branch information
shinokaro committed Jun 22, 2024
1 parent 960b2d2 commit c4fe81a
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions bin/ocran
Original file line number Diff line number Diff line change
Expand Up @@ -368,14 +368,7 @@ EOF
include
end

# Searches for features that are loaded from gems, then produces a
# list of files included in those gems' manifests. Also returns a
# list of original features that caused those gems to be
# included. Ruby provides Gem.loaded_specs to detect gems.
# Now, we also detect gems that are not included in Gem.loaded_specs.
# Therefore, we look for any loaded file from a gem path.
def Ocran.find_gem_files(features)
features_from_gems = []
def Ocran.scanning_gemfile
gems = {}

# If a Bundler Gemfile was provided, add all gems it specifies
Expand All @@ -400,6 +393,19 @@ EOF
# which ensures that Bundler itself will always be included.
end

gems
end

# Searches for features that are loaded from gems, then produces a
# list of files included in those gems' manifests. Also returns a
# list of original features that caused those gems to be
# included. Ruby provides Gem.loaded_specs to detect gems.
# Now, we also detect gems that are not included in Gem.loaded_specs.
# Therefore, we look for any loaded file from a gem path.
def self.find_gem_files(features)
features_from_gems = []
gems = Ocran.scanning_gemfile

if defined?(Gem)
require_relative "../lib/ocran/gem_spec_queryable"
# Include Gems that are loaded
Expand Down

0 comments on commit c4fe81a

Please sign in to comment.