class Nabokov::Nabokovfile
Class represents the nabokovfile with the settings for nabokov
Attributes
localizations_repo_local_path[RW]
@return [String] The localizations repo local path
localizations_repo_master_branch[RW]
@return [String] The localizations repo master branch
localizations_repo_url[RW]
@return [String] The localizations repo url string
project_local_path[RW]
@return [String] The project repo local path
project_localization_file_paths[RW]
@return [Hash] The Hash with key as localization name and value as repspected localization file path
Public Class Methods
new(path)
click to toggle source
# File lib/nabokov/core/nabokovfile.rb, line 20 def initialize(path) raise "Path is a required parameter" if path.nil? raise "Couldn't find nabokov file at '#{path}'" unless File.exist?(path) nabokovfile = File.read(path) yaml_data = read_data_from_yaml_file(nabokovfile, path) validate_content(yaml_data) read_content(yaml_data) end
Private Instance Methods
build_localization_local_path()
click to toggle source
# File lib/nabokov/core/nabokovfile.rb, line 52 def build_localization_local_path repo_url_path = URI(self.localizations_repo_url).path.to_s home_dir = Dir.home.to_s repo_url_name_without_extension = File.basename(repo_url_path, File.extname(repo_url_path)).downcase repo_url_organization = File.dirname(repo_url_path).downcase nabokov_dir_name = "/.nabokov" home_dir + nabokov_dir_name + repo_url_organization + "/" + repo_url_name_without_extension end
read_content(content_hash)
click to toggle source
# File lib/nabokov/core/nabokovfile.rb, line 47 def read_content(content_hash) read_localizations_repo_content(content_hash) read_project_repo_content(content_hash) end
read_data_from_yaml_file(yaml_file, path)
click to toggle source
# File lib/nabokov/core/nabokovfile.rb, line 36 def read_data_from_yaml_file(yaml_file, path) YAML.load(yaml_file) rescue Psych::SyntaxError raise "File at '#{path}' doesn't have a legit YAML syntax" end
read_localizations_repo_content(content_hash)
click to toggle source
# File lib/nabokov/core/nabokovfile.rb, line 61 def read_localizations_repo_content(content_hash) localizations_repo = content_hash[NabokovfileKeyes.localizations_repo] self.localizations_repo_url = localizations_repo[NabokovfileKeyes.localizations_repo_url] self.localizations_repo_master_branch = localizations_repo[NabokovfileKeyes.localizations_repo_master_branch].nil? ? "master" : localizations_repo[NabokovfileKeyes.localizations_repo_master_branch] end
read_project_repo_content(content_hash)
click to toggle source
# File lib/nabokov/core/nabokovfile.rb, line 67 def read_project_repo_content(content_hash) project_repo = content_hash[NabokovfileKeyes.project_repo] self.project_localization_file_paths = project_repo[NabokovfileKeyes.project_localization_file_paths] self.project_local_path = project_repo[NabokovfileKeyes.project_local_path] self.localizations_repo_local_path = build_localization_local_path end
validate_content(content_hash)
click to toggle source
# File lib/nabokov/core/nabokovfile.rb, line 42 def validate_content(content_hash) validator = NabokovfileContentValidator.new(content_hash) validator.validate end