souls 1.19.6 → 1.20.0

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: 0b5f7b94188e33045595ee50df3761dc486c786992aea9f803560f27500f4aae
4
- data.tar.gz: 6d0659f46eb9ca1f9154c4cec5b97381cc04ca2f773b2bd1752eb82c0f6dac2e
3
+ metadata.gz: 690c4e033ba2db83f5f7889ac33cd199dbd4cd6b9b69f83c9d55cdd97ff5d3b3
4
+ data.tar.gz: aaf41d5d0ffaf0610c1cf99f26eb67df7e8c1d59e0bf40dd4b2eb525e3839ae4
5
5
  SHA512:
6
- metadata.gz: 3ff3dcf7fa1cf290a4998ec3bf1428f2c4fc94973095e9d7a678ccd7b528fdbdaf5f8c5f58149784f97a0219467c992bc0ccbd75b989fefd428a88d0d248ec4a
7
- data.tar.gz: 20e054999324d5d082544a4ca31e11bdde030aec3f664bf127df8a8912fbffa62864eb8ece8a701f75e0df37bf7126105438b44ef13c4d5ed4ab19836d85ab67
6
+ metadata.gz: f0a118b3bedfa8fdf60f6f7125b05dd05a9a49d2e818dad1bcfab50f98586fa173fdbbaa0417083dc0fa857c12461a18e54d628b365b40e57d693d6aa9323f96
7
+ data.tar.gz: ec064cf74ce3992b7169aca42b2f208eb3c81ce7dd2855df4b0c9f1a474028ca8d1b1631ac057d0864e81214fec48c71786bb8ebf6c6f1d358a48567d3d13818
@@ -13,16 +13,28 @@ module SOULs
13
13
  puts(Paint % ["✓ %{white_text}", :red, { white_text: ["Deleted file #{text}", :white] }])
14
14
  end
15
15
 
16
- def error(text)
17
- puts(Paint["🚨 #{text}", :red])
16
+ def error(text, emoji = nil)
17
+ if emoji
18
+ puts(Paint["#{emoji} #{text}", :red])
19
+ else
20
+ puts(Paint["🚨 #{text}", :red])
21
+ end
18
22
  end
19
23
 
20
- def warning(text)
21
- puts(Paint["🚨 #{text}", :yellow])
24
+ def warning(text, emoji = nil)
25
+ if emoji
26
+ puts(Paint["#{emoji} #{text}", :yellow])
27
+ else
28
+ puts(Paint["🚨 #{text}", :yellow])
29
+ end
22
30
  end
23
31
 
24
- def success(text)
25
- puts(Paint["🎉 #{text}", :green])
32
+ def success(text, emoji = nil)
33
+ if emoji
34
+ puts(Paint["#{emoji} #{text}", :green])
35
+ else
36
+ puts(Paint["🎉 #{text}", :green])
37
+ end
26
38
  end
27
39
 
28
40
  def sync(text)
@@ -1,6 +1,6 @@
1
- require_relative "./templates/functions_env_yaml"
1
+ require_relative "./templates/functions/functions_env_yaml"
2
2
 
3
- Dir["#{SOULs::SOULS_PATH}/lib/souls/cli/create/templates/*/*.rb"].map do |f|
3
+ Dir["#{SOULs::SOULS_PATH}/lib/souls/cli/create/templates/functions/*/*.rb"].map do |f|
4
4
  require f
5
5
  end
6
6
 
@@ -62,7 +62,7 @@ module SOULs
62
62
  end
63
63
 
64
64
  def get_runtime_create_method(runtime:)
65
- Dir["#{SOULs::SOULS_PATH}/lib/souls/cli/create/templates/#{runtime}/*"].map do |n|
65
+ Dir["#{SOULs::SOULS_PATH}/lib/souls/cli/create/templates/functions/#{runtime}/*"].map do |n|
66
66
  n.split("/").last.gsub(".rb", "")
67
67
  end
68
68
  end
@@ -11,9 +11,21 @@ module SOULs
11
11
  end
12
12
 
13
13
  runtime = current_dir.match(/cf-(\D+\d+)-/)[1]
14
+ runtime_lang = current_dir.match(/^cf-(\D+)\d+-/)
15
+ entry_point =
16
+ case runtime_lang
17
+ when "nodejs"
18
+ current_dir.underscore.camelize(:lower)
19
+ when "python"
20
+ current_dir.underscore
21
+ when "go"
22
+ current_dir.underscore.camelize
23
+ else
24
+ current_dir
25
+ end
14
26
  system(
15
27
  "
16
- gcloud functions deploy #{current_dir} --project=#{project_id} \
28
+ gcloud functions deploy #{current_dir} --entry-point=#{entry_point} --project=#{project_id} \
17
29
  --runtime #{runtime} --trigger-http --allow-unauthenticated --env-vars-file .env.yaml
18
30
  "
19
31
  )
@@ -15,15 +15,14 @@ module SOULs
15
15
  return false if url.blank?
16
16
 
17
17
  worker_file_names = get_workers_file_paths
18
- return false if worker_file_names.blank?
19
18
 
20
- sync_pubsub_topics_and_subscriptions(workers: worker_file_names, worker_url: url)
19
+ sync_pubsub_topics_and_subscriptions(worker_file_names: worker_file_names, worker_url: url)
21
20
  SOULs::Painter.sync("All Jobs with PubSub Subscription!")
22
21
  end
23
22
 
24
23
  private
25
24
 
26
- def sync_pubsub_topics_and_subscriptions(worker_url:, workers: {})
25
+ def sync_pubsub_topics_and_subscriptions(worker_url:, worker_file_names: {})
27
26
  project_id = SOULs.configuration.project_id
28
27
  pubsub = Google::Cloud::Pubsub.new(project_id: project_id)
29
28
  topics = pubsub.topics
@@ -37,21 +36,30 @@ module SOULs
37
36
  souls_topics = topic_names.select { |n| n.include?("souls-#{worker_name}") }
38
37
 
39
38
  souls_topics.each do |name|
40
- file_name = name.gsub("-", "_")
41
- value = workers[file_name.to_sym] || 0
42
- workers[file_name.to_sym] = value - 1
39
+ file_name = name.underscore
40
+ value = worker_file_names[file_name.to_sym] || 0
41
+ worker_file_names[file_name.to_sym] = value - 1
43
42
  end
44
43
 
45
- workers.each do |key, value|
46
- topic_id = key.to_s.gsub("_", "-")
47
- if value == 1
48
- create_topic(topic_id: topic_id)
49
- create_push_subscription(worker_url: worker_url, topic_id: topic_id)
44
+ if worker_file_names.blank?
45
+ return if souls_topics.blank?
46
+
47
+ souls_topics.each do |topic_id|
48
+ delete_topic(topic_id: topic_id)
49
+ delete_subscription(topic_id: topic_id)
50
+ end
51
+ else
52
+ worker_file_names.each do |key, value|
53
+ topic_id = key.to_s.gsub("_", "-")
54
+ if value == 1
55
+ create_topic(topic_id: topic_id)
56
+ create_push_subscription(worker_url: worker_url, topic_id: topic_id)
57
+ end
58
+ delete_topic(topic_id: topic_id) if value == -1
59
+ delete_subscription(topic_id: topic_id) if value == -1
50
60
  end
51
- delete_topic(topic_id: topic_id) if value == -1
52
- delete_subscription(topic_id: topic_id) if value == -1
53
61
  end
54
- workers
62
+ worker_file_names
55
63
  end
56
64
 
57
65
  def create_topic(topic_id: "worker-mailer")
@@ -66,7 +74,7 @@ module SOULs
66
74
  pubsub = Google::Cloud::Pubsub.new(project_id: project_id)
67
75
  topic = pubsub.topic(topic_id.to_s)
68
76
  topic.delete
69
- SOULs::Painter.error("Topic #{topic_id} deleted.")
77
+ SOULs::Painter.warning("Topic #{topic_id} deleted.", "✨")
70
78
  end
71
79
 
72
80
  def delete_subscription(topic_id: "worker-mailer")
@@ -100,7 +108,7 @@ module SOULs
100
108
  end
101
109
  workers.delete("base_query")
102
110
  workers.each do |file|
103
- response[:"souls_#{worker_name}_#{file}"] = 1
111
+ response["souls_#{worker_name.underscore}_#{file}".to_sym] = 1
104
112
  end
105
113
  response
106
114
  end
data/lib/souls/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module SOULs
2
- VERSION = "1.19.6".freeze
2
+ VERSION = "1.20.0".freeze
3
3
  public_constant :VERSION
4
4
  end
@@ -1 +1 @@
1
- 1.19.6
1
+ 1.20.0
@@ -1 +1 @@
1
- 1.19.6
1
+ 1.20.0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: souls
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.19.6
4
+ version: 1.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - POPPIN-FUMI
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2022-01-06 00:00:00.000000000 Z
13
+ date: 2022-01-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -190,15 +190,15 @@ files:
190
190
  - lib/souls/cli/console/index.rb
191
191
  - lib/souls/cli/create/functions.rb
192
192
  - lib/souls/cli/create/index.rb
193
- - lib/souls/cli/create/templates/functions_env_yaml.rb
194
- - lib/souls/cli/create/templates/go/function.rb
195
- - lib/souls/cli/create/templates/go/go.rb
196
- - lib/souls/cli/create/templates/nodejs/index.rb
197
- - lib/souls/cli/create/templates/nodejs/package.rb
198
- - lib/souls/cli/create/templates/python/main.rb
199
- - lib/souls/cli/create/templates/python/requirements.rb
200
- - lib/souls/cli/create/templates/ruby/app.rb
201
- - lib/souls/cli/create/templates/ruby/gemfile.rb
193
+ - lib/souls/cli/create/templates/functions/functions_env_yaml.rb
194
+ - lib/souls/cli/create/templates/functions/go/function.rb
195
+ - lib/souls/cli/create/templates/functions/go/go.rb
196
+ - lib/souls/cli/create/templates/functions/nodejs/index.rb
197
+ - lib/souls/cli/create/templates/functions/nodejs/package.rb
198
+ - lib/souls/cli/create/templates/functions/python/main.rb
199
+ - lib/souls/cli/create/templates/functions/python/requirements.rb
200
+ - lib/souls/cli/create/templates/functions/ruby/app.rb
201
+ - lib/souls/cli/create/templates/functions/ruby/gemfile.rb
202
202
  - lib/souls/cli/db/create_migration.rb
203
203
  - lib/souls/cli/db/create_migration_rbs.rb
204
204
  - lib/souls/cli/db/index.rb