Skip to content

Commit 2393f9f

Browse files
committed
Test suite, shortcuts and refactoring
1 parent d54e59c commit 2393f9f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+756
-173
lines changed

.gitmodules

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "lib/Symfony/Component/Serializer"]
2+
path = lib/Symfony/Component/Serializer
3+
url = http://github.com/symfony/Serializer.git
4+
[submodule "lib/Symfony/Component/Yaml"]
5+
path = lib/Symfony/Component/Yaml
6+
url = http://github.com/symfony/Yaml.git

.travis.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
language: php
2+
3+
php:
4+
- 5.3
5+
- 5.4

CHANGELOG.md

Whitespace-only changes.

Ladybug.zip

325 KB
Binary file not shown.

README.md

+16-3
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ There are more examples in `examples` directory.
8383

8484
## Installation
8585

86-
As easy as [download](https://github.com/raulfraile/Ladybug/zipball/master), include the library and use the provided helpers:
86+
As easy as [download](https://github.com/raulfraile/Ladybug/raw/master/Ladybug.zip), include the library and use the provided helpers:
8787

8888
``` php
8989
<?php
@@ -102,12 +102,25 @@ The are 5 helpers:
102102
`ladybug_dump_die($var1[, $var2[, ...]])`: Dumps one or more variables and
103103
terminates the current script
104104

105-
`ladybug_dump_return($var1[, $var2[, ...]])`: Dumps one or more variables and
106-
returns the string
105+
`ladybug_dump_return($format, $var1[, $var2[, ...]])`: Dumps one or more variables and
106+
returns the dump in any of the following formats:
107+
108+
* yml: Returns the dump in YAML
109+
* json: Returns the dump in JSON
110+
* xml: Returns the dump in XML
111+
* php: Returns the dump in PHP arrays
107112

108113
`ladybug_dump_ini([$extension])`: Dumps all configuration options
109114

110115
`ladybug_dump_ext()`: Dumps loaded extensions
116+
117+
There are also some shortcuts in case you are not using this function names:
118+
119+
`ld($var1[, $var2[, ...]])`: shortcut for ladybug_dump
120+
121+
`ldd($var1[, $var2[, ...]])`: shortcut for ladybug_dump_die
122+
123+
`ldr($format, $var1[, $var2[, ...]])`: shortcut for ladybug_return
111124

112125
## Customizable
113126

bin/deploy.php

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
set_time_limit(0);
5+
6+
// create temporary folder with files and components
7+
$temp = '/tmp/Ladybug';
8+
9+
if (is_dir($temp)) rrmdir($temp);
10+
rmkdir($temp);
11+
12+
$files = array(
13+
'LICENSE',
14+
'README.md',
15+
'examples/',
16+
'tests/',
17+
'lib/Ladybug/'
18+
);
19+
20+
$components = array(
21+
'Serializer' => array(
22+
'git' => 'http://github.com/symfony/Serializer.git',
23+
'target' => 'lib/Symfony/Component/Serializer'
24+
),
25+
'Yaml' => array(
26+
'git' => 'http://github.com/symfony/Yaml.git',
27+
'target' => 'lib/Symfony/Component/Yaml'
28+
)
29+
);
30+
31+
// add files
32+
foreach ($files as $item) {
33+
if (is_dir(__DIR__ . '/../' . $item)) rmkdir($temp . '/' . $item);
34+
rcopy(__DIR__ . '/../' . $item, $temp . '/' . $item);
35+
}
36+
37+
// add git components
38+
foreach ($components as $key => $item) {
39+
if (!is_dir($temp . '/' . $item['target'])) rmkdir($item['target']);
40+
41+
$command = "git clone $item['git'] $temp/$item['target']";
42+
echo "$command\n";
43+
44+
shell_exec($command);
45+
}
46+
47+
// create the zip file
48+
$zip = new ZipArchive();
49+
$filename = __DIR__ . '/../Ladybug.zip';
50+
51+
if (is_file($filename)) unlink($filename);
52+
53+
if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
54+
exit("cannot open <$filename>\n");
55+
}
56+
57+
raddzip($temp, $zip);
58+
59+
$zip->close();
60+
61+
// functions from https://github.com/asiermarques/Leophard/blob/master/leophard_install.php
62+
function rrmdir($dir) {
63+
if (is_dir($dir)) {
64+
$objects = scandir($dir);
65+
foreach ($objects as $object) {
66+
if ($object != "." && $object != "..") {
67+
if (filetype($dir."/".$object) == "dir") rrmdir($dir."/".$object);
68+
else unlink($dir."/".$object);
69+
}
70+
}
71+
reset($objects);
72+
rmdir($dir);
73+
}
74+
}
75+
76+
function rcopy($src, $dst) {
77+
//if (file_exists($dst)) rrmdir($dst);
78+
if (is_dir($src)) {
79+
@mkdir($dst);
80+
$files = scandir($src);
81+
foreach ($files as $file)
82+
if ($file != "." && $file != "..") rcopy("$src/$file", "$dst/$file");
83+
}
84+
else if (file_exists($src)) copy($src, $dst);
85+
}
86+
87+
function rmkdir($dir) {
88+
@mkdir($dir, 0777, true);
89+
}
90+
91+
function raddzip($src, & $zip) {
92+
if (is_dir($src)) {
93+
$zip->addEmptyDir($src);
94+
95+
$files = scandir($src);
96+
foreach ($files as $file)
97+
if ($file != "." && $file != "..") raddzip("$src/$file", $zip);
98+
}
99+
else if (file_exists($src)) {
100+
$zip->addFile("$src", preg_replace('/^\/tmp\/Ladybug/', '', $src));
101+
}
102+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 3166c1f493673ab60a592fe388a86c33a313cc68
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit c7f3b6f68658d9a6a2f2f25d223898b7cf5be98d

examples/export.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
require_once __DIR__.'/../lib/Ladybug/Autoloader.php';
3+
Ladybug\Ladybug_Autoloader::register();
4+
5+
$var1 = NULL;
6+
$var2 = 15;
7+
$var3 = 15.5;
8+
$var4 = 'hello world!';
9+
$var5 = false;
10+
$var6 = new \DateTime();
11+
$var7 = array(1, 2, 3, new \DateTime());
12+
13+
echo ladybug_dump_return('json', $var1, $var2, $var3, $var4, $var5, $var6, $var7);

examples/objects.php

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class Foo {
1313
public function __construct() {$this->a = new Foo2();}
1414
public function getBar() { return $this->bar; }
1515
public function setBar($bar = 1, $bar2 = TRUE, $bar3 = NULL) { $this->bar = $bar; }
16+
public function __toString() {return $this->bar . ' - ' . $this->bar2; }
1617
}
1718

1819
$foo = new Foo();

examples/simple_variables.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
$var3 = 15.5;
88
$var4 = 'hello world!';
99
$var5 = false;
10-
11-
ladybug_dump($var1, $var2, $var3, $var4, $var5);
10+
$v=new \Symfony\Component\Serializer\Serializer();
11+
ladybug_dump($var1, $var2, $var3, $var4, $var5,$v);

lib/Ladybug/Asset/experiment.log

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
OptiPNG 0.6.3: Advanced PNG optimizer.
2+
Copyright (C) 2001-2009 Cosmin Truta.
3+
4+
This program is open-source software. See LICENSE for more details.
5+
6+
Portions of this software are based in part on the work of:
7+
Jean-loup Gailly and Mark Adler (zlib)
8+
Glenn Randers-Pehrson and the PNG Development Group (libpng)
9+
Miyasaka Masaru (BMP support)
10+
David Koblas (GIF support)
11+
12+
Using libpng version 1.2.42 and zlib version 1.2.3.3
13+
14+
** Processing: experiment.png
15+
Error: Can't open the input file
16+
17+
** Status report
18+
1 file(s) have been processed.
19+
1 error(s) have been encountered.

lib/Ladybug/Asset/filefind.png

585 Bytes
Loading

lib/Ladybug/Asset/minify.php

+23-21
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,27 @@
33
$css = file_get_contents('tree.css');
44

55
/* Strips Comments */
6-
$css = preg_replace('!/\*.*?\*/!s','', $css);
7-
$css = preg_replace('/\n\s*\n/',"\n", $css);
8-
9-
/* Minifies */
10-
$css = preg_replace('/[\n\r \t]/',' ', $css);
11-
$css = preg_replace('/ +/',' ', $css);
12-
$css = preg_replace('/ ?([,:;{}]) ?/','$1',$css);
13-
14-
/* Kill Trailing Semicolon, Contributed by Oliver */
15-
$css = preg_replace('/;}/','}',$css);
16-
17-
// Replace images with data:uri
18-
$urls = array();
19-
preg_match_all('/url\(([^\)]+)\)/', $css, $urls);
20-
21-
foreach ($urls[1] as $url) {
22-
$data_uri = 'data:image/png;base64,' . base64_encode(file_get_contents($url));
23-
$css = str_replace($url, $data_uri, $css);
24-
}
25-
26-
file_put_contents('tree.min.css', $css);
6+
$css = preg_replace('!/\*.*?\*/!s','', $css);
7+
$css = preg_replace('/\n\s*\n/',"\n", $css);
8+
9+
/* Minifies */
10+
$css = preg_replace('/[\n\r \t]/',' ', $css);
11+
$css = preg_replace('/ +/',' ', $css);
12+
$css = preg_replace('/ ?([,:;{}]) ?/','$1',$css);
13+
14+
/* Kill Trailing Semicolon, Contributed by Oliver */
15+
$css = preg_replace('/;}/','}',$css);
16+
17+
// Replace images with data:uri
18+
$urls = array();
19+
preg_match_all('/url\(([^\)]+)\)/', $css, $urls);
20+
21+
foreach ($urls[1] as $url) {
22+
$data_uri = 'data:image/png;base64,' . base64_encode(file_get_contents($url));
23+
$css = str_replace($url, $data_uri, $css);
24+
}
25+
26+
$css = trim($css);
27+
28+
file_put_contents('tree.min.css', $css);
2729

lib/Ladybug/Asset/tree.css

+11-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ol.tree
33
{
44
padding: 0 0 0 15px;
55

6-
font-family: 'Bitstream Vera Sans Mono','Courier New',monospace;
6+
font-family: 'Courier New',monospace;
77
font-size: 12px;
88
}
99
li
@@ -62,6 +62,16 @@ ol.tree
6262
font-style: italic;
6363
}
6464

65+
.switcher {
66+
font-weight: bold;
67+
font-style: italic;
68+
}
69+
70+
.tostring {
71+
background: url(filefind.png) left center no-repeat;
72+
padding-left: 11px;
73+
}
74+
6575
a.external {
6676
background: url(link.png) left center no-repeat;
6777
padding-left: 11px;

lib/Ladybug/Asset/tree.min.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/Ladybug/Autoloader.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ static public function autoload($class)
3636
{
3737

3838
if (0 !== strpos($class, 'Ladybug')) {
39-
return;
39+
//return;
4040
}
41-
41+
4242
$file = dirname(__FILE__).'/../'.str_replace(array('\\', "\0"), array('/', ''), $class).'.php';
4343

4444
if (is_file($file)) {

0 commit comments

Comments
 (0)