@@ -34,12 +34,21 @@ if ($opts['md']) {
3434}
3535
3636$ table_titles = array (
37- 'changes ' => 'Production Changes ' ,
38- 'changes-dev ' => 'Dev Changes ' ,
37+ true => array (
38+ 'changes ' => 'Production Changes ' ,
39+ 'changes-dev ' => 'Dev Changes ' ,
40+ ),
41+ false => array (
42+ 'changes ' => 'Indirect Production Changes ' ,
43+ 'changes-dev ' => 'Indirect Dev Changes ' ,
44+ )
3945);
4046
41- foreach ($ changes as $ k => $ diff ) {
42- print tableize ($ table_titles [$ k ], $ diff , $ table_opts );
47+ foreach (array (true , false ) as $ direct ) {
48+ foreach ($ changes as $ k => $ diff ) {
49+ $ diff = filterDirect ($ diff , $ direct );
50+ print tableize ($ table_titles [$ direct ][$ k ], $ diff , $ table_opts );
51+ }
4352}
4453
4554function diff ($ key , $ data_from , $ data_to ) {
@@ -70,6 +79,18 @@ function diff($key, $data_from, $data_to) {
7079 return $ pkgs ;
7180}
7281
82+ function filterDirect ($ diff , $ direct )
83+ {
84+ if (empty ($ diff )) return $ diff ;
85+
86+ $ filtered = array ();
87+ foreach ($ diff as $ key => $ v ) {
88+ if ($ v [3 ]['direct ' ] != $ direct ) continue ;
89+ $ filtered [$ key ] = $ v ;
90+ }
91+ return $ filtered ;
92+ }
93+
7394function version ($ pkg )
7495{
7596 if ((substr ($ pkg ->version ,0 ,4 ) == 'dev- ' || '-dev ' === substr ($ pkg ->version , -4 )) && isset ($ pkg ->source ) && isset ($ pkg ->source ->reference )) {
@@ -104,7 +125,7 @@ function tableize($header, $data, $opts = array()) {
104125
105126 $ widths = array (maxLength (array_merge (array ($ header ), array_keys ($ data ))));
106127
107- $ count = 3 ; // it will always be 3. The fourth item is a properties array
128+ $ count = count ( reset ( $ data )) - 1 ;
108129 for ($ i = 0 ; $ i < $ count ; $ i ++) {
109130 $ widths [] = max (strlen ($ titles [$ i + 1 ]), maxLength (array_map (function ($ k ) use ($ data , $ i ) { return $ data [$ k ][$ i ]; }, array_keys ($ data ))));
110131 }
@@ -116,17 +137,7 @@ function tableize($header, $data, $opts = array()) {
116137 $ lines [] = tabelizeLine ($ titles , $ widths );
117138 $ lines [] = separatorLine ($ widths , $ opts ['joint ' ]);
118139
119- $ lines [] = fillLine (array ("Direct " ), '~ ' , $ widths );
120-
121140 foreach ($ data as $ key => $ v ) {
122- if (! $ v [3 ]['direct ' ]) continue ;
123- $ lines [] = tabelizeLine (array_merge (array ($ key ), array_slice ($ v , 0 , $ count )), $ widths );
124- }
125-
126- $ lines [] = fillLine (array ("Indirect " ), '~ ' , $ widths );
127-
128- foreach ($ data as $ key => $ v ) {
129- if ($ v [3 ]['direct ' ]) continue ;
130141 $ lines [] = tabelizeLine (array_merge (array ($ key ), array_slice ($ v , 0 , $ count )), $ widths );
131142 }
132143
542553 exit (0 );
543554}
544555# vim: ff=unix ts=4 ss=4 sr et
545-
0 commit comments