confrb 1.0

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 +65 -0
  3. metadata +45 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: dce20723dba46522772c29be5d17f8895830c498b151b21e61c1987766fa073e
4
+ data.tar.gz: bb4c5e003e265873d9b637ffe7e56acf5549fd3a61cd7702ab5edb928fc94d93
5
+ SHA512:
6
+ metadata.gz: df3255415f4668326196449c68bf71d9ea52c4199ee45e406f7b2a39488b7172e67e61243a1136c22d7e5cf44107b19f4be196ca0df13521a99dce3b9fdfd658
7
+ data.tar.gz: 763d109b26b7bff6c31c92a114f3402b346232ea4acb3d98412ba9ee89b3d5282d9c60a466c63754195d37a718c3026152a5de90e1119623a72eb893ae593f16
@@ -0,0 +1,65 @@
1
+ # Require everything!
2
+ require 'fileutils'
3
+ require 'json'
4
+ require 'yaml'
5
+ module BasicCfrb
6
+ extend self # Make sure this extends self so it can be used as a module!
7
+
8
+ def setup(name)
9
+ dotname = "." + name
10
+ FileUtils.mkdir_p(dotname)
11
+ end
12
+
13
+ def mkcfg(dir, cfgname, content, opts={})
14
+ as_json=opts.fetch(:json, false)
15
+ as_yaml=opts.fetch(:yaml, false)
16
+ dotdir = "." + dir
17
+ cfgpath = File.join(dotdir, cfgname)
18
+ FileUtils.touch(cfgpath)
19
+ if as_json == true
20
+ content = content.to_json
21
+ File.write(cfgpath, content)
22
+ elsif as_yaml == true
23
+ content = content.to_yaml
24
+ File.write(cfgpath, content)
25
+ else
26
+ File.write(cfgpath, content)
27
+ end
28
+ end
29
+
30
+ def mknested(dir, nesteddir)
31
+ dotdir = "." + dir
32
+ FileUtils.mkdir_p(File.join(dotdir, nesteddir))
33
+ end
34
+
35
+ def readcfg(dir, cfgname, opts={})
36
+ dotdir = "." + dir
37
+ as_json=opts.fetch(:json, false)
38
+ as_yaml=opts.fetch(:yaml, false)
39
+ if as_json == true
40
+ content = File.read(File.join(dotdir, cfgname)).to_json
41
+ return content
42
+ elsif as_yaml == true
43
+ content = File.read(File.join(dotdir, cfgname)).yaml
44
+ return content
45
+ else
46
+ File.read(File.join(dotdir, cfgname))
47
+ end
48
+
49
+ end
50
+
51
+ def rmcfg(dir, cfgname)
52
+ dotdir = "." + dir
53
+ File.delete(File.join(dotdir, cfgname))
54
+ end
55
+
56
+ def rmdb(dir)
57
+ dotdir = "." + dir
58
+ FileUtils.rm_rf(dotdir)
59
+ end
60
+
61
+ def rmnested(dir, nested)
62
+ dotdir = File.join("." + dir, nested)
63
+ FileUtils.rm_rf(dotdir)
64
+ end
65
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: confrb
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
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: '0'
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: []