Class: Steep::Drivers::Init
- Inherits:
-
Object
- Object
- Steep::Drivers::Init
- Includes:
- Utils::DriverHelper
- Defined in:
- lib/steep/drivers/init.rb
Constant Summary collapse
- TEMPLATE =
<<~EOF # target :lib do # signature "sig" # # check "lib" # Directory name # check "Gemfile" # File name # check "app/models/**/*.rb" # Glob # # ignore "lib/templates/*.rb" # # # library "pathname", "set" # Standard libraries # # library "strong_json" # Gems # end # target :spec do # signature "sig", "sig-private" # # check "spec" # # # library "pathname", "set" # Standard libraries # # library "rspec" # end EOF
Instance Attribute Summary collapse
-
#force_write ⇒ Object
Returns the value of attribute force_write.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Attributes included from Utils::DriverHelper
Instance Method Summary collapse
-
#initialize(stdout:, stderr:) ⇒ Init
constructor
A new instance of Init.
- #run ⇒ Object
Methods included from Utils::DriverHelper
Constructor Details
#initialize(stdout:, stderr:) ⇒ Init
Returns a new instance of Init.
33 34 35 36 37 |
# File 'lib/steep/drivers/init.rb', line 33 def initialize(stdout:, stderr:) @stdout = stdout @stderr = stderr @force_write = false end |
Instance Attribute Details
#force_write ⇒ Object
Returns the value of attribute force_write.
6 7 8 |
# File 'lib/steep/drivers/init.rb', line 6 def force_write @force_write end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
5 6 7 |
# File 'lib/steep/drivers/init.rb', line 5 def stderr @stderr end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
4 5 6 |
# File 'lib/steep/drivers/init.rb', line 4 def stdout @stdout end |
Instance Method Details
#run ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/steep/drivers/init.rb', line 39 def run path = steepfile || Pathname("Steepfile") if path.file? && !force_write stdout.puts "#{path} already exists, --force to overwrite" return 1 end stdout.puts "Writing #{path}..." path.write(TEMPLATE) 0 end |