X-Git-Url: https://git.r.bdr.sh/rbdr/lyricli.rb/blobdiff_plain/34d0bf15a6f4009de376ceed1d7d5cca24a8dfe7..278e6d0afff19cce3ab8ad256c9ab8239bcf6289:/doc/Lyricli/Configuration.html diff --git a/doc/Lyricli/Configuration.html b/doc/Lyricli/Configuration.html index 77112a3..54b439c 100644 --- a/doc/Lyricli/Configuration.html +++ b/doc/Lyricli/Configuration.html @@ -99,7 +99,19 @@
+

Overview

+
+

+This class handles the configuration of Lyricli +

+ + +
+
+
+ +

Constant Summary

@@ -143,7 +155,10 @@ -
+

+Ensure this is only called once. +

+
@@ -160,7 +175,7 @@
  • - - (Object) [](key) + - (String, ...) [](key) @@ -174,7 +189,10 @@ -
    +

    +Access configuration properties, loads config if needed beforehand. +

    +
  • @@ -196,7 +214,11 @@ -
    +

    +Assigns a new value to a configuration key, loads config if needed and +saves it after updating. +

    +
    @@ -218,7 +240,11 @@ -
    +

    +Deletes a key from the configuration, loads config if needed and saves it +after deleting. +

    +
    @@ -243,7 +269,7 @@

    -A new instance of Configuration. +Defines the paths to the default and user configuration files.

    @@ -268,7 +294,8 @@ A new instance of Configuration.

    -TODO: Apart from this, load a default yml that will be used for this. +Loads the configuration from the user file, attempts to create it from +defaults if it’s not present.

    @@ -292,7 +319,10 @@ TODO: Apart from this, load a default yml that will be used for this. -
    +

    +Serializes the `@config` Hash to JSON and saves it to a file. +

    +
    @@ -315,7 +345,7 @@ TODO: Apart from this, load a default yml that will be used for this.

    -A new instance of Configuration +Defines the paths to the default and user configuration files

    @@ -330,14 +360,14 @@ A new instance of Configuration
     
     
    -4
    -5
    -6
     7
    -8
    +8 +9 +10 +11 -
    # File 'lib/lyricli/configuration.rb', line 4
    +      
    # File 'lib/lyricli/configuration.rb', line 7
     
     def initialize
       @config_path = "~/.lyricli.conf"
    @@ -365,18 +395,31 @@ A new instance of Configuration
       
     
       
    -
    +
    +
    +

    +Ensure this is only called once. Only use the instance class variable to +access this method, as its constructor is private. +

    + + +
    +
    +
    + + +
     
     
    -12
    -13
    -14
    +17 +18 +19
    -
    # File 'lib/lyricli/configuration.rb', line 12
    +      
    # File 'lib/lyricli/configuration.rb', line 17
     
     def self.instance
       @@instance
    @@ -395,25 +438,77 @@ A new instance of Configuration
           

    - - (Object) [](key) + - (String, ...) [](key) + + +

    +
    +

    +Access configuration properties, loads config if needed beforehand. +

    + +
    +
    +
    +

    Parameters:

    +
      - +
    • + + key + + + (String) + + + + — +

      +the configuration key to access +

      +
      + +
    • + + + +

      Returns:

      +
        + +
      • + + + (String, Hash, Array) + + + + — +

        +the value of the configuration key. +

        +
        + +
      • + +
      + +
       
       
      -16
      -17
      -18
      -19
      +25 +26 +27 +28
      -
      # File 'lib/lyricli/configuration.rb', line 16
      +      
      # File 'lib/lyricli/configuration.rb', line 25
       
       def [](key)
         load_config unless @config
      @@ -433,20 +528,72 @@ A new instance of Configuration
         
       
         
      -
      +
      +
      +

      +Assigns a new value to a configuration key, loads config if needed and +saves it after updating. +

      + + +
      +
      +
      +

      Parameters:

      +
        + +
      • + + key + + + (String) + + + + — +

        +the configuration key to set +

        +
        + +
      • + +
      • + + value + + + (Object) + + + + — +

        +the value for the configuration key, can be any object as long as it can be +converted to JSON +

        +
        + +
      • + +
      + + +
       
       
      -21
      -22
      -23
      -24
      -25
      +36 +37 +38 +39 +40
      -
      # File 'lib/lyricli/configuration.rb', line 21
      +      
      # File 'lib/lyricli/configuration.rb', line 36
       
       def []=(key, value)
         load_config unless @config
      @@ -467,20 +614,54 @@ A new instance of Configuration
         
       
         
      -
      +
      +
      +

      +Deletes a key from the configuration, loads config if needed and saves it +after deleting. +

      + + +
      +
      +
      +

      Parameters:

      +
        + +
      • + + key + + + (String) + + + + — +

        +the key to delete +

        +
        + +
      • + +
      + + +
       
       
      -27
      -28
      -29
      -30
      -31
      +46 +47 +48 +49 +50
      -
      # File 'lib/lyricli/configuration.rb', line 27
      +      
      # File 'lib/lyricli/configuration.rb', line 46
       
       def delete(key)
         load_config unless @config
      @@ -504,8 +685,8 @@ A new instance of Configuration
       

      -TODO: Apart from this, load a default yml that will be used for this. And -just extend everything from the user’s config. +Loads the configuration from the user file, attempts to create it from +defaults if it’s not present. sets the `@config` instance variable.

      @@ -520,19 +701,19 @@ just extend everything from the user’s config.
       
       
      -37
      -38
      -39
      -40
      -41
      -42
      -43
      -44
      -45
      -46
      +56 +57 +58 +59 +60 +61 +62 +63 +64 +65
      -
      # File 'lib/lyricli/configuration.rb', line 37
      +      
      # File 'lib/lyricli/configuration.rb', line 56
       
       def load_config
         path = File.expand_path(@config_path)
      @@ -558,21 +739,33 @@ just extend everything from the user’s config.
         
       
         
      -
      +
      +
      +

      +Serializes the `@config` Hash to JSON and saves it to a file. +

      + + +
      +
      +
      + + +
       
       
      -48
      -49
      -50
      -51
      -52
      -53
      +68 +69 +70 +71 +72 +73
      -
      # File 'lib/lyricli/configuration.rb', line 48
      +      
      # File 'lib/lyricli/configuration.rb', line 68
       
       def save_config
         path = File.expand_path(@config_path)
      @@ -590,7 +783,7 @@ just extend everything from the user’s config.