sifttter-redux 0.5.4 → 0.6
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +5 -1
- data/Gemfile +1 -0
- data/Rakefile +78 -25
- data/bin/srd +74 -63
- data/features/1.ui.feature +7 -0
- data/features/2.initialization.feature +130 -0
- data/features/step_definitions/sifttter-redux_steps.rb +19 -0
- data/features/support/env.rb +20 -0
- data/lib/sifttter-redux/constants.rb +33 -0
- data/lib/{sifttter_redux/date_range_maker.rb → sifttter-redux/date-range-maker.rb} +23 -47
- data/lib/sifttter-redux/dropbox-uploader.rb +64 -0
- data/lib/{sifttter_redux → sifttter-redux}/sifttter.rb +16 -21
- data/lib/sifttter-redux.rb +164 -0
- data/res/preference_prompts.yaml +17 -0
- data/{sifttter_redux.gemspec → sifttter-redux.gemspec} +2 -1
- data/test/date_range_maker_test.rb +1 -1
- data/tmp/srd/.dropbox_uploader +0 -0
- data/tmp/srd/.sifttter_redux +13 -0
- data/tmp/srd/.sifttter_redux_log +10 -0
- metadata +34 -14
- data/lib/sifttter_redux/cli_message.rb +0 -270
- data/lib/sifttter_redux/configuration.rb +0 -89
- data/lib/sifttter_redux/dropbox_uploader.rb +0 -77
- data/lib/sifttter_redux/version.rb +0 -6
- data/lib/sifttter_redux.rb +0 -218
- data/test/cli_message_test.rb +0 -54
- data/test/configuration_test.rb +0 -78
@@ -0,0 +1,17 @@
|
|
1
|
+
:prompts:
|
2
|
+
- prompt: Where do you want to download Sifttter files to (temporarily)?
|
3
|
+
default: /tmp/sifttter
|
4
|
+
key: sifttter_local_filepath
|
5
|
+
section: sifttter_redux
|
6
|
+
- prompt: Where are your Sifttter files located in Dropbox?
|
7
|
+
default: /Apps/ifttt/sifttter
|
8
|
+
key: sifttter_remote_filepath
|
9
|
+
section: sifttter_redux
|
10
|
+
- prompt: Where do you want to download Day One files to (temporarily)?
|
11
|
+
default: /tmp/dayone
|
12
|
+
key: dayone_local_filepath
|
13
|
+
section: sifttter_redux
|
14
|
+
- prompt: Where are your Day One files located in Dropbox?
|
15
|
+
default: /Apps/Day\ One/Journal.dayone/entries
|
16
|
+
key: dayone_remote_filepath
|
17
|
+
section: sifttter_redux
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require '
|
4
|
+
require 'sifttter-redux/constants'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'sifttter-redux'
|
@@ -27,5 +27,6 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_development_dependency('rdoc', '4.1.1')
|
28
28
|
spec.add_development_dependency('aruba', '0.5.4')
|
29
29
|
spec.add_runtime_dependency('chronic', '0.10.2')
|
30
|
+
spec.add_runtime_dependency('cliutils', '1.1.0')
|
30
31
|
spec.add_runtime_dependency('gli','2.9.0')
|
31
32
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'date'
|
2
2
|
require 'test_helper'
|
3
|
-
require File.join(File.dirname(__FILE__), '..', 'lib/
|
3
|
+
require File.join(File.dirname(__FILE__), '..', 'lib/sifttter-redux/date-range-maker.rb')
|
4
4
|
|
5
5
|
class DateRangeMakerTest < Test::Unit::TestCase
|
6
6
|
def test_today
|
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
:sifttter_redux:
|
3
|
+
:config_location: "/Users/abach/Git/sifttter-redux/features/support/../../tmp/srd/.sifttter_redux"
|
4
|
+
:log_level: WARN
|
5
|
+
:version: 0.5.4
|
6
|
+
:sifttter_local_filepath: "/Users/abach/Git/sifttter-redux/features/support/../../tmp/srd/sifttter_download"
|
7
|
+
:sifttter_remote_filepath: "/Apps/ifttt/Sifttter"
|
8
|
+
:dayone_local_filepath: "/Users/abach/Git/sifttter-redux/features/support/../../tmp/srd/day_one_download"
|
9
|
+
:dayone_remote_filepath: "/Apps/Day\\ One/Journal.dayone/entries"
|
10
|
+
:db_uploader:
|
11
|
+
:base_filepath: "/usr/local/opt"
|
12
|
+
:dbu_filepath: "/usr/local/opt/Dropbox-Uploader"
|
13
|
+
:exe_filepath: "/usr/local/opt/Dropbox-Uploader/dropbox_uploader.sh"
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Logfile created on 2014-03-22 08:12:43 -0600 by logger.rb/44203
|
2
|
+
D, [2014-03-22T08:12:43.563366 #13209] DEBUG -- : CONFIGURING DROPBOX UPLOADER...
|
3
|
+
D, [2014-03-22T08:12:43.563826 #13209] DEBUG -- : Answer to "Location for Dropbox-Uploader": /usr/local/opt
|
4
|
+
W, [2014-03-22T08:12:43.563882 #13209] WARN -- : Using pre-existing Dropbox Uploader at /usr/local/opt/Dropbox-Uploader...
|
5
|
+
D, [2014-03-22T08:12:43.563920 #13209] DEBUG -- : COLLECTING PREFERENCES...
|
6
|
+
D, [2014-03-22T08:12:43.564297 #13209] DEBUG -- : Answer to "Temporary path to download Sifttter files to": ~/sifttter_download
|
7
|
+
D, [2014-03-22T08:12:43.564661 #13209] DEBUG -- : Answer to "Path to Sifttter files in Dropbox": /Apps/ifttt/Sifttter
|
8
|
+
D, [2014-03-22T08:12:43.564995 #13209] DEBUG -- : Answer to "Temporary path to download Day One files to": ~/day_one_download
|
9
|
+
D, [2014-03-22T08:12:43.565542 #13209] DEBUG -- : Answer to "Path to Day One files in Dropbox": /Apps/Day\ One/Journal.dayone/entries
|
10
|
+
D, [2014-03-22T08:12:43.565605 #13209] DEBUG -- : Configuration values: {:sifttter_redux=>{:config_location=>"/Users/abach/Git/sifttter-redux/features/support/../../tmp/srd/.sifttter_redux", :log_level=>"WARN", :version=>"0.5.4", :sifttter_local_filepath=>"/Users/abach/Git/sifttter-redux/features/support/../../tmp/srd/sifttter_download", :sifttter_remote_filepath=>"/Apps/ifttt/Sifttter", :dayone_local_filepath=>"/Users/abach/Git/sifttter-redux/features/support/../../tmp/srd/day_one_download", :dayone_remote_filepath=>"/Apps/Day\\ One/Journal.dayone/entries"}, :db_uploader=>{:base_filepath=>"/usr/local/opt", :dbu_filepath=>"/usr/local/opt/Dropbox-Uploader", :exe_filepath=>"/usr/local/opt/Dropbox-Uploader/dropbox_uploader.sh"}}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sifttter-redux
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.6'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Bach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.10.2
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: cliutils
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.1.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.1.0
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: gli
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,18 +114,22 @@ files:
|
|
100
114
|
- README.md
|
101
115
|
- Rakefile
|
102
116
|
- bin/srd
|
103
|
-
-
|
104
|
-
-
|
105
|
-
-
|
106
|
-
-
|
107
|
-
- lib/
|
108
|
-
- lib/
|
109
|
-
- lib/
|
110
|
-
-
|
111
|
-
-
|
112
|
-
-
|
117
|
+
- features/1.ui.feature
|
118
|
+
- features/2.initialization.feature
|
119
|
+
- features/step_definitions/sifttter-redux_steps.rb
|
120
|
+
- features/support/env.rb
|
121
|
+
- lib/sifttter-redux.rb
|
122
|
+
- lib/sifttter-redux/constants.rb
|
123
|
+
- lib/sifttter-redux/date-range-maker.rb
|
124
|
+
- lib/sifttter-redux/dropbox-uploader.rb
|
125
|
+
- lib/sifttter-redux/sifttter.rb
|
126
|
+
- res/preference_prompts.yaml
|
127
|
+
- sifttter-redux.gemspec
|
113
128
|
- test/date_range_maker_test.rb
|
114
129
|
- test/test_helper.rb
|
130
|
+
- tmp/srd/.dropbox_uploader
|
131
|
+
- tmp/srd/.sifttter_redux
|
132
|
+
- tmp/srd/.sifttter_redux_log
|
115
133
|
homepage: https://github.com/bachya/sifttter-redux
|
116
134
|
licenses:
|
117
135
|
- MIT
|
@@ -138,8 +156,10 @@ signing_key:
|
|
138
156
|
specification_version: 4
|
139
157
|
summary: Automated IFTTT to Day One engine.
|
140
158
|
test_files:
|
141
|
-
-
|
142
|
-
-
|
159
|
+
- features/1.ui.feature
|
160
|
+
- features/2.initialization.feature
|
161
|
+
- features/step_definitions/sifttter-redux_steps.rb
|
162
|
+
- features/support/env.rb
|
143
163
|
- test/date_range_maker_test.rb
|
144
164
|
- test/test_helper.rb
|
145
165
|
has_rdoc:
|
@@ -1,270 +0,0 @@
|
|
1
|
-
require 'logger'
|
2
|
-
require 'readline'
|
3
|
-
|
4
|
-
module SifttterRedux
|
5
|
-
# ======================================================
|
6
|
-
# CliManager Module
|
7
|
-
# Singleton to manage common CLI interfacing
|
8
|
-
# ======================================================
|
9
|
-
module CLIMessage
|
10
|
-
# ====================================================
|
11
|
-
# Methods
|
12
|
-
# ====================================================
|
13
|
-
# ----------------------------------------------------
|
14
|
-
# activate_logging method
|
15
|
-
#
|
16
|
-
# Creates a simple logger to use
|
17
|
-
# @return Void
|
18
|
-
# ----------------------------------------------------
|
19
|
-
def self.activate_logging
|
20
|
-
@@logger = Logger.new(File.join(ENV['HOME'], '.sifttter_redux_log'))
|
21
|
-
end
|
22
|
-
|
23
|
-
# ----------------------------------------------------
|
24
|
-
# deactivate_logging method
|
25
|
-
#
|
26
|
-
# Stops logging to file.
|
27
|
-
# @return Void
|
28
|
-
# ----------------------------------------------------
|
29
|
-
def self.deactivate_logging
|
30
|
-
@@logger = nil
|
31
|
-
end
|
32
|
-
|
33
|
-
# ----------------------------------------------------
|
34
|
-
# debug method
|
35
|
-
#
|
36
|
-
# Logs a debug message to the logfile.
|
37
|
-
# @param m The message to log
|
38
|
-
# @return Void
|
39
|
-
# ----------------------------------------------------
|
40
|
-
def self.debug(m)
|
41
|
-
@@logger.debug(m.blue) unless @@logger.nil?
|
42
|
-
end
|
43
|
-
|
44
|
-
# ----------------------------------------------------
|
45
|
-
# error method
|
46
|
-
#
|
47
|
-
# Outputs a formatted-red error message.
|
48
|
-
# @param m The message to output
|
49
|
-
# @return Void
|
50
|
-
# ----------------------------------------------------
|
51
|
-
def self.error(m)
|
52
|
-
puts "# #{ m }".red
|
53
|
-
@@logger.error(m.red) unless @@logger.nil?
|
54
|
-
end
|
55
|
-
|
56
|
-
# ----------------------------------------------------
|
57
|
-
# info method
|
58
|
-
#
|
59
|
-
# Outputs a formatted-blue informational message.
|
60
|
-
# @param m The message to output
|
61
|
-
# @return Void
|
62
|
-
# ----------------------------------------------------
|
63
|
-
def self.info(m)
|
64
|
-
puts "# #{ m }".blue
|
65
|
-
@@logger.debug(m.blue) unless @@logger.nil?
|
66
|
-
end
|
67
|
-
|
68
|
-
# ----------------------------------------------------
|
69
|
-
# info_block method
|
70
|
-
#
|
71
|
-
# Wraps a block in an opening and closing info message.
|
72
|
-
# @param m1 The opening message to output
|
73
|
-
# @param m2 The closing message to output
|
74
|
-
# @param multiline Whether the message should be multiline
|
75
|
-
# @return Void
|
76
|
-
# ----------------------------------------------------
|
77
|
-
def self.info_block(m1, m2 = 'Done.', multiline = false)
|
78
|
-
if block_given?
|
79
|
-
if multiline
|
80
|
-
info(m1)
|
81
|
-
else
|
82
|
-
print "# #{ m1 }".blue
|
83
|
-
end
|
84
|
-
|
85
|
-
yield
|
86
|
-
|
87
|
-
if multiline
|
88
|
-
info(m2)
|
89
|
-
else
|
90
|
-
puts m2.blue
|
91
|
-
end
|
92
|
-
else
|
93
|
-
fail ArgumentError, 'Did not specify a valid block'
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
# ----------------------------------------------------
|
98
|
-
# log_level method
|
99
|
-
#
|
100
|
-
# Creates a simple logger to use
|
101
|
-
# @return Void
|
102
|
-
# ----------------------------------------------------
|
103
|
-
LOG_LEVELS = {
|
104
|
-
'DEBUG' => Logger::DEBUG,
|
105
|
-
'INFO' => Logger::INFO,
|
106
|
-
'WARN' => Logger::WARN,
|
107
|
-
'ERROR' => Logger::ERROR,
|
108
|
-
'FATAL' => Logger::FATAL,
|
109
|
-
'UNKNOWN' => Logger::UNKNOWN
|
110
|
-
}
|
111
|
-
|
112
|
-
def self.log_level(level)
|
113
|
-
@@logger.level = LOG_LEVELS[level] if LOG_LEVELS.key?(level)
|
114
|
-
end
|
115
|
-
|
116
|
-
# ----------------------------------------------------
|
117
|
-
# prompt method
|
118
|
-
#
|
119
|
-
# Outputs a prompt, collects the user's response, and
|
120
|
-
# returns it.
|
121
|
-
# @param prompt The prompt to output
|
122
|
-
# @param default The default option
|
123
|
-
# @return String
|
124
|
-
# ----------------------------------------------------
|
125
|
-
def self.prompt(prompt, default = nil, start_dir = '')
|
126
|
-
Readline.completion_append_character = nil
|
127
|
-
Readline.completion_proc = lambda do |prefix|
|
128
|
-
files = Dir["#{start_dir}#{prefix}*"]
|
129
|
-
files.
|
130
|
-
map { |f| File.expand_path(f) }.
|
131
|
-
map { |f| File.directory?(f) ? f + "/" : f }
|
132
|
-
end
|
133
|
-
choice = Readline.readline("# #{ prompt }#{ default.nil? ? ':' : " [default: #{ default }]:" } ".green)
|
134
|
-
if choice.empty?
|
135
|
-
r = default
|
136
|
-
else
|
137
|
-
r = choice
|
138
|
-
end
|
139
|
-
@@logger.debug("Answer to \"#{ prompt }\": #{ r }") unless @@logger.nil?
|
140
|
-
r
|
141
|
-
end
|
142
|
-
|
143
|
-
# ----------------------------------------------------
|
144
|
-
# section method
|
145
|
-
#
|
146
|
-
# Outputs a formatted-purple section message.
|
147
|
-
# @param m The message to output
|
148
|
-
# @return Void
|
149
|
-
# ----------------------------------------------------
|
150
|
-
def self.section(m)
|
151
|
-
puts "---> #{ m }".purple
|
152
|
-
@@logger.debug(m.purple) unless @@logger.nil?
|
153
|
-
end
|
154
|
-
|
155
|
-
# ----------------------------------------------------
|
156
|
-
# section_block method
|
157
|
-
#
|
158
|
-
# Wraps a block in an opening and closing section
|
159
|
-
# message.
|
160
|
-
# @param m1 The opening message to output
|
161
|
-
# @param m2 The closing message to output
|
162
|
-
# @param multiline A multiline message or not
|
163
|
-
# @return Void
|
164
|
-
# ----------------------------------------------------
|
165
|
-
def self.section_block(m, multiline = true)
|
166
|
-
if block_given?
|
167
|
-
if multiline
|
168
|
-
section(m)
|
169
|
-
else
|
170
|
-
print "---> #{ m }".purple
|
171
|
-
end
|
172
|
-
|
173
|
-
yield
|
174
|
-
else
|
175
|
-
error = 'Did not specify a valid block'
|
176
|
-
fail ArgumentError, error
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
# ----------------------------------------------------
|
181
|
-
# success method
|
182
|
-
#
|
183
|
-
# Outputs a formatted-green success message.
|
184
|
-
# @param m The message to output
|
185
|
-
# @return Void
|
186
|
-
# ----------------------------------------------------
|
187
|
-
def self.success(m)
|
188
|
-
puts "# #{ m }".green
|
189
|
-
@@logger.debug(m.green) unless @@logger.nil?
|
190
|
-
end
|
191
|
-
|
192
|
-
# ----------------------------------------------------
|
193
|
-
# warning method
|
194
|
-
#
|
195
|
-
# Outputs a formatted-yellow warning message.
|
196
|
-
# @param m The message to output
|
197
|
-
# @return Void
|
198
|
-
# ----------------------------------------------------
|
199
|
-
def self.warning(m)
|
200
|
-
puts "# #{ m }".yellow
|
201
|
-
@@logger.warn(m.yellow) unless @@logger.nil?
|
202
|
-
end
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
# ======================================================
|
207
|
-
# String Class
|
208
|
-
# ======================================================
|
209
|
-
class String
|
210
|
-
# ----------------------------------------------------
|
211
|
-
# colorize method
|
212
|
-
#
|
213
|
-
# Outputs a string in a formatted color.
|
214
|
-
# @param color_code The code to use
|
215
|
-
# @return Void
|
216
|
-
# ----------------------------------------------------
|
217
|
-
def colorize(color_code)
|
218
|
-
"\e[#{ color_code }m#{ self }\e[0m"
|
219
|
-
end
|
220
|
-
|
221
|
-
# ----------------------------------------------------
|
222
|
-
# blue method
|
223
|
-
#
|
224
|
-
# Convenience method to output a blue string
|
225
|
-
# @return Void
|
226
|
-
# ----------------------------------------------------
|
227
|
-
def blue
|
228
|
-
colorize(34)
|
229
|
-
end
|
230
|
-
|
231
|
-
# ----------------------------------------------------
|
232
|
-
# green method
|
233
|
-
#
|
234
|
-
# Convenience method to output a green string
|
235
|
-
# @return Void
|
236
|
-
# ----------------------------------------------------
|
237
|
-
def green
|
238
|
-
colorize(32)
|
239
|
-
end
|
240
|
-
|
241
|
-
# ----------------------------------------------------
|
242
|
-
# purple method
|
243
|
-
#
|
244
|
-
# Convenience method to output a purple string
|
245
|
-
# @return Void
|
246
|
-
# ----------------------------------------------------
|
247
|
-
def purple
|
248
|
-
colorize(35)
|
249
|
-
end
|
250
|
-
|
251
|
-
# ----------------------------------------------------
|
252
|
-
# red method
|
253
|
-
#
|
254
|
-
# Convenience method to output a red string
|
255
|
-
# @return Void
|
256
|
-
# ----------------------------------------------------
|
257
|
-
def red
|
258
|
-
colorize(31)
|
259
|
-
end
|
260
|
-
|
261
|
-
# ----------------------------------------------------
|
262
|
-
# yellow method
|
263
|
-
#
|
264
|
-
# Convenience method to output a yellow string
|
265
|
-
# @return Void
|
266
|
-
# ----------------------------------------------------
|
267
|
-
def yellow
|
268
|
-
colorize(33)
|
269
|
-
end
|
270
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
|
3
|
-
module SifttterRedux
|
4
|
-
# ======================================================
|
5
|
-
# Configuration Module
|
6
|
-
#
|
7
|
-
# Manages any configuration values and the flat file
|
8
|
-
# into which they get stored.
|
9
|
-
# ======================================================
|
10
|
-
module Configuration
|
11
|
-
extend self
|
12
|
-
|
13
|
-
@_data = {}
|
14
|
-
# ====================================================
|
15
|
-
# Methods
|
16
|
-
# ====================================================
|
17
|
-
# ----------------------------------------------------
|
18
|
-
# deep_merge! method
|
19
|
-
#
|
20
|
-
# Deep merges two hashes.
|
21
|
-
# deep_merge by Stefan Rusterholz;
|
22
|
-
# see http://www.ruby-forum.com/topic/142809
|
23
|
-
# @return Void
|
24
|
-
# ----------------------------------------------------
|
25
|
-
def deep_merge!(target, data)
|
26
|
-
merger = proc{|key, v1, v2|
|
27
|
-
Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }
|
28
|
-
target.merge! data, &merger
|
29
|
-
end
|
30
|
-
|
31
|
-
def method_missing(name, *args, &block)
|
32
|
-
@_data[name.to_sym] || @_data.merge!(name.to_sym => {})
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.add_section(section_name)
|
36
|
-
@_data[section_name] = {} unless @_data.key?(section_name)
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.config_path
|
40
|
-
@_config_path
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.delete_section(section_name)
|
44
|
-
@_data.delete(section_name) if @_data.key?(section_name)
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.dump
|
48
|
-
@_data
|
49
|
-
end
|
50
|
-
|
51
|
-
# ----------------------------------------------------
|
52
|
-
# load method
|
53
|
-
#
|
54
|
-
# Loads the configuration data (if it exists) and sets
|
55
|
-
# the filepath to the flat file.
|
56
|
-
# @param path The filepath
|
57
|
-
# @return Void
|
58
|
-
# ----------------------------------------------------
|
59
|
-
def self.load(path)
|
60
|
-
@_config_path = path
|
61
|
-
|
62
|
-
if File.exists?(path)
|
63
|
-
data = YAML.load_file(path)
|
64
|
-
deep_merge!(@_data, data)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
# ----------------------------------------------------
|
69
|
-
# reset method
|
70
|
-
#
|
71
|
-
# Clears the configuration data.
|
72
|
-
# @return Void
|
73
|
-
# ----------------------------------------------------
|
74
|
-
def self.reset
|
75
|
-
@_data = {}
|
76
|
-
end
|
77
|
-
|
78
|
-
# ----------------------------------------------------
|
79
|
-
# save method
|
80
|
-
#
|
81
|
-
# Saves the configuration data to the previously
|
82
|
-
# stored flat file.
|
83
|
-
# @return Void
|
84
|
-
# ----------------------------------------------------
|
85
|
-
def self.save
|
86
|
-
File.open(@_config_path, 'w') { |f| f.write(@_data.to_yaml) }
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|