Class: Blend::Status::Project
Instance Attribute Summary collapse
-
#juice_client ⇒ Object
Returns the value of attribute juice_client.
-
#juice_id ⇒ Object
Returns the value of attribute juice_id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#resolve ⇒ Object
Returns the value of attribute resolve.
Instance Method Summary collapse
- #bugtracking ⇒ Object
- #check(key, method) ⇒ Object
- #config ⇒ Object
-
#domains ⇒ Object
Project Metadata.
- #domains_status ⇒ Object
- #environment_status ⇒ Object
- #environments ⇒ Object
- #feeds ⇒ Object
- #github_members ⇒ Object
- #github_teams ⇒ Object
- #header(text) ⇒ Object
- #heroku_apps(env = nil) ⇒ Object
- #hipchat ⇒ Object
-
#initialize(name, resolve = false) ⇒ Project
constructor
A new instance of Project.
- #juice_users_synced ⇒ Object
- #juice_users_synced_diff ⇒ Object
- #production ⇒ Object
-
#project_found ⇒ Object
Checks.
- #read_only_teams ⇒ Object
- #reload ⇒ Object
- #repo_status ⇒ Object
- #repos ⇒ Object
- #repos_setup ⇒ Object
- #servers(env = nil) ⇒ Object
- #source_control ⇒ Object
- #staging ⇒ Object
-
#team_status ⇒ Object
Sub status systems.
- #write_teams ⇒ Object
Constructor Details
#initialize(name, resolve = false) ⇒ Project
Returns a new instance of Project.
12 13 14 15 16 17 18 |
# File 'lib/blend/status/project.rb', line 12 def initialize( name, resolve = false ) @name = name @juice_client = Blend::Client.juice_client reload @resolve = resolve @resolver = ProjectResolver.new( self ) end |
Instance Attribute Details
#juice_client ⇒ Object
Returns the value of attribute juice_client.
10 11 12 |
# File 'lib/blend/status/project.rb', line 10 def juice_client @juice_client end |
#juice_id ⇒ Object
Returns the value of attribute juice_id.
10 11 12 |
# File 'lib/blend/status/project.rb', line 10 def juice_id @juice_id end |
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/blend/status/project.rb', line 10 def name @name end |
#resolve ⇒ Object
Returns the value of attribute resolve.
10 11 12 |
# File 'lib/blend/status/project.rb', line 10 def resolve @resolve end |
Instance Method Details
#bugtracking ⇒ Object
160 161 162 163 164 |
# File 'lib/blend/status/project.rb', line 160 def bugtracking f = (feeds['asana'] || []) + (feeds['lighthouse'] || []) return nil if f.length == 0 f end |
#check(key, method) ⇒ Object
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/blend/status/project.rb', line 194 def check key, method ret = __send__( method ) ret = false if ret.nil? ret = false if ret.is_a? Array and ret.length == 0 pass = ret if ret.is_a? Array ret = ret.collect do |x| if x.is_a? Hash x[:name] || x['name'] else x end end.join( ", ") end ret = "" if !ret printf "%20s: ", key if( pass ) printf "\u2713 #{ret}\n".encode('utf-8').green else printf "\u2718 #{ret}\n".encode('utf-8').red if @resolve r = "resolve_#{method}".to_sym @resolver.__send__(r) if @resolver.respond_to? r reload end end end |
#config ⇒ Object
72 73 74 |
# File 'lib/blend/status/project.rb', line 72 def config @config ||= (@juice_client.project( @juice_id ) || {})['blend_config'] end |
#domains ⇒ Object
Project Metadata
64 65 66 67 68 69 70 |
# File 'lib/blend/status/project.rb', line 64 def domains environment_status.collect do |x| x.domains.collect do |domain| {environment: x.environment, domain: domain } end end.flatten end |
#domains_status ⇒ Object
54 55 56 57 58 |
# File 'lib/blend/status/project.rb', line 54 def domains_status @domains_status ||= domains.collect do |x| Domain.new( @project, x[:environment], x[:domain] ) end end |
#environment_status ⇒ Object
48 49 50 51 52 |
# File 'lib/blend/status/project.rb', line 48 def environment_status @environment_status ||= (servers || []).collect do |server| Environment.new( self, server['name'], server['environment']['name'].downcase ) end end |
#environments ⇒ Object
80 81 82 |
# File 'lib/blend/status/project.rb', line 80 def environments @environments ||= @juice_client.environments( @juice_id ).group_by{|x| x['name'].downcase} end |
#feeds ⇒ Object
76 77 78 |
# File 'lib/blend/status/project.rb', line 76 def feeds @feeds ||= @juice_client.feeds( @juice_id ).group_by { |x| x['feed_name'] } end |
#github_members ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/blend/status/project.rb', line 100 def github_members read_only_members = read_only_teams.collect { |ts| ts.members }.flatten write_team_members = write_teams.collect { |ts| ts.members }.flatten read_only_members -= write_team_members write_team_members.collect do |x| {name: x, access: :full} end + read_only_members.collect do |x| {name: x, access: :read} end end |
#github_teams ⇒ Object
183 184 185 186 187 |
# File 'lib/blend/status/project.rb', line 183 def github_teams # return []] if @juice_id.nil? return [] if config.nil? config['teams'] end |
#header(text) ⇒ Object
189 190 191 192 |
# File 'lib/blend/status/project.rb', line 189 def header text puts puts "#{text}".blue.underline end |
#heroku_apps(env = nil) ⇒ Object
174 175 176 |
# File 'lib/blend/status/project.rb', line 174 def heroku_apps( env = nil ) servers(env).collect { |x| [x['name'], x['environment']['name']]} end |
#hipchat ⇒ Object
178 179 180 181 |
# File 'lib/blend/status/project.rb', line 178 def hipchat return nil if config.nil? config['hipchat_room'] end |
#juice_users_synced ⇒ Object
148 149 150 |
# File 'lib/blend/status/project.rb', line 148 def juice_users_synced juice_users_synced_diff.length == 0 end |
#juice_users_synced_diff ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/blend/status/project.rb', line 136 def juice_users_synced_diff team_juice_users = {} github_members.each do |member| user = juice_client.user_from_github_user member[:name] team_juice_users[user['id']] = user if user end juice_users = juice_client.project_users( @juice_id ).group_by{ |x| x['id'] } not_in_juice = team_juice_users.keys - juice_users.keys end |
#production ⇒ Object
166 167 168 |
# File 'lib/blend/status/project.rb', line 166 def production environments['production'] end |
#project_found ⇒ Object
Checks
88 89 90 |
# File 'lib/blend/status/project.rb', line 88 def project_found !@juice_id.nil? && @juice_id != "" end |
#read_only_teams ⇒ Object
92 93 94 |
# File 'lib/blend/status/project.rb', line 92 def read_only_teams team_status.select { |team| team.read_only? } end |
#reload ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/blend/status/project.rb', line 20 def reload @juice_id = @juice_client.project_id_from_name @name @teams = nil @repos = nil @environment_status = nil @domains_status = nil @config = nil @feeds = nil @environments = nil end |
#repo_status ⇒ Object
42 43 44 45 46 |
# File 'lib/blend/status/project.rb', line 42 def repo_status @repos ||= (repos || []).collect do |name, repo| Repo.new( self, name, repo ) end end |
#repos ⇒ Object
113 114 115 116 117 118 119 120 121 |
# File 'lib/blend/status/project.rb', line 113 def repos ret = {} team_status.each do |x| x.repos.each do |repo| ret[repo.full_name] = repo end end ret end |
#repos_setup ⇒ Object
123 124 125 |
# File 'lib/blend/status/project.rb', line 123 def repos_setup repos.keys end |
#servers(env = nil) ⇒ Object
152 153 154 155 156 157 158 |
# File 'lib/blend/status/project.rb', line 152 def servers( env = nil ) if( env ) (feeds['heroku'] || []).group_by { |x| x['environment']['name'].downcase }[env] else feeds['heroku'] end end |
#source_control ⇒ Object
127 128 129 130 131 132 133 134 |
# File 'lib/blend/status/project.rb', line 127 def source_control a = (feeds['github'] || []).collect { |x| "#{x['namespace']}/#{x['name']}" } b = repos_setup return false if (a-b).length != 0 || (b-a).length != 0 return false if a.length == 0 || b.length == 0 return a end |
#staging ⇒ Object
170 171 172 |
# File 'lib/blend/status/project.rb', line 170 def staging environments['staging'] end |
#team_status ⇒ Object
Sub status systems
36 37 38 39 40 |
# File 'lib/blend/status/project.rb', line 36 def team_status @teams ||= (github_teams || []).collect do |team| Team.new( self, team ) end end |
#write_teams ⇒ Object
96 97 98 |
# File 'lib/blend/status/project.rb', line 96 def write_teams team_status.select { |team| !team.read_only? } end |