easy_app_helper 0.0.8 → 0.0.9
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/README.md +2 -2
- data/lib/easy_app_helper/config.rb +4 -14
- data/lib/easy_app_helper/places.rb +42 -0
- data/lib/easy_app_helper/version.rb +1 -1
- data/lib/easy_app_helper.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3f63bdf83edcaeec2428490a62ddfaf57cbf2e6
|
4
|
+
data.tar.gz: 9cb82c768e6991e0bf4aafb18e01b2f1369db5e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c31b6806be5d12f0020a5ff9afa18c600dfeb5d5c851e323157c90b7ed7975f8e7e975862d9c7ac6aaab6f44b9312547d8a9c35c044af6acbd92ba6209b6a252
|
7
|
+
data.tar.gz: be781cca91d84972d16aff9f76fbbfbe9bc8afa48ff7723ff65df4c9ac725143dbd0c2370d634208ef12cbb20ad37ec0c766140e7ad5619492237b063aaeda16
|
data/README.md
CHANGED
@@ -100,7 +100,7 @@ class MyApp
|
|
100
100
|
puts app_config.to_yaml
|
101
101
|
end
|
102
102
|
|
103
|
-
def add_specifc_command_line_options(opt)
|
103
|
+
def add_specifc_command_line_options(opt)
|
104
104
|
opt.on :s, :stupid, 'This is a very stupid option', :argument => false
|
105
105
|
end
|
106
106
|
end
|
@@ -111,7 +111,7 @@ app = MyApp.new
|
|
111
111
|
With this example you can already test some of the behaviours brought to the application by the different modules.
|
112
112
|
|
113
113
|
$ ruby ./test_app.rb
|
114
|
-
|
114
|
+
|
115
115
|
Nothing displayed... hum in fact normal.
|
116
116
|
|
117
117
|
*The EasyAppHelper::Base module*
|
@@ -14,9 +14,10 @@ require 'yaml'
|
|
14
14
|
# - A mechanism (based on Slop) to add your own command line options.
|
15
15
|
# - A generated inline help.
|
16
16
|
# This module provides the following 5 levels of configuration:
|
17
|
-
# - Admin wide YAML config file, for options common to all your EasyAppHelper applications
|
17
|
+
# - Admin wide YAML config file, for options common to all your EasyAppHelper applications.
|
18
18
|
# - System wide YAML config file.
|
19
19
|
# - User YAML config file.
|
20
|
+
# These 3 levels depends on you OS (see EasyAppHelper::Config::Places).
|
20
21
|
# - Command line options.
|
21
22
|
# - Command line supplied YAML config file(any option defined here will override the previous).
|
22
23
|
# All these 5 levels of configuration override with consistent override mechanism.
|
@@ -25,8 +26,6 @@ module EasyAppHelper::Config
|
|
25
26
|
|
26
27
|
include EasyAppHelper::Common
|
27
28
|
|
28
|
-
|
29
|
-
|
30
29
|
# If the option --config-file has been specified, it will be loaded and override
|
31
30
|
# current configuration according to rules
|
32
31
|
def load_custom_config
|
@@ -35,24 +34,15 @@ module EasyAppHelper::Config
|
|
35
34
|
end
|
36
35
|
|
37
36
|
|
38
|
-
|
39
37
|
module EasyAppHelper::Config::Instanciator
|
40
38
|
extend EasyAppHelper::Common::Instanciator
|
41
39
|
|
42
40
|
# Default module priority
|
43
41
|
MODULE_PRIORITY = 10
|
44
|
-
|
45
|
-
# Where could be stored admin configuration that rules all EasyAppHelper
|
46
|
-
# based applications.
|
47
|
-
ADMIN_CONFIG_POSSIBLE_PLACES = ["/etc"]
|
48
42
|
ADMIN_CONFIG_FILENAME = EasyAppHelper.name
|
49
43
|
|
50
|
-
#
|
51
|
-
|
52
|
-
"/usr/local/etc"]
|
53
|
-
|
54
|
-
# Where could be stored user configuration
|
55
|
-
USER_CONFIG_POSSIBLE_PLACES = ["#{ENV['HOME']}/.config"]
|
44
|
+
# include paths specific to the OS
|
45
|
+
include EasyAppHelper::Config::Places.get_OS_module
|
56
46
|
|
57
47
|
# Potential extensions a config file can have
|
58
48
|
CONFIG_FILE_POSSIBLE_EXTENSIONS = ['conf', 'yml', 'cfg', 'yaml', 'CFG', 'YML', 'YAML', 'Yaml']
|
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
module EasyAppHelper
|
3
|
+
module Config
|
4
|
+
module UnixPlaces
|
5
|
+
# Where could be stored admin configuration that rules all EasyAppHelper
|
6
|
+
# based applications.
|
7
|
+
ADMIN_CONFIG_POSSIBLE_PLACES = ["/etc"]
|
8
|
+
|
9
|
+
# Where could be stored system wide configuration
|
10
|
+
SYSTEM_CONFIG_POSSIBLE_PLACES = ["/etc",
|
11
|
+
"/usr/local/etc"]
|
12
|
+
|
13
|
+
# Where could be stored user configuration
|
14
|
+
USER_CONFIG_POSSIBLE_PLACES = ["#{ENV['HOME']}/.config"]
|
15
|
+
end
|
16
|
+
|
17
|
+
module WindowsPlaces
|
18
|
+
# Where could be stored admin configuration that rules all EasyAppHelper
|
19
|
+
# based applications.
|
20
|
+
ADMIN_CONFIG_POSSIBLE_PLACES = ["#{ENV['systemRoot']}/Config"]
|
21
|
+
|
22
|
+
# Where could be stored system wide configuration
|
23
|
+
SYSTEM_CONFIG_POSSIBLE_PLACES = ['C:/Windows/Config', "#{ENV['ALLUSERSPROFILE']}/Application Data"]
|
24
|
+
|
25
|
+
# Where could be stored user configuration
|
26
|
+
USER_CONFIG_POSSIBLE_PLACES = [ENV['APPDATA']]
|
27
|
+
end
|
28
|
+
|
29
|
+
module Places
|
30
|
+
CONF ={
|
31
|
+
mingw32: EasyAppHelper::Config::WindowsPlaces
|
32
|
+
}
|
33
|
+
DEFAULT = EasyAppHelper::Config::UnixPlaces
|
34
|
+
|
35
|
+
def self.get_OS_module
|
36
|
+
conf = CONF[RbConfig::CONFIG['target_os'].to_sym]
|
37
|
+
conf.nil? ? DEFAULT : conf
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
data/lib/easy_app_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_app_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- L.Briais
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- lib/easy_app_helper/common.rb
|
85
85
|
- lib/easy_app_helper/config.rb
|
86
86
|
- lib/easy_app_helper/logger.rb
|
87
|
+
- lib/easy_app_helper/places.rb
|
87
88
|
- lib/easy_app_helper/version.rb
|
88
89
|
homepage: https://github.com/lbriais/easy_app_helper
|
89
90
|
licenses:
|