firespring_dev_commands 2.1.1.pre.alpha.5 → 2.1.2.pre.alpha.1

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: 9e54929040a40491ff1d2b36af03da9c718e2770a507cf29f62ab7b24993b8d8
4
- data.tar.gz: da2feb3080c1864f22b988b9898a08408c874e29251be018b7f82f7290d5a922
3
+ metadata.gz: a3db1999f6439e25498a7a5dc84b96d7191cea3be8210382d8302502d07cae3d
4
+ data.tar.gz: 4be9c55b74b4bfcee808d4ce888a39ba9bb8db3598ae0421a67bf86628bf5983
5
5
  SHA512:
6
- metadata.gz: bd65f5fb950c89f42cbb761c39241a0f6fd414f99c22e3b8ae6800bc1361ba46b104dd70e1a890477789db04750d14ab8529db53be96e8917f16d4424b2daa46
7
- data.tar.gz: 85dd595b1e98265d75c41d24d3a98e72dbafa4d1fd112a04849d37061441251e5018a8295ab38486ccc78622052af98c0e111c0fc3498bf221d06072703be3b7
6
+ metadata.gz: c4221e8f43391c3e7db66a6e46bf4b60baa7d4524cc4e0706529f18599c29ec69490be451339a45926ff0d26200d517d2af25451c5535c92ff91515c135e9c57
7
+ data.tar.gz: 2874a653490e414a00a0e6ff94c12bb1ce7e29d65218b1b7e90b04cebaa801bf7dde1fe53bdb2d0770bb15dfc6dc815cdaa4fe069a62d861a2dec7e7032fca46
@@ -23,6 +23,7 @@ module Dev
23
23
  # The name of the file containing the Aws settings
24
24
  CONFIG_FILE = "#{Dev::Aws::CONFIG_DIR}/config".freeze
25
25
 
26
+ # Returns the config ini file associated with this object
26
27
  def self.config_ini
27
28
  IniFile.new(filename: CONFIG_FILE, default: 'default')
28
29
  end
@@ -11,6 +11,7 @@ module Dev
11
11
  # The local file where temporary credentials are stored
12
12
  CONFIG_FILE = "#{Dev::Aws::CONFIG_DIR}/credentials".freeze
13
13
 
14
+ # Returns the config ini file associated with this object
14
15
  def self.config_ini
15
16
  IniFile.new(filename: CONFIG_FILE, default: 'default')
16
17
  end
@@ -89,8 +89,8 @@ module Dev
89
89
  true
90
90
  end
91
91
 
92
- # Remove all leading non '{' characters
93
- # Remove all trailing non '}' characters
92
+ # Remove all leading non left-curly-brace characters
93
+ # Remove all trailing non right-curly-brace characters
94
94
  def strip_non_json(str)
95
95
  str.sub(/\A[^{]*{/m, '{').sub(/}[^}]*\z/m, '}')
96
96
  end
@@ -3,21 +3,26 @@ require 'dotenv'
3
3
 
4
4
  module Dev
5
5
  class Slack
6
+ # A class to manage slack global configuration settings
6
7
  class Global
7
8
  # The filename where we store the local auth information
8
9
  CONFIG_FILE = "#{Dir.home}/.env.slack".freeze
9
10
 
11
+ # The name of the environmental setting which holds the slack token
10
12
  SLACK_API_TOKEN = 'SLACK_API_TOKEN'.freeze
11
13
 
14
+ # Method to load the slack config file and then configure slack
12
15
  def configure
13
16
  # Always load the env slack auth
14
17
  Dotenv.load(CONFIG_FILE) if File.exist?(CONFIG_FILE)
15
18
 
16
19
  ::Slack.configure do |c|
17
- c.token = ENV.fetch('SLACK_API_TOKEN', nil)
20
+ c.token = ENV.fetch(SLACK_API_TOKEN, nil)
18
21
  c.logger = LOG if ENV['ENABLE_SLACK_DEBUG'].to_s.strip == 'true'
19
22
  end
20
23
  end
24
+
25
+ # Run the configure when creating this class to load any existing settings
21
26
  new.configure
22
27
 
23
28
  # Write the new slack auth value to the env file
@@ -1,18 +1,23 @@
1
1
  require 'slack'
2
2
 
3
3
  module Dev
4
+ # The main slack class for posting/uploading messages
4
5
  class Slack
6
+ # The attribute which contains the underlying slack web client object
5
7
  attr_accessor :client
6
8
 
9
+ # Create a new slack web client and make sure it has valid credentials
7
10
  def initialize
8
11
  @client = ::Slack::Web::Client.new
9
12
  @client.auth_test
10
13
  end
11
14
 
15
+ # Post the text to the given channel
12
16
  def post(channel:, text:)
13
17
  client.chat_postMessage(channel:, text:)
14
18
  end
15
19
 
20
+ # Upload the text to the give channel as a text file
16
21
  def upload_text(channel:, text:, title: 'Text File', filename: 'file.txt')
17
22
  raise 'text should be a string' unless text.is_a?(String)
18
23
 
@@ -6,11 +6,14 @@ module Dev
6
6
  class Application
7
7
  # Contains rake tasks for displaying and setting application variables in parameter store
8
8
  class Config < Dev::Template::ApplicationInterface
9
- attr_reader :path
9
+ attr_reader :path_prefix, :key_parameter_path
10
+
11
+ # Allow for custom config path_prefix for the application
12
+ # Allow for custom key parameter path (otherwise base it off the path prefix)
13
+ def initialize(name, path_prefix, key_parameter_path: nil, exclude: [])
14
+ @path_prefix = path_prefix
15
+ @key_parameter_path = key_parameter_path || "#{path_prefix}/kms/id"
10
16
 
11
- # Allow for custom config path for the application
12
- def initialize(name, path, exclude: [])
13
- @path = path
14
17
  super(name, exclude:)
15
18
  end
16
19
 
@@ -18,7 +21,7 @@ module Dev
18
21
  def create_list_task!
19
22
  # Have to set a local variable to be accessible inside of the instance_eval block
20
23
  application = @name
21
- path = @path
24
+ path_prefix = @path_prefix
22
25
  exclude = @exclude
23
26
 
24
27
  DEV_COMMANDS_TOP_LEVEL.instance_eval do
@@ -29,7 +32,7 @@ module Dev
29
32
  desc "List all #{application} configs"
30
33
  task list: %w(init) do
31
34
  puts
32
- Dev::Aws::Parameter.new.list(path).each do |it|
35
+ Dev::Aws::Parameter.new.list(path_prefix).each do |it|
33
36
  puts " #{it.name} => #{it.value} (#{it.type})"
34
37
  end
35
38
  puts
@@ -44,7 +47,8 @@ module Dev
44
47
  def create_set_task!
45
48
  # Have to set a local variable to be accessible inside of the instance_eval block
46
49
  application = @name
47
- path = @path
50
+ path_prefix = @path_prefix
51
+ key_parameter_path = @key_parameter_path
48
52
  exclude = @exclude
49
53
 
50
54
  DEV_COMMANDS_TOP_LEVEL.instance_eval do
@@ -58,7 +62,7 @@ module Dev
58
62
  "\n\toptionally specify ENCRYPT=true to change a String type to a SecureString type"
59
63
  task set: %w(ensure_aws_credentials) do
60
64
  raise 'NAME is required' if ENV['NAME'].to_s.strip.blank?
61
- raise 'NAME is not found in this apps parameters' if Dev::Aws::Parameter.new.list(path).none? { |it| it.name == ENV['NAME'] }
65
+ raise 'NAME is not found in this apps parameters' if Dev::Aws::Parameter.new.list(path_prefix).none? { |it| it.name == ENV['NAME'] }
62
66
  raise 'VALUE is required' if ENV['VALUE'].to_s.strip.blank?
63
67
 
64
68
  param_path = ENV.fetch('NAME', nil)
@@ -68,7 +72,7 @@ module Dev
68
72
  params = {type: 'String'}
69
73
  if ENV['ENCRYPT'].to_s.strip == 'true' || old_value.type == 'SecureString'
70
74
  params[:type] = 'SecureString'
71
- params[:key_id] = Dev::Aws::Parameter.new.get_value("#{path}/kms/id")
75
+ params[:key_id] = Dev::Aws::Parameter.new.get_value(key_parameter_path)
72
76
  end
73
77
 
74
78
  message = 'This will change '.light_green +
@@ -6,6 +6,6 @@ module Dev
6
6
  # Use 'v.v.v.pre.alpha.v' for pre-release vesions
7
7
  # Use 'v.v.v.beta.v for beta versions
8
8
  # Use semantic versioning for any releases (https://semver.org/)
9
- VERSION = '2.1.1.pre.alpha.5'.freeze
9
+ VERSION = '2.1.2.pre.alpha.1'.freeze
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firespring_dev_commands
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1.pre.alpha.5
4
+ version: 2.1.2.pre.alpha.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firespring
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-15 00:00:00.000000000 Z
11
+ date: 2023-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport