dotcfg 0.2.2.1 → 0.2.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +91 -0
  3. data/VERSION +1 -0
  4. data/dotcfg.gemspec +23 -0
  5. metadata +4 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 79c06e46ff116bcffb49039fd744e60a3eff7a9d
4
- data.tar.gz: 4256ffcdc131801388e55080b2c6b6745af4922b
3
+ metadata.gz: 192adf2a1b0e448047180f8ee735571214bf0631
4
+ data.tar.gz: d781cbd6faac3c2bb38bf9a4ffacd7a114510ee2
5
5
  SHA512:
6
- metadata.gz: 3bf62f76bce323997e1967167f6abbc5483255d50f6c060d503cd81918cc238cf9cfe19ef3bb33666ef1567fe5adc1049b49c13a66f8fe41f90d009fd67509a6
7
- data.tar.gz: 8efb629375b0237236c60b5ca720d06dfcd9eb01bd3457ba3891b8c9769e080b317d0ea3656f73275a8cd3303b66ebb90cf6bef9f8c00e9670e2d9ae37cdd104
6
+ metadata.gz: 371a3eb7885e4b396edc4243242ad95b89ae58934852bbfd2237d4200c17dfec90f5f810b25bfa36fc380416bf268fb744494ab068379de4a91704c1931f5b14
7
+ data.tar.gz: a9086de3e44faaecb004b89c53e71c7a5d89d17ffb6ccc57e58b4946a1424d530c635fe8b190b508f9a82473efedee9d69feba20eee1feb72a1a2b6b8d973870
data/README.md ADDED
@@ -0,0 +1,91 @@
1
+ [![Gem Version](https://badge.fury.io/rb/dotcfg.svg)](http://badge.fury.io/rb/dotcfg)
2
+ [![Code Climate](https://codeclimate.com/github/rickhull/dotcfg/badges/gpa.svg)](https://codeclimate.com/github/rickhull/dotcfg/badges)
3
+ [![Dependency Status](https://gemnasium.com/rickhull/dotcfg.svg)](https://gemnasium.com/rickhull/dotcfg)
4
+ [![Security Status](https://hakiri.io/github/rickhull/dotcfg/master.svg)](https://hakiri.io/github/rickhull/dotcfg/master/shield)
5
+
6
+ dotcfg
7
+ ======
8
+ dotcfg is a simple, intuitive way for your app to store configuration data on the filesystem -- ideally within the user's home directory, presumably in a dotfile. If your config data can be represented by a Hash, then dotcfg can easily serialize and persist that data between runs.
9
+
10
+ ### Serialization Formats
11
+ dotcfg currently understands [JSON](http://json.org) and [YAML](http://yaml.org), defaulting to YAML.
12
+
13
+ Installation
14
+ ------------
15
+ Install the gem:
16
+ ```
17
+ $ gem install dotcfg # sudo as necessary
18
+ ```
19
+
20
+ Or, if using [Bundler](http://bundler.io/), add to your Gemfile:
21
+ ```ruby
22
+ gem 'dotcfg', '~> 0.1'
23
+ ```
24
+
25
+ Usage
26
+ -----
27
+ ```ruby
28
+ require 'dotcfg'
29
+
30
+ # if file exists, read and load it; otherwise initialize the file
31
+ CFG = DotCfg.new '~/.example'
32
+
33
+ CFG[:does_not_exist]
34
+ # => nil
35
+
36
+ CFG['hello'] = 'world'
37
+ CFG['hello']
38
+ # => "world"
39
+
40
+ puts CFG.pretty
41
+ # ---
42
+ # hello: world
43
+
44
+ CFG.serialize
45
+ # => "---\nhello: world\n"
46
+
47
+ CFG.save
48
+ # write to ~/.example
49
+ ```
50
+
51
+ Use JSON
52
+ ```ruby
53
+ require 'dotcfg'
54
+
55
+ # if file exists, read and load it; otherwise initialize the file
56
+ CFG = DotCfg.new '~/.example', :json
57
+
58
+ # ...
59
+
60
+ puts CFG.pretty
61
+ # {
62
+ # "hello": "world"
63
+ # }
64
+
65
+ CFG.serialize
66
+ # => "{\"hello\":\"world\"}"
67
+
68
+ # ...
69
+ ```
70
+
71
+ Details
72
+ -------
73
+ ### Symbols and Strings
74
+
75
+ When JSON consumes symbols, it emits strings. So if you want to use JSON, use strings rather than symbols for your config items. YAML cycles strings and symbols independently, so stick to one or the other.
76
+
77
+ ### The Simplest Thing That Could Possibly Work
78
+ ```ruby
79
+ PROCS = {
80
+ json: {
81
+ to: proc { |data| data.to_json },
82
+ from: proc { |json| JSON.parse json },
83
+ pretty: proc { |data| JSON.pretty_generate data },
84
+ },
85
+ yaml: {
86
+ to: proc { |data| data.to_yaml },
87
+ from: proc { |yaml| YAML.load yaml },
88
+ pretty: proc { |data| data.to_yaml },
89
+ },
90
+ }
91
+ ```
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.3.1
data/dotcfg.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'dotcfg'
3
+ s.summary = 'simple filesystem de/serialization for app configs'
4
+ s.author = 'Rick Hull'
5
+ s.homepage = 'https://github.com/rickhull/dotcfg'
6
+ s.license = 'MIT'
7
+ s.description = 'JSON and YAML config serialization and persistence'
8
+ s.add_runtime_dependency 'json', '~> 1'
9
+ s.add_development_dependency 'buildar', '~> 2'
10
+
11
+ # set version dynamically from version file contents
12
+ this_dir = File.expand_path('..', __FILE__)
13
+ version_file = File.join(this_dir, 'VERSION')
14
+ s.version = File.read(version_file).chomp
15
+
16
+ s.files = %w[
17
+ dotcfg.gemspec
18
+ VERSION
19
+ README.md
20
+ Rakefile
21
+ lib/dotcfg.rb
22
+ ]
23
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dotcfg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2.1
4
+ version: 0.2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rick Hull
@@ -44,7 +44,10 @@ executables: []
44
44
  extensions: []
45
45
  extra_rdoc_files: []
46
46
  files:
47
+ - README.md
47
48
  - Rakefile
49
+ - VERSION
50
+ - dotcfg.gemspec
48
51
  - lib/dotcfg.rb
49
52
  homepage: https://github.com/rickhull/dotcfg
50
53
  licenses: