easy_app_helper 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e4a396d8e647a55809d2da33c85316587cff1663
4
+ data.tar.gz: 8b6fd6361da1c97cea0681dbe87ad03c06418439
5
+ SHA512:
6
+ metadata.gz: 0c9db25b1668515ed811c09d526281f5f6638cf8ca4fb95a385fcef32161a28945441c84e0946a59c86180f7a4bf21115ec1a895c41397750ec21931f332f949
7
+ data.tar.gz: d196eca609e0d2b5693510683d31a992f822cf651c1920aaad935958815df470d85a5ae5f5cc266c37592f98d28257782c661a54fde50de4b5c77f057167f7f8
data/README.md CHANGED
@@ -6,7 +6,7 @@ The goal is to be as transparent as possible for the application whilst providin
6
6
 
7
7
  Currently the only runtime dependency is on the [Slop gem] [2].
8
8
 
9
-
9
+ [Why this gem][4] ?
10
10
 
11
11
  ## Installation
12
12
 
@@ -24,6 +24,8 @@ Or install it yourself as:
24
24
 
25
25
  ## Usage
26
26
 
27
+ ### Including the basic module
28
+
27
29
  To benefit from the different helpers. Once you installed the gem, you just need to require it:
28
30
 
29
31
  ```ruby
@@ -247,7 +249,7 @@ ex:
247
249
  D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Processing helper module: EasyAppHelper::Base::Instanciator
248
250
  D, [2013-03-20T13:14:32.164733 #10564] DEBUG -- : Processing helper module: EasyAppHelper::Common::Instanciator
249
251
 
250
- You can observe that for each included module, the framwork 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.
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.
251
253
 
252
254
  ## Contributing
253
255
 
@@ -257,7 +259,17 @@ You can observe that for each included module, the framwork uses its related so-
257
259
  4. Push to the branch (`git push origin my-new-feature`)
258
260
  5. Create new Pull Request
259
261
 
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
+
269
+ That's all folks.
270
+
260
271
 
261
272
  [1]: https://rubygems.org/gems/easy_app_helper "EasyAppHelper gem"
262
273
  [2]: https://rubygems.org/gems/slop "Slop gem"
263
- [3]: http://rubydoc.info/github/lbriais/easy_app_helper/master/frames "EasyAppHelper documentation"
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"
@@ -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::VERSION
8
+ spec.version = EasyAppHelper::EASY_APP_HELPER_VERSION
9
9
  spec.authors = ["L.Briais"]
10
10
  spec.email = ["lbnetid+rb@gmail.com"]
11
11
  spec.description = %q{Easy Application Helpers framework}
@@ -12,6 +12,7 @@ require 'logger'
12
12
  # This contains very basic default values and methods.
13
13
  #
14
14
  module EasyAppHelper::Common
15
+
15
16
  # Default log-level
16
17
  DEFAULT_LOG_LEVEL = Logger::Severity::WARN
17
18
 
@@ -36,35 +36,14 @@ module EasyAppHelper::Logger
36
36
  logger.level = level
37
37
  end
38
38
 
39
+ def logger=(logger)
40
+ @logger = logger
41
+ end
39
42
 
40
- # Build logger for the application. Depending on config may end-up up to nowhere
41
- # (by default), STDOUT, STDERR or a file. See --help or EasyAppHelper::Config#help
42
- # for all options.
43
- def build_logger
44
- @logger = EasyAppHelper::Common::DummyLogger.instance
45
- issue_report = nil
46
- if app_config[:debug]
47
- unless app_config[:"log-file"].nil?
48
- begin
49
- if File.exists? app_config[:"log-file"]
50
- logger_type = File.open(app_config[:"log-file"], File::WRONLY | File::APPEND)
51
- else
52
- logger_type = File.open(app_config[:"log-file"], File::WRONLY | File::CREAT)
53
- end
54
- rescue Exception => e
55
- logger_type = STDOUT
56
- issue_report = e.message
57
- end
58
- else
59
- logger_type = STDOUT
60
- end
61
- logger_type = STDERR if app_config[:"debug-on-err"]
62
- @logger = Logger.new(logger_type)
63
- end
64
- app_config[:'log-level'] = DEFAULT_LOG_LEVEL if app_config[:'log-level'].nil?
65
- logger.level = app_config[:"log-level"]
66
- logger.error issue_report if issue_report
67
- logger.debug "Logger is created."
43
+ # Displays the message according to application verbosity and logs it as info.
44
+ def puts_and_logs(msg)
45
+ puts msg if app_config[:verbose]
46
+ logger.info(msg)
68
47
  end
69
48
 
70
49
 
@@ -93,7 +72,33 @@ module EasyAppHelper::Logger::Instanciator
93
72
 
94
73
  # Creates the application logger
95
74
  def self.post_config_action(app)
96
- app.build_logger
75
+ # Build logger for the application. Depending on config may end-up up to nowhere
76
+ # (by default), STDOUT, STDERR or a file. See --help or EasyAppHelper::Config#help
77
+ # for all options.
78
+ @logger = EasyAppHelper::Common::DummyLogger.instance
79
+ issue_report = nil
80
+ if app.app_config[:debug]
81
+ unless app.app_config[:"log-file"].nil?
82
+ begin
83
+ if File.exists? app.app_config[:"log-file"]
84
+ logger_type = File.open(app.app_config[:"log-file"], File::WRONLY | File::APPEND)
85
+ else
86
+ logger_type = File.open(app.app_config[:"log-file"], File::WRONLY | File::CREAT)
87
+ end
88
+ rescue Exception => e
89
+ logger_type = STDOUT
90
+ issue_report = e.message
91
+ end
92
+ else
93
+ logger_type = STDOUT
94
+ end
95
+ logger_type = STDERR if app.app_config[:"debug-on-err"]
96
+ app.logger = Logger.new(logger_type)
97
+ end
98
+ app.app_config[:'log-level'] = EasyAppHelper::Common::DEFAULT_LOG_LEVEL if app.app_config[:'log-level'].nil?
99
+ app.logger.level = app.app_config[:"log-level"]
100
+ app.logger.error issue_report if issue_report
101
+ app.logger.debug "Logger is created."
97
102
  end
98
103
 
99
104
  end
@@ -6,5 +6,6 @@
6
6
  ################################################################################
7
7
 
8
8
  module EasyAppHelper
9
- VERSION = "0.0.7"
9
+ # Framework version
10
+ EASY_APP_HELPER_VERSION = "0.0.8"
10
11
  end
metadata CHANGED
@@ -1,78 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_app_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
5
- prerelease:
4
+ version: 0.0.8
6
5
  platform: ruby
7
6
  authors:
8
7
  - L.Briais
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-20 00:00:00.000000000 Z
11
+ date: 2013-03-23 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: pry
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: slop
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  description: Easy Application Helpers framework
@@ -97,27 +88,26 @@ files:
97
88
  homepage: https://github.com/lbriais/easy_app_helper
98
89
  licenses:
99
90
  - MIT
91
+ metadata: {}
100
92
  post_install_message:
101
93
  rdoc_options: []
102
94
  require_paths:
103
95
  - lib
104
96
  required_ruby_version: !ruby/object:Gem::Requirement
105
- none: false
106
97
  requirements:
107
- - - ! '>='
98
+ - - '>='
108
99
  - !ruby/object:Gem::Version
109
100
  version: '0'
110
101
  required_rubygems_version: !ruby/object:Gem::Requirement
111
- none: false
112
102
  requirements:
113
- - - ! '>='
103
+ - - '>='
114
104
  - !ruby/object:Gem::Version
115
105
  version: '0'
116
106
  requirements: []
117
107
  rubyforge_project:
118
- rubygems_version: 1.8.25
108
+ rubygems_version: 2.0.0.rc.2
119
109
  signing_key:
120
- specification_version: 3
110
+ specification_version: 4
121
111
  summary: Provides cool helpers to your application, including configuration and logging
122
112
  features
123
113
  test_files: []