minus5_daemon 0.2.0 → 0.2.4

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/lib/minus5_daemon.rb CHANGED
@@ -7,10 +7,11 @@ require 'yaml'
7
7
  #gems
8
8
  require 'rubygems'
9
9
 
10
- gem 'daemons', '= 1.1.3'
10
+ gem 'daemons', '= 1.1.4'
11
11
  require 'daemons'
12
+ require 'hashie'
12
13
 
13
14
  $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/minus5_daemon/"
14
15
  require 'runner.rb'
15
16
  require 'base.rb'
16
- require 'em_base.rb'
17
+ require 'em_base.rb'
@@ -10,19 +10,19 @@ module Minus5
10
10
 
11
11
  class Runner
12
12
 
13
- def initialize(klass = nil)
13
+ def initialize(klass)
14
14
  @klass = klass
15
- # asserts
16
15
  init_logger
17
- @options = OpenStruct.new(
16
+ @config_file_set = false
17
+ @options = Hashie::Mash.new(
18
18
  :daemonize => true,
19
19
  :config_file => 'config.yml',
20
- :config_file_set => false,
21
20
  :environment => 'production',
22
21
  :app_name => start_script_name,
23
22
  :app_root => app_root)
24
23
  parse_arg_options
25
24
  load_config
25
+ load_environment_file
26
26
  end
27
27
 
28
28
  attr_reader :logger
@@ -39,12 +39,19 @@ module Minus5
39
39
 
40
40
  private
41
41
 
42
+ def load_environment_file
43
+ file = "#{@options.app_root}/config/#{@options.environment}.yml"
44
+ if File.exists?(file)
45
+ @options.merge!(YAML.load_file(file))
46
+ end
47
+ end
48
+
42
49
  def load_config
43
50
  config_file = "#{@options.app_root}/config/#{@options.config_file}"
44
51
  if File.exists?(config_file)
45
- @options.config = YAML.load_file config_file
52
+ @options.config = Hashie::Mash.new(YAML.load_file(config_file))
46
53
  else
47
- if @options.config_file_set
54
+ if @config_file_set
48
55
  msg = "config file #{config_file} not found"
49
56
  @logger.error msg
50
57
  raise msg
@@ -74,7 +81,7 @@ module Minus5
74
81
  opts.on('-c','--config=file',"Use specified config file. This is yaml config file name from app_root/config dir.") do |file|
75
82
  file = "#{file}.yml" unless file.include?(".")
76
83
  @options.config_file = file
77
- @options.config_file_set = true
84
+ @config_file_set = true
78
85
  end
79
86
  opts.on('-a','--app-name=file',"Use specified application name for daemon process.") do |name|
80
87
  @options.app_name = name
@@ -122,4 +129,4 @@ module Minus5
122
129
  end
123
130
 
124
131
  end
125
- end
132
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minus5_daemon
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 4
10
+ version: 0.2.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Igor Anic
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-31 00:00:00 +02:00
18
+ date: 2011-07-05 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,14 +26,46 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- hash: 21
29
+ hash: 27
30
30
  segments:
31
31
  - 1
32
32
  - 1
33
- - 3
34
- version: 1.1.3
33
+ - 4
34
+ version: 1.1.4
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: hashie
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ hash: 23
46
+ segments:
47
+ - 1
48
+ - 0
49
+ - 0
50
+ version: 1.0.0
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: eventmachine
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ hash: 59
62
+ segments:
63
+ - 0
64
+ - 12
65
+ - 10
66
+ version: 0.12.10
67
+ type: :runtime
68
+ version_requirements: *id003
37
69
  description: " minus5_daemon is a simple lib for crating Ruby daemons\n it is built on top daemons.rb (http://daemons.rubyforge.org/)\n"
38
70
  email: ianic@minus5.hr
39
71
  executables: []