easy_app_helper 0.0.9 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3f63bdf83edcaeec2428490a62ddfaf57cbf2e6
4
- data.tar.gz: 9cb82c768e6991e0bf4aafb18e01b2f1369db5e8
3
+ metadata.gz: 9e26f7e3e20c41919179c83e8afbef9e91f80686
4
+ data.tar.gz: b76f54662fb9ef9146724ce1721b430d0c6c1a14
5
5
  SHA512:
6
- metadata.gz: c31b6806be5d12f0020a5ff9afa18c600dfeb5d5c851e323157c90b7ed7975f8e7e975862d9c7ac6aaab6f44b9312547d8a9c35c044af6acbd92ba6209b6a252
7
- data.tar.gz: be781cca91d84972d16aff9f76fbbfbe9bc8afa48ff7723ff65df4c9ac725143dbd0c2370d634208ef12cbb20ad37ec0c766140e7ad5619492237b063aaeda16
6
+ metadata.gz: f6f59da41828b98e70e5bfbc27805a74efa8c8a8c63481c135dc74726a1792edb102dbc73868b52fbaefe49e3e6e99badea4fbb686c3c34ccf7de2f9bdcf2075
7
+ data.tar.gz: 44385236b44fcb4b3b928a7cc81fb13ef59168f35bfd538ee7e8834b2cfaf6c773aed7f5e1d052ebf911bfa006989d059f584f001708ee009f173b0f30dcb9c1
data/README.md CHANGED
@@ -1,12 +1,38 @@
1
1
  # EasyAppHelper
2
2
 
3
+ **This [gem][EAP] aims at providing useful helpers for command line applications.**
4
+
5
+ This is a complete rewrite of the initial easy_app_helper gem. **It is not compatible with
6
+ apps designed for easy_app_helper prior to version 1.0.0**, although they could be very easily adapted.
7
+ But anyway you always specify your gem dependencies using the [pessimistic version operator]
8
+ (http://docs.rubygems.org/read/chapter/16#page74), don't you ? Older applications should do it to tell your application
9
+ to use the latest version of the 0.x.x series instead.
10
+
11
+ The new **EasyAppHelper** module prodides:
12
+
13
+ * A **super charged Config class** that:
14
+ * Manages **multiple sources of configuration**(command line, multiple config files...) in a **layered config**.
15
+ * Provides an **easy to customize merge mechanism** for the different **config layers** that exposes a "live view"
16
+ of the merged configuration, while keeping a way to access or modify independently any of them.
17
+ * Allows **flexibility** when dealing with modification and provides a way to roll back modifications done to config
18
+ anytime, fully reload it, blast it... Export feature could be very easily added and will probably.
19
+ * A **Logger tightly coupled with the Config** class, that will behave correctly regarding options specified be it from
20
+ command line or from any source of the config object...
21
+ * Embeds [Slop][slop] to handle **command line parameters** and keeps any parameter defined in a **separated layer of
22
+ the global config object**.
23
+ * A mechanism that ensures that as soon as you access any of the objects or methods exposed by EasyAppHelper,
24
+ all of them are **fully configured and ready to be used**.
25
+
26
+ If you are writing command line applications, I hope you will like because it's very easy to use, and as unobtrusive as
27
+ possible (you choose when you want to include or use as a module) while providing a ready-for-prod config, logger
28
+ and command line management.
29
+
30
+
31
+ Currently the only runtime dependency is the cool [Slop gem][slop] which is used to process the command line options.
3
32
 
4
- This [gem] [1] provides a suite of helpers for command line applications.
5
- The goal is to be as transparent as possible for the application whilst providing consistent helpers that add dedidacted behaviours to your application.
33
+ [Why this gem][4] ?
6
34
 
7
- Currently the only runtime dependency is on the [Slop gem] [2].
8
35
 
9
- [Why this gem][4] ?
10
36
 
11
37
  ## Installation
12
38
 
@@ -22,234 +48,417 @@ Or install it yourself as:
22
48
 
23
49
  $ gem install easy_app_helper
24
50
 
25
- ## Usage
26
-
27
- ### Including the basic module
28
51
 
29
- To benefit from the different helpers. Once you installed the gem, you just need to require it:
30
-
31
- ```ruby
32
- require 'easy_app_helper'
33
- ```
34
52
 
35
- And then in the "main class" of your application, include the modules you want to use and call init_app_helper in the initialize method. Then what you can do with each module is defined by each module itself.
36
53
 
37
- The basic behaviour (when you include EasyAppHelper), actually adds basic command line handling (actually handled by [Slop] [2]), and provides the mechanism to enable you to add any other EasyAppHelper module.
54
+ ## Usage
38
55
 
39
- ex:
56
+ To use it, once you installed them, you just need to require it:
40
57
 
41
58
  ```ruby
42
59
  require 'easy_app_helper'
43
-
44
- class MyApp
45
- include EasyAppHelper
46
- def initialize
47
- init_app_helper "my_app"
48
- end
49
- end
50
60
  ```
51
61
 
52
- This basically does... nothing. I mean the only behaviour it adds to your application is the ability to pass --help to the application to see the inline help (that it builds). On top of this you then have access to some other command line options like --auto, --simulate, --verbose, but for those it is up to your application to check their value using the app_config attribute which is available in your MyApp instance.
53
-
54
- You could then do something like:
62
+ Then can can immediately access the logger or the config objects. Here under a first example:
55
63
 
56
64
  ```ruby
57
65
  require 'easy_app_helper'
58
66
 
59
- class MyApp
67
+ # You can directly access the config or the logger through the **EasyAppHelper** module
68
+ puts "The application verbose flag is #{EasyAppHelper.config[:verbose]}"
69
+
70
+ # You can directly use the logger according to the command line flags
71
+ # This will do nothing unless --debug is set and --log-level is set to the correct level
72
+ EasyAppHelper.logger.info "Hi guys!"
73
+
74
+ # Fed up with the **EasyAppHelper** prefix ? Just include the module where you want
75
+ include EasyAppHelper
76
+
77
+ # You can override programmatically any part of the config
78
+ config[:debug] = true
79
+ logger.level = 1
80
+ config[:test] = 'Groovy'
81
+ EasyAppHelper.logger.info "Hi guys!... again"
82
+
83
+ # You can see the internals of the config
84
+ puts config.internal_configs.to_yaml
85
+ # Which will output
86
+ #:modified:
87
+ # :content:
88
+ # :log-level: 1
89
+ # :debug: true
90
+ # :test: cool
91
+ # :source: Changed by code
92
+ #:command_line:
93
+ # :content:
94
+ # :auto:
95
+ # :simulate:
96
+ # :verbose: true
97
+ # :help:
98
+ # :config-file:
99
+ # :config-override:
100
+ # :debug:
101
+ # :debug-on-err:
102
+ # :log-level:
103
+ # :log-file:
104
+ # :source: Command line
105
+ #:system:
106
+ # :content: {}
107
+ # :source:
108
+ # :origin: EasyAppHelper
109
+ #:global:
110
+ # :content: {}
111
+ # :source:
112
+ # :origin: ''
113
+ #:user:
114
+ # :content: {}
115
+ # :source:
116
+ # :origin: ''
117
+ #:specific_file:
118
+ # :content: {}
119
+
120
+ # You see of course that the two modifications we did are in the modified sub-hash
121
+ # And now the merged config
122
+ puts config.to_hash
123
+
124
+ # But you can see the modified part as it is:
125
+ puts config.internal_configs[:modified]
126
+
127
+ # Of course you can access it from any class
128
+ class Dummy
60
129
  include EasyAppHelper
130
+
61
131
  def initialize
62
- init_app_helper "my_app", "My Super Application", "This is the application everybody was waiting for.", "1.0"
63
- if app_config[:verbose]
64
- puts "Waouh, hello World !!"
65
- end
132
+ puts "#{config[:test]} baby !"
133
+ # Back to the original
134
+ config.reset
135
+ puts config.internal_configs[:modified]
66
136
  end
67
137
  end
68
- ```
69
138
 
70
- You can actually access any field from your application configuration through the app_config attribute.
139
+ Dummy.new
71
140
 
72
- ### Other modules
73
- Some other modules are provided:
141
+ # Some methods are provided to ease common tasks. For example this one will log at info level
142
+ # (so only displayed if debug mode and log level low enough), but will also puts on the console
143
+ # if verbose if set...
144
+ puts_and_logs "Hi world"
74
145
 
75
- * EasyAppHelper::Logger provides logging facilities and config line options including log-level, log-file etc...
76
- * EasyAppHelper::Config provides easy YAML based configuration to your script with multiple level of override (admin wide -> system wide -> user -> command line options -> --config-file). All the configuration being accessible through the app_config hash attribute
146
+ # It is actually one of the few methods added to regular Logger class (The added value of this logger
147
+ # is much more to be tightly coupled with the config object). Thus could access it like that:
148
+ logger.puts_and_logs "Hi world"
77
149
 
78
- See [classes documentation] [3] for more information.
150
+ # or even
151
+ EasyAppHelper.logger.puts_and_logs "Hi world... 3 is enough."
152
+ ```
79
153
 
80
- ### Complete example
81
154
 
82
- Here under a more complete (still useless) example using all the modules.
155
+ ## Configuration layers
83
156
 
84
- ```ruby
85
- require 'easy_app_helper'
157
+ **EasyAppHelper** will look for files in numerous places. **Both Unix and Windows places are handled**.
158
+ All the files are [Yaml][yaml] files but could have names with different extensions.
86
159
 
87
- class MyApp
88
- include EasyAppHelper
89
- include EasyAppHelper::Config
90
- include EasyAppHelper::Logger
160
+ You can look in the classes documentation to know exactly which extensions and places the config
161
+ files are looked for.
91
162
 
92
- def initialize
93
- init_app_helper "my_app", "My Super Application", "This is the application everybody was waiting for.", "1.0"
94
- logger.info "Application is now started."
95
- show_config if app_config[:verbose]
96
- end
163
+ ### System config file
97
164
 
98
- def show_config
99
- puts "Application config is"
100
- puts app_config.to_yaml
101
- end
165
+ This config file is common to all applications that use EasyAppHelper. For example on a Unix system
166
+ regarding the rules described above, the framework will for the following files in that order:
102
167
 
103
- def add_specifc_command_line_options(opt)
104
- opt.on :s, :stupid, 'This is a very stupid option', :argument => false
105
- end
106
- end
168
+ ```text
169
+ # It will be loaded in the :system layer
170
+ /etc/EasyAppHelper.conf
171
+ /etc/EasyAppHelper.yml
172
+ /etc/EasyAppHelper.cfg
173
+ /etc/EasyAppHelper.yaml
174
+ /etc/EasyAppHelper.CFG
175
+ /etc/EasyAppHelper.YML
176
+ /etc/EasyAppHelper.YAML
177
+ /etc/EasyAppHelper.Yaml
178
+ ```
107
179
 
108
- app = MyApp.new
180
+ ### Application config files
181
+
182
+ An application config file names are determined from the config.script_filename property. This initially contains
183
+ the bare name of the script, but you can replace with whatever you want. Changing this property causes actually
184
+ the impacted files to be reloaded.
185
+
186
+ It is in fact a two level configuration. One is global (the :global layer) and the other is at user level (the
187
+ :user layer).
188
+
189
+ For example on a Unix system or cygwin
190
+
191
+ ```text
192
+ # For the :global layer
193
+ /etc/myscript.conf
194
+ /etc/myscript.yml
195
+ /etc/myscript.cfg
196
+ /etc/myscript.yaml
197
+ /etc/myscript.CFG
198
+ /etc/myscript.YML
199
+ /etc/myscript.YAML
200
+ /etc/myscript.Yaml
201
+ /usr/local/etc/myscript.conf
202
+ /usr/local/etc/myscript.yml
203
+ /usr/local/etc/myscript.cfg
204
+ /usr/local/etc/myscript.yaml
205
+ /usr/local/etc/myscript.CFG
206
+ /usr/local/etc/myscript.YML
207
+ /usr/local/etc/myscript.YAML
208
+ /usr/local/etc/myscript.Yaml
209
+ # For the :user level
210
+ ${HOME}/.config/myscript.conf
211
+ ${HOME}/.config/myscript.yml
212
+ ${HOME}/.config/myscript.cfg
213
+ ${HOME}/.config/myscript.yaml
214
+ ${HOME}/.config/myscript.CFG
215
+ ${HOME}/.config/myscript.YML
216
+ ${HOME}/.config/myscript.YAML
217
+ ${HOME}/.config/myscript.Yaml
109
218
  ```
110
219
 
111
- With this example you can already test some of the behaviours brought to the application by the different modules.
220
+ ### Command line specified config file
112
221
 
113
- $ ruby ./test_app.rb
222
+ The command line option ```--config-file``` provides a way to specify explicitly a config file. On top of this the
223
+ option ```--config-override``` tells **EasyAppHelper** to ignore :system, :global and :user levels.
114
224
 
115
- Nothing displayed... hum in fact normal.
225
+ The file will be loaded in a separated layer called :specific_file
116
226
 
117
- *The EasyAppHelper::Base module*
118
227
 
119
- $ ruby ./test_app.rb --verbose
120
- Application config is
121
- ---
122
- :verbose: true
123
- :log-level: 2
228
+ ### The command line options
124
229
 
125
- Here again we see the impact of the --verbose
230
+ **EasyAppHelper** already provides by default some command line options. Imagine you have the following program.
126
231
 
127
- $ ruby ./test_app.rb --help
232
+ ```ruby
233
+ #!/usr/bin/env ruby
128
234
 
129
- Usage: my_app [options]
130
- My Super Application Version: 1.0
235
+ require 'easy_app_helper'
131
236
 
132
- This is the application everybody was waiting for.
133
- -- Generic options -------------------------------------------
134
- --auto Auto mode. Bypasses questions to user.
135
- --simulate Do not perform the actual underlying actions.
136
- -v, --verbose Enable verbose mode.
137
- -h, --help Displays this help.
237
+ class MyApp
238
+ include EasyAppHelper
138
239
 
139
- -- Debug and logging options ---------------------------------
140
- --debug Run in debug mode.
141
- --debug-on-err Run in debug mode with output to stderr.
142
- --log-level Log level from 0 to 5, default 2.
143
- --log-file File to log to.
240
+ APP_NAME = "My super application"
241
+ VERSION = '0.0.1'
242
+ DESCRIPTION = 'This application is a proof of concept for EasyAppHelper.'
144
243
 
145
- -- Configuration options -------------------------------------
146
- --config-file Specify a config file.
147
244
 
148
- -- Script specific options------------------------------------
149
- -s, --stupid This is a very stupid option
245
+ def initialize
246
+ # Providing this data is optional but brings better logging and online help
247
+ config.describes_application(app_name: APP_NAME, app_version: VERSION, app_description: DESCRIPTION)
248
+ end
150
249
 
151
250
 
152
- Here we see that:
251
+ def run
252
+ if config[:help]
253
+ puts config.help
254
+ exit 0
255
+ end
256
+ puts_and_logs "Application is starting"
257
+ do_some_processing
258
+ end
153
259
 
154
- * each included module added its own part in the global help
155
- * The information passed to init_app_helper has been used in order to build a consistent help.
156
- * The method implemented add_specifc_command_line_options did add the --stupid command line option and that it fits within the global help. the syntax is the [Slop] [2] syntax, and many other options are available. See the [Slop] [2] for further info.
260
+ def do_some_processing
261
+ puts_and_logs "Starting some heavy processing"
262
+ end
157
263
 
158
- *The EasyAppHelper::Debug module*
264
+ end
159
265
 
160
- Now let's try some options related to the EasyAppHelper::Logger module
161
266
 
162
- $ ruby ./test_app.rb --debug
267
+ MyApp.new.run
268
+ ```
163
269
 
164
- Nothing is displayed. Why ? We used the logger.info stuff !! Just because the default log-level is 2 (Logger::Severity::WARN), whereas we did a info (Logger::Severity::INFO equals to 1).
165
- Thus we can do a:
270
+ And you run it without any command line option
166
271
 
167
- $ ruby ./test_app.rb --debug --log-level 1
168
- I, [2013-03-20T10:58:40.819096 #13172] INFO -- : Application is now started.
272
+ ```text
273
+ ./test4_app.rb
274
+ ```
169
275
 
170
- Which correctly displays the log.
171
- Of course, as mentioned by the inline doc, this could go to a log file using the --log-file option...
276
+ No output...
172
277
 
173
- *The EasyAppHelper::Config module*
278
+ Let' try
174
279
 
175
- From what we did, nothing really shows what the config module brought to the application, whereas in fact this is the one bringing the more features...
280
+ ```text
281
+ ./test4_app.rb --help
176
282
 
177
- This module will try to find config files (YAML format) in different places. All the config files could have a lot of different extensions (EasyAppHelper::Config::Instanciator::CONFIG_FILE_POSSIBLE_EXTENSIONS). Here under we will just say ".ext", but all of them are tried:
283
+ Usage: test4_app [options]
284
+ My super application Version: 0.0.1
178
285
 
179
- First it will try to find the file:
286
+ This application is a proof of concept for EasyAppHelper.
287
+ -- Generic options -------------------------------------------------------------
288
+ --auto Auto mode. Bypasses questions to user.
289
+ --simulate Do not perform the actual underlying actions.
290
+ -v, --verbose Enable verbose mode.
291
+ -h, --help Displays this help.
292
+ -- Configuration options -------------------------------------------------------
293
+ --config-file Specify a config file.
294
+ --config-override If specified override all other config.
295
+ -- Debug and logging options ---------------------------------------------------
296
+ --debug Run in debug mode.
297
+ --debug-on-err Run in debug mode with output to stderr.
298
+ --log-level Log level from 0 to 5, default 2.
299
+ --log-file File to log to.
180
300
 
181
- /etc/EasyAppHelper.ext
301
+ ```
302
+ You see there the online help. And then the program exists.
182
303
 
183
- In this file you could define some options common to all the scripts you will build on top of EasyAppHelper helpers.
304
+ Let's try the ```--verbose``` flag
184
305
 
185
- Then it will try to find (it will stop on the first found):
306
+ ```text
307
+ ./test4_app.rb --verbose
308
+ Application is starting
309
+ Starting some heavy processing
310
+ ```
186
311
 
187
- /etc/my_app.ext
188
- /usr/local/etc/my_app.ext
312
+ You see that the puts_and_logs is sensitive to the ```--verbose``` switch...
189
313
 
190
- In this file you could define some options common to all users
314
+ But what if I debug
315
+ ```text
316
+ ./test4_app.rb --debug
317
+ ```
191
318
 
192
- Then it will try to find:
319
+ Humm... nothing... Let's provide the log level
193
320
 
194
- ${HOME}/.config/my_app.conf
321
+ ```text
322
+ ./test4_app.rb --debug --log-level 0
323
+ I, [2013-06-23T19:37:24.975392 #10276] INFO -- My super application: Application is starting
324
+ I, [2013-06-23T19:37:24.975592 #10276] INFO -- My super application: Starting some heavy processing
325
+ ```
195
326
 
196
- Where each user will generally store his own configuration.
327
+ You see there that the puts_and_logs logs as well with the log level 1 (Info)... Nice looks like it was claiming
328
+ this in its name... ;-)
197
329
 
198
- Each of these file adds options to the common app_config hash. Enabling a simple and powerful override mechanism.
330
+ If I mix ?
199
331
 
200
- Then everything defined on the command line will itself override what has been defined in these config files.
201
- Then if --config-file option is specified in the command line, it tries to load that file.
332
+ ```text
333
+ ./test4_app.rb --debug --log-level 0 --verbose
334
+ Application is starting
335
+ I, [2013-06-23T19:39:05.712558 #11768] INFO -- My super application: Application is starting
336
+ Starting some heavy processing
337
+ I, [2013-06-23T19:39:05.712834 #11768] INFO -- My super application: Starting some heavy processing
338
+ ```
202
339
 
203
- Thus in the end following mechanism:
340
+ So far so good...
204
341
 
205
- admin wide -> system wide -> user -> command line options -> --config-file
342
+ ### Debugging the framework itself
206
343
 
344
+ If you want, you can even debug what happens during **EasyAppHelper** initialisation, for this you can use the
345
+ ```DEBUG_EASY_MODULES``` environment variable. As how and where everything has to be logged is only specified when
346
+ you actually provide command line options, **EasyAppHelper** provides a temporary logger to itself and will
347
+ after all dump the logger content to the logger you specified and if you specify... So that you don't miss a log.
348
+
349
+ ```text
350
+ $ DEBUG_EASY_MODULES=y ruby ./test4_app.rb
351
+
352
+ D, [2013-06-23T19:43:47.977031 #16294] DEBUG -- : Temporary initialisation logger created...
353
+ D, [2013-06-23T19:43:47.977861 #16294] DEBUG -- : Trying "/etc/EasyAppHelper.conf" as config file.
354
+ D, [2013-06-23T19:43:47.977908 #16294] DEBUG -- : Trying "/etc/EasyAppHelper.yml" as config file.
355
+ D, [2013-06-23T19:43:47.977938 #16294] DEBUG -- : Loading config file "/etc/EasyAppHelper.cfg"
356
+ D, [2013-06-23T19:43:47.978300 #16294] DEBUG -- : Trying "/etc/test4_app.conf" as config file.
357
+ D, [2013-06-23T19:43:47.978332 #16294] DEBUG -- : Trying "/etc/test4_app.yml" as config file.
358
+ D, [2013-06-23T19:43:47.978355 #16294] DEBUG -- : Trying "/etc/test4_app.cfg" as config file.
359
+ D, [2013-06-23T19:43:47.978381 #16294] DEBUG -- : Trying "/etc/test4_app.yaml" as config file.
360
+ D, [2013-06-23T19:43:47.978403 #16294] DEBUG -- : Trying "/etc/test4_app.CFG" as config file.
361
+ D, [2013-06-23T19:43:47.978424 #16294] DEBUG -- : Trying "/etc/test4_app.YML" as config file.
362
+ D, [2013-06-23T19:43:47.978445 #16294] DEBUG -- : Trying "/etc/test4_app.YAML" as config file.
363
+ D, [2013-06-23T19:43:47.978466 #16294] DEBUG -- : Trying "/etc/test4_app.Yaml" as config file.
364
+ D, [2013-06-23T19:43:47.978491 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.conf" as config file.
365
+ D, [2013-06-23T19:43:47.978529 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.yml" as config file.
366
+ D, [2013-06-23T19:43:47.978553 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.cfg" as config file.
367
+ D, [2013-06-23T19:43:47.978575 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.yaml" as config file.
368
+ D, [2013-06-23T19:43:47.978597 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.CFG" as config file.
369
+ D, [2013-06-23T19:43:47.978619 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.YML" as config file.
370
+ D, [2013-06-23T19:43:47.978670 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.Yaml" as config file.
371
+ I, [2013-06-23T19:43:47.978695 #16294] INFO -- : No config file found for layer global.
372
+ D, [2013-06-23T19:43:47.978725 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.conf" as config file.
373
+ D, [2013-06-23T19:43:47.978748 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.yml" as config file.
374
+ D, [2013-06-23T19:43:47.978770 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.cfg" as config file.
375
+ D, [2013-06-23T19:43:47.978792 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.yaml" as config file.
376
+ D, [2013-06-23T19:43:47.978817 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.CFG" as config file.
377
+ D, [2013-06-23T19:43:47.978840 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.YML" as config file.
378
+ D, [2013-06-23T19:43:47.978861 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.YAML" as config file.
379
+ D, [2013-06-23T19:43:47.978974 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.Yaml" as config file.
380
+ I, [2013-06-23T19:43:47.979000 #16294] INFO -- : No config file found for layer user.
381
+ I, [2013-06-23T19:43:47.979025 #16294] INFO -- : No config file found for layer specific_file.
382
+ D, [2013-06-23T19:43:47.979514 #16294] DEBUG -- : Trying "/etc/EasyAppHelper.conf" as config file.
383
+ D, [2013-06-23T19:43:47.979561 #16294] DEBUG -- : Trying "/etc/EasyAppHelper.yml" as config file.
384
+ D, [2013-06-23T19:43:47.979591 #16294] DEBUG -- : Loading config file "/etc/EasyAppHelper.cfg"
385
+ D, [2013-06-23T19:43:47.979717 #16294] DEBUG -- : Trying "/etc/test4_app.conf" as config file.
386
+ D, [2013-06-23T19:43:47.979747 #16294] DEBUG -- : Trying "/etc/test4_app.yml" as config file.
387
+ D, [2013-06-23T19:43:47.979800 #16294] DEBUG -- : Trying "/etc/test4_app.cfg" as config file.
388
+ D, [2013-06-23T19:43:47.979823 #16294] DEBUG -- : Trying "/etc/test4_app.yaml" as config file.
389
+ D, [2013-06-23T19:43:47.979845 #16294] DEBUG -- : Trying "/etc/test4_app.CFG" as config file.
390
+ D, [2013-06-23T19:43:47.979867 #16294] DEBUG -- : Trying "/etc/test4_app.YML" as config file.
391
+ D, [2013-06-23T19:43:47.979908 #16294] DEBUG -- : Trying "/etc/test4_app.YAML" as config file.
392
+ D, [2013-06-23T19:43:47.979935 #16294] DEBUG -- : Trying "/etc/test4_app.Yaml" as config file.
393
+ D, [2013-06-23T19:43:47.979959 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.conf" as config file.
394
+ D, [2013-06-23T19:43:47.979981 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.yml" as config file.
395
+ D, [2013-06-23T19:43:47.980004 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.cfg" as config file.
396
+ D, [2013-06-23T19:43:47.980026 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.yaml" as config file.
397
+ D, [2013-06-23T19:43:47.980047 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.CFG" as config file.
398
+ D, [2013-06-23T19:43:47.980069 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.YML" as config file.
399
+ D, [2013-06-23T19:43:47.980091 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.YAML" as config file.
400
+ D, [2013-06-23T19:43:47.980112 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.Yaml" as config file.
401
+ I, [2013-06-23T19:43:47.980135 #16294] INFO -- : No config file found for layer global.
402
+ D, [2013-06-23T19:43:47.980181 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.conf" as config file.
403
+ D, [2013-06-23T19:43:47.980207 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.yml" as config file.
404
+ D, [2013-06-23T19:43:47.980230 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.cfg" as config file.
405
+ D, [2013-06-23T19:43:47.980252 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.yaml" as config file.
406
+ D, [2013-06-23T19:43:47.980274 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.CFG" as config file.
407
+ D, [2013-06-23T19:43:47.980296 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.YML" as config file.
408
+ D, [2013-06-23T19:43:47.980319 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.YAML" as config file.
409
+ D, [2013-06-23T19:43:47.980361 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.Yaml" as config file.
410
+ I, [2013-06-23T19:43:47.980395 #16294] INFO -- : No config file found for layer user.
411
+ I, [2013-06-23T19:43:47.980418 #16294] INFO -- : No config file found for layer specific_file.
412
+ D, [2013-06-23T19:43:47.981934 #16294] DEBUG -- : Config layers:
413
+ ---
414
+ :modified:
415
+ :content: {}
416
+ :source: Changed by code
417
+ :command_line:
418
+ :content:
419
+ :auto:
420
+ :simulate:
421
+ :verbose: true
422
+ :help:
423
+ :config-file:
424
+ :config-override:
425
+ :debug: true
426
+ :debug-on-err:
427
+ :log-level: 0
428
+ :log-file:
429
+ :source: Command line
430
+ :system:
431
+ :content:
432
+ :copyright: (c) 2012-2013 Nanonet
433
+ :source: /etc/EasyAppHelper.cfg
434
+ :origin: EasyAppHelper
435
+ :global:
436
+ :content: {}
437
+ :source:
438
+ :origin: test4_app
439
+ :user:
440
+ :content: {}
441
+ :source:
442
+ :origin: test4_app
443
+ :specific_file:
444
+ :content: {}
445
+
446
+ D, [2013-06-23T19:43:47.985357 #16294] DEBUG -- : Merged config:
447
+ ---
448
+ :copyright: (c) 2012-2013 Nanonet
449
+ :verbose: true
450
+ :debug: true
451
+ :log-level: 0
452
+
453
+ Application is starting
454
+ I, [2013-06-23T19:43:47.986298 #16294] INFO -- My super application: Application is starting
455
+ Starting some heavy processing
456
+ I, [2013-06-23T19:43:47.986460 #16294] INFO -- My super application: Starting some heavy processing
457
+ ```
207
458
 
208
- ### Debugging the framework itself
459
+ You can notice that what **EasyAppHelper** initialisation logged and what you application logged
460
+ did eventually end-up in the same log...
209
461
 
210
- If you want to debug what happens during the framework instanciation, you can use the DEBUG_EASY_MODULES environment variable.
211
-
212
- ex:
213
-
214
- $ DEBUG_EASY_MODULES=y ruby ./test_app.rb
215
- D, [2013-03-20T13:14:32.149109 #10564] DEBUG -- : Processing helper module: EasyAppHelper::Logger::Instanciator
216
- D, [2013-03-20T13:14:32.149109 #10564] DEBUG -- : Processing helper module: EasyAppHelper::Config::Instanciator
217
- D, [2013-03-20T13:14:32.149109 #10564] DEBUG -- : Trying "/etc/EasyAppHelper.conf" as config file.
218
- D, [2013-03-20T13:14:32.149109 #10564] DEBUG -- : Trying "/etc/EasyAppHelper.yml" as config file.
219
- D, [2013-03-20T13:14:32.149109 #10564] DEBUG -- : Trying "/etc/EasyAppHelper.cfg" as config file.
220
- D, [2013-03-20T13:14:32.149109 #10564] DEBUG -- : Trying "/etc/EasyAppHelper.yaml" as config file.
221
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/etc/EasyAppHelper.CFG" as config file.
222
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/etc/EasyAppHelper.YML" as config file.
223
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/etc/EasyAppHelper.YAML" as config file.
224
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/etc/EasyAppHelper.Yaml" as config file.
225
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/etc/my_app.conf" as config file.
226
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/etc/my_app.yml" as config file.
227
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/etc/my_app.cfg" as config file.
228
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/etc/my_app.yaml" as config file.
229
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/etc/my_app.CFG" as config file.
230
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/etc/my_app.YML" as config file.
231
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/etc/my_app.YAML" as config file.
232
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/etc/my_app.Yaml" as config file.
233
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/usr/local/etc/my_app.conf" as config file.
234
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/usr/local/etc/my_app.yml" as config file.
235
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/usr/local/etc/my_app.cfg" as config file.
236
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/usr/local/etc/my_app.yaml" as config file.
237
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/usr/local/etc/my_app.CFG" as config file.
238
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/usr/local/etc/my_app.YML" as config file.
239
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/usr/local/etc/my_app.YAML" as config file.
240
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/usr/local/etc/my_app.Yaml" as config file.
241
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/home/user_home_dir/.config/my_app.conf" as config file.
242
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/home/user_home_dir/.config/my_app.yml" as config file.
243
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/home/user_home_dir/.config/my_app.cfg" as config file.
244
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/home/user_home_dir/.config/my_app.yaml" as config file.
245
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/home/user_home_dir/.config/my_app.CFG" as config file.
246
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/home/user_home_dir/.config/my_app.YML" as config file.
247
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/home/user_home_dir/.config/my_app.YAML" as config file.
248
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Trying "/home/user_home_dir/.config/my_app.Yaml" as config file.
249
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Processing helper module: EasyAppHelper::Base::Instanciator
250
- D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Processing helper module: EasyAppHelper::Common::Instanciator
251
-
252
- You can observe that for each of the included module, the framework uses its related so-called instanciator in order to know how to start the module, externalizing the methods into a separated module to avoid poluting your own application with methods useless for you when you include the module.
253
462
 
254
463
  ## Contributing
255
464
 
@@ -259,17 +468,12 @@ You can observe that for each of the included module, the framework uses its rel
259
468
  4. Push to the branch (`git push origin my-new-feature`)
260
469
  5. Create new Pull Request
261
470
 
262
- ### Creating your own EasyAppHelper module
263
-
264
- You need to write two modules
265
-
266
- * One EasyAppHelper::MyModule that will provide the features mixed in your application.
267
- * One EasyAppHelper::MyModule::Instanciator that will extend (not include) EasyAppHelper::Common::Instanciator and that will be responsible to initialize your module.
268
471
 
269
472
  That's all folks.
270
473
 
271
474
 
272
- [1]: https://rubygems.org/gems/easy_app_helper "EasyAppHelper gem"
273
- [2]: https://rubygems.org/gems/slop "Slop gem"
274
- [3]: http://rubydoc.info/github/lbriais/easy_app_helper/master/frames "EasyAppHelper documentation"
275
- [4]: https://github.com/lbriais/easy_app_helper/wiki "EasyAppHelper wiki"
475
+ [EAP]: https://rubygems.org/gems/easy_app_helper "**EasyAppHelper** gem"
476
+ [slop]: https://rubygems.org/gems/slop "Slop gem"
477
+ [yaml]: http://www.yaml.org/ "The Yaml official site"
478
+ [3]: http://rubydoc.info/github/lbriais/easy_app_helper/master/frames "**EasyAppHelper** documentation"
479
+ [4]: https://github.com/lbriais/easy_app_helper/wiki "**EasyAppHelper** wiki"