Sha256: 2ca716d3fe1346c10b6b2db6cc6f44d8a129a451cfde741c24eaae99b908e606

Contents?: true

Size: 597 Bytes

Versions: 44

Compression:

Stored size: 597 Bytes

Contents

module Perus::Pinger
    class Replace < Command
        description 'Looks for the string matched by "grep" in the file
                     specified by "path" and replaces it with "replacement".
                     Valid values for "path" are contained in the pinger
                     config file.'
        option :path, restricted: true
        option :grep
        option :replacement

        def run
            text = IO.read(options.path)
            text.gsub!(/#{options.grep}/, options.replacement)
            IO.write(options.path, text)
            true
        end
    end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
perus-1.0.7 lib/perus/pinger/commands/replace.rb
perus-1.0.6 lib/perus/pinger/commands/replace.rb
perus-1.0.5 lib/perus/pinger/commands/replace.rb
perus-1.0.4 lib/perus/pinger/commands/replace.rb
perus-1.0.3 lib/perus/pinger/commands/replace.rb
perus-1.0.2 lib/perus/pinger/commands/replace.rb
perus-1.0.1 lib/perus/pinger/commands/replace.rb
perus-1.0.0 lib/perus/pinger/commands/replace.rb
perus-0.1.35 lib/perus/pinger/commands/replace.rb
perus-0.1.34 lib/perus/pinger/commands/replace.rb
perus-0.1.33 lib/perus/pinger/commands/replace.rb
perus-0.1.32 lib/perus/pinger/commands/replace.rb
perus-0.1.31 lib/perus/pinger/commands/replace.rb
perus-0.1.30 lib/perus/pinger/commands/replace.rb
perus-0.1.29 lib/perus/pinger/commands/replace.rb
perus-0.1.28 lib/perus/pinger/commands/replace.rb
perus-0.1.27 lib/perus/pinger/commands/replace.rb
perus-0.1.26 lib/perus/pinger/commands/replace.rb
perus-0.1.25 lib/perus/pinger/commands/replace.rb
perus-0.1.24 lib/perus/pinger/commands/replace.rb