configdir 0.0.3
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.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +19 -0
- data/Rakefile +1 -0
- data/configdir.gemspec +20 -0
- data/lib/configdir/version.rb +3 -0
- data/lib/configdir.rb +23 -0
- metadata +53 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Configdir
|
2
|
+
=========
|
3
|
+
|
4
|
+
A `configdir` is a directory-based configuration system where each
|
5
|
+
configuration option is represented by the filename and the
|
6
|
+
configuration value by the contents of the file. The files usually
|
7
|
+
contain a single line which represents the value of the configuration
|
8
|
+
item.
|
9
|
+
|
10
|
+
TODO
|
11
|
+
====
|
12
|
+
|
13
|
+
* Support multi-valued configuration attributes
|
14
|
+
* Perform error checking
|
15
|
+
|
16
|
+
Inspiration
|
17
|
+
-----------
|
18
|
+
|
19
|
+
DJB and DJB-inspired software.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/configdir.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "configdir/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "configdir"
|
7
|
+
s.version = Configdir::VERSION
|
8
|
+
s.authors = ["Abhas Abhinav"]
|
9
|
+
s.email = ["abhas@deeproot.co.in"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Read configration from files in a directory}
|
12
|
+
s.description = %q{This gem read the configuration from files a directory and returns a hash. Each file is assumed to have one configuration value on its first line.}
|
13
|
+
|
14
|
+
s.rubyforge_project = "configdir"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
end
|
data/lib/configdir.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require "configdir/version"
|
2
|
+
|
3
|
+
module Configdir
|
4
|
+
|
5
|
+
def self.read(configdir)
|
6
|
+
@cfgdir = Hash.new
|
7
|
+
Dir.foreach(configdir) do |conf|
|
8
|
+
next if conf == '.' or conf == '..'
|
9
|
+
@cfgdir[conf.to_sym] = File.open(configdir + "/" + conf).first.chomp
|
10
|
+
end
|
11
|
+
return @cfgdir
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.write(configdir, s)
|
15
|
+
@settings = s
|
16
|
+
@settings.keys.each do |file|
|
17
|
+
f = File.open(configdir + "/" + file.to_s, "w")
|
18
|
+
f.write(@settings[file])
|
19
|
+
f.close
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: configdir
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Abhas Abhinav
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-01 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: This gem read the configuration from files a directory and returns a
|
15
|
+
hash. Each file is assumed to have one configuration value on its first line.
|
16
|
+
email:
|
17
|
+
- abhas@deeproot.co.in
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- .gitignore
|
23
|
+
- Gemfile
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- configdir.gemspec
|
27
|
+
- lib/configdir.rb
|
28
|
+
- lib/configdir/version.rb
|
29
|
+
homepage: ''
|
30
|
+
licenses: []
|
31
|
+
post_install_message:
|
32
|
+
rdoc_options: []
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
requirements: []
|
48
|
+
rubyforge_project: configdir
|
49
|
+
rubygems_version: 1.8.15
|
50
|
+
signing_key:
|
51
|
+
specification_version: 3
|
52
|
+
summary: Read configration from files in a directory
|
53
|
+
test_files: []
|