Class: Goodcheck::Commands::Init
- Inherits:
-
Object
- Object
- Goodcheck::Commands::Init
- Defined in:
- lib/goodcheck/commands/init.rb
Constant Summary collapse
- 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
Instance Attribute Summary collapse
-
#force ⇒ Object
readonly
Returns the value of attribute force.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
-
#initialize(stdout:, stderr:, path:, force:) ⇒ Init
constructor
A new instance of Init.
- #run ⇒ Object
Constructor Details
#initialize(stdout:, stderr:, path:, force:) ⇒ Init
Returns a new instance of Init.
25 26 27 28 29 30 |
# File 'lib/goodcheck/commands/init.rb', line 25 def initialize(stdout:, stderr:, path:, force:) @stdout = stdout @stderr = stderr @path = path @force = force end |
Instance Attribute Details
#force ⇒ Object (readonly)
Returns the value of attribute force.
23 24 25 |
# File 'lib/goodcheck/commands/init.rb', line 23 def force @force end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
22 23 24 |
# File 'lib/goodcheck/commands/init.rb', line 22 def path @path end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
21 22 23 |
# File 'lib/goodcheck/commands/init.rb', line 21 def stderr @stderr end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
20 21 22 |
# File 'lib/goodcheck/commands/init.rb', line 20 def stdout @stdout end |
Instance Method Details
#run ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/goodcheck/commands/init.rb', line 32 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 |