Sha256: af7cbd94b553e9131aca555a40309e40b744dc7cb66aa8d72d992609c1b8917b
Contents?: true
Size: 1.16 KB
Versions: 3
Compression:
Stored size: 1.16 KB
Contents
module Foobara module Generators # TODO: do this in the .gemspec instead... module RackConnectorGenerator module Generators # Kind of tricky... for the first time we will be loading an existing file in the working directory # and modifying it. class GemfileGenerator < RackConnectorGenerator def template_path "Gemfile" end def target_path "Gemfile" end def generate(_elements_to_generate) contents = File.read(template_path) match = contents.match(/^gem /) if match new_entry = [ 'gem "foobara-rack-connector", github: "foobara/rack-connector"', 'gem "rackup"', 'gem "rerun"' ].join("\n") "#{match.pre_match}\n#{new_entry}\n#{match}#{match.post_match}" else # TODO: maybe print a warning and return the original Gemfile # :nocov: raise "Not sure how to inject rack_connector into the Gemfile" # :nocov: end end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems