Class: Sanctum::Command::Config
- Inherits:
-
Object
- Object
- Sanctum::Command::Config
- Includes:
- Sanctum::Colorizer
- Defined in:
- lib/sanctum/command/config.rb
Overview
Intentionally not extending Base This command creates an example config
Instance Attribute Summary collapse
-
#config_path ⇒ Object
readonly
Returns the value of attribute config_path.
-
#example_file ⇒ Object
readonly
Returns the value of attribute example_file.
Instance Method Summary collapse
- #config_exist? ⇒ Boolean
- #create_config_file ⇒ Object
-
#initialize(options = {}, _args = []) ⇒ Config
constructor
A new instance of Config.
- #run ⇒ Object
Methods included from Sanctum::Colorizer
#blue, #colorize, colorize=, colorize?, #green, #light_blue, #pink, #red, #yellow
Constructor Details
#initialize(options = {}, _args = []) ⇒ Config
Returns a new instance of Config.
11 12 13 14 15 16 17 |
# File 'lib/sanctum/command/config.rb', line 11 def initialize(={}, _args=[]) = {working_dir: Dir.pwd}.merge() relative_path = File. File.dirname(__FILE__) @config_path = "#{[:working_dir]}/sanctum.yaml" @example_file = "#{relative_path}/sanctum.example.yaml" end |
Instance Attribute Details
#config_path ⇒ Object (readonly)
Returns the value of attribute config_path.
9 10 11 |
# File 'lib/sanctum/command/config.rb', line 9 def config_path @config_path end |
#example_file ⇒ Object (readonly)
Returns the value of attribute example_file.
9 10 11 |
# File 'lib/sanctum/command/config.rb', line 9 def example_file @example_file end |
Instance Method Details
#config_exist? ⇒ Boolean
24 25 26 |
# File 'lib/sanctum/command/config.rb', line 24 def config_exist? File.file?(config_path) end |
#create_config_file ⇒ Object
28 29 30 |
# File 'lib/sanctum/command/config.rb', line 28 def create_config_file FileUtils.cp(example_file, config_path) end |
#run ⇒ Object
19 20 21 22 |
# File 'lib/sanctum/command/config.rb', line 19 def run raise yellow("config file already exists") if config_exist? create_config_file end |