confrb 1.8 → 1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/confrb.rb +13 -17
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56a83b4fa46ce5e7cf508babd19e67bc988d68648083c00d549a744e866514bf
4
- data.tar.gz: 13a6ca74daedef594fd197e5c37dce61b8dde613355d75dc755f9ce94853c330
3
+ metadata.gz: 30725b1e35a0f6d3302899d61b5790b5924aa575856dfa64f1427f3dc7f6dfac
4
+ data.tar.gz: c1add6c9c9d122dff3682caf0ed16631a968325db93c82ecdf0023cbb56ae220
5
5
  SHA512:
6
- metadata.gz: 4e5b81841ee2f41d034b1852c31dbf4ce541367c1d744b5c83866d775a3a185dfc21e9ccb310e1bff0eb7d37e8fa6ca94857458547b269c07bb10f3b39fd7d3f
7
- data.tar.gz: 3e1105f85c8742450774296f0fe39c0b1b26746fd8e8e30603347b7a35611029c18a896c0807c43bde3d952849072fac589ad901c47413bad1d073ff4f256f11
6
+ metadata.gz: d53d3c316ee9dbf06af8d9fdf95d39b62598cef369c3c9a3bceaa917c7ae508afd11bfa335b03651f48cb6801468f9a9dee30a2170aec6a04bc9d5edaca4bd5c
7
+ data.tar.gz: 9acd96dd3bf750fb8f3b42ffff57d36c66fa030d9c5d4e78ad73366975b44f8cc7a9217345cd633085bed446da5f464d6dc286892c0276856c1119c51d22a9cc
@@ -30,20 +30,18 @@ class Confrb
30
30
 
31
31
  ##
32
32
  # Create/overwrite a config file and write data to it. Can
33
- # serialize a hash as yaml or json, or write a string.
33
+ # serialize data as yaml or json, or write a string.
34
34
  # @param [String] cfgname Name of config file to write to
35
35
  # @param [String] content The content to write, defaults to an empty string.
36
36
  # @param [Hash] opts Optional param hash
37
37
  # @option opts [boolean] :json If true, serialize content
38
- # as JSON (ignored if content isn't a hash) Default #
39
- # false
38
+ # as JSON Default: false
40
39
  # @option opts [boolean] :yaml If true, serialize content
41
- # as YAML (ignored if content isn't a hash) Default #
42
- # false (json: true takes precedence)
40
+ # as YAML Default: false (json: true takes precedence)
43
41
  # @return path to configuration file created.
44
42
  def mkcfg(cfgname, content='', opts = {})
45
- as_json = opts.fetch(:json, false) && content.is_a?(Hash)
46
- as_yaml = opts.fetch(:yaml, false) && content.is_a?(Hash)
43
+ as_json = opts.fetch(:json, false)
44
+ as_yaml = opts.fetch(:yaml, false)
47
45
  dotdir = "." + @db
48
46
  cfgpath = File.join(dotdir, cfgname)
49
47
  FileUtils.touch(cfgpath)
@@ -79,7 +77,7 @@ class Confrb
79
77
  # content as YAML. Default false (json: true takes
80
78
  # precedence
81
79
  # @return [String|Hash] Loaded contents, either a String
82
- # if not indicated to treat as JSON or YAML, or a hash
80
+ # if not indicated to treat as JSON or YAML, or a data structure
83
81
  # deserialized from content string
84
82
  def readcfg(cfgname, opts = {})
85
83
  dotdir = "." + @db
@@ -122,21 +120,19 @@ class Confrb
122
120
  end
123
121
 
124
122
  ##
125
- # Create/append to a config file. Can
126
- # serialize a hash as yaml or json, or write a string
123
+ # Create/append to a config file and write data to it. Can
124
+ # serialize data as yaml or json, or write a string.
127
125
  # @param [String] cfgname Name of config file to write to
128
- # @param [String] content The content to write.
126
+ # @param [String] content The content to write, defaults to an empty string.
129
127
  # @param [Hash] opts Optional param hash
130
128
  # @option opts [boolean] :json If true, serialize content
131
- # as JSON (ignored if content isn't a hash) Default #
132
- # false
129
+ # as JSON Default: false
133
130
  # @option opts [boolean] :yaml If true, serialize content
134
- # as YAML (ignored if content isn't a hash) Default #
135
- # false (json: true takes precedence)
131
+ # as YAML Default: false (json: true takes precedence)
136
132
  # @return path to configuration file created.
137
133
  def writecfg(cfgname, content, opts = {})
138
- as_json = opts.fetch(:json, false) && content.is_a?(Hash)
139
- as_yaml = opts.fetch(:yaml, false) && content.is_a?(Hash)
134
+ as_json = opts.fetch(:json, false)
135
+ as_yaml = opts.fetch(:yaml, false)
140
136
  dotdir = "." + @db
141
137
  cfgpath = File.join(dotdir, cfgname)
142
138
  FileUtils.touch(cfgpath)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: confrb
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.8'
4
+ version: '1.9'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gurjus Bhasin