servitude 0.4.0 → 0.5.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: 53cfb7474208ec999ec104ff7f6cbebc5a95cdfc
4
- data.tar.gz: 5eb37804b51441b9ac8556eb3b587ecb099751a2
3
+ metadata.gz: 0cb042d305f0b88d3c0f0c6fb30c68cf5e594ee0
4
+ data.tar.gz: 7428b62b9bdb7e62fcde7638b22f97ae381e1a87
5
5
  SHA512:
6
- metadata.gz: 5a84f41870b6242178b9ae7fabe6f710965666be7f59dc376508034f206b57d74f1edb597d0bdcb53501dcc39c194de527020c97a946d9b92bc44fe108c90d5c
7
- data.tar.gz: cf03f89b9c90305ecfe663fe695ce43ef47c9a125511a4df69e76f2cc35452dcd10c4c9778f0ad19d953bbdb303f701912c3f5edfa2e998131910655d57d2aad
6
+ metadata.gz: 2771c1e6a3ae5152a48b61784cb2a9cad04455f417d2688b4614a85f82eed2491f9cd592a03c83bf78467ff563bebdcd6e19ed687c1c09c92daf8330f3a7cf05
7
+ data.tar.gz: da0c91b560eabf6c12869a0b93f6c8eab4a065e825e56ed0e11f27c585af4fc781d107a778d9076853150fe7a7de5d1c5fd98b0b8ae65e3cbb8e36ce0bc81f55
data/README.md CHANGED
@@ -68,12 +68,12 @@ If you do not call ::boot, an error is raised before your server can be started.
68
68
  boot host_namespace: AwesomeServer,
69
69
  app_id: 'awesome-server',
70
70
  app_name: 'Aswesome Server',
71
- company: 'Awesome, Inc.',
71
+ attribution: "v#{VERSION} \u00A9#{Time.now.year} Awesome, Inc."
72
+ author: 'Awesome, Inc.',
72
73
  default_config_path: "/etc/awesome/awesome-server.conf",
73
74
  default_log_path: "/var/log/awesome/awesome-server.log",
74
75
  default_pid_path: "/var/run/awesome/awesome-server.pid",
75
76
  default_thread_count: 1,
76
- version_copyright: "v#{VERSION} \u00A9#{Time.now.year} Awesome, Inc."
77
77
  end
78
78
 
79
79
  ### Servitude::Cli
@@ -25,13 +25,13 @@ module SimpleServer
25
25
  boot host_namespace: SimpleServer,
26
26
  app_id: 'simple-server',
27
27
  app_name: 'Simple Server',
28
- company: 'LFE',
28
+ attribution: "v#{VERSION} \u00A9#{Time.now.year} LFE",
29
+ author: 'LFE',
29
30
  use_config: false,
30
31
  default_config_path: nil,
31
32
  default_log_path: nil,
32
33
  default_pid_path: nil,
33
- default_thread_count: nil,
34
- version_copyright: "v#{VERSION} \u00A9#{Time.now.year} LFE"
34
+ default_thread_count: nil
35
35
 
36
36
  class Server
37
37
 
@@ -31,13 +31,13 @@ module EchoServer
31
31
  boot host_namespace: EchoServer,
32
32
  app_id: 'echo-server',
33
33
  app_name: 'Echo Server',
34
- company: 'LFE',
34
+ attribution: "v#{VERSION} \u00A9#{Time.now.year} LFE",
35
+ author: 'LFE',
35
36
  use_config: false,
36
37
  default_config_path: nil,
37
38
  default_log_path: nil,
38
39
  default_pid_path: nil,
39
- default_thread_count: nil,
40
- version_copyright: "v#{VERSION} \u00A9#{Time.now.year} LFE"
40
+ default_thread_count: nil
41
41
 
42
42
  class Server
43
43
 
@@ -42,13 +42,13 @@ module EchoServer
42
42
  boot host_namespace: EchoServer,
43
43
  app_id: 'echo-server-with-cli',
44
44
  app_name: 'Echo Server With CLI',
45
- company: 'LFE',
45
+ attribution: "v#{VERSION} \u00A9#{Time.now.year} LFE",
46
+ author: 'LFE',
46
47
  use_config: false,
47
48
  default_config_path: "#{PROJECT_ROOT}}/config/#{APP_FOLDER}.conf",
48
49
  default_log_path: "#{PROJECT_ROOT}/tmp/#{APP_FOLDER}.log",
49
50
  default_pid_path: "#{PROJECT_ROOT}/tmp/#{APP_FOLDER}.pid",
50
- default_thread_count: nil,
51
- version_copyright: "v#{VERSION} \u00A9#{Time.now.year} LFE"
51
+ default_thread_count: nil
52
52
 
53
53
  class Cli < Servitude::Cli::Service
54
54
  end
@@ -42,13 +42,13 @@ module EchoServer
42
42
  boot host_namespace: EchoServer,
43
43
  app_id: 'echo-server-with-cli-and-file-config',
44
44
  app_name: 'Echo Server With CLI And File Config',
45
- company: 'LFE',
45
+ attribution: "v#{VERSION} \u00A9#{Time.now.year} LFE",
46
+ author: 'LFE',
46
47
  use_config: true,
47
48
  default_config_path: "#{PROJECT_ROOT}/config/4.conf",
48
49
  default_log_path: "#{PROJECT_ROOT}/tmp/#{APP_FOLDER}.log",
49
50
  default_pid_path: "#{PROJECT_ROOT}/tmp/#{APP_FOLDER}.pid",
50
- default_thread_count: nil,
51
- version_copyright: "v#{VERSION} \u00A9#{Time.now.year} LFE"
51
+ default_thread_count: nil
52
52
 
53
53
  class Cli < Servitude::Cli::Service
54
54
  end
@@ -50,13 +50,13 @@ module EchoServer
50
50
  boot host_namespace: EchoServer,
51
51
  app_id: 'echo-server-with-cli-and-env-config',
52
52
  app_name: 'Echo Server With CLI And Env Config',
53
- company: 'LFE',
53
+ attribution: "v#{VERSION} \u00A9#{Time.now.year} LFE",
54
+ author: 'LFE',
54
55
  use_config: true,
55
56
  default_config_path: "#{PROJECT_ROOT}/config/5.conf",
56
57
  default_log_path: "#{PROJECT_ROOT}/tmp/#{APP_FOLDER}.log",
57
58
  default_pid_path: "#{PROJECT_ROOT}/tmp/#{APP_FOLDER}.pid",
58
- default_thread_count: nil,
59
- version_copyright: "v#{VERSION} \u00A9#{Time.now.year} LFE"
59
+ default_thread_count: nil
60
60
 
61
61
  class Cli < Servitude::Cli::Service
62
62
  end
@@ -16,27 +16,61 @@ module Servitude
16
16
 
17
17
  module ClassMethods
18
18
 
19
- def boot( host_namespace: raise(ArgumentError, 'host_namespace keyword is required'),
20
- app_id: host_namespace.name.split( '::' ).join( '-' ).downcase,
21
- app_name: host_namespace.name.split( '::' ).join( ' ' ),
22
- company: raise(ArgumentError, 'company keyword is required'),
19
+ def boot( host_namespace: nil,
20
+ app_id: ( host_namespace.name.split( '::' ).join( '-' ).downcase rescue nil ),
21
+ app_name: ( host_namespace.name.split( '::' ).join( ' ' ) rescue nil ),
22
+ author: nil,
23
+ company: nil, # TODO: Remove when company keyword deprecation expires
24
+ attribution: ( "v#{host_namespace::VERSION} Copyright © #{Time.now.year} #{author || company}" rescue nil ),
23
25
  use_config: false,
24
26
  default_config_path: nil,
25
27
  default_log_path: nil,
26
28
  default_pid_path: nil,
27
29
  default_thread_count: nil,
28
- version_copyright: "v#{host_namespace::VERSION} Copyright © #{Time.now.year} #{company}" )
30
+ version_copyright: nil ) # TODO: Remove when version_copyright keyword deprecation expires
31
+ unless host_namespace
32
+ raise ArgumentError, 'host_namespace keyword is required'
33
+ end
34
+ unless app_id
35
+ raise ArgumentError, 'app_id keyword is required'
36
+ end
37
+ unless app_name
38
+ raise ArgumentError, 'app_name keyword is required'
39
+ end
40
+ unless author || company
41
+ raise ArgumentError, 'author keyword is required'
42
+ end
43
+ unless attribution || version_copyright
44
+ raise ArgumentError, 'attribution keyword is required'
45
+ end
46
+
47
+ # TODO: Remove when company keyword deprecation expires
48
+ if company
49
+ Util.deprecate "#{Base.name}.boot company: #{company.inspect}",
50
+ "#{Base.name}.boot author: #{company.inspect}"
51
+ author = company
52
+ end
53
+
54
+ # TODO: Remove when version_copyright keyword deprecation expires
55
+ if version_copyright
56
+ Util.deprecate "#{Base.name}.boot version_copyright: #{version_copyright.inspect}",
57
+ "#{Base.name}.boot attribution: #{version_copyright.inspect}"
58
+ attribution = version_copyright
59
+ end
60
+
29
61
  Servitude::const_set :NS, host_namespace
30
62
 
31
63
  const_set :APP_ID, app_id
32
64
  const_set :APP_NAME, app_name
33
- const_set :COMPANY, company
65
+ const_set :AUTHOR, author
66
+ const_set :COMPANY, author # TODO: Remove when company keyword deprecation expires
67
+ const_set :ATTRIBUTION, attribution
34
68
  const_set :DEFAULT_CONFIG_PATH, default_config_path
35
69
  const_set :DEFAULT_LOG_PATH, default_log_path
36
70
  const_set :DEFAULT_PID_PATH, default_pid_path
37
71
  const_set :DEFAULT_THREAD_COUNT, default_thread_count
38
72
  const_set :USE_CONFIG, use_config
39
- const_set :VERSION_COPYRIGHT, version_copyright
73
+ const_set :VERSION_COPYRIGHT, attribution # TODO: Remove when version_copyright keyword deprecation expires
40
74
 
41
75
  Servitude::boot_called = true
42
76
  end
@@ -0,0 +1,19 @@
1
+ require 'rainbow'
2
+
3
+ module Servitude
4
+
5
+ module Util
6
+
7
+ def self.deprecate( deprecated_usage, sanctioned_usage )
8
+ $stderr.print Rainbow( " *** DEPRECATED " ).yellow.inverse
9
+ $stderr.print ' '
10
+ $stderr.print Rainbow( deprecated_usage ).underline
11
+ $stderr.print Rainbow(" -- use ")
12
+ $stderr.print Rainbow( sanctioned_usage ).underline
13
+ $stderr.print Rainbow(" instead")
14
+ $stderr.puts ''
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -1,3 +1,3 @@
1
1
  module Servitude
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
data/lib/servitude.rb CHANGED
@@ -16,6 +16,7 @@ module Servitude
16
16
  autoload :Server, 'servitude/server'
17
17
  autoload :ServerThreaded, 'servitude/server_threaded'
18
18
  autoload :SupervisionError, 'servitude/supervision_error'
19
+ autoload :Util, 'servitude/util'
19
20
 
20
21
  INT = "INT"
21
22
  TERM = "TERM"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servitude
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Harrelson
@@ -203,6 +203,7 @@ files:
203
203
  - lib/servitude/server_logging.rb
204
204
  - lib/servitude/server_threaded.rb
205
205
  - lib/servitude/supervision_error.rb
206
+ - lib/servitude/util.rb
206
207
  - lib/servitude/version.rb
207
208
  - servitude.gemspec
208
209
  - spec/servitude/pretty_print_spec.rb