Class: Shards::Site

Inherits:
BaseYamlObject show all
Defined in:
lib/shards/site.rb

Instance Attribute Summary collapse

Attributes inherited from BaseYamlObject

#internal_host, #stage, #yaml

Attributes inherited from Base

#subdomain_param

Attributes included from Meta

#config

Instance Method Summary collapse

Methods inherited from BaseYamlObject

#command_to_read_remote, #command_to_remote, #copy_file_to_extra_dirs, #dir, #file, #file_path, #fingerprint_command, #fingerprints, #initialize, #local_fingerprint, #proxy_read_remote_file, #remote_file, #remote_fingerprint, #same_fingerprint?, #ssh!, #target_config_dir

Methods inherited from Base

#default_region, method_list, #set_config

Methods included from Meta

#add, #custom_yaml, #default_yaml, #get_config, #method_list, #output, #print_output, #proxy, #proxy_user, #reset_output, #run, #ssh_conn, #test_env?, #write_extra_config_dirs, #yaml_file

Constructor Details

This class inherits a constructor from Shards::BaseYamlObject

Instance Attribute Details

#clientObject

Returns the value of attribute client.



7
8
9
# File 'lib/shards/site.rb', line 7

def client
  @client
end

#shardObject

Returns the value of attribute shard.



7
8
9
# File 'lib/shards/site.rb', line 7

def shard
  @shard
end

Instance Method Details

#add_site(dryrun: false) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/shards/site.rb', line 13

def add_site dryrun: false

  add_data

  if dryrun
    add_site_message
  else
    write_yaml
  end

end

#deleteObject



45
46
47
48
49
50
51
52
# File 'lib/shards/site.rb', line 45

def delete
  site_to_delete = select_by_domain
  raise "there are more than one site with this domain" if site_to_delete.count > 1
  raise "there are not a site with this domain" if site_to_delete.count < 1
  @shard=site_to_delete.first['shard']
  @yaml=reject_by_domain
  write_yaml
end

#domain_paramObject



25
26
27
# File 'lib/shards/site.rb', line 25

def domain_param
  subdomain_param || domain
end

#exist?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/shards/site.rb', line 29

def exist?
  !select_by_domain.empty?
end

#reject_by_domainObject



37
38
39
# File 'lib/shards/site.rb', line 37

def reject_by_domain
  yaml.reject { |x| x['domain']==domain_param }
end

#select_by_domainObject



33
34
35
# File 'lib/shards/site.rb', line 33

def select_by_domain
  yaml.select { |x| x['domain']==domain_param }
end

#select_by_shardObject



41
42
43
# File 'lib/shards/site.rb', line 41

def select_by_shard
  yaml.select { |x| x['shard']==shard }
end

#write_yamlObject



54
55
56
57
# File 'lib/shards/site.rb', line 54

def write_yaml
  super
  write_extra_config_dirs stage
end