rbatch 1.5.1 → 1.6.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.
- data/Rakefile +1 -1
- data/lib/rbatch/config.rb +23 -7
- metadata +2 -2
data/Rakefile
CHANGED
data/lib/rbatch/config.rb
CHANGED
@@ -5,11 +5,14 @@ module RBatch
|
|
5
5
|
|
6
6
|
module_function
|
7
7
|
|
8
|
+
# Alias of RBatch::Config.new
|
9
|
+
def config ; Config.new end
|
10
|
+
|
8
11
|
# Read config file and return hash opject.
|
9
12
|
#
|
10
|
-
# Default config file path is "../
|
13
|
+
# Default config file path is "../conf/(Program Base name).yaml"
|
11
14
|
# ==== Sample
|
12
|
-
# config : ./
|
15
|
+
# config : ./conf/sample2.yaml
|
13
16
|
# key: value
|
14
17
|
# array:
|
15
18
|
# - item1
|
@@ -17,13 +20,26 @@ module RBatch
|
|
17
20
|
# - item3
|
18
21
|
# script : ./bin/sample2.rb
|
19
22
|
# require 'rbatch'
|
20
|
-
# p RBatch::
|
23
|
+
# p RBatch::Config.new
|
24
|
+
# # or p RBatch::config
|
21
25
|
# => {"key" => "value", "array" => ["item1", "item2", "item3"]}
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
+
class Config
|
27
|
+
@path
|
28
|
+
@config
|
29
|
+
def initialize
|
30
|
+
file = Pathname(File.basename(RBatch.program_name)).sub_ext(".yaml").to_s
|
31
|
+
dir = File.join(File.join(File.dirname(RBatch.program_name),".."),"conf")
|
32
|
+
@path = File.join(dir,file)
|
33
|
+
@config = YAML::load_file(@path)
|
34
|
+
end
|
35
|
+
def[](key)
|
36
|
+
raise RBatch::Config::Exception, "Value of key=\"#{key}\" is nil" if @config[key].nil?
|
37
|
+
@config[key]
|
38
|
+
end
|
39
|
+
def path ; @path ; end
|
40
|
+
def to_s ; @config.to_s ;end
|
26
41
|
end
|
27
42
|
|
43
|
+
class RBatch::Config::Exception < Exception; end
|
28
44
|
end
|
29
45
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rbatch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.
|
5
|
+
version: 1.6.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- fetaro
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2013-01-
|
13
|
+
date: 2013-01-14 00:00:00 Z
|
14
14
|
dependencies: []
|
15
15
|
|
16
16
|
description: ""
|