Class: MarkVersionConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/mark_version/mark_version_config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_folder_name = '.mark_version') ⇒ MarkVersionConfig

Returns a new instance of MarkVersionConfig.



6
7
8
# File 'lib/mark_version/mark_version_config.rb', line 6

def initialize(base_folder_name = '.mark_version')
  @base_folder_name = base_folder_name
end

Instance Attribute Details

#base_folder_nameObject (readonly)

Returns the value of attribute base_folder_name.



4
5
6
# File 'lib/mark_version/mark_version_config.rb', line 4

def base_folder_name
  @base_folder_name
end

Instance Method Details

#add_release_branch(branch) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/mark_version/mark_version_config.rb', line 31

def add_release_branch(branch)
  configs = project_configs

  configs['release_branches'] = [] if configs['release_branches'].nil?

  configs['release_branches'] << branch

  write_project(configs)
end

#auto_push?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/mark_version/mark_version_config.rb', line 51

def auto_push?
  local_configs['auto_push']
end

#initObject



10
11
12
13
14
15
16
17
# File 'lib/mark_version/mark_version_config.rb', line 10

def init
  f1 = open(project_config_file, 'w')
  f1.puts('{ }')
  f1.close
  f2 = open(local_config_file, 'w')
  f2.puts('{ }')
  f2.close
end

#local_config_fileObject



23
24
25
# File 'lib/mark_version/mark_version_config.rb', line 23

def local_config_file
  "#{base_folder_name}/LOCAL_CONFIG"
end

#project_config_fileObject



19
20
21
# File 'lib/mark_version/mark_version_config.rb', line 19

def project_config_file
  "#{base_folder_name}/CONFIG"
end

#release_branchesObject



27
28
29
# File 'lib/mark_version/mark_version_config.rb', line 27

def release_branches
  project_configs['release_branches'] || []
end

#remove_release_branch(branch) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/mark_version/mark_version_config.rb', line 41

def remove_release_branch(branch)
  configs = project_configs

  return false if configs['release_branches'].nil?

  configs['release_branches'] = configs['release_branches'] - [branch]

  write_project(configs)
end

#set_auto_push(set) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/mark_version/mark_version_config.rb', line 55

def set_auto_push(set)
  configs = local_configs

  configs['auto_push'] = set

  write_local(configs)
end