Sha256: c57904c9c51470abac42f959ba3d71caed2b6a9a3ed6305cbd28e1f323c4d7b3

Contents?: true

Size: 917 Bytes

Versions: 9

Compression:

Stored size: 917 Bytes

Contents

module Goodcheck
  module Commands
    class Init
      CONFIG = <<-EOC
rules:
  - id: com.example.1
    pattern: Github
    message: Do you want to write GitHub?
    glob: 
      - "**/*.rb"
      - "**/*.yaml"
      - "**/*.yml"
      - "**/*.html"
    fail:
      - Signup via Github
    pass:
      - Signup via GitHub
      EOC

      attr_reader :stdout
      attr_reader :stderr
      attr_reader :path
      attr_reader :force

      def initialize(stdout:, stderr:, path:, force:)
        @stdout = stdout
        @stderr = stderr
        @path = path
        @force = force
      end

      def run
        if path.file? && !force
          stderr.puts "#{path} already exists. Try --force option to overwrite the file."
          return 1
        end

        path.open("w") do |io|
          io.print(CONFIG)
        end

        stdout.puts "Wrote #{path}. ✍️"

        0
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
goodcheck-1.4.1 lib/goodcheck/commands/init.rb
goodcheck-1.4.0 lib/goodcheck/commands/init.rb
goodcheck-1.3.1 lib/goodcheck/commands/init.rb
goodcheck-1.2.0 lib/goodcheck/commands/init.rb
goodcheck-1.1.0 lib/goodcheck/commands/init.rb
goodcheck-1.0.0 lib/goodcheck/commands/init.rb
goodcheck-0.3.0 lib/goodcheck/commands/init.rb
goodcheck-0.2.0 lib/goodcheck/commands/init.rb
goodcheck-0.1.0 lib/goodcheck/commands/init.rb