cfa 0.2.0 → 0.3.0
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 +19 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c7c319b95af69d63982cc26ad42fe34fd9b093c
|
4
|
+
data.tar.gz: 444f7f376376ed86f043d141d3e03f72ea1be175
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8928604db487fc98241e9f30723aeea719a98f7e54c8b2963f9429ac4308c51de8501757ed625391ba304dc86976c0ed0ed8eb5db66608b48276184a99323bfc
|
7
|
+
data.tar.gz: 58fbf54148ae3943c12cf0b90d3cae9b4809ae351870086e9180c6308ebaab0f7e367346777f1a8d911b9f6854db496ca17e407dff4ab8d83359d5e174ef71b2
|
data/lib/cfa/base_model.rb
CHANGED
@@ -10,11 +10,12 @@ module CFA
|
|
10
10
|
# `string #serialize(object)`, `object #parse(string)` and `object #empty`
|
11
11
|
# For example see {CFA::AugeasParser}
|
12
12
|
# @param file_path [String] expected path passed to file_handler
|
13
|
-
# @param file_handler [.read, .write] object
|
14
|
-
# It
|
15
|
-
# `write(string, string)`. For example see {CFA::MemoryFile}
|
16
|
-
|
17
|
-
|
13
|
+
# @param file_handler [.read, .write] an object able to read/write a string.
|
14
|
+
# It has to provide methods `string read(string)` and
|
15
|
+
# `write(string, string)`. For an example see {CFA::MemoryFile}.
|
16
|
+
# If unspecified or `nil`, {.default_file_handler} is asked.
|
17
|
+
def initialize(parser, file_path, file_handler: nil)
|
18
|
+
@file_handler = file_handler || BaseModel.default_file_handler
|
18
19
|
@parser = parser
|
19
20
|
@file_path = file_path
|
20
21
|
@loaded = false
|
@@ -51,6 +52,19 @@ module CFA
|
|
51
52
|
@loaded
|
52
53
|
end
|
53
54
|
|
55
|
+
# Gets default file handler used when nil passed as file_handler in
|
56
|
+
# constructor
|
57
|
+
def self.default_file_handler
|
58
|
+
@default_file_handler ||= File
|
59
|
+
end
|
60
|
+
|
61
|
+
# Sets default file handler. Useful when needed to change default like if
|
62
|
+
# whole program use non standard file reading.
|
63
|
+
# @param value for value specification see constructor
|
64
|
+
def self.default_file_handler=(value)
|
65
|
+
@default_file_handler = value
|
66
|
+
end
|
67
|
+
|
54
68
|
protected
|
55
69
|
|
56
70
|
# generates accessors for trivial key-value attributes
|
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josef Reidinger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-augeas
|