cfa 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cfa/base_model.rb +21 -2
  3. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20d0d56ba26b5b824817fedbd1dd5111952bfc15
4
- data.tar.gz: a3d8b0c17b1727c18ee25aea940db711a7d5714c
3
+ metadata.gz: ea6e4639e7b32b029af4f8e59ce6cc4951654934
4
+ data.tar.gz: 6775d4085722ba982b8ab801b5d623df8110bba9
5
5
  SHA512:
6
- metadata.gz: aa97b3fed3d901bc8901d58d57b4612d4455b0a4552d4e90c190865c0a1bd62627ff8e36accf05cbb8efa9855b8b36a2551de482ce31451f85dfd3eb70f47138
7
- data.tar.gz: f6a930470d3151060eb00e0f24d5f7cbb0db0f103e13ab84997a7dc04fef1098cd99d0cdf5b949061174cbf386fbefa42328270beb1ba9e2b655c40bdf68a1df
6
+ metadata.gz: d36646d8d6cb6b171c1d7db0b9435ab4b3e69153e17ab0ffed8afeb35c0dcdad36aeeb4ea5e223b8bd19f641f7044791c8e11b9281739482f694545a90331a6f
7
+ data.tar.gz: d2c49f5cc8459a36efa7c2116d241606dca3c4de284e4c179e40fee59bfaa4912d408354920fb464db39bbfcd83cdfe21b83f05bd79c1e25f88bf1012d468b36
@@ -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
- generic_set(key, value)
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.1
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-04-25 00:00:00.000000000 Z
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.4.5.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: