potluck 0.0.4 → 0.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1c7870515c28013595dbe15f34ba4c2cf3e76fabbbd55c1859066462df9227f
4
- data.tar.gz: a87627ecfe3232593fd0f7223089a15893ad3e7227aed8a47d48ec32326b0572
3
+ metadata.gz: 67a2b224bd6ed00dcfe15688c0ebaa8764649cc7a201174c20c6238bab45bc27
4
+ data.tar.gz: e1fececdb06d683f1879ac8baab15a26ba8bb6db2a15a3ea8e0dd247876435e9
5
5
  SHA512:
6
- metadata.gz: 6b4cc348d159c69e95de691c0e6f0c159ef94818174f3f45319e76e21b971669e600a1d3fb4040edecc0a05b130c6ab0fcdcd2eb08dfdf3fe5e32936d13d7685
7
- data.tar.gz: 9e69dd441a0bf951edbccf7d7c590a9697327033e3e88a61801ceaefb3d05ba13734ecba4580f446e1497964a947d99b725a25832d9c0e8efe841a8fdc3414c0
6
+ metadata.gz: 43b41b2bade1a6b87ee0d266a38f0d59b7417e5a652804521952356d7aec8fb9f98c3e2727e903e5b79b91587ff621c557b7be90325e86db303ab66cf5c193d1
7
+ data.tar.gz: 6ffedd39746332d83f7c09b3cf3a7a4e40c60503eb88f3083e904347712a60a508199fcb44b8d8949250992e61de160e476654f5acb2f4a1b7ca867e26a13ba8
data/README.md CHANGED
@@ -1,6 +1,19 @@
1
1
  # Potluck
2
2
 
3
- Potluck is an extensible Ruby framework for managing external processes.
3
+ Potluck is an extensible Ruby framework for configuring, controlling, and interacting with external
4
+ processes. It leverages `launchctl` for starting and stopping processes when the command is available (e.g.
5
+ when developing locally on macOS) while gracefully taking either a more passive or manual role with external
6
+ processes in other environments (e.g. production).
7
+
8
+ The core Potluck gem provides a simple interface which is used by service-specific extensions to the gem.
9
+ Currently there are two official extensions:
10
+
11
+ * [Potluck::Nginx](potluck-nginx/README.md) - Generates Nginx configuration files and (optionally) controls
12
+ the Nginx process with `launchctl` or manual commands. Allows for multiple Ruby apps as well as other
13
+ external processes to all seamlessly use Nginx simultaneously.
14
+ * [Potluck::Postgres](potluck-postgres/README.md) - Provides control of the Postgres process and basic
15
+ common functionality for connecting to and setting up a database. Uses the
16
+ [Sequel](https://github.com/jeremyevans/sequel) and [pg](https://github.com/ged/ruby-pg) gems.
4
17
 
5
18
  ## Installation
6
19
 
@@ -18,7 +31,9 @@ gem install potluck
18
31
 
19
32
  ## Usage
20
33
 
21
- [Coming soon.]
34
+ The core Potluck gem is not meant to be used directly. Rather its `Service` class defines a common interface
35
+ for external processes which can be inherited by service-specific child classes. See
36
+ [Potluck::Nginx](potluck-nginx/README.md) and [Potluck::Postgres](potluck-postgres/README.md) for examples.
22
37
 
23
38
  ## Contributing
24
39
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -4,16 +4,16 @@ require('fileutils')
4
4
 
5
5
  module Potluck
6
6
  ##
7
- # A Ruby interface for controlling, configuring, and interacting with external processes. Serves as a
7
+ # General error class used for errors encountered with a service.
8
+ #
9
+ class ServiceError < StandardError; end
10
+
11
+ ##
12
+ # A Ruby interface for configuring, controlling, and interacting with external processes. Serves as a
8
13
  # parent class for service-specific child classes.
9
14
  #
10
15
  class Service
11
16
  SERVICE_PREFIX = 'potluck.npickens.'
12
-
13
- PLIST_XML = '<?xml version="1.0" encoding="UTF-8"?>'
14
- PLIST_DOCTYPE = '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/Prope'\
15
- 'rtyList-1.0.dtd">'
16
-
17
17
  LAUNCHCTL_ERROR_REGEX = /^-|\t[^0]\t/.freeze
18
18
 
19
19
  ##
@@ -23,9 +23,8 @@ module Potluck
23
23
  # be sent to stdout and stderr if none is supplied.
24
24
  # * +manage+ - True if the service runs locally and should be managed by this process (default: true if
25
25
  # launchctl is available and false otherwise).
26
- # * +is_local+ - DEPRECATED. True if the service runs locally (use +manage+ instead).
27
26
  #
28
- def initialize(logger: nil, manage: launchctl?, is_local: (is_local_omitted = true; nil))
27
+ def initialize(logger: nil, manage: launchctl?)
29
28
  @logger = logger
30
29
  @manage = !!manage
31
30
 
@@ -37,14 +36,6 @@ module Potluck
37
36
  elsif manage
38
37
  ensure_launchctl!
39
38
  end
40
-
41
- # DEPRECATED. Use +manage+ instead.
42
- @is_local = is_local.nil? ? (IS_MACOS && ensure_launchctl! rescue false) : is_local
43
-
44
- unless is_local_omitted
45
- warn("#{self.class}#initialize `is_local` parameter is deprecated and will be removed soon (use "\
46
- '`manage` instead)')
47
- end
48
39
  end
49
40
 
50
41
  ##
@@ -65,7 +56,7 @@ module Potluck
65
56
  # Checks if launchctl is available and raises an error if not.
66
57
  #
67
58
  def ensure_launchctl!
68
- launchctl? || raise("Cannot manage #{self.class.to_s.split('::').last}: launchctl not found")
59
+ launchctl? || raise(ServiceError.new("Cannot manage #{self.pretty_name}: launchctl not found"))
69
60
  end
70
61
 
71
62
  ##
@@ -142,7 +133,7 @@ module Potluck
142
133
  run(start_command)
143
134
  wait { status == :inactive }
144
135
 
145
- raise("Could not start #{self.class.pretty_name}") if status != :active
136
+ raise(ServiceError.new("Could not start #{self.class.pretty_name}")) if status != :active
146
137
 
147
138
  log("#{self.class.pretty_name} started")
148
139
  end
@@ -156,7 +147,7 @@ module Potluck
156
147
  run(stop_command)
157
148
  wait { status != :inactive }
158
149
 
159
- raise("Could not stop #{self.class.pretty_name}") if status != :inactive
150
+ raise(ServiceError.new("Could not stop #{self.class.pretty_name}")) if status != :inactive
160
151
 
161
152
  log("#{self.class.pretty_name} stopped")
162
153
  end
@@ -184,7 +175,7 @@ module Potluck
184
175
 
185
176
  if status != 0
186
177
  output.split("\n").each { |line| log(line, :error) }
187
- raise("Command exited with status #{status.to_i}: #{command}")
178
+ raise(ServiceError.new("Command exited with status #{status.to_i}: #{command}"))
188
179
  else
189
180
  output
190
181
  end
@@ -255,8 +246,9 @@ module Potluck
255
246
  #
256
247
  def self.plist(content)
257
248
  <<~EOS
258
- #{PLIST_XML}
259
- #{PLIST_DOCTYPE}
249
+ <?xml version="1.0" encoding="UTF-8"?>
250
+ #{'<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.'\
251
+ '0.dtd">'}
260
252
  <plist version="1.0">
261
253
  <dict>
262
254
  <key>Label</key>
@@ -271,17 +263,4 @@ module Potluck
271
263
  EOS
272
264
  end
273
265
  end
274
-
275
- ##
276
- # DEPRECATED. Old name of Potluck::Service class.
277
- #
278
- Dish = Service.clone
279
-
280
- # :nodoc: all
281
- class Dish
282
- def self.inherited(subclass)
283
- warn("Potluck::Dish has been renamed to Potluck::Service. Please update #{subclass} to inherit from "\
284
- 'Potluck::Service instead of Potluck::Dish.')
285
- end
286
- end
287
266
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Potluck
4
- VERSION = '0.0.4'
4
+ VERSION = '0.0.5'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: potluck
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Pickens
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-28 00:00:00.000000000 Z
11
+ date: 2021-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler