Class: BigKeeper::BigkeeperParser
- Inherits:
-
Object
- Object
- BigKeeper::BigkeeperParser
- Defined in:
- lib/big_keeper/util/bigkeeper_parser.rb
Overview
Bigkeeper file parser
Constant Summary collapse
- @@config =
{}
- @@current_user =
''
Class Method Summary collapse
- .config ⇒ Object
- .home_git ⇒ Object
- .home_name ⇒ Object
- .home_pulls ⇒ Object
- .module_full_path(home_path, user_name, module_name) ⇒ Object
- .module_git(module_name) ⇒ Object
- .module_names ⇒ Object
- .module_path(user_name, module_name) ⇒ Object
- .module_pulls(module_name) ⇒ Object
- .parse(bigkeeper) ⇒ Object
- .parse_home(name, params) ⇒ Object
- .parse_modules ⇒ Object
- .parse_modules_pod(name, params) ⇒ Object
- .parse_pod(name, params) ⇒ Object
- .parse_user(name) ⇒ Object
- .parse_user_pod(name, params) ⇒ Object
- .parse_version(name) ⇒ Object
- .verify_modules(modules) ⇒ Object
- .version ⇒ Object
Class Method Details
.config ⇒ Object
151 152 153 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 151 def self.config @@config end |
.home_git ⇒ Object
101 102 103 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 101 def self.home_git() @@config[:home][:git] end |
.home_name ⇒ Object
97 98 99 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 97 def self.home_name @@config[:name] end |
.home_pulls ⇒ Object
105 106 107 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 105 def self.home_pulls() @@config[:home][:pulls] end |
.module_full_path(home_path, user_name, module_name) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 109 def self.module_full_path(home_path, user_name, module_name) if @@config[:users] \ && @@config[:users][user_name] \ && @@config[:users][user_name][:pods] \ && @@config[:users][user_name][:pods][module_name] \ && @@config[:users][user_name][:pods][module_name][:path] @@config[:users][user_name][:pods][module_name][:path] else File.("#{home_path}/../#{module_name}") end end |
.module_git(module_name) ⇒ Object
133 134 135 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 133 def self.module_git(module_name) @@config[:modules][module_name][:git] end |
.module_names ⇒ Object
147 148 149 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 147 def self.module_names @@config[:modules].keys end |
.module_path(user_name, module_name) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 121 def self.module_path(user_name, module_name) if @@config[:users] \ && @@config[:users][user_name] \ && @@config[:users][user_name][:pods] \ && @@config[:users][user_name][:pods][module_name] \ && @@config[:users][user_name][:pods][module_name][:path] @@config[:users][user_name][:pods][module_name][:path] else "../#{module_name}" end end |
.module_pulls(module_name) ⇒ Object
137 138 139 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 137 def self.module_pulls(module_name) @@config[:modules][module_name][:pulls] end |
.parse(bigkeeper) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 30 def self.parse(bigkeeper) if @@config.empty? content = File.read bigkeeper content.gsub!(/version\s/, 'BigKeeper::version ') content.gsub!(/user\s/, 'BigKeeper::user ') content.gsub!(/home\s/, 'BigKeeper::home ') content.gsub!(/pod\s/, 'BigKeeper::pod ') content.gsub!(/modules\s/, 'BigKeeper::modules ') eval content # p @@config end end |
.parse_home(name, params) ⇒ Object
56 57 58 59 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 56 def self.parse_home(name, params) @@config[:home] = params @@config[:name] = name end |
.parse_modules ⇒ Object
87 88 89 90 91 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 87 def self.parse_modules modules = @@config[:modules] modules = {} if modules.nil? @@config[:modules] = modules end |
.parse_modules_pod(name, params) ⇒ Object
81 82 83 84 85 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 81 def self.parse_modules_pod(name, params) modules = @@config[:modules] modules[name] = params @@config[:modules] = modules end |
.parse_pod(name, params) ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 61 def self.parse_pod(name, params) if params[:path] parse_user_pod(name, params) elsif params[:git] parse_modules_pod(name, params) else raise %(There should be ':path =>' or ':git =>' for pod #{name}) end end |
.parse_user(name) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 48 def self.parse_user(name) @@current_user = name users = @@config[:users] users = {} if users.nil? users[name] = {} @@config[:users] = users end |
.parse_user_pod(name, params) ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 71 def self.parse_user_pod(name, params) users = @@config[:users] user = users[@@current_user] pods = user[:pods] pods = {} if pods.nil? pods[name] = params user[:pods] = pods @@config[:users] = users end |
.parse_version(name) ⇒ Object
44 45 46 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 44 def self.parse_version(name) @@config[:version] = name end |
.verify_modules(modules) ⇒ Object
141 142 143 144 145 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 141 def self.verify_modules(modules) modules.each do |item| raise "Can not find module #{item} in Bigkeeper file" unless @@config[:modules][item] end end |
.version ⇒ Object
93 94 95 |
# File 'lib/big_keeper/util/bigkeeper_parser.rb', line 93 def self.version @@config[:version] end |