servitude 1.1.0 → 1.2.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: dce6d48e55e0ea709cbac0ab8bb83576f5d4f855
4
- data.tar.gz: c96667392283ea694bd05cdccbfe48a054a40416
3
+ metadata.gz: 85cc543e4150da3e50ab21b3d7da7327000136ba
4
+ data.tar.gz: 86d3362587eca8a8d697f248084ecd061bf5370a
5
5
  SHA512:
6
- metadata.gz: b79ae5973d8b1788a8ff27956081e746bc61bd91f53bab9bd5f509d04994950dd395883a0e87aa8c80b2ce256301805c65632000dfeaa859927d31e16a736a4a
7
- data.tar.gz: f0946a59b22f543d219a45c3286ea3c93d6e26ae77080399c10faf137285b9ac231cb726200c64d71a4344fac8decc2fb6c83caeb07f0dd6c5c5a4e8b3c9b470
6
+ metadata.gz: eb87b5cb3a43be43341eae3dd78414dd3183d1e5e8b2c303b9562aeb38ebb991ad8ca372abc2a0fb8deea129e09e7553fa0fc8b065feb6a64d76735f3bd40e0b
7
+ data.tar.gz: 3e92d301380d50a38960b101e0625f2f0c39998fe857fc240bc9f25c32d7a66e4fbdb6526ecc6a73b59b5dac1fd6323ed0df01e62907158ab73cdb4b998e99a3
data/README.md CHANGED
@@ -102,23 +102,17 @@ For details on how to add commands to your custom or standard service CLIs see t
102
102
  ### Servitude::Configuration
103
103
 
104
104
  All Servitude servers automatically have a configuration instantiated for them (although it may be empty). The default class for the configuration is
105
- Servitude::Configuration. In order to define a custom configuration, define a custom configuraiton class (which may inherit from Servitude::Configuration)
106
- and simply override the Servitude::Server#configuration method in your Server class. Be sure the custom configuration calss accepts the command line
105
+ Servitude::Configuration. In order to define a custom configuration, define a custom configuration class (which may inherit from Servitude::Configuration)
106
+ and simply override the Servitude::Cli::Service#configuration method in your Server class. Be sure the custom configuration calss accepts the command line
107
107
  options and passes them to the super class's initializer or configuration will be completely broken.
108
108
 
109
109
  module AwesomeServer
110
- class Configuration < Servitude::Configuration
111
- def initialize( cli_options )
112
- super( cli_options )
113
- # possibly do something else ...
114
- end
115
- end
116
-
117
- class Server
118
- include Servitude::Server
119
-
120
- def configuration_class
121
- AwesomeServer::Configuration
110
+ class Cli < Servitude::Cli::Base
111
+ # necessary so Thor does not pick this method up as a CLI method
112
+ no_commands do
113
+ def configuration_class
114
+ AwesomeServer::Configuration
115
+ end
122
116
  end
123
117
  end
124
118
  end
@@ -53,9 +53,18 @@ module EchoServer
53
53
  attribution: "v#{VERSION} \u00A9#{Time.now.year} LFE",
54
54
  author: 'LFE',
55
55
  use_config: true,
56
- default_config_path: "#{PROJECT_ROOT}/config/5.conf",
56
+ default_config_path: "#{PROJECT_ROOT}/config/5.conf"
57
57
 
58
58
  class Cli < Servitude::Cli::Service
59
+
60
+ no_commands do
61
+
62
+ def configuration_class
63
+ Servitude::EnvironmentConfiguration
64
+ end
65
+
66
+ end
67
+
59
68
  end
60
69
 
61
70
  class Server
@@ -88,10 +97,6 @@ module EchoServer
88
97
 
89
98
  protected
90
99
 
91
- def configuration_class
92
- Servitude::EnvironmentConfiguration
93
- end
94
-
95
100
  def config_filters
96
101
  %w(threads)
97
102
  end
@@ -41,22 +41,32 @@ module Servitude
41
41
  no_commands do
42
42
 
43
43
  def start_interactive
44
- server = Servitude::server_class.new( options.merge( use_config: Servitude::USE_CONFIG, log: 'STDOUT' ))
44
+ server = Servitude::server_class.new( configuration( options, use_config: Servitude::USE_CONFIG, log: 'STDOUT' ))
45
+ binding.pry
45
46
  server.start
46
47
  end
47
48
 
48
49
  def start_daemon
49
- server = Servitude::Daemon.new( options.merge( use_config: Servitude::USE_CONFIG ))
50
+ server = Servitude::Daemon.new( configuration( options, use_config: Servitude::USE_CONFIG ))
50
51
  server.start
51
52
  end
52
53
 
54
+ def configuration_class
55
+ Servitude::Configuration
56
+ end
57
+
58
+ def configuration( options, additional_options={} )
59
+ options = options.merge( additional_options )
60
+ Servitude.configuration = configuration_class.load( options )
61
+ end
62
+
53
63
  end
54
64
 
55
65
  desc "status", "Check the status of the server daemon"
56
66
  pid_option
57
67
  method_option :quiet, type: :boolean, aliases: '-q', desc: "Do not prompt to remove an old PID file", default: false
58
68
  def status
59
- result = Servitude::Daemon.new( options.merge( use_config: Servitude::USE_CONFIG )).status
69
+ result = Servitude::Daemon.new( configuration( options, use_config: Servitude::USE_CONFIG )).status
60
70
  at_exit { exit result }
61
71
  end
62
72
 
@@ -64,7 +74,7 @@ module Servitude
64
74
  pid_option
65
75
  method_option :quiet, type: :boolean, aliases: '-q', desc: "Do not prompt to remove an old PID file", default: false
66
76
  def stop
67
- server = Servitude::Daemon.new( options.merge( use_config: Servitude::USE_CONFIG ))
77
+ server = Servitude::Daemon.new( configuration( options, use_config: Servitude::USE_CONFIG ))
68
78
  server.stop
69
79
  end
70
80
 
@@ -29,7 +29,6 @@ module Servitude
29
29
  @cli_options = cli_options
30
30
 
31
31
  run_hook :before_initialize
32
- initialize_config
33
32
  initialize_loggers
34
33
  run_hook :after_initialize
35
34
  end
@@ -52,14 +51,6 @@ module Servitude
52
51
  raise NotImplementedError
53
52
  end
54
53
 
55
- def initialize_config
56
- Servitude.configuration = configuration_class.load( cli_options )
57
- end
58
-
59
- def configuration_class
60
- Servitude::Configuration
61
- end
62
-
63
54
  private
64
55
 
65
56
  def finalize
@@ -1,3 +1,3 @@
1
1
  module Servitude
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servitude
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Harrelson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-12 00:00:00.000000000 Z
11
+ date: 2014-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler