Class: SOULs::Sync

Inherits:
Thor
  • Object
show all
Defined in:
lib/souls/cli/sync/conf.rb,
lib/souls/cli/sync/model.rb,
lib/souls/cli/sync/pubsub.rb

Instance Method Summary collapse

Instance Method Details

#confObject



4
5
6
7
8
9
# File 'lib/souls/cli/sync/conf.rb', line 4

def conf
  SOULs::Gcloud.new.config_set
  update_conf
  update_conf(strain: "api")
  SOULs::Painter.sync("`config/souls.rb`, `apps/api/config/souls.rb`")
end

#modelObject



8
9
10
11
12
13
14
15
# File 'lib/souls/cli/sync/model.rb', line 8

def model
  cp_dir = %w[db app/models spec/factories]
  cp_dir.each do |dir|
    cp_and_dl_files(dir: dir)
    cp_env_files
  end
  SOULs::Painter.sync(cp_dir.to_s)
end

#pubsubObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/souls/cli/sync/pubsub.rb', line 4

def pubsub
  project_id = SOULs.configuration.project_id
  worker_name = FileUtils.pwd.split("/").last

  unless worker_name.match(/^worker-(\d|\w)+(-)*(\d|\w)+$/)
    SOULs::Painter.error("You are at wrong dir!\nPlease go to worker-* dir!")
    return false
  end

  url = `gcloud run services list --platform=managed \
   --project=#{project_id} |grep souls-#{project_id}-#{worker_name}| awk '{print $4}'`.strip
  return false if url.blank?

  worker_file_names = get_workers_file_paths

  sync_pubsub_topics_and_subscriptions(worker_file_names: worker_file_names, worker_url: url)
  SOULs::Painter.sync("All Jobs with PubSub Subscription!")
end