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



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

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)


62
63
64
# File 'lib/mark_version/mark_version_config.rb', line 62

def auto_push?
  local_configs['auto_push']
end

#initObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/mark_version/mark_version_config.rb', line 10

def init
  f1 = open(project_config_file, 'w')
  f1.puts("{\n\"release_branches\": [\"master\"]\n}\n"
         )

  f1.close
  f2 = open(local_config_file, 'w')
  f2.puts("{\n\"auto_push\":  false\n}\n"
         )
  f2.close
end

#local_config_fileObject



34
35
36
# File 'lib/mark_version/mark_version_config.rb', line 34

def local_config_file
  "#{base_folder_name}/LOCAL_CONFIG"
end

#project_config_fileObject



30
31
32
# File 'lib/mark_version/mark_version_config.rb', line 30

def project_config_file
  "#{base_folder_name}/CONFIG"
end

#release_branchesObject



38
39
40
# File 'lib/mark_version/mark_version_config.rb', line 38

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

#remove_release_branch(branch) ⇒ Object



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

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



66
67
68
69
70
71
72
# File 'lib/mark_version/mark_version_config.rb', line 66

def set_auto_push(set)
  configs = local_configs

  configs['auto_push'] = set

  write_local(configs)
end