confrb 0.8alpha

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 +7 -0
  2. data/lib/confrb.rb +48 -0
  3. metadata +45 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 570aff3871d003b0724d94bc36327290c57e1472a0624a6186ed211611f10a15
4
+ data.tar.gz: 616dd3d6e98cf7ffef553b49ffb6787f0fd1c3402e35252f3ee05914032d79f8
5
+ SHA512:
6
+ metadata.gz: 6aee7a4ac1ffbb6ea56b2c52c054d1d928300564bd189133319da419d07c3f6d74a83c76017dac52802e54273034af7295855e1919aeb3061be1cb6ba6c90eb9
7
+ data.tar.gz: b054b40ee7f45dcd862a658e8b776a6ec9b66625f18750ba95058c8ca1f710530bfaed76fcecc473654e8fad14702e1b727b2dafeeaf5b27025fe6d30b09b6d2
@@ -0,0 +1,48 @@
1
+ require 'fileutils'
2
+ require 'json'
3
+ require 'yaml'
4
+ module BasicCfrb
5
+ extend self # Make sure this extends self so it can be used as a module!
6
+
7
+ def setup(name)
8
+ dotname = "." + name
9
+ FileUtils.mkdir_p(dotname)
10
+ end
11
+
12
+ def mkcfg(dir, cfgname, content, opts={})
13
+ as_json=opts.fetch(:json, false)
14
+ as_yaml=opts.fetch(:yaml, false)
15
+ dotdir = "." + dir
16
+ cfgpath = File.join(dotdir, cfgname)
17
+ FileUtils.touch(cfgpath)
18
+ if as_json == true
19
+ content = content.to_json
20
+ File.write(cfgpath, content)
21
+ elsif as_yaml == true
22
+ content = content.to_yaml
23
+ File.write(cfgpath, content)
24
+ else
25
+ File.write(cfgpath, content)
26
+ end
27
+ end
28
+
29
+ def mknested(dir, nesteddir)
30
+ dotdir = "." + dir
31
+ FileUtils.mkdir_p(File.join(dotdir, nesteddir))
32
+ end
33
+
34
+ def readcfg(dir, cfgname, opts={})
35
+ dotdir = "." + dir
36
+ as_json=opts.fetch(:json, false)
37
+ as_yaml=opts.fetch(:yaml, false)
38
+ if as_json == true
39
+ content = File.read(File.join(dotdir, cfgname)).to_json
40
+ return content
41
+ elsif as_yaml == true
42
+ content = File.read(File.join(dotdir, cfgname)).yaml
43
+ return content
44
+ else
45
+ File.read(File.join(dotdir, cfgname))
46
+ end
47
+ end
48
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: confrb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.8alpha
5
+ platform: ruby
6
+ authors:
7
+ - Gurjus Bhasin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-12-18 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A Ruby Gem which allows you to store configuration files using hidden
14
+ directories. Plaintext, unencrypted. Useful for simple text adventure games, etc.
15
+ Docs and examples at https://gitlab.com/Gsbhasin84/confrb
16
+ email: gsbhasin84@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - lib/confrb.rb
22
+ homepage: https://gitlab.com/Gsbhasin84/confrb
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">"
38
+ - !ruby/object:Gem::Version
39
+ version: 1.3.1
40
+ requirements: []
41
+ rubygems_version: 3.0.6
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Plaintext configuration library for Ruby
45
+ test_files: []