Class: Sem::CLI::SharedConfigs::Files

Inherits:
Dracula
  • Object
show all
Defined in:
lib/sem/cli/shared_configs.rb

Instance Method Summary collapse

Instance Method Details

#add(shared_config_name) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/sem/cli/shared_configs.rb', line 67

def add(shared_config_name)
  shared_config = Sem::API::SharedConfig.find!(shared_config_name)

  local_path = options["local-path"]

  abort "File #{local_path} not found" unless File.exist?(local_path)

  path = options["path-on-semaphore"]
  content = File.read(local_path)

  shared_config.add_config_file(:path => path, :content => content, :encrypted => options["encrypted"])

  puts "Added #{path} to #{shared_config_name}"
end

#list(shared_config_name) ⇒ Object



52
53
54
55
56
57
58
59
60
61
# File 'lib/sem/cli/shared_configs.rb', line 52

def list(shared_config_name)
  shared_config = Sem::API::SharedConfig.find!(shared_config_name)
  files = shared_config.files

  if !files.empty?
    Sem::Views::Files.list(files)
  else
    Sem::Views::SharedConfigs.add_first_file(shared_config)
  end
end

#remove(shared_config_name) ⇒ Object



84
85
86
87
88
89
90
# File 'lib/sem/cli/shared_configs.rb', line 84

def remove(shared_config_name)
  shared_config = Sem::API::SharedConfig.find!(shared_config_name)

  shared_config.remove_config_file(options[:path])

  puts "Removed #{options[:path]} from #{shared_config_name}"
end