class RSGem::Tasks::EnsureAuthor

Constants

OUTPUT
TEMP_EMAIL
TEMP_USERNAME

Public Instance Methods

perform() click to toggle source
# File lib/rsgem/tasks/ensure_author.rb, line 13
def perform
  ensure_author
end

Private Instance Methods

ensure_author() click to toggle source
# File lib/rsgem/tasks/ensure_author.rb, line 27
def ensure_author
  return unless missing_git_user?

  gemspec.gsub!(/spec.email\s+=\s+.+/,
                "spec.email = ['#{TEMP_EMAIL}']")

  gemspec.gsub!(/spec.authors\s+=\s+.+/,
                "spec.authors = ['#{TEMP_USERNAME}']")
  write_gemspec
end
gemspec() click to toggle source
# File lib/rsgem/tasks/ensure_author.rb, line 19
def gemspec
  @gemspec ||= File.read(context.gemspec_path)
end
missing_git_user?() click to toggle source
# File lib/rsgem/tasks/ensure_author.rb, line 38
def missing_git_user?
  `git config user.email`.strip.empty? || `git config user.name`.strip.empty?
end
warning_message() click to toggle source
# File lib/rsgem/tasks/ensure_author.rb, line 42
def warning_message
  return unless missing_git_user?

  "No git user set. Setting #{TEMP_EMAIL} and #{TEMP_USERNAME} in gemspec, "\
  'please change this before publishing your gem.'
end
write_gemspec() click to toggle source
# File lib/rsgem/tasks/ensure_author.rb, line 23
def write_gemspec
  File.write(context.gemspec_path, gemspec)
end