Module: Shards::Meta

Included in:
Base, Db, List
Defined in:
lib/shards/meta/list.rb,
lib/shards/meta/meta.rb

Defined Under Namespace

Classes: List

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



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

def config
  @config
end

Instance Method Details

#add(text) ⇒ Object



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

def add text
  @output << text
end

#custom_yamlObject



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

def custom_yaml
  YAML.load_file ENV['FORMAT_METHODS_FILE']
end

#default_yamlObject



21
22
23
# File 'lib/shards/meta/meta.rb', line 21

def default_yaml
  YAML.load_file File.join(Shards::LIB_PATH,'settings','format_methods.yaml')
end

#get_config(class_name) ⇒ Object



9
10
11
# File 'lib/shards/meta/meta.rb', line 9

def get_config class_name
  yaml_file[class_name]
end

#method_list(class_name) ⇒ Object



50
51
52
# File 'lib/shards/meta/meta.rb', line 50

def method_list class_name
  get_config(class_name).keys
end

#outputObject



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

def output
  @output.join("\n")
end


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

def print_output
  puts output unless test_env?
  reset_output
end

#proxyObject



60
61
62
# File 'lib/shards/meta/meta.rb', line 60

def proxy
  stage.get 'proxy'
end

#proxy_userObject



64
65
66
# File 'lib/shards/meta/meta.rb', line 64

def  proxy_user
  ENV['PROXY_USER']
end

#reset_outputObject



42
43
44
# File 'lib/shards/meta/meta.rb', line 42

def reset_output
  @output=[' ']
end

#run(var) ⇒ Object



13
14
15
# File 'lib/shards/meta/meta.rb', line 13

def run var
  eval( config[var.to_s] )
end

#ssh_connObject



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

def ssh_conn
  Net::SSH.start(proxy, proxy_user) do |ssh|
    yield ssh
  end
end

#test_env?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/shards/meta/meta.rb', line 46

def test_env?
  ENV['TEST'] || false
end

#write_extra_config_dirs(stage) ⇒ Object



68
69
70
71
72
# File 'lib/shards/meta/meta.rb', line 68

def write_extra_config_dirs stage
  unless stage.get('extra_config_dirs').empty?
    copy_file_to_extra_dirs(stage.get('extra_config_dirs'))
  end
end

#yaml_fileObject



17
18
19
# File 'lib/shards/meta/meta.rb', line 17

def yaml_file
  ENV['FORMAT_METHODS_FILE'].nil? ? default_yaml : default_yaml.merge(custom_yaml)
end