Class: RSGem::Tasks::CleanGemfile

Inherits:
Base
  • Object
show all
Defined in:
lib/rsgem/tasks/clean_gemfile.rb

Overview

Gemfile should only have the gemspec directive. An exception is when you need to develop against a gem that hasn’t yet been released, in this case you can declare that dependency in the Gemfile:

gem 'rack', github: 'rack/rack'

gemspec is the place to declare dependencies.

github.com/rootstrap/tech-guides/blob/master/open-source/developing_gems.md#gemfilegemfilelockgemspec

Constant Summary collapse

OUTPUT =
OutputStruct.new(name: 'Clean gemfile')

Instance Attribute Summary

Attributes inherited from Base

#args, #context

Instance Method Summary collapse

Methods inherited from Base

#call, #initialize

Methods included from Output

#with_output

Constructor Details

This class inherits a constructor from RSGem::Tasks::Base

Instance Method Details

#performObject



19
20
21
22
23
# File 'lib/rsgem/tasks/clean_gemfile.rb', line 19

def perform
  gemfile.gsub!(/gem .+\n/, '') # Remove all gem definitions
  gemfile.sub!(/\n\z/, '') # Remove last new line character
  write_to_gemfile
end