class MarkVersionConfig
Attributes
base_folder_name[R]
Public Class Methods
new(base_folder_name = '.mark_version')
click to toggle source
# File lib/mark_version/mark_version_config.rb, line 6 def initialize(base_folder_name = '.mark_version') @base_folder_name = base_folder_name end
Public Instance Methods
add_release_branch(branch)
click to toggle source
# 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?()
click to toggle source
# File lib/mark_version/mark_version_config.rb, line 62 def auto_push? local_configs['auto_push'] end
init()
click to toggle source
# File lib/mark_version/mark_version_config.rb, line 10 def init f1 = open(project_config_file, 'w') f1.puts(<<CONF { "release_branches": ["master"] } CONF ) f1.close f2 = open(local_config_file, 'w') f2.puts(<<CONF { "auto_push": false } CONF ) f2.close end
local_config_file()
click to toggle source
# File lib/mark_version/mark_version_config.rb, line 34 def local_config_file "#{base_folder_name}/LOCAL_CONFIG" end
project_config_file()
click to toggle source
# File lib/mark_version/mark_version_config.rb, line 30 def project_config_file "#{base_folder_name}/CONFIG" end
release_branches()
click to toggle source
# File lib/mark_version/mark_version_config.rb, line 38 def release_branches project_configs['release_branches'] || [] end
remove_release_branch(branch)
click to toggle source
# 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)
click to toggle source
# 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
Private Instance Methods
local_configs()
click to toggle source
# File lib/mark_version/mark_version_config.rb, line 76 def local_configs content = File.read(local_config_file) rescue '' JSON.parse(content) rescue {} end
project_configs()
click to toggle source
# File lib/mark_version/mark_version_config.rb, line 85 def project_configs content = File.read(project_config_file) rescue '' JSON.parse(content) rescue {} end
write_local(configs)
click to toggle source
# File lib/mark_version/mark_version_config.rb, line 81 def write_local(configs) File.write(local_config_file, configs.to_json) end
write_project(configs)
click to toggle source
# File lib/mark_version/mark_version_config.rb, line 90 def write_project(configs) File.write(project_config_file, configs.to_json) end