cfa 0.2.0 → 0.3.0

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 +19 -5
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a42d93bb712da73feacfe946e0c86f5d4dd7e58
4
- data.tar.gz: 685ff8ce8306ee7fc6774d6315467025d7949a56
3
+ metadata.gz: 7c7c319b95af69d63982cc26ad42fe34fd9b093c
4
+ data.tar.gz: 444f7f376376ed86f043d141d3e03f72ea1be175
5
5
  SHA512:
6
- metadata.gz: 4bfc91bbc8091d276004cfc5f772c13bc146ae52df5e5843afa22548c2ab00683a06c6a48323b12fd54cc7f000eee31839945aee7e2d2313f072563892fb427a
7
- data.tar.gz: 784e7db8da973a2f64e11e82f9e93a25206afb5ae75daca59e027e7ca1e18ba7f14c1062c279cf6dac5bd4a8079becf015ac186e13f745989fd53b002737b78c
6
+ metadata.gz: 8928604db487fc98241e9f30723aeea719a98f7e54c8b2963f9429ac4308c51de8501757ed625391ba304dc86976c0ed0ed8eb5db66608b48276184a99323bfc
7
+ data.tar.gz: 58fbf54148ae3943c12cf0b90d3cae9b4809ae351870086e9180c6308ebaab0f7e367346777f1a8d911b9f6854db496ca17e407dff4ab8d83359d5e174ef71b2
@@ -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, that can read/write string.
14
- # It have to provide methods `string read(string)` and
15
- # `write(string, string)`. For example see {CFA::MemoryFile}
16
- def initialize(parser, file_path, file_handler: File)
17
- @file_handler = file_handler
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.2.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-15 00:00:00.000000000 Z
11
+ date: 2015-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-augeas