Class: Pixab::RepoManager

Inherits:
Object
  • Object
show all
Defined in:
lib/projects/RepoManager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRepoManager

Returns a new instance of RepoManager.



13
14
15
# File 'lib/projects/RepoManager.rb', line 13

def initialize()
  read_repo_infos
end

Instance Attribute Details

#featureObject (readonly)

Returns the value of attribute feature.



11
12
13
# File 'lib/projects/RepoManager.rb', line 11

def feature
  @feature
end

#root_pathObject (readonly)

Returns the value of attribute root_path.



11
12
13
# File 'lib/projects/RepoManager.rb', line 11

def root_path
  @root_path
end

Instance Method Details

#feature_branchObject



64
65
66
# File 'lib/projects/RepoManager.rb', line 64

def feature_branch
  feature["branch_prefix"] + feature_name
end

#feature_nameObject



60
61
62
# File 'lib/projects/RepoManager.rb', line 60

def feature_name
  feature["name"]
end

#main_repoObject



37
38
39
# File 'lib/projects/RepoManager.rb', line 37

def main_repo
  repos.first
end

#main_repo_nameObject



41
42
43
# File 'lib/projects/RepoManager.rb', line 41

def main_repo_name
  main_repo["name"]
end

#read_repo_infosObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/projects/RepoManager.rb', line 17

def read_repo_infos
  mbox_root = `mbox status --only root`
  Utilities.check_shell_result('Error: This is not `Mbox` directory')
  @root_path = mbox_root.split().last
  
  FileUtils.cd(root_path)
  json = File.read(".mbox/config.json")
  obj = JSON.parse(json)
  current_feature_name = obj["current_feature_name"]
  if current_feature_name.empty?
    puts "Error: You are currently in Free Mode".red
    exit(1)
  end
  @feature = obj["features"][current_feature_name.downcase]
end

#reposObject



33
34
35
# File 'lib/projects/RepoManager.rb', line 33

def repos
 feature["repos"]
end

#sub_repo_namesObject



54
55
56
57
58
# File 'lib/projects/RepoManager.rb', line 54

def sub_repo_names
  sub_repos.map do |sub_repo|
    sub_repo["name"]
  end
end

#sub_reposObject



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

def sub_repos
  if repos.length > 1
    sub_repos = repos.dup
    sub_repos.delete_at(0)
    return sub_repos
  end
  return []
end