djinn 0.1.2 → 0.1.5
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/VERSION +1 -1
- data/djinn.gemspec +2 -2
- data/lib/djinn/base/dsl.rb +17 -1
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
data/djinn.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{djinn}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Craig Paterson"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-10-13}
|
13
13
|
s.description = %q{Helper for creating simple custom daemons}
|
14
14
|
s.email = %q{darksavant@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/djinn/base/dsl.rb
CHANGED
@@ -73,9 +73,14 @@ module Djinn
|
|
73
73
|
end
|
74
74
|
yield options if block_given?
|
75
75
|
options.parse!
|
76
|
+
#Apply defaults
|
77
|
+
@config_items.each do |ci|
|
78
|
+
config[ci.key] = ci.default_value if ci.has_default? unless config.include?(ci.key)
|
79
|
+
end
|
80
|
+
# Check for missing arguments
|
76
81
|
@config_items.each do |ci|
|
77
82
|
if ci.required?
|
78
|
-
puts "Missing argument: #{ci.key}\n\n#{
|
83
|
+
puts "Missing argument: #{ci.key}\n\n#{options}"
|
79
84
|
exit(1)
|
80
85
|
end unless config.include?(ci.key) or config.include?(:__stop)
|
81
86
|
end
|
@@ -122,6 +127,16 @@ module Djinn
|
|
122
127
|
def required?
|
123
128
|
@required
|
124
129
|
end
|
130
|
+
|
131
|
+
def default d
|
132
|
+
@default = d
|
133
|
+
end
|
134
|
+
|
135
|
+
def default_value; @default; end
|
136
|
+
|
137
|
+
def has_default?
|
138
|
+
!@default.nil?
|
139
|
+
end
|
125
140
|
|
126
141
|
# Parse the individual configuration option
|
127
142
|
def parse! opts, config
|
@@ -130,6 +145,7 @@ module Djinn
|
|
130
145
|
switches = []
|
131
146
|
switches << (defined?(@short_switch) && @short_switch) ? @short_switch : nil
|
132
147
|
switches << (defined?(@long_switch) && @long_switch) ? @long_switch : nil
|
148
|
+
@description = "#{@description} (Default: #{@default})" if @default
|
133
149
|
opts.on(switches[0], switches[1], @description) do |o|
|
134
150
|
config[@key] = o
|
135
151
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: djinn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 5
|
10
|
+
version: 0.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Craig Paterson
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-10-13 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|