easy_app_helper 1.0.14 → 2.0.2

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.
data/README.md CHANGED
@@ -1,51 +1,30 @@
1
- # EasyAppHelper
1
+ # EasyAppHelper v2
2
+ [![Build Status](https://travis-ci.org/lbriais/easy_app_helper.svg)](https://travis-ci.org/lbriais/easy_app_helper)
3
+ [![Gem Version](https://badge.fury.io/rb/easy_app_helper.svg)](http://badge.fury.io/rb/easy_app_helper)
2
4
 
3
- [![Build Status](https://travis-ci.org/lbriais/easy_app_helper.png?branch=old_release_1_x)](https://travis-ci.org/lbriais/easy_app_helper)
4
- [![Gem Version](https://badge.fury.io/rb/easy_app_helper.png?branch=old_release_1_x)](http://badge.fury.io/rb/easy_app_helper)
5
+ Every Ruby script on Earth has basically the same fundamental needs:
5
6
 
6
- __This branch is deprecated, use the [v2.x branch](https://github.com/lbriais/easy_app_helper) instead !__
7
+ * Config files everywhere accross the system, some of them belonging to the administrator some to the user
8
+ running the application, some coming from the command line options and more...
9
+ * Display a nice command-line help
10
+ * Logging stuff either to STDOUT, STDERR or to a specific log file.
7
11
 
12
+ __If, like everyone, you have those basic needs, then this [gem][EAP] is definitely for you.__
8
13
 
9
- **This [gem][EAP] aims at providing useful helpers for command line applications.**
10
-
11
- This is a complete rewrite of the initial easy_app_helper gem. **It is not compatible with
12
- apps designed for easy_app_helper prior to version 1.0.0**, although they could be very easily adapted
13
- (anyway you always specify your gem dependencies using [semantic versioning](http://semver.org/) and the [pessimistic version operator]
14
- (http://robots.thoughtbot.com/post/2508037841/rubys-pessimistic-operator), don't you ? More info [here](http://guides.rubygems.org/patterns/#declaring_dependencies)). Older applications should explicitly
15
- require to use the latest version of the 0.x.x series instead. The config files themselves remain
16
- compatible with all versions of **EasyAppHelper**, as they are actually just plain Yaml files...
17
-
18
- The new **EasyAppHelper** module provides:
19
-
20
- * A **super charged Config class** that:
21
- * Manages **multiple sources of configuration**(command line, multiple config files...) in a **layered config**.
22
- * Provides an **easy to customize merge mechanism** for the different **config layers** that renders a "live view"
23
- of the merged configuration, while keeping a way to access or modify independently any of them.
24
- * Allows **flexibility** when dealing with modification and provides a way to roll back modifications done to config
25
- anytime, fully reload it, blast it... Export feature could be very easily added and will probably.
26
- * A **Logger tightly coupled with the Config** class, that will behave regarding options specified be it from
27
- command line or from any source(layer) of the config object...
28
- * Embeds [Slop][slop] to handle **command line parameters** and keeps all parameters specified from the command
29
- line in a **dedicated layer of the config object**.
30
- * A mechanism that ensures that as soon as you access any of the objects or methods exposed by EasyAppHelper,
31
- all of them are **fully configured and ready to be used**.
14
+ This is a complete rewrite of the [easy_app_helper gem v1.x][EAP1] now based on the [stacked_config Gem][SC] for the
15
+ config file management part, but it maintains some compatibility with previous version. See
16
+ [compatibility issues with previous versions](#compatibility-issues-with-previous-versions) for more information.
32
17
 
33
18
  If you are writing command line applications, I hope you will like it because it's very easy to use,
34
19
  and as unobtrusive as possible (you choose when you want to include or use as a module) while providing
35
20
  a ready-for-prod config, logger and command line management.
36
21
 
37
22
 
38
- Currently the only runtime dependency is the cool [Slop gem][slop] which is used to process the command line options.
39
-
40
- [Why this gem][wiki] ?
41
-
42
-
43
-
44
23
  ## Installation
45
24
 
46
25
  Add this line to your application's Gemfile:
47
26
 
48
- gem 'easy_app_helper'
27
+ gem 'easy_app_helper', '~> 2.0'
49
28
 
50
29
  And then execute:
51
30
 
@@ -56,17 +35,16 @@ Or install it yourself as:
56
35
  $ gem install easy_app_helper
57
36
 
58
37
 
59
-
60
-
61
38
  ## Usage
62
39
 
63
- To use it, once you installed them, you just need to require it:
40
+ ### The config files handling
64
41
 
65
- ```ruby
66
- require 'easy_app_helper'
67
- ```
42
+ Basically all the config files management is delegated to the [stacked_config Gem][SC]. Please check its documentation
43
+ to know how it works. In your own script the 'merged' ([read for more][SC]) configuration is available using the
44
+ `EasyAppHelper.config` object.
68
45
 
69
- Then you can immediately access the logger or the config objects. Here under a first example:
46
+ To use it, you just need to require it, you can or not include the `EasyAppHelper` module. It's methods are both
47
+ available as module or mixin methods.
70
48
 
71
49
  ```ruby
72
50
  require 'easy_app_helper'
@@ -74,250 +52,95 @@ require 'easy_app_helper'
74
52
  # You can directly access the config or the logger through the **EasyAppHelper** module
75
53
  puts "The application verbose flag is #{EasyAppHelper.config[:verbose]}"
76
54
 
77
- # You can directly use the logger according to the command line flags
78
- # This will do nothing unless --debug is set and --log-level is set to the correct level
79
- EasyAppHelper.logger.info "Hi guys!"
80
-
81
- # Fed up with the **EasyAppHelper** prefix ? Just include the module where you want
55
+ # Fed up with the 'EasyAppHelper' prefix ? Just include the module where you want
82
56
  include EasyAppHelper
83
-
84
- # You can override programmatically any part of the config
85
- config[:debug] = true
86
- logger.level = 1
87
- config[:test] = 'Groovy'
88
- EasyAppHelper.logger.info "Hi guys!... again"
89
-
90
- # You can see the internals of the config
91
- puts config.internal_configs.to_yaml
92
- # Which will output
93
- #:modified:
94
- # :content:
95
- # :log-level: 1
96
- # :debug: true
97
- # :test: cool
98
- # :source: Changed by code
99
- #:command_line:
100
- # :content:
101
- # :auto:
102
- # :simulate:
103
- # :verbose: true
104
- # :help:
105
- # :config-file:
106
- # :config-override:
107
- # :debug:
108
- # :debug-on-err:
109
- # :log-level:
110
- # :log-file:
111
- # :source: Command line
112
- #:system:
113
- # :content: {}
114
- # :source:
115
- # :origin: EasyAppHelper
116
- #:internal:
117
- # :content: {}
118
- # :source:
119
- # :origin: ''
120
- #:global:
121
- # :content: {}
122
- # :source:
123
- # :origin: ''
124
- #:user:
125
- # :content: {}
126
- # :source:
127
- # :origin: ''
128
- #:specific_file:
129
- # :content: {}
130
-
131
- # You see of course that the three modifications we did appear actually in the modified sub-hash
132
- # And now the merged config
133
- puts config.to_hash
134
-
135
- # But you can see the modified part as it is:
136
- puts config.internal_configs[:modified]
137
-
138
- # Of course you can access it from any class
139
- class Dummy
140
- include EasyAppHelper
141
-
142
- def initialize
143
- puts "#{config[:test]} baby !"
144
- # Back to the original
145
- config.reset
146
- puts config.internal_configs[:modified]
147
- end
148
- end
149
-
150
- Dummy.new
151
-
152
- # Some methods are provided to ease common tasks. For example this one will log at info level
153
- # (so only displayed if debug mode and log level low enough), but will also puts on the console
154
- # if verbose if set...
155
- puts_and_logs "Hi world"
156
-
157
- # It is actually one of the few methods added to regular Logger class (The added value of this logger
158
- # is much more to be tightly coupled with the config object). Thus could access it like that:
159
- logger.puts_and_logs "Hi world"
160
-
161
- # or even
162
- EasyAppHelper.logger.puts_and_logs "Hi world... 3 is enough."
57
+ puts "The application verbose flag is #{config[:verbose]}"
163
58
  ```
164
59
 
60
+ Check the [stacked_config Gem][SC] help to further understand about the `config` object.
165
61
 
166
- ## Configuration layers
167
-
168
- **EasyAppHelper** will look for files in numerous places. **Both Unix and Windows places are handled**.
169
- All the files are [Yaml][yaml] files but could have names with different extensions.
62
+ ### The logger
170
63
 
171
- You can look in the [classes documentation][doc] to know exactly which extensions and places the config
172
- files are looked for.
64
+ The logger behaviour is tightly coupled with config part and there are few config options already available to drive
65
+ the way it will work. By default the logger will just log to the `File::NULL` device (/dev/null on Unix systems).
173
66
 
174
- ### System config file
67
+ * __debug__: if specified the logger will log to STDOUT.
68
+ * __debug-on-err__: if specified the logger will log to STDERR.
69
+ * __log-level__: Specify the logger log level from 0 to 5, default 2 (in your code you can use one of the
70
+ `Logger::Severity.constants` if you prefer).
71
+ * __log-file__: Specifies a file to log to.
175
72
 
176
- This config file is common to all applications that use EasyAppHelper. For example on a Unix system
177
- regarding the rules described above, the framework will for the following files in that order:
73
+ By default the `EasyAppHelper.logger` is an instance of a standard `Logger` but can specify your own using the
74
+ `EasyAppHelper::Logger::Initializer.setup_logger` method.
178
75
 
179
- ```text
180
- # It will be loaded in the :system layer
181
- /etc/EasyAppHelper.conf
182
- /etc/EasyAppHelper.yml
183
- /etc/EasyAppHelper.cfg
184
- /etc/EasyAppHelper.yaml
185
- /etc/EasyAppHelper.CFG
186
- /etc/EasyAppHelper.YML
187
- /etc/EasyAppHelper.YAML
188
- /etc/EasyAppHelper.Yaml
189
- ```
76
+ ```ruby
77
+ require 'easy_app_helper'
190
78
 
191
- ### Internal config file
192
-
193
- This is an internal config file for the Gem itself. It will be located in the ```etc/``` or ```config/``` directory **inside** the Gem.
194
- It is a way for a Gem to define a system default configuration.
195
-
196
- ```text
197
- # The :internal layer
198
- etc/myscript.conf
199
- etc/myscript.yml
200
- etc/myscript.cfg
201
- etc/myscript.yaml
202
- etc/myscript.CFG
203
- etc/myscript.YML
204
- etc/myscript.YAML
205
- etc/myscript.Yaml
206
- config/myscript.conf
207
- config/myscript.yml
208
- config/myscript.cfg
209
- config/myscript.yaml
210
- config/myscript.CFG
211
- config/myscript.YML
212
- config/myscript.YAML
213
- config/myscript.Yaml
214
- ```
79
+ # You can directly use the logger according to the command line, or config file, flags
80
+ # This will do nothing unless --debug is set and --log-level is set to the correct level
81
+ EasyAppHelper.logger.info "Hi guys!"
215
82
 
83
+ # Fed up with the **EasyAppHelper** prefix ? Just include the module where you want
84
+ include EasyAppHelper
216
85
 
217
- ### Application config files
218
-
219
- Application config file names are determined from the config.script_filename property. It initially contains
220
- the bare name of the script(path and extension removed), but you can replace with whatever you want. Changing
221
- this property causes actually the impacted files to be reloaded.
222
-
223
- It is in fact a two level configuration. One is global (the :global layer) and the other is at user level (the
224
- :user layer).
225
-
226
- For example on a Unix system or cygwin
227
-
228
- ```text
229
- # For the :global layer
230
- /etc/myscript.conf
231
- /etc/myscript.yml
232
- /etc/myscript.cfg
233
- /etc/myscript.yaml
234
- /etc/myscript.CFG
235
- /etc/myscript.YML
236
- /etc/myscript.YAML
237
- /etc/myscript.Yaml
238
- /usr/local/etc/myscript.conf
239
- /usr/local/etc/myscript.yml
240
- /usr/local/etc/myscript.cfg
241
- /usr/local/etc/myscript.yaml
242
- /usr/local/etc/myscript.CFG
243
- /usr/local/etc/myscript.YML
244
- /usr/local/etc/myscript.YAML
245
- /usr/local/etc/myscript.Yaml
246
- # For the :user level
247
- ${HOME}/.config/myscript.conf
248
- ${HOME}/.config/myscript.yml
249
- ${HOME}/.config/myscript.cfg
250
- ${HOME}/.config/myscript.yaml
251
- ${HOME}/.config/myscript.CFG
252
- ${HOME}/.config/myscript.YML
253
- ${HOME}/.config/myscript.YAML
254
- ${HOME}/.config/myscript.Yaml
86
+ logger.level = 1
87
+ logger.info "Hi guys!... again"
255
88
  ```
256
89
 
257
- ### Command line specified config file
90
+ `EasyAppHelper` introduces a nice method coupled with both the `verbose` option and log-related options:
91
+ `puts_and_logs`. It will perform a `puts` if the `verbose` option is set. And on top it will log at 'info' level if
92
+ the `debug` option is set (or on STDERR if `debug-on-err` is set).
258
93
 
259
- The command line option ```--config-file``` provides a way to specify explicitly a config file. On top of this the
260
- option ```--config-override``` tells **EasyAppHelper** to ignore :system, :internal, :global and :user levels.
94
+ ```ruby
95
+ require 'easy_app_helper'
261
96
 
262
- The file will be loaded in a separated layer called :specific_file
97
+ include EasyAppHelper
263
98
 
99
+ puts_and_logs 'Hello world'
100
+ ```
264
101
 
265
102
  ### The command line options
266
103
 
267
- **EasyAppHelper** already provides by default some command line options. Imagine you have the following program.
104
+ The command line options is one of the config layers maintained by the [stacked_config Gem][SC], and therefore there
105
+ is not much to say except that [easy_app_helper][EAP] adds itself some options related to the logging as seen in the
106
+ [logger part](#the-logger).
107
+
108
+ Of course as described in the [stacked_config Gem][SC] documentation, you can define your own options:
109
+
110
+ Let's say you have a `my_script.rb`:
268
111
 
269
112
  ```ruby
270
113
  #!/usr/bin/env ruby
271
114
 
272
115
  require 'easy_app_helper'
273
116
 
274
- class MyApp
275
- include EasyAppHelper
276
-
277
- APP_NAME = "My super application"
278
- VERSION = '0.0.1'
279
- DESCRIPTION = 'This application is a proof of concept for EasyAppHelper.'
280
-
281
-
282
- def initialize
283
- # Providing this data is optional but brings better logging and online help
284
- config.describes_application(app_name: APP_NAME, app_version: VERSION, app_description: DESCRIPTION)
285
- end
117
+ include EasyAppHelper
286
118
 
119
+ APP_NAME = "My super application"
120
+ VERSION = '0.0.1'
121
+ DESCRIPTION = 'This application is a proof of concept for EasyAppHelper.'
287
122
 
288
- def run
289
- if config[:help]
290
- puts config.help
291
- exit 0
292
- end
293
- puts_and_logs "Application is starting"
294
- do_some_processing
295
- end
123
+ config.describes_application(app_name: APP_NAME, app_version: VERSION, app_description: DESCRIPTION)
296
124
 
297
- def do_some_processing
298
- puts_and_logs "Starting some heavy processing"
299
- end
300
125
 
126
+ config.add_command_line_section('My script options') do |slop|
127
+ slop.on :u, :useless, 'Stupid option', :argument => false
128
+ slop.on :anint, 'Stupid option with integer argument', :argument => true, :as => Integer
301
129
  end
302
130
 
303
-
304
- MyApp.new.run
305
- ```
306
-
307
- And you run it without any command line option
308
-
309
- ```text
310
- ./test4_app.rb
131
+ if config[:help]
132
+ puts config.command_line_help
133
+ end
311
134
  ```
312
135
 
313
- No output...
136
+ Then if you do:
314
137
 
315
- Let' try
138
+ $ ./my_script.rb -h
316
139
 
317
- ```text
318
- ./test4_app.rb --help
140
+ You will obtain a nice command line help:
319
141
 
320
- Usage: test4_app [options]
142
+ ```
143
+ Usage: my_script [options]
321
144
  My super application Version: 0.0.1
322
145
 
323
146
  This application is a proof of concept for EasyAppHelper.
@@ -334,215 +157,35 @@ This application is a proof of concept for EasyAppHelper.
334
157
  --debug-on-err Run in debug mode with output to stderr.
335
158
  --log-level Log level from 0 to 5, default 2.
336
159
  --log-file File to log to.
337
-
338
- ```
339
- You see there the online help. And then the program exists.
340
-
341
- Let's try the ```--verbose``` flag
342
-
343
- ```text
344
- ./test4_app.rb --verbose
345
- Application is starting
346
- Starting some heavy processing
160
+ -- My script options -----------------------------------------------------------
161
+ -u, --useless Stupid option
162
+ --anint Stupid option with integer argument
347
163
  ```
348
164
 
349
- You see that the puts_and_logs is sensitive to the ```--verbose``` switch...
165
+ See [stacked_config Gem][SC] documentation for more options.
350
166
 
351
- But what if I debug
352
- ```text
353
- ./test4_app.rb --debug
354
- ```
355
167
 
356
- Humm... nothing... Let's provide the log level
357
-
358
- ```text
359
- ./test4_app.rb --debug --log-level 0
360
- I, [2013-06-23T19:37:24.975392 #10276] INFO -- My super application: Application is starting
361
- I, [2013-06-23T19:37:24.975592 #10276] INFO -- My super application: Starting some heavy processing
362
- ```
363
-
364
- You see there that the puts_and_logs logs as well with the log level 1 (Info)... Nice looks like it was claiming
365
- this in its name... ;-)
366
-
367
- If I mix ?
368
-
369
- ```text
370
- ./test4_app.rb --debug --log-level 0 --verbose
371
- Application is starting
372
- I, [2013-06-23T19:39:05.712558 #11768] INFO -- My super application: Application is starting
373
- Starting some heavy processing
374
- I, [2013-06-23T19:39:05.712834 #11768] INFO -- My super application: Starting some heavy processing
375
- ```
168
+ ## Compatibility issues with previous versions
376
169
 
377
- So far so good...
378
-
379
- ### Specifying command line parameters
380
-
381
- As said, internally **EasyAppHelper** uses the [Slop gem][slop] to handle the command line parameters.
382
- You can configure the internal Slop object by calling the add_command_line_section method of the config
383
- object. You could create a method that setup your application command line parameters like this:
384
-
385
- ```ruby
386
- def add_cmd_line_options
387
- config.add_command_line_section do |slop|
388
- slop.on :u, :useless, 'Stupid option', :argument => false
389
- slop.on :anint, 'Stupid option with integer argument', :argument => true, :as => Integer
390
- end
391
- end
392
-
393
- ```
394
-
395
- See [Slop gem][slop] API documentation for more options.
396
-
397
-
398
- ### Debugging the framework itself
399
-
400
- If you want, you can even debug what happens during **EasyAppHelper** initialisation, for this you can use the
401
- ```DEBUG_EASY_MODULES``` environment variable. As how and where everything has to be logged is only specified when
402
- you actually provide command line options, **EasyAppHelper** provides a temporary logger to itself and will
403
- after all dump the logger content to the logger you specified and if you specify... So that you don't miss a log.
404
-
405
- ```text
406
- $ DEBUG_EASY_MODULES=y ruby ./test4_app.rb
407
-
408
- D, [2013-06-23T19:43:47.977031 #16294] DEBUG -- : Temporary initialisation logger created...
409
- D, [2013-06-23T19:43:47.977861 #16294] DEBUG -- : Trying "/etc/EasyAppHelper.conf" as config file.
410
- D, [2013-06-23T19:43:47.977908 #16294] DEBUG -- : Trying "/etc/EasyAppHelper.yml" as config file.
411
- D, [2013-06-23T19:43:47.977938 #16294] DEBUG -- : Loading config file "/etc/EasyAppHelper.cfg"
412
- D, [2013-06-23T19:43:47.977961 #16294] DEBUG -- : Trying "/home/laurent/devel/ruby/gems/test4_app/etc/test4_app.conf" as config file.
413
- D, [2013-06-23T19:43:47.977982 #16294] DEBUG -- : Trying "/home/laurent/devel/ruby/gems/test4_app/etc/test4_app.yml" as config file.
414
- D, [2013-06-23T19:43:47.977995 #16294] DEBUG -- : Trying "/home/laurent/devel/ruby/gems/test4_app/etc/test4_app.cfg" as config file.
415
- D, [2013-06-23T19:43:47.978032 #16294] DEBUG -- : Trying "/home/laurent/devel/ruby/gems/test4_app/etc/test4_app.yaml" as config file.
416
- D, [2013-06-23T19:43:47.978082 #16294] DEBUG -- : Trying "/home/laurent/devel/ruby/gems/test4_app/etc/test4_app.CFG" as config file.
417
- D, [2013-06-23T19:43:47.978119 #16294] DEBUG -- : Trying "/home/laurent/devel/ruby/gems/test4_app/etc/test4_app.YML" as config file.
418
- D, [2013-06-23T19:43:47.978163 #16294] DEBUG -- : Trying "/home/laurent/devel/ruby/gems/test4_app/etc/test4_app.YAML" as config file.
419
- D, [2013-06-23T19:43:47.978206 #16294] DEBUG -- : Trying "/home/laurent/devel/ruby/gems/test4_app/etc/test4_app.Yaml" as config file.
420
- I, [2013-06-23T19:43:47.978255 #16294] INFO -- : No config file found for layer internal.
421
- D, [2013-06-23T19:43:47.978300 #16294] DEBUG -- : Trying "/etc/test4_app.conf" as config file.
422
- D, [2013-06-23T19:43:47.978332 #16294] DEBUG -- : Trying "/etc/test4_app.yml" as config file.
423
- D, [2013-06-23T19:43:47.978355 #16294] DEBUG -- : Trying "/etc/test4_app.cfg" as config file.
424
- D, [2013-06-23T19:43:47.978381 #16294] DEBUG -- : Trying "/etc/test4_app.yaml" as config file.
425
- D, [2013-06-23T19:43:47.978403 #16294] DEBUG -- : Trying "/etc/test4_app.CFG" as config file.
426
- D, [2013-06-23T19:43:47.978424 #16294] DEBUG -- : Trying "/etc/test4_app.YML" as config file.
427
- D, [2013-06-23T19:43:47.978445 #16294] DEBUG -- : Trying "/etc/test4_app.YAML" as config file.
428
- D, [2013-06-23T19:43:47.978466 #16294] DEBUG -- : Trying "/etc/test4_app.Yaml" as config file.
429
- D, [2013-06-23T19:43:47.978491 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.conf" as config file.
430
- D, [2013-06-23T19:43:47.978529 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.yml" as config file.
431
- D, [2013-06-23T19:43:47.978553 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.cfg" as config file.
432
- D, [2013-06-23T19:43:47.978575 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.yaml" as config file.
433
- D, [2013-06-23T19:43:47.978597 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.CFG" as config file.
434
- D, [2013-06-23T19:43:47.978619 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.YML" as config file.
435
- D, [2013-06-23T19:43:47.978670 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.Yaml" as config file.
436
- I, [2013-06-23T19:43:47.978695 #16294] INFO -- : No config file found for layer global.
437
- D, [2013-06-23T19:43:47.978725 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.conf" as config file.
438
- D, [2013-06-23T19:43:47.978748 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.yml" as config file.
439
- D, [2013-06-23T19:43:47.978770 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.cfg" as config file.
440
- D, [2013-06-23T19:43:47.978792 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.yaml" as config file.
441
- D, [2013-06-23T19:43:47.978817 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.CFG" as config file.
442
- D, [2013-06-23T19:43:47.978840 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.YML" as config file.
443
- D, [2013-06-23T19:43:47.978861 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.YAML" as config file.
444
- D, [2013-06-23T19:43:47.978974 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.Yaml" as config file.
445
- I, [2013-06-23T19:43:47.979000 #16294] INFO -- : No config file found for layer user.
446
- I, [2013-06-23T19:43:47.979025 #16294] INFO -- : No config file found for layer specific_file.
447
- D, [2013-06-23T19:43:47.979514 #16294] DEBUG -- : Trying "/etc/EasyAppHelper.conf" as config file.
448
- D, [2013-06-23T19:43:47.979561 #16294] DEBUG -- : Trying "/etc/EasyAppHelper.yml" as config file.
449
- D, [2013-06-23T19:43:47.979591 #16294] DEBUG -- : Loading config file "/etc/EasyAppHelper.cfg"
450
- D, [2013-06-23T19:43:47.979717 #16294] DEBUG -- : Trying "/etc/test4_app.conf" as config file.
451
- D, [2013-06-23T19:43:47.979747 #16294] DEBUG -- : Trying "/etc/test4_app.yml" as config file.
452
- D, [2013-06-23T19:43:47.979800 #16294] DEBUG -- : Trying "/etc/test4_app.cfg" as config file.
453
- D, [2013-06-23T19:43:47.979823 #16294] DEBUG -- : Trying "/etc/test4_app.yaml" as config file.
454
- D, [2013-06-23T19:43:47.979845 #16294] DEBUG -- : Trying "/etc/test4_app.CFG" as config file.
455
- D, [2013-06-23T19:43:47.979867 #16294] DEBUG -- : Trying "/etc/test4_app.YML" as config file.
456
- D, [2013-06-23T19:43:47.979908 #16294] DEBUG -- : Trying "/etc/test4_app.YAML" as config file.
457
- D, [2013-06-23T19:43:47.979935 #16294] DEBUG -- : Trying "/etc/test4_app.Yaml" as config file.
458
- D, [2013-06-23T19:43:47.979959 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.conf" as config file.
459
- D, [2013-06-23T19:43:47.979981 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.yml" as config file.
460
- D, [2013-06-23T19:43:47.980004 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.cfg" as config file.
461
- D, [2013-06-23T19:43:47.980026 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.yaml" as config file.
462
- D, [2013-06-23T19:43:47.980047 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.CFG" as config file.
463
- D, [2013-06-23T19:43:47.980069 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.YML" as config file.
464
- D, [2013-06-23T19:43:47.980091 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.YAML" as config file.
465
- D, [2013-06-23T19:43:47.980112 #16294] DEBUG -- : Trying "/usr/local/etc/test4_app.Yaml" as config file.
466
- I, [2013-06-23T19:43:47.980135 #16294] INFO -- : No config file found for layer global.
467
- D, [2013-06-23T19:43:47.980181 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.conf" as config file.
468
- D, [2013-06-23T19:43:47.980207 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.yml" as config file.
469
- D, [2013-06-23T19:43:47.980230 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.cfg" as config file.
470
- D, [2013-06-23T19:43:47.980252 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.yaml" as config file.
471
- D, [2013-06-23T19:43:47.980274 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.CFG" as config file.
472
- D, [2013-06-23T19:43:47.980296 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.YML" as config file.
473
- D, [2013-06-23T19:43:47.980319 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.YAML" as config file.
474
- D, [2013-06-23T19:43:47.980361 #16294] DEBUG -- : Trying "/home/laurent/.config/test4_app.Yaml" as config file.
475
- I, [2013-06-23T19:43:47.980395 #16294] INFO -- : No config file found for layer user.
476
- I, [2013-06-23T19:43:47.980418 #16294] INFO -- : No config file found for layer specific_file.
477
- D, [2013-06-23T19:43:47.981934 #16294] DEBUG -- : Config layers:
478
- ---
479
- :modified:
480
- :content: {}
481
- :source: Changed by code
482
- :command_line:
483
- :content:
484
- :auto:
485
- :simulate:
486
- :verbose: true
487
- :help:
488
- :config-file:
489
- :config-override:
490
- :debug: true
491
- :debug-on-err:
492
- :log-level: 0
493
- :log-file:
494
- :source: Command line
495
- :system:
496
- :content:
497
- :copyright: (c) 2012-2013 Nanonet
498
- :source: /etc/EasyAppHelper.cfg
499
- :origin: EasyAppHelper
500
- :internal:
501
- :content: {}
502
- :source:
503
- :origin: test4_app
504
- :global:
505
- :content: {}
506
- :source:
507
- :origin: test4_app
508
- :user:
509
- :content: {}
510
- :source:
511
- :origin: test4_app
512
- :specific_file:
513
- :content: {}
514
-
515
- D, [2013-06-23T19:43:47.985357 #16294] DEBUG -- : Merged config:
516
- ---
517
- :copyright: (c) 2012-2013 Nanonet
518
- :verbose: true
519
- :debug: true
520
- :log-level: 0
521
-
522
- Application is starting
523
- I, [2013-06-23T19:43:47.986298 #16294] INFO -- My super application: Application is starting
524
- Starting some heavy processing
525
- I, [2013-06-23T19:43:47.986460 #16294] INFO -- My super application: Starting some heavy processing
526
- ```
170
+ [easy_app_helper][EAP] v2.x is not fully compatible with previous branch 1.x. But for common usage it should
171
+ nevertheless be the case.
527
172
 
528
- You can notice that what **EasyAppHelper** initialisation logged and what you application logged
529
- did eventually end-up in the same log...
173
+ There is a (not perfect) compatibility mode that you can trigger by setting the `easy_app_helper_compatibility_mode`
174
+ property to true in one of your config files.
530
175
 
531
176
 
532
177
  ## Contributing
533
178
 
534
- 1. Fork it
535
- 2. Create your feature branch (`git checkout -b my-new-feature`)
536
- 3. Commit your changes (`git commit -am 'Add some feature'`)
537
- 4. Push to the branch (`git push origin my-new-feature`)
538
- 5. Create new Pull Request
179
+ 1. [Fork it] ( https://github.com/lbriais/easy_app_helper/fork ), clone your fork.
180
+ 2. Create your feature branch (`git checkout -b my-new-feature`) and develop your super extra feature.
181
+ 3. Commit your changes (`git commit -am 'Add some feature'`).
182
+ 4. Push to the branch (`git push origin my-new-feature`).
183
+ 5. Create a Pull Request.
539
184
 
540
185
 
541
- That's all folks.
186
+ __That's all folks.__
542
187
 
543
188
 
544
- [EAP]: https://rubygems.org/gems/easy_app_helper "EasyAppHelper gem"
545
- [slop]: https://rubygems.org/gems/slop "Slop gem"
546
- [yaml]: http://www.yaml.org/ "The Yaml official site"
547
- [doc]: http://rubydoc.info/github/lbriais/easy_app_helper/master "EasyAppHelper documentation"
548
- [wiki]: https://github.com/lbriais/easy_app_helper/wiki "EasyAppHelper wiki"
189
+ [EAP]: https://rubygems.org/gems/easy_app_helper "EasyAppHelper gem"
190
+ [EAP1]: https://rubygems.org/gems/easy_app_helper/tree/old_release_1_x "EasyAppHelper gem DEPRECATED branch"
191
+ [SC]: https://github.com/lbriais/stacked_config "The stacked_config Gem"
data/Rakefile CHANGED
@@ -1,8 +1 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new
5
-
6
- task :default => :spec
7
- task :test => :spec
8
-
1
+ require 'bundler/gem_tasks'
@@ -5,7 +5,7 @@ require 'easy_app_helper/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'easy_app_helper'
8
- spec.version = EasyAppHelper::EASY_APP_HELPER_VERSION
8
+ spec.version = EasyAppHelper::VERSION
9
9
  spec.authors = ['L.Briais']
10
10
  spec.email = ['lbnetid+rb@gmail.com']
11
11
  spec.description = %q{Easy Application Helpers framework}
@@ -13,15 +13,15 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = 'https://github.com/lbriais/easy_app_helper'
14
14
  spec.license = 'MIT'
15
15
 
16
- spec.files = `git ls-files`.split($/).delete_if { |file| file =~ /^(bin|\.)/ or file =~ /test\d*_app\.rb$/ }
17
- # spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features|etc)/})
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_development_dependency 'bundler'
22
22
  spec.add_development_dependency 'rake'
23
23
  spec.add_development_dependency 'pry'
24
- spec.add_development_dependency 'rspec', '~> 2.0'
24
+ spec.add_development_dependency 'rspec', '~> 3.0'
25
25
 
26
- spec.add_runtime_dependency 'slop', '~> 3.0'
26
+ spec.add_runtime_dependency 'stacked_config', '~> 0.1', '>= 0.1.2'
27
27
  end