cfa 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cfa/base_model.rb +21 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea6e4639e7b32b029af4f8e59ce6cc4951654934
|
4
|
+
data.tar.gz: 6775d4085722ba982b8ab801b5d623df8110bba9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d36646d8d6cb6b171c1d7db0b9435ab4b3e69153e17ab0ffed8afeb35c0dcdad36aeeb4ea5e223b8bd19f641f7044791c8e11b9281739482f694545a90331a6f
|
7
|
+
data.tar.gz: d2c49f5cc8459a36efa7c2116d241606dca3c4de284e4c179e40fee59bfaa4912d408354920fb464db39bbfcd83cdfe21b83f05bd79c1e25f88bf1012d468b36
|
data/lib/cfa/base_model.rb
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
require "cfa/matcher"
|
2
|
+
require "cfa/placer"
|
3
|
+
# FIXME: tree should be generic and not augeas specific,
|
4
|
+
# not needed in 1.0 as planned
|
5
|
+
require "cfa/augeas_parser"
|
6
|
+
|
1
7
|
module CFA
|
2
8
|
# A base class for models. Represents a configuration file as an object
|
3
9
|
# with domain-specific attributes/methods. For persistent storage,
|
@@ -98,17 +104,30 @@ module CFA
|
|
98
104
|
def self.attributes(attrs)
|
99
105
|
attrs.each_pair do |method_name, key|
|
100
106
|
define_method(method_name) do
|
101
|
-
generic_get(key)
|
107
|
+
tree_value_plain(generic_get(key))
|
102
108
|
end
|
103
109
|
|
104
110
|
define_method(:"#{method_name.to_s}=") do |value|
|
105
|
-
|
111
|
+
tree_value_change(key, value)
|
106
112
|
end
|
107
113
|
end
|
108
114
|
end
|
109
115
|
|
110
116
|
protected
|
111
117
|
|
118
|
+
def tree_value_plain(value)
|
119
|
+
value.is_a?(AugeasTreeValue) ? value.value : value
|
120
|
+
end
|
121
|
+
|
122
|
+
def tree_value_change(key, value)
|
123
|
+
old_value = generic_get(key)
|
124
|
+
if old_value.is_a?(AugeasTreeValue)
|
125
|
+
old_value.value = value
|
126
|
+
value = old_value
|
127
|
+
end
|
128
|
+
generic_set(key, value)
|
129
|
+
end
|
130
|
+
|
112
131
|
attr_accessor :data
|
113
132
|
|
114
133
|
def merge_changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josef Reidinger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-augeas
|
@@ -61,9 +61,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
61
|
version: 1.3.6
|
62
62
|
requirements: []
|
63
63
|
rubyforge_project:
|
64
|
-
rubygems_version: 2.
|
64
|
+
rubygems_version: 2.2.5
|
65
65
|
signing_key:
|
66
66
|
specification_version: 4
|
67
67
|
summary: CFA (Config Files API) provides an easy way to create models on top of configuration
|
68
68
|
files
|
69
69
|
test_files: []
|
70
|
+
has_rdoc:
|