Module: EbmSharedLib
- Defined in:
- lib/ebmsharedlib/options.rb,
lib/ebmsharedlib/utilities.rb
Overview
Greg Seitz
Copyright 2013, eBay Inc.
All rights reserved.
http://www.ebay.com
Defined Under Namespace
Constant Summary collapse
- ROOT_PATH =
File.("~/.ebm")
- CONFIG_DIR =
"build_configs"- CONFIG_PATH =
"#{ROOT_PATH}/#{CONFIG_DIR}"- CONFIG_SUFFIX =
".config"
Class Method Summary collapse
-
.config_name_from_dir(dir) ⇒ Object
expects us to be in the top level dir that has the same name as the config.
- .get_repo_name(git_path) ⇒ Object
- .prepare_config_repo ⇒ Object
- .printer ⇒ Object
-
.read_repo_config(config_name) ⇒ Object
read and return the config info for this repo.
Class Method Details
.config_name_from_dir(dir) ⇒ Object
expects us to be in the top level dir that has the same name as the config. Such as /Users/gseitz/Develop/ebay/iphone_3.1 will extract the config_name of iphone_3.1
77 78 79 |
# File 'lib/ebmsharedlib/utilities.rb', line 77 def self.config_name_from_dir(dir) config_name = "#{Dir.pwd}".split("/").last end |
.get_repo_name(git_path) ⇒ Object
81 82 83 |
# File 'lib/ebmsharedlib/utilities.rb', line 81 def self.get_repo_name(git_path) repo_name = git_path.split("/").last.split(".git")[0] end |
.prepare_config_repo ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/ebmsharedlib/utilities.rb', line 45 def self.prepare_config_repo # make the root if missing `mkdir -p #{ROOT_PATH}` # try to pull, if it fails could be due to repo not cloned cmd = "git pull" if EbmSharedLib::CL.do_cmd_result(cmd, CONFIG_PATH) != 0 # pull failed, try to clone cmd = "git clone [email protected]:eBayMobile/build_configs.git" if EbmSharedLib::CL.do_cmd_result(cmd, ROOT_PATH) != 0 raise "Unable to clone build_configs repo into #{ROOT_PATH}" end end end |
.printer ⇒ Object
85 86 87 |
# File 'lib/ebmsharedlib/utilities.rb', line 85 def self.printer @printer ||= Printer.new end |
.read_repo_config(config_name) ⇒ Object
read and return the config info for this repo
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/ebmsharedlib/utilities.rb', line 62 def self.read_repo_config(config_name) config_path = "#{EbmSharedLib::CONFIG_PATH}/configs/#{config_name}#{EbmSharedLib::CONFIG_SUFFIX}" begin json = File.open(config_path, 'r') {|f| f.read } info = JSON.parse(json) info.recursively_symbolize_keys! rescue raise "Error opening config file JSON: #{config_path}" end end |