profig 0.08 → 0.09
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/bin/profig +15 -3
- data/lib/profig/config.rb +8 -4
- data/lib/profig/install.rb +13 -1
- metadata +4 -4
data/bin/profig
CHANGED
@@ -11,6 +11,9 @@ def parse_args()
|
|
11
11
|
OptionParser.new do |opts|
|
12
12
|
opts.banner = 'Usage: profig'
|
13
13
|
|
14
|
+
opts.on('-f', '--file FILE', 'Select file') do |f|
|
15
|
+
options[:file] = f
|
16
|
+
end
|
14
17
|
opts.on('-d', '--directory DIR', 'Select directory') do |d|
|
15
18
|
options[:directory] = d
|
16
19
|
end
|
@@ -24,10 +27,19 @@ def main()
|
|
24
27
|
p opts
|
25
28
|
p args
|
26
29
|
|
30
|
+
file = opts[:file]
|
27
31
|
dir = opts[:directory]
|
28
|
-
|
29
|
-
|
30
|
-
|
32
|
+
if file.nil? and dir.nil?
|
33
|
+
config_path = '/var/lib/profig/conf.d'
|
34
|
+
elsif file.nil?
|
35
|
+
config_path = dir
|
36
|
+
elsif dir.nil?
|
37
|
+
config_path = file
|
38
|
+
else
|
39
|
+
config_path = [file,dir]
|
40
|
+
end
|
41
|
+
|
42
|
+
config = Profig.load_config(config_path)
|
31
43
|
Profig.run(config)
|
32
44
|
end
|
33
45
|
|
data/lib/profig/config.rb
CHANGED
@@ -10,6 +10,7 @@ class Item
|
|
10
10
|
|
11
11
|
def initialize(name, opts)
|
12
12
|
@name = name
|
13
|
+
opts = {} if opts.nil?
|
13
14
|
@opts = opts
|
14
15
|
end
|
15
16
|
end
|
@@ -38,7 +39,7 @@ class Section
|
|
38
39
|
end
|
39
40
|
|
40
41
|
|
41
|
-
def self.
|
42
|
+
def self.load_config_directory(directory)
|
42
43
|
# do a stable ordering by alphabetical
|
43
44
|
files = Dir.glob("#{directory}/*").sort
|
44
45
|
confs = []
|
@@ -91,9 +92,12 @@ def self.yaml_to_sections(yaml)
|
|
91
92
|
return section_acc
|
92
93
|
end
|
93
94
|
|
94
|
-
|
95
|
-
|
96
|
-
|
95
|
+
def self.load_config(path)
|
96
|
+
if File.file? path then
|
97
|
+
confs = [YAML.load_file(path)]
|
98
|
+
elsif File.directory? path then
|
99
|
+
confs = load_config_directory(path)
|
100
|
+
end
|
97
101
|
return yaml_to_sections(confs)
|
98
102
|
end
|
99
103
|
|
data/lib/profig/install.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
module Profig
|
3
3
|
# Handlers for various installers / package managers
|
4
4
|
|
5
|
-
|
5
|
+
# Package Installers
|
6
|
+
#
|
6
7
|
def self.handle_cabal(pkg_name, opts)
|
7
8
|
cmd = "cabal install #{package_name}"
|
8
9
|
system cmd
|
@@ -29,4 +30,15 @@ def self.handle_yum(pkg_name, opts)
|
|
29
30
|
end
|
30
31
|
|
31
32
|
|
33
|
+
# Source Installers
|
34
|
+
#
|
35
|
+
def self.handle_rake(path, opts)
|
36
|
+
pwd = Dir.pwd
|
37
|
+
Dir.chdir path
|
38
|
+
target = opts['target']
|
39
|
+
cmd = "rake #{target}"
|
40
|
+
system cmd
|
41
|
+
Dir.chdir pwd
|
42
|
+
end
|
43
|
+
|
32
44
|
end # module
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: profig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: "0.
|
8
|
+
- 9
|
9
|
+
version: "0.09"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Matthew Graham
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-08-06 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|