Class: Mobilis::GenericProject

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
ActionsProjectsTake
Defined in:
lib/mobilis/generic_project.rb

Overview

base class for projects. Child classes should override generate and as needed child_env_vars

Instance Method Summary collapse

Methods included from ActionsProjectsTake

#append_line, #oblivious_run_command, #run_command, #run_docker, #set_file_contents, #set_second_line, #write_file

Constructor Details

#initialize(data, metaproject) ⇒ GenericProject

Returns a new instance of GenericProject.



21
22
23
24
25
26
27
# File 'lib/mobilis/generic_project.rb', line 21

def initialize data, metaproject
  @data = data
  data[:attributes] = {} unless data[:attributes]
  data[:options] = [] unless data[:options]
  data[:links] = [] unless data[:links]
  @metaproject = metaproject
end

Instance Method Details

#child_env_varsObject

environment env vars added to linked child services



31
32
33
# File 'lib/mobilis/generic_project.rb', line 31

def child_env_vars
  []
end

#childrenObject



39
40
41
# File 'lib/mobilis/generic_project.rb', line 39

def children
  links.map {|name| @metaproject.project_by_name name }
end

#displayObject



51
52
53
# File 'lib/mobilis/generic_project.rb', line 51

def display
  ap @data
end

#docker_image_nameObject



75
76
77
# File 'lib/mobilis/generic_project.rb', line 75

def docker_image_name
  return "#{ @metaproject.username }/#{ name }"
end

#env_varsObject



35
36
37
# File 'lib/mobilis/generic_project.rb', line 35

def env_vars
  []
end

#generateObject

generate the local file structure to support the project



96
97
98
# File 'lib/mobilis/generic_project.rb', line 96

def generate
  FileUtils.mkdir_p name
end

#generate_build_shObject



81
82
83
84
85
# File 'lib/mobilis/generic_project.rb', line 81

def generate_build_sh
  write_file "build.sh" do |f|
    f.write "docker build -t #{ docker_image_name } ."
  end
end

#git_commit_all(message) ⇒ Object



88
89
90
91
92
# File 'lib/mobilis/generic_project.rb', line 88

def git_commit_all message
  # FIXME
  #run_command ["git", "add", "."]
  #run_command ["git", "commit", "-m", message]
end

#linked_to_rails_projectObject



47
48
49
# File 'lib/mobilis/generic_project.rb', line 47

def linked_to_rails_project
  parents.find {|l| l.instance_of? Mobilis::RailsProject}
end


67
68
69
# File 'lib/mobilis/generic_project.rb', line 67

def links
  @data[:links]
end

#nameObject



55
56
57
# File 'lib/mobilis/generic_project.rb', line 55

def name
  @data[:name]
end

#optionsObject



59
60
61
# File 'lib/mobilis/generic_project.rb', line 59

def options
  @data[:options]
end

#parentsObject



43
44
45
# File 'lib/mobilis/generic_project.rb', line 43

def parents
  @metaproject.projects.filter {|l| l.links.include? name}
end


71
72
73
# File 'lib/mobilis/generic_project.rb', line 71

def set_links new_links
  @data[:links] = new_links
end

#typeObject



63
64
65
# File 'lib/mobilis/generic_project.rb', line 63

def type
  @data[:type]
end