Skip to content

Commit

Permalink
Allow custom gemfile vars in Customize
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-sharp committed Feb 29, 2024
1 parent 1495c7b commit e5d2cec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/appraisal/appraisal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def git_source(*args, &block)

def write_gemfile
File.open(gemfile_path, "w") do |file|
signature = Customize.heading || "This file was generated by Appraisal"
signature = Customize.heading(self) || "This file was generated by Appraisal"
file.puts([comment_lines(signature), quoted_gemfile].join("\n\n"))
end
end
Expand Down
14 changes: 12 additions & 2 deletions lib/appraisal/customize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,22 @@ def initialize(heading: nil, single_quotes: false)
@@single_quotes = single_quotes
end

def self.heading
@@heading ||= nil
def self.heading(gemfile)
customize(@@heading, gemfile)
end

def self.single_quotes
@@single_quotes ||= false
end

private

def self.customize(heading, gemfile)
return nil unless heading

heading.gsub('%{gemfile}', gemfile.send('gemfile_name')).
gsub('%{gemfile_path}', gemfile.gemfile_path).
gsub('%{relative_gemfile_path}', gemfile.relative_gemfile_path)
end
end
end

0 comments on commit e5d2cec

Please sign in to comment.