configable 0.0.2 → 0.0.4
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/lib/configable.rb +6 -3
- data/lib/configable/version.rb +3 -3
- metadata +3 -3
data/lib/configable.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#!ruby -Ku
|
2
2
|
# -*- encoding: UTF-8 -*-
|
3
3
|
require 'ya2yaml'
|
4
|
+
require 'fileutils'
|
4
5
|
|
5
6
|
class Module
|
6
7
|
def define_class_method(name)
|
@@ -15,20 +16,21 @@ module Configable
|
|
15
16
|
|
16
17
|
define_class_method(config.method) { config }
|
17
18
|
define_method(config.method) { config }
|
18
|
-
end
|
19
|
+
end
|
19
20
|
|
20
21
|
class ConfigFile
|
21
22
|
# �ݒ�f�[�^�̃��[�h
|
22
23
|
def load
|
23
|
-
val
|
24
|
+
val=@default
|
24
25
|
# �t�@�C���̓ǂݍ���
|
25
26
|
if File.exist?(@file)
|
26
27
|
open(@file, "rb") do |f|
|
27
28
|
l = YAML::load(f)
|
28
|
-
val =
|
29
|
+
val = val.merge(l) if l.is_a? Hash
|
29
30
|
end
|
30
31
|
end
|
31
32
|
# �������ށi�����l��ύX�����ꍇ�ȂǁB
|
33
|
+
FileUtils.mkpath File.dirname(File.expand_path(@file))
|
32
34
|
open(@file,"wb") {|f| f.puts val.ya2yaml(:syck_compatible => true) }
|
33
35
|
# ������������f�t�H���g�l��߂�
|
34
36
|
val
|
@@ -39,6 +41,7 @@ module Configable
|
|
39
41
|
end
|
40
42
|
def save!
|
41
43
|
# �������ށi�����l��ύX�����ꍇ�ȂǁB
|
44
|
+
FileUtils.mkpath File.dirname(File.expand_path(@file))
|
42
45
|
open(@file,"wb") {|f| f.puts @values.ya2yaml(:syck_compatible => true) }
|
43
46
|
end
|
44
47
|
|
data/lib/configable/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module Configable
|
2
|
-
VERSION = "0.0.
|
3
|
-
end
|
1
|
+
module Configable
|
2
|
+
VERSION = "0.0.4"
|
3
|
+
end
|
metadata
CHANGED