html5-starter 0.1.3b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. data/LICENSE +3 -0
  2. data/README.md +135 -0
  3. data/VERSION +1 -0
  4. data/lib/app/helpers/html5_boilerplate_helper.rb +47 -0
  5. data/lib/html5-boilerplate.rb +6 -0
  6. data/stylesheets/_html5-boilerplate.scss +15 -0
  7. data/stylesheets/html5-boilerplate/_fonts.scss +36 -0
  8. data/stylesheets/html5-boilerplate/_handheld.scss +8 -0
  9. data/stylesheets/html5-boilerplate/_helpers.scss +25 -0
  10. data/stylesheets/html5-boilerplate/_print.scss +20 -0
  11. data/stylesheets/html5-boilerplate/_reset.scss +50 -0
  12. data/stylesheets/html5-boilerplate/_styles.scss +100 -0
  13. data/templates/project/_flashes.html.haml +4 -0
  14. data/templates/project/_footer.html.haml +2 -0
  15. data/templates/project/_head.html.haml +32 -0
  16. data/templates/project/_header.html.haml +1 -0
  17. data/templates/project/_javascripts.html.haml +38 -0
  18. data/templates/project/_stylesheets.html.haml +8 -0
  19. data/templates/project/application.html.haml +15 -0
  20. data/templates/project/files/404.html +22 -0
  21. data/templates/project/files/apple-touch-icon.png +0 -0
  22. data/templates/project/files/build/build.xml +636 -0
  23. data/templates/project/files/build/buildinfo.properties +5 -0
  24. data/templates/project/files/build/config/build.properties +3 -0
  25. data/templates/project/files/build/config/default.properties +79 -0
  26. data/templates/project/files/build/config/project.properties +49 -0
  27. data/templates/project/files/build/createproject.sh +73 -0
  28. data/templates/project/files/build/tools/ant-contrib-1.0b3.jar +0 -0
  29. data/templates/project/files/build/tools/css-compressor/CSSCompression.php +465 -0
  30. data/templates/project/files/build/tools/css-compressor/changelog.txt +22 -0
  31. data/templates/project/files/build/tools/css-compressor/cli.php +101 -0
  32. data/templates/project/files/build/tools/css-compressor/helpers/hex2short-colors.json +39 -0
  33. data/templates/project/files/build/tools/css-compressor/helpers/hex2short-safe.json +16 -0
  34. data/templates/project/files/build/tools/css-compressor/helpers/long2hex-colors.json +127 -0
  35. data/templates/project/files/build/tools/css-compressor/lib/Cleanup.php +218 -0
  36. data/templates/project/files/build/tools/css-compressor/lib/Color.php +199 -0
  37. data/templates/project/files/build/tools/css-compressor/lib/Combine.php +191 -0
  38. data/templates/project/files/build/tools/css-compressor/lib/Combine/Aural.php +109 -0
  39. data/templates/project/files/build/tools/css-compressor/lib/Combine/Background.php +107 -0
  40. data/templates/project/files/build/tools/css-compressor/lib/Combine/Border.php +98 -0
  41. data/templates/project/files/build/tools/css-compressor/lib/Combine/BorderOutline.php +109 -0
  42. data/templates/project/files/build/tools/css-compressor/lib/Combine/BorderRadius.php +262 -0
  43. data/templates/project/files/build/tools/css-compressor/lib/Combine/Font.php +125 -0
  44. data/templates/project/files/build/tools/css-compressor/lib/Combine/List.php +104 -0
  45. data/templates/project/files/build/tools/css-compressor/lib/Combine/MarginPadding.php +190 -0
  46. data/templates/project/files/build/tools/css-compressor/lib/Compress.php +212 -0
  47. data/templates/project/files/build/tools/css-compressor/lib/Control.php +236 -0
  48. data/templates/project/files/build/tools/css-compressor/lib/Exception.php +32 -0
  49. data/templates/project/files/build/tools/css-compressor/lib/Format.php +187 -0
  50. data/templates/project/files/build/tools/css-compressor/lib/Individuals.php +307 -0
  51. data/templates/project/files/build/tools/css-compressor/lib/Numeric.php +103 -0
  52. data/templates/project/files/build/tools/css-compressor/lib/Option.php +133 -0
  53. data/templates/project/files/build/tools/css-compressor/lib/Organize.php +149 -0
  54. data/templates/project/files/build/tools/css-compressor/lib/Selectors.php +245 -0
  55. data/templates/project/files/build/tools/css-compressor/lib/Setup.php +292 -0
  56. data/templates/project/files/build/tools/css-compressor/lib/Trim.php +213 -0
  57. data/templates/project/files/build/tools/css-compressor/license.txt +21 -0
  58. data/templates/project/files/build/tools/htmlcompressor-0.9.8.jar +0 -0
  59. data/templates/project/files/build/tools/jpegtran.exe +0 -0
  60. data/templates/project/files/build/tools/optipng-0.6.4-exe/LICENSE.txt +21 -0
  61. data/templates/project/files/build/tools/optipng-0.6.4-exe/optipng.exe +0 -0
  62. data/templates/project/files/build/tools/yuicompressor-2.4.2.jar +0 -0
  63. data/templates/project/files/crossdomain.xml +25 -0
  64. data/templates/project/files/favicon.ico +0 -0
  65. data/templates/project/files/gitignore.txt +32 -0
  66. data/templates/project/files/gitignore_placeholder.txt +2 -0
  67. data/templates/project/files/google.yml +22 -0
  68. data/templates/project/files/htaccess +415 -0
  69. data/templates/project/files/humans.txt +43 -0
  70. data/templates/project/files/lighttpd.conf +149 -0
  71. data/templates/project/files/mime.types +80 -0
  72. data/templates/project/files/nginx.conf +108 -0
  73. data/templates/project/files/robots.txt +5 -0
  74. data/templates/project/files/web.config +207 -0
  75. data/templates/project/handheld.scss +8 -0
  76. data/templates/project/index.html +81 -0
  77. data/templates/project/javascripts/libs/dd_belatedpng.js +13 -0
  78. data/templates/project/javascripts/libs/jquery-1.4.4.js +7179 -0
  79. data/templates/project/javascripts/libs/jquery-1.4.4.min.js +167 -0
  80. data/templates/project/javascripts/libs/modernizr-1.6.min.js +30 -0
  81. data/templates/project/javascripts/plugins.js +13 -0
  82. data/templates/project/javascripts/rails.js +156 -0
  83. data/templates/project/javascripts/script.js +26 -0
  84. data/templates/project/manifest.rb +101 -0
  85. data/templates/project/partials/_base.scss +23 -0
  86. data/templates/project/style.scss +70 -0
  87. metadata +171 -0
@@ -0,0 +1,307 @@
1
+ <?php
2
+ /**
3
+ * CSS Compressor [VERSION]
4
+ * [DATE]
5
+ * Corey Hart @ http://www.codenothing.com
6
+ */
7
+
8
+ Class CSSCompression_Individuals
9
+ {
10
+ /**
11
+ * Individual patterns
12
+ *
13
+ * @class Control: Compression Controller
14
+ * @class Numeric: Numeric handler
15
+ * @class Color: Color Handler
16
+ * @param (array) options: Reference to options
17
+ * @param (regex) rdirectional: Properties that may have multiple directions
18
+ * @param (regex) rborderradius: Checks property for border-radius declaration
19
+ * @param (regex) rnoneprop: Properties that can have none as their value(will be converted to 0)
20
+ * @param (regex) rclip: Looks for rect grouping in clip declaration
21
+ * @param (regex) rsplitter: Checks font properties for font-size/line-height split
22
+ * @param (regex) rfilter: Special alpha filter for msie
23
+ * @param (regex) rspace: Checks for unescaped space
24
+ * @param (regex) rspace: Checks for unescaped slash
25
+ * @param (array) weights: Array of font-weight name conversions to their numeric counterpart
26
+ */
27
+ private $Control;
28
+ private $Numeric;
29
+ private $Color;
30
+ private $options = array();
31
+ private $rdirectional = "/^(margin|padding|border-spacing)$/";
32
+ private $rborderradius = "/border[a-z-]*radius/";
33
+ private $rradiusfull = "/^(-moz-|-webkit-)?border-radius$/";
34
+ private $rnoneprop = "/^(border|background|border-(top|right|bottom|left))$/";
35
+ private $rclip = "/^rect\(\s*(\-?\d*\.?\d*?\w*)(,|\s)(\-?\d*\.?\d*?\w*)(,|\s)(\-?\d*\.?\d*?\w*)(,|\s)(\-?\d*\.?\d*?\w*)\s*\)$/";
36
+ private $rsplitter = "/(^|(?<!\\\)\s)([^\/ ]+)\/([^\/ ]+)((?<!\\\)\s|$)/";
37
+ private $rfilter = "/[\"']?PROGID\\\?:DXImageTransform\\\?.Microsoft\\\?.Alpha\(Opacity\\\?=(\d+\\\?\.?\d*)\)[\"']?/i";
38
+ private $rspace = "/(?<!\\\)\s/";
39
+ private $rslash = "/(?<!\\\)\//";
40
+ private $weights = array(
41
+ "normal" => 400,
42
+ "bold" => 700,
43
+ );
44
+
45
+ /**
46
+ * Stash a reference to the controller on each instantiation
47
+ *
48
+ * @param (class) control: CSSCompression Controller
49
+ */
50
+ public function __construct( CSSCompression_Control $control ) {
51
+ $this->Control = $control;
52
+ $this->Numeric = $control->Numeric;
53
+ $this->Color = $control->Color;
54
+ $this->options = &$control->Option->options;
55
+ }
56
+
57
+ /**
58
+ * Runs special unit/directional compressions
59
+ *
60
+ * @param (string) prop: CSS Property
61
+ * @param (string) val: Value of CSS Property
62
+ */
63
+ public function individuals( $prop, $val ) {
64
+ // Properties should always be lowercase
65
+ $prop = strtolower( $prop );
66
+
67
+ // Split up each definiton for color and numeric compressions
68
+ $parts = preg_split( $this->rspace, $val );
69
+ foreach ( $parts as &$v ) {
70
+ if ( ! $v || $v == '' ) {
71
+ continue;
72
+ }
73
+
74
+ // Remove uneeded decimals/units
75
+ if ( $this->options['format-units'] ) {
76
+ $v = $this->Numeric->numeric( $v );
77
+ }
78
+
79
+ // Color compression
80
+ $v = $this->Color->color( $v );
81
+ }
82
+ $val = trim( implode( ' ', $parts ) );
83
+
84
+ // Special border radius handling
85
+ if ( preg_match( $this->rborderradius, $prop ) ) {
86
+ $val = $this->borderRadius( $prop, $val );
87
+ }
88
+ // Remove uneeded side definitions if possible
89
+ else if ( $this->options['directional-compress'] && count( $parts ) > 1 && preg_match( $this->rdirectional, $prop ) ) {
90
+ $val = $this->directionals( strtolower( $val ) );
91
+ }
92
+
93
+ // Font-weight converter
94
+ if ( $this->options['fontweight2num'] && ( $prop == 'font-weight' || $prop == 'font' ) ) {
95
+ $val = $this->fontweight( $val );
96
+ }
97
+
98
+ // Special font value conversions
99
+ if ( $prop == 'font' ) {
100
+ $val = $this->font( $val );
101
+ }
102
+
103
+ // Special clip value compressions
104
+ if ( $prop == 'clip' ) {
105
+ $val = $this->clip( $val );
106
+ }
107
+
108
+ // None to 0 converter
109
+ $val = $this->none( $prop, $val );
110
+
111
+ // MSIE Filters
112
+ $val = $this->filter( $prop, $val );
113
+
114
+ // Return for list retrival
115
+ return array( $prop, $val );
116
+ }
117
+
118
+ /**
119
+ * Preps border radius for directional compression
120
+ *
121
+ * @param (string) prop: Property Declaration
122
+ * @param (string) val: Declaration Value
123
+ */
124
+ private function borderRadius( $prop, $val ) {
125
+ if ( preg_match( $this->rslash, $val ) ) {
126
+ $parts = preg_split( $this->rslash, $val, 2 );
127
+ // We have to redo numeric compression because the slash may hav intruded
128
+ foreach ( $parts as &$row ) {
129
+ $p = preg_split( $this->rspace, $row );
130
+ foreach ( $p as &$v ) {
131
+ if ( ! $v || $v == '' ) {
132
+ continue;
133
+ }
134
+
135
+ // Remove uneeded decimals/units
136
+ if ( $this->options['format-units'] ) {
137
+ $v = $this->Numeric->numeric( $v );
138
+ }
139
+ }
140
+ $row = implode( ' ', $p );
141
+ if ( $this->options['directional-compress'] ) {
142
+ $row = $this->directionals( strtolower( $row ) );
143
+ }
144
+ }
145
+ $val = implode( '/', $parts );
146
+ }
147
+ else if ( $this->options['directional-compress'] && preg_match( $this->rradiusfull, $prop ) ) {
148
+ $val = $this->directionals( strtolower( $val ) );
149
+ }
150
+
151
+ return $val;
152
+ }
153
+
154
+ /**
155
+ * Finds directional compression on methods like margin/padding
156
+ *
157
+ * @param (string) val: Value of CSS Property
158
+ */
159
+ private function directionals( $val ) {
160
+ // Split up each definiton
161
+ $direction = preg_split( $this->rspace, $val );
162
+
163
+ // 4 Direction reduction
164
+ $count = count( $direction );
165
+ if ( $count == 4 ) {
166
+ // All 4 sides are the same, combine into 1 definition
167
+ if ( $direction[ 0 ] == $direction[ 1 ] && $direction[ 2 ] == $direction[ 3 ] && $direction[ 0 ] == $direction[ 3 ] ) {
168
+ $direction = array( $direction[ 0 ] );
169
+ }
170
+ // top-bottom/left-right are the same, reduce definition
171
+ else if ( $direction[ 0 ] == $direction[ 2 ] && $direction[ 1 ] == $direction[ 3 ] ) {
172
+ $direction = array( $direction[ 0 ], $direction[ 1 ] );
173
+ }
174
+ // Only left-right are the same
175
+ else if ( $direction[ 1 ] == $direction[ 3 ] ) {
176
+ $direction = array( $direction[ 0 ], $direction[ 1 ], $direction[ 2 ] );
177
+ }
178
+ }
179
+ // 3 Direction reduction
180
+ else if ( $count == 3 ) {
181
+ // All directions are the same
182
+ if ( $direction[ 0 ] == $direction[ 1 ] && $direction[ 1 ] == $direction[ 2 ] ) {
183
+ $direction = array( $direction[ 0 ] );
184
+ }
185
+ // Only top(first) and bottom(last) are the same
186
+ else if ( $direction[ 0 ] == $direction[ 2 ] ) {
187
+ $direction = array( $direction[ 0 ], $direction[ 1 ] );
188
+ }
189
+ }
190
+ // 2 Direction reduction
191
+ // Both directions are the same, combine into single definition
192
+ else if ( $count == 2 && $direction[ 0 ] == $direction[ 1 ] ) {
193
+ $direction = array( $direction[ 0 ] );
194
+ }
195
+
196
+ // Return the combined version of the directions
197
+ // Single entries will just return
198
+ return implode( ' ', $direction );
199
+ }
200
+
201
+ /**
202
+ * Converts font-weight names to numbers
203
+ *
204
+ * @param (string) val: font-weight prop value
205
+ */
206
+ private function fontweight( $val ) {
207
+ if ( preg_match( $this->rspace, $val ) ) {
208
+ $parts = preg_split( $this->rspace, $val );
209
+ foreach ( $parts as &$item ) {
210
+ $lower = strtolower( $item );
211
+ if ( isset( $this->weights[ $lower ] ) && $lower != 'normal' ) {
212
+ $item = $this->weights[ $lower ];
213
+ }
214
+ }
215
+ $val = implode( ' ', $parts );
216
+ }
217
+ else if ( isset( $this->weights[ strtolower( $val ) ] ) ) {
218
+ $val = $this->weights[ strtolower( $val ) ];
219
+ }
220
+
221
+ return $val;
222
+ }
223
+
224
+ /**
225
+ * Special font conversions
226
+ *
227
+ * @param (string) val: property value
228
+ */
229
+ private function font( $val ) {
230
+ // Split out the font-size/line-height split and run through numerical handlers
231
+ if ( preg_match( $this->rsplitter, $val, $match, PREG_OFFSET_CAPTURE ) ) {
232
+ $size = $this->Numeric->numeric( $match[ 2 ][ 0 ] );
233
+ $height = $this->Numeric->numeric( $match[ 3 ][ 0 ] );
234
+ $concat = $match[ 1 ][ 0 ] . $size . '/' . $height . $match[ 4 ][ 0 ];
235
+ $val = substr_replace( $val, $concat, $match[ 0 ][ 1 ], strlen( $match[ 0 ][ 0 ] ) );
236
+ }
237
+
238
+ return $val;
239
+ }
240
+
241
+ /**
242
+ * Special clip conversions
243
+ *
244
+ * @param (string) val: property value
245
+ */
246
+ private function clip( $val ) {
247
+ if ( preg_match( $this->rclip, $val, $match ) ) {
248
+ $positions = array( 1, 3, 5, 7 );
249
+ $clean = 'rect(';
250
+ foreach ( $positions as $pos ) {
251
+ if ( ! isset( $match[ $pos ] ) ) {
252
+ return $val;
253
+ }
254
+
255
+ $clean .= $this->Numeric->numeric( $match[ $pos ] ) . ( isset( $match[ $pos + 1 ] ) ? $match[ $pos + 1 ] : '' );
256
+ }
257
+ $val = $clean . ')';
258
+ }
259
+
260
+ return $val;
261
+ }
262
+
263
+ /**
264
+ * Convert none vals to 0
265
+ *
266
+ * @param (string) prop: Current Property
267
+ * @param (string) val: property value
268
+ */
269
+ private function none( $prop, $val ) {
270
+ if ( preg_match( $this->rnoneprop, $prop ) && $val == 'none' ) {
271
+ $val = '0';
272
+ }
273
+
274
+ return $val;
275
+ }
276
+
277
+ /**
278
+ * MSIE Filter Conversion
279
+ *
280
+ * @param (string) prop: Current Property
281
+ * @param (string) val: property value
282
+ */
283
+ private function filter( $prop, $val ) {
284
+ if ( preg_match( "/filter/", $prop ) ) {
285
+ $val = preg_replace( $this->rfilter, "alpha(opacity=$1)", $val );
286
+ }
287
+
288
+ return $val;
289
+ }
290
+
291
+ /**
292
+ * Access to private methods for testing
293
+ *
294
+ * @param (string) method: Method to be called
295
+ * @param (array) args: Array of paramters to be passed in
296
+ */
297
+ public function access( $method, $args ) {
298
+ if ( method_exists( $this, $method ) ) {
299
+ return call_user_func_array( array( $this, $method ), $args );
300
+ }
301
+ else {
302
+ throw new CSSCompression_Exception( "Unknown method in Individuals Class - " . $method );
303
+ }
304
+ }
305
+ };
306
+
307
+ ?>
@@ -0,0 +1,103 @@
1
+ <?php
2
+ /**
3
+ * CSS Compressor [VERSION]
4
+ * [DATE]
5
+ * Corey Hart @ http://www.codenothing.com
6
+ */
7
+
8
+ Class CSSCompression_Numeric
9
+ {
10
+ /**
11
+ * Numeric Patterns
12
+ *
13
+ * @class Control: Compression Controller
14
+ * @param (array) options: Reference to options
15
+ * @param (regex) rdecimal: Checks for zero decimal
16
+ * @param (regex) rzero: Checks for preceding 0 to decimal unit
17
+ * @param (regex) runit: Checks for suffix on 0 unit
18
+ */
19
+ private $Control;
20
+ private $options = array();
21
+ private $rdecimal = "/^(\+|\-)?(\d*\.[1-9]*0*)(\%|[a-z]{2})$/i";
22
+ private $rzero = "/^(\+|\-)?0(\.\d+)(\%|[a-z]{2})?$/i";
23
+ private $runit = "/^0(\%|[a-z]{2})$/i";
24
+
25
+ /**
26
+ * Stash a reference to the controller on each instantiation
27
+ *
28
+ * @param (class) control: CSSCompression Controller
29
+ */
30
+ public function __construct( CSSCompression_Control $control ) {
31
+ $this->Control = $control;
32
+ $this->options = &$control->Option->options;
33
+ }
34
+
35
+ /**
36
+ * Runs all numeric operations
37
+ *
38
+ * @param (string) str: Unit string
39
+ */
40
+ public function numeric( $str ) {
41
+ $str = $this->decimal( $str );
42
+ $str = $this->zeroes( $str );
43
+ $str = $this->units( $str );
44
+ return $str;
45
+ }
46
+
47
+ /**
48
+ * Remove's unecessary decimal, ie 13.0px => 13px
49
+ *
50
+ * @param (string) str: Unit string
51
+ */
52
+ private function decimal( $str ) {
53
+ if ( preg_match( $this->rdecimal, $str, $match ) ) {
54
+ $str = ( $match[ 1 ] == '-' ? '-' : '' ) . floatval( $match[ 2 ] ) . $match[ 3 ];
55
+ }
56
+
57
+ return $str;
58
+ }
59
+
60
+ /**
61
+ * Removes suffix from 0 unit, ie 0px; => 0;
62
+ *
63
+ * @param (string) str: Unit string
64
+ */
65
+ private function units( $str ) {
66
+ if ( preg_match( $this->runit, $str, $match ) ) {
67
+ $str = '0';
68
+ }
69
+
70
+ return $str;
71
+ }
72
+
73
+
74
+ /**
75
+ * Removes leading zero in decimal, ie 0.33px => .33px
76
+ *
77
+ * @param (string) str: Unit string
78
+ */
79
+ private function zeroes( $str ) {
80
+ if ( preg_match( $this->rzero, $str, $match ) ) {
81
+ $str = ( isset( $match[ 1 ] ) && $match[ 1 ] == '-' ? '-' : '' ) . $match[ 2 ] . ( isset( $match[ 3 ] ) ? $match[ 3 ] : '' );
82
+ }
83
+
84
+ return $str;
85
+ }
86
+
87
+ /**
88
+ * Access to private methods for testing
89
+ *
90
+ * @param (string) method: Method to be called
91
+ * @param (array) args: Array of paramters to be passed in
92
+ */
93
+ public function access( $method, $args ) {
94
+ if ( method_exists( $this, $method ) ) {
95
+ return call_user_func_array( array( $this, $method ), $args );
96
+ }
97
+ else {
98
+ throw new CSSCompression_Exception( "Unknown method in Numeric Class - " . $method );
99
+ }
100
+ }
101
+ };
102
+
103
+ ?>
@@ -0,0 +1,133 @@
1
+ <?php
2
+ /**
3
+ * CSS Compressor [VERSION]
4
+ * [DATE]
5
+ * Corey Hart @ http://www.codenothing.com
6
+ */
7
+
8
+ Class CSSCompression_Option
9
+ {
10
+ /**
11
+ * Option Patterns
12
+ *
13
+ * @class Control: Compression Controller
14
+ * @param (string) custom: Name of the custom mode
15
+ * @param (array) options: Instance settings
16
+ */
17
+ private $Control;
18
+ private $custom = '__custom';
19
+ public $options = array();
20
+
21
+ /**
22
+ * Stash a reference to the controller on each instantiation
23
+ *
24
+ * @param (class) control: CSSCompression Controller
25
+ */
26
+ public function __construct( CSSCompression_Control $control ) {
27
+ $this->Control = $control;
28
+ $this->options = CSSCompression::$defaults;
29
+ $control->mode = $this->custom;
30
+ }
31
+
32
+ /**
33
+ * Maintainable access to the options array
34
+ *
35
+ * - Passing no arguments returns the entire options array
36
+ * - Passing a single name argument returns the value for the option
37
+ * - Passing both a name and value, sets the value to the name key, and returns the value
38
+ * - Passing an array will merge the options with the array passed, for object like extension
39
+ *
40
+ * @param (mixed) name: The key name of the option
41
+ * @param (mixed) value: Value to set the option
42
+ */
43
+ public function option( $name = NULL, $value = NULL ) {
44
+ if ( $name === NULL ) {
45
+ return $this->options;
46
+ }
47
+ else if ( is_array( $name ) ) {
48
+ return $this->merge( $name );
49
+ }
50
+ else if ( $value === NULL ) {
51
+ return isset( $this->options[ $name ] ) ? $this->options[ $name ] : NULL;
52
+ }
53
+ else {
54
+ // Readability doesn't signify custom settings
55
+ if ( $name != 'readability' ) {
56
+ $this->Control->mode = $this->custom;
57
+ }
58
+
59
+ return ( $this->options[ $name ] = $value );
60
+ }
61
+ }
62
+
63
+ /**
64
+ * Reset's the default options
65
+ *
66
+ * @params none;
67
+ */
68
+ public function reset(){
69
+ // Reset and return the new options
70
+ return $this->options = CSSCompression::$defaults;
71
+ }
72
+
73
+ /**
74
+ * Extend like function to merge an array of preferences into
75
+ * the options array.
76
+ *
77
+ * @param (mixed) options: Array of preferences to merge into options
78
+ */
79
+ public function merge( $options = array() ) {
80
+ $modes = CSSCompression::modes();
81
+ if ( $options && is_array( $options ) && count( $options ) ) {
82
+ $this->Control->mode = $this->custom;
83
+ foreach ( $this->options as $key => $value ) {
84
+ if ( ! isset( $options[ $key ] ) ) {
85
+ continue;
86
+ }
87
+ else if ( strtolower( $options[ $key ] ) == 'on' ) {
88
+ $this->options[ $key ] = true;
89
+ }
90
+ else if ( strtolower( $options[ $key ] ) == 'off' ) {
91
+ $this->options[ $key ] = false;
92
+ }
93
+ else {
94
+ $this->options[ $key ] = intval( $options[ $key ] );
95
+ }
96
+ }
97
+ }
98
+ else if ( $options && is_string( $options ) && array_key_exists( $options, $modes ) ) {
99
+ $this->Control->mode = $options;
100
+
101
+ // Default all to true, the mode has to force false
102
+ foreach ( $this->options as $key => $value ) {
103
+ if ( $key != 'readability' ) {
104
+ $this->options[ $key ] = true;
105
+ }
106
+ }
107
+
108
+ // Merge mode into options
109
+ foreach ( $modes[ $options ] as $key => $value ) {
110
+ $this->options[ $key ] = $value;
111
+ }
112
+ }
113
+
114
+ return $this->options;
115
+ }
116
+
117
+ /**
118
+ * Access to private methods for testing
119
+ *
120
+ * @param (string) method: Method to be called
121
+ * @param (array) args: Array of paramters to be passed in
122
+ */
123
+ public function access( $method, $args ) {
124
+ if ( method_exists( $this, $method ) ) {
125
+ return call_user_func_array( array( $this, $method ), $args );
126
+ }
127
+ else {
128
+ throw new CSSCompression_Exception( "Unknown method in Option Class - " . $method );
129
+ }
130
+ }
131
+ };
132
+
133
+ ?>