Module: Bashy
- Defined in:
- lib/bashy.rb
Defined Under Namespace
Classes: Add, ArgumentError, Clean, GistFetchError, List, Pull, Remove, Run, Show
Constant Summary collapse
- SNIPPET_PATH =
Our folder where we’ll be storing our snippets and config.
File.join(Etc.getpwuid.dir, '.bashy/snippets')
- CONFIG_PATH =
File.join(SNIPPET_PATH, 'bashy_config.yml')
Class Attribute Summary collapse
-
.config ⇒ Object
Returns the value of attribute config.
Class Method Summary collapse
Class Attribute Details
.config ⇒ Object
Returns the value of attribute config.
14 15 16 |
# File 'lib/bashy.rb', line 14 def config @config end |
Class Method Details
.check_and_load_config_directory ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/bashy.rb', line 16 def check_and_load_config_directory # Check that our storage path is in tact and ready to write to. FileUtils.mkdir_p(SNIPPET_PATH) unless File.exists?(SNIPPET_PATH) # Now we'll create our config file if it doesn't exist. unless File.exists?(CONFIG_PATH) FileUtils.touch(CONFIG_PATH) @config = default_config_file save_config else # Setup our config object to be accessed everywhere. File.open(CONFIG_PATH) do |yf| @config = YAML::load(yf) end end end |
.save_config ⇒ Object
32 33 34 35 36 |
# File 'lib/bashy.rb', line 32 def save_config File.open(CONFIG_PATH, 'w' ) do |out| YAML.dump(@config, out) end end |