distil 0.10.4 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/Rakefile +2 -1
  2. data/VERSION +1 -1
  3. data/assets/distil.js +359 -0
  4. data/bin/distil +33 -10
  5. data/distil.gemspec +35 -24
  6. data/lib/distil/configurable/file-set.rb +86 -0
  7. data/lib/distil/configurable/interpolated.rb +36 -0
  8. data/lib/distil/configurable/output-path.rb +25 -0
  9. data/lib/distil/configurable/project-path.rb +25 -0
  10. data/lib/distil/configurable.rb +164 -0
  11. data/lib/distil/error-reporter.rb +63 -0
  12. data/lib/distil/product/concatenated.rb +85 -0
  13. data/lib/distil/product/css-product.rb +37 -0
  14. data/lib/distil/product/debug.rb +34 -0
  15. data/lib/distil/product/javascript-base-product.rb +35 -0
  16. data/lib/distil/product/javascript-doc-product.rb +61 -0
  17. data/lib/distil/product/javascript-product.rb +131 -0
  18. data/lib/distil/product/minified.rb +32 -0
  19. data/lib/distil/product.rb +97 -0
  20. data/lib/distil/project/distil-project.rb +99 -0
  21. data/lib/distil/project/external-project.rb +53 -0
  22. data/lib/distil/project.rb +78 -0
  23. data/lib/distil/source-file/css-file.rb +14 -0
  24. data/lib/distil/source-file/html-file.rb +14 -0
  25. data/lib/distil/source-file/javascript-file.rb +17 -0
  26. data/lib/distil/source-file/json-file.rb +16 -0
  27. data/lib/distil/source-file.rb +172 -0
  28. data/lib/distil/target.rb +235 -0
  29. data/lib/distil/task/css-dependency-task.rb +64 -0
  30. data/lib/distil/task/jsl-dependency-task.rb +49 -0
  31. data/lib/distil/task/nib-task.rb +72 -0
  32. data/lib/distil/task/validate-js-task.rb +75 -0
  33. data/lib/distil/task.rb +50 -0
  34. data/lib/distil.rb +72 -0
  35. data/lib/jsl.conf +4 -0
  36. data/vendor/jsl-0.3.0/src/Makefile.ref +16 -6
  37. data/vendor/jsl-0.3.0/src/config.mk +32 -2
  38. data/vendor/jsl-0.3.0/src/fdlibm/Makefile.ref +1 -2
  39. data/vendor/jsl-0.3.0/src/jsl.c +124 -13
  40. data/vendor/jsl-0.3.0/src/rules.mk +2 -1
  41. metadata +49 -28
  42. data/lib/bootstrap-template.js +0 -58
  43. data/lib/configurable.rb +0 -161
  44. data/lib/file-set.rb +0 -49
  45. data/lib/file-types/css-file.rb +0 -12
  46. data/lib/file-types/html-file.rb +0 -11
  47. data/lib/file-types/javascript-file.rb +0 -24
  48. data/lib/file-types/json-file.rb +0 -17
  49. data/lib/filter.rb +0 -41
  50. data/lib/filters/css-filter.rb +0 -58
  51. data/lib/filters/file-reference-filter.rb +0 -30
  52. data/lib/filters/jsl-dependency-filter.rb +0 -44
  53. data/lib/project.rb +0 -174
  54. data/lib/source-file.rb +0 -197
  55. data/lib/target.rb +0 -102
  56. data/lib/task.rb +0 -212
  57. data/lib/tasks/copy-task.rb +0 -17
  58. data/lib/tasks/css-task.rb +0 -12
  59. data/lib/tasks/javascript-task.rb +0 -206
  60. data/lib/tasks/multiple-output-task.rb +0 -140
  61. data/lib/tasks/output-task.rb +0 -76
  62. data/lib/tasks/single-output-task.rb +0 -104
  63. data/lib/tasks/test-task.rb +0 -280
@@ -84,6 +84,11 @@ endif
84
84
  ifeq ($(OS_ARCH), CYGWIN32_NT)
85
85
  OS_ARCH := WINNT
86
86
  endif
87
+ ifeq (MINGW32_NT,$(findstring MINGW32_NT,$(OS_ARCH)))
88
+ OS_RELEASE := $(patsubst MINGW32_NT-%,%,$(OS_ARCH))
89
+ OS_ARCH_ENVIRONMENT := MINGW32_NT
90
+ OS_ARCH := WINNT
91
+ endif
87
92
 
88
93
  # Virtually all Linux versions are identical.
89
94
  # Any distinctions are handled in linux.h
@@ -96,10 +101,14 @@ else
96
101
  ifeq ($(OS_ARCH),Darwin)
97
102
  OS_CONFIG := Darwin
98
103
  else
104
+ ifeq ($(OS_ARCH_ENVIRONMENT),MINGW32_NT)
105
+ OS_CONFIG := MinGW$(OS_RELEASE)
106
+ else
99
107
  OS_CONFIG := $(OS_ARCH)$(OS_OBJTYPE)$(OS_RELEASE)
100
108
  endif
101
109
  endif
102
110
  endif
111
+ endif
103
112
 
104
113
  ASFLAGS =
105
114
  DEFINES =
@@ -114,7 +123,7 @@ endif
114
123
 
115
124
  ifdef BUILD_OPT
116
125
  OPTIMIZER = -O
117
- DEFINES += -UDEBUG -DNDEBUG -UDEBUG_$(shell whoami)
126
+ DEFINES += -UDEBUG -DNDEBUG -UDEBUG_$(USER)
118
127
  OBJDIR_TAG = _OPT
119
128
  else
120
129
  ifdef USE_MSVC
@@ -122,11 +131,16 @@ OPTIMIZER = -Zi
122
131
  else
123
132
  OPTIMIZER = -g
124
133
  endif
125
- DEFINES += -DDEBUG -DDEBUG_$(shell whoami)
134
+ DEFINES += -DDEBUG -DDEBUG_$(USER)
126
135
  OBJDIR_TAG = _DBG
127
136
  endif
128
137
 
138
+ ifeq ($(OS_ARCH), WINNT)
139
+ SO_SUFFIX = dll
140
+ EXE_DOTSUFFIX = .exe
141
+ else
129
142
  SO_SUFFIX = so
143
+ endif
130
144
 
131
145
  NS_USE_NATIVE = 1
132
146
 
@@ -145,6 +159,22 @@ CLASSPATH = $(JDK)/lib/classes.zip$(SEP)$(CLASSDIR)/$(OBJDIR)
145
159
 
146
160
  include $(DEPTH)/config/$(OS_CONFIG).mk
147
161
 
162
+ ifndef OBJ_SUFFIX
163
+ ifdef USE_MSVC
164
+ OBJ_SUFFIX = obj
165
+ else
166
+ OBJ_SUFFIX = o
167
+ endif
168
+ endif
169
+
170
+ ifndef HOST_BIN_SUFFIX
171
+ ifeq ($(OS_ARCH),WINNT)
172
+ HOST_BIN_SUFFIX = .exe
173
+ else
174
+ HOST_BIN_SUFFIX =
175
+ endif
176
+ endif
177
+
148
178
  # Name of the binary code directories
149
179
  ifdef BUILD_IDG
150
180
  OBJDIR = $(OS_CONFIG)$(OBJDIR_TAG).OBJD
@@ -91,8 +91,7 @@ include $(DEPTH)/config.mk
91
91
  #
92
92
  # Default IEEE libm
93
93
  #
94
- CFLAGS += -DXP_UNIX $(OPTIMIZER) $(OS_CFLAGS) $(DEFINES) $(INCLUDES) \
95
- -DJSFILE $(XCFLAGS) -D_IEEE_LIBM
94
+ CFLAGS += $(OPTIMIZER) $(OS_CFLAGS) $(DEFINES) $(INCLUDES) -DJSFILE $(XCFLAGS) -D_IEEE_LIBM
96
95
 
97
96
  # Need for jstypes.h and friends
98
97
  INCLUDES += -I..
@@ -63,11 +63,13 @@
63
63
  #include "jsscript.h"
64
64
  #include "jsstr.h"
65
65
 
66
- #ifdef XP_UNIX
66
+ #if defined(XP_UNIX) || defined(_MINGW)
67
67
  #include <unistd.h>
68
68
  #include <sys/types.h>
69
69
  #include <dirent.h>
70
+ #ifndef _MINGW
70
71
  #include <sys/wait.h>
72
+ #endif
71
73
  #include <sys/stat.h>
72
74
  #endif
73
75
 
@@ -180,6 +182,12 @@ typedef struct JSLPathList {
180
182
  char path[MAXPATHLEN+1];
181
183
  } JSLPathList;
182
184
 
185
+ typedef struct JSLAliasList {
186
+ JSCList links;
187
+ char path[MAXPATHLEN+1];
188
+ char alias[MAXPATHLEN+1];
189
+ } JSLAliasList;
190
+
183
191
  typedef struct JSLScriptList {
184
192
  JSCList links;
185
193
 
@@ -189,6 +197,7 @@ typedef struct JSLScriptList {
189
197
  } JSLScriptList;
190
198
 
191
199
  JSLScriptList gScriptList;
200
+ JSLAliasList gScriptAliasList;
192
201
  JSLPathList gIncludePathList;
193
202
 
194
203
 
@@ -305,8 +314,9 @@ IsDir(char *filename)
305
314
 
306
315
 
307
316
 
308
- #ifdef WIN32
317
+ #if defined(WIN32)
309
318
 
319
+ #ifndef _MINGW
310
320
  struct dirent {
311
321
  char d_name[MAXPATHLEN];
312
322
  };
@@ -371,6 +381,7 @@ closedir(DIR *dir)
371
381
  }
372
382
  return 0;
373
383
  }
384
+ #endif
374
385
 
375
386
  /* caller should allocate MAXPATHLEN; does not set errno; returns null on failure */
376
387
  static char *
@@ -603,6 +614,36 @@ OutputErrorMessage(const char *path, int lineno, int colno, const char *errName,
603
614
  }
604
615
  }
605
616
 
617
+ static JSLAliasList*
618
+ AllocAliasListItem(const char *alias, const char *path)
619
+ {
620
+ JSLAliasList *aliasItem= malloc(sizeof(JSLAliasList));
621
+ memset(aliasItem, 0, sizeof(JSLAliasList));
622
+
623
+ JS_INIT_CLIST(&aliasItem->links);
624
+ strncpy(aliasItem->path, path, MAXPATHLEN);
625
+ strncpy(aliasItem->alias, alias, MAXPATHLEN);
626
+
627
+ return aliasItem;
628
+ }
629
+
630
+ static void
631
+ AddAliasToList(JSLAliasList *aliasList, const char *alias, const char *path)
632
+ {
633
+ JSLAliasList *aliasItem= AllocAliasListItem(alias, path);
634
+ JS_APPEND_LINK(&aliasItem->links, &aliasList->links);
635
+ }
636
+
637
+ static void
638
+ FreeAliasList(JSContext *cx, JSLAliasList *aliasList)
639
+ {
640
+ while (!JS_CLIST_IS_EMPTY(&aliasList->links)) {
641
+ JSLAliasList *item = (JSLAliasList*)JS_LIST_HEAD(&aliasList->links);
642
+ JS_REMOVE_LINK(&item->links);
643
+ JS_free(cx, item);
644
+ }
645
+ }
646
+
606
647
  static JSLPathList*
607
648
  AllocPathListItem(const char *path)
608
649
  {
@@ -804,6 +845,7 @@ ResolveScriptPath(const char *relpath, char *path, JSLScriptList *parentScript)
804
845
  JSBool result;
805
846
  struct stat _stat;
806
847
  JSLPathList *inc;
848
+ JSLAliasList *alias;
807
849
 
808
850
  char workingDir[MAXPATHLEN+1];
809
851
  workingDir[0] = 0;
@@ -832,6 +874,22 @@ ResolveScriptPath(const char *relpath, char *path, JSLScriptList *parentScript)
832
874
  if (result && -1!=stat(path, &_stat))
833
875
  return JS_TRUE;
834
876
 
877
+ // Check for an alias match. Aliased files still must exist or the search
878
+ // will continue.
879
+ for (alias= (JSLAliasList*)JS_LIST_HEAD(&gScriptAliasList.links);
880
+ alias!=&gScriptAliasList;
881
+ alias= (JSLAliasList*)JS_NEXT_LINK(&alias->links))
882
+ {
883
+ if (0==strcmp(relpath, alias->alias))
884
+ {
885
+ if (-1==stat(alias->path, &_stat))
886
+ continue;
887
+ strcpy(path, alias->path);
888
+ return JS_TRUE;
889
+ }
890
+ }
891
+
892
+ // Nothing matches, so look in include folders...
835
893
  for (inc= (JSLPathList*)JS_LIST_HEAD(&gIncludePathList.links);
836
894
  inc!=&gIncludePathList;
837
895
  inc= (JSLPathList*)JS_NEXT_LINK(&inc->links))
@@ -1800,20 +1858,72 @@ ProcessSettingErr_Garbage:
1800
1858
  *linepos = 0;
1801
1859
 
1802
1860
  AddPathToList(&gIncludePathList, path);
1803
- /*
1804
- if (JS_FALSE) {
1805
- ProcessSettingErr_MissingPath:
1806
- fclose(file);
1807
- return LintConfError(cx, path, lineno, "invalid include setting: missing path");
1808
- ProcessSettingErr_MissingQuote:
1809
- fclose(file);
1810
- return LintConfError(cx, path, lineno, "invalid include setting: missing or mismatched quote");
1811
- ProcessSettingErr_Garbage:
1861
+ }
1862
+ else if (strncasecmp(linepos, "alias", strlen("alias")) == 0) {
1863
+ char delimiter;
1864
+ char *path;
1865
+ char *alias;
1866
+
1867
+ if (!enable) {
1812
1868
  fclose(file);
1813
- return LintConfError(cx, path, lineno, "invalid include setting: garbage after path");
1869
+ return LintConfError(cx, path, lineno, "-alias is an invalid setting");
1814
1870
  }
1815
- */
1871
+
1872
+ linepos += strlen("alias");
1873
+
1874
+ /* require (but skip) whitespace */
1875
+ if (!*linepos || !isspace(*linepos)) goto ProcessSettingErr_MissingPath;
1876
+ while (*linepos && isspace(*linepos))
1877
+ linepos++;
1878
+ if (!*linepos) goto ProcessSettingErr_MissingPath;
1879
+
1880
+ /* allow quote */
1881
+ if (*linepos == '\'') {
1882
+ delimiter = *linepos;
1883
+ linepos++;
1884
+ }
1885
+ else if (*linepos == '"') {
1886
+ delimiter = *linepos;
1887
+ linepos++;
1888
+ }
1889
+ else
1890
+ delimiter = 0;
1891
+
1892
+ /* read alias */
1893
+ if (!*linepos) goto ProcessSettingErr_MissingQuote;
1894
+ alias = linepos;
1895
+ while (*linepos)
1896
+ {
1897
+ if (delimiter && *linepos==delimiter)
1898
+ break;
1899
+ if (!delimiter && isspace(*linepos))
1900
+ break;
1901
+ linepos++;
1816
1902
  }
1903
+ if (delimiter && *linepos!=delimiter) goto ProcessSettingErr_MissingQuote;
1904
+ if (!delimiter && !isspace(*linepos)) goto ProcessSettingErr_MissingPath;
1905
+
1906
+ /* terminate path */
1907
+ *linepos++= 0;
1908
+
1909
+ /* require (but skip) whitespace */
1910
+ while (*linepos && isspace(*linepos))
1911
+ linepos++;
1912
+ if (!*linepos) goto ProcessSettingErr_MissingPath;
1913
+
1914
+ /* read path */
1915
+ if (!*linepos) goto ProcessSettingErr_MissingQuote;
1916
+ path = linepos;
1917
+ while (*linepos && *linepos != delimiter)
1918
+ linepos++;
1919
+ if (delimiter && !*linepos) goto ProcessSettingErr_MissingQuote;
1920
+
1921
+ /* yank ending quote */
1922
+ if (linepos[0] && linepos[1]) goto ProcessSettingErr_Garbage;
1923
+ *linepos = 0;
1924
+
1925
+ AddAliasToList(&gScriptAliasList, alias, path);
1926
+ }
1817
1927
  else if (strncasecmp(linepos, "output-format", strlen("output-format")) == 0) {
1818
1928
  linepos += strlen("output-format");
1819
1929
 
@@ -2304,6 +2414,7 @@ main(int argc, char **argv, char **envp)
2304
2414
  argv++;
2305
2415
 
2306
2416
  JS_INIT_CLIST(&gScriptList.links);
2417
+ JS_INIT_CLIST(&gScriptAliasList.links);
2307
2418
  JS_INIT_CLIST(&gIncludePathList.links);
2308
2419
  JS_ASSERT(sizeof(placeholders) / sizeof(placeholders[0]) == JSLPlaceholder_Limit);
2309
2420
 
@@ -58,7 +58,8 @@ ifdef USE_MSVC
58
58
  # TARGETS = $(LIBRARY) # $(PROGRAM) not supported for MSVC yet
59
59
  TARGETS += $(SHARED_LIBRARY) $(PROGRAM) # it is now
60
60
  else
61
- TARGETS += $(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM)
61
+ # TARGETS += $(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM)
62
+ TARGETS += $(LIBRARY) $(PROGRAM)
62
63
  endif
63
64
 
64
65
  all:
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 10
8
- - 4
9
- version: 0.10.4
7
+ - 11
8
+ - 0
9
+ version: 0.11.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jeff Watkins
@@ -14,10 +14,23 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-05 00:00:00 -07:00
17
+ date: 2010-06-06 00:00:00 -07:00
18
18
  default_executable: distil
19
- dependencies: []
20
-
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: json
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 4
30
+ - 3
31
+ version: 1.4.3
32
+ type: :runtime
33
+ version_requirements: *id001
21
34
  description: A build tool for Javascript and CSS that takes advantage of best-of-breed helper applications Javascript Lint and JSDoc Toolkit
22
35
  email:
23
36
  executables:
@@ -29,32 +42,40 @@ extra_rdoc_files: []
29
42
  files:
30
43
  - Rakefile
31
44
  - VERSION
45
+ - assets/distil.js
32
46
  - bin/distil
33
47
  - distil.gemspec
34
- - lib/bootstrap-template.js
35
- - lib/configurable.rb
36
- - lib/file-set.rb
37
- - lib/file-types/css-file.rb
38
- - lib/file-types/html-file.rb
39
- - lib/file-types/javascript-file.rb
40
- - lib/file-types/json-file.rb
41
- - lib/filter.rb
42
- - lib/filters/css-filter.rb
43
- - lib/filters/file-reference-filter.rb
44
- - lib/filters/jsl-dependency-filter.rb
48
+ - lib/distil.rb
49
+ - lib/distil/configurable.rb
50
+ - lib/distil/configurable/file-set.rb
51
+ - lib/distil/configurable/interpolated.rb
52
+ - lib/distil/configurable/output-path.rb
53
+ - lib/distil/configurable/project-path.rb
54
+ - lib/distil/error-reporter.rb
55
+ - lib/distil/product.rb
56
+ - lib/distil/product/concatenated.rb
57
+ - lib/distil/product/css-product.rb
58
+ - lib/distil/product/debug.rb
59
+ - lib/distil/product/javascript-base-product.rb
60
+ - lib/distil/product/javascript-doc-product.rb
61
+ - lib/distil/product/javascript-product.rb
62
+ - lib/distil/product/minified.rb
63
+ - lib/distil/project.rb
64
+ - lib/distil/project/distil-project.rb
65
+ - lib/distil/project/external-project.rb
66
+ - lib/distil/source-file.rb
67
+ - lib/distil/source-file/css-file.rb
68
+ - lib/distil/source-file/html-file.rb
69
+ - lib/distil/source-file/javascript-file.rb
70
+ - lib/distil/source-file/json-file.rb
71
+ - lib/distil/target.rb
72
+ - lib/distil/task.rb
73
+ - lib/distil/task/css-dependency-task.rb
74
+ - lib/distil/task/jsl-dependency-task.rb
75
+ - lib/distil/task/nib-task.rb
76
+ - lib/distil/task/validate-js-task.rb
45
77
  - lib/jsdoc.conf
46
78
  - lib/jsl.conf
47
- - lib/project.rb
48
- - lib/source-file.rb
49
- - lib/target.rb
50
- - lib/task.rb
51
- - lib/tasks/copy-task.rb
52
- - lib/tasks/css-task.rb
53
- - lib/tasks/javascript-task.rb
54
- - lib/tasks/multiple-output-task.rb
55
- - lib/tasks/output-task.rb
56
- - lib/tasks/single-output-task.rb
57
- - lib/tasks/test-task.rb
58
79
  - lib/test/HtmlTestReporter.js
59
80
  - lib/test/Test.js
60
81
  - lib/test/TestReporter.js
@@ -1,58 +0,0 @@
1
- /*jsl:ignore*/ /**#nocode+*/
2
- (function() {
3
- var baseUrl= findScriptBaseName();
4
-
5
- function findScriptBaseName()
6
- {
7
- var scripts= document.getElementsByTagName("script");
8
- if (!scripts || !scripts.length)
9
- throw new Error("Could not find script");
10
-
11
- var l= scripts.length;
12
- var s;
13
-
14
- for (--l; l>=0; --l)
15
- {
16
- s= scripts[l];
17
- if (s.src)
18
- {
19
- var src= s.src;
20
- var lastSlash= src.lastIndexOf('/');
21
-
22
- if (-1===lastSlash)
23
- throw new Error("Couldn't determine path from src: " + src);
24
-
25
- return src.substring(0, lastSlash+1);
26
- }
27
- }
28
-
29
- throw new Error("No script tags with src attribute.");
30
- }
31
-
32
- window.__bootstrap_nextScript= function()
33
- {
34
- if (!scripts.length)
35
- window.__filename__= null;
36
- else
37
- window.__filename__= scripts.shift();
38
- }
39
-
40
- var scripts= [];
41
-
42
- function loadScript(script)
43
- {
44
- script= baseUrl + script;
45
- scripts.push(script);
46
-
47
- if (!window.__filename__)
48
- window.__bootstrap_nextScript();
49
-
50
- document.write( ['<', 'script type="text/javascript"',
51
- ' onload="window.__bootstrap_nextScript()"',
52
- ' src="', script, '"></script>'].join("") );
53
- }
54
-
55
- @LOAD_SCRIPTS@
56
-
57
- })();
58
- /**#nocode-*/ /*jsl:end*/
data/lib/configurable.rb DELETED
@@ -1,161 +0,0 @@
1
- module Kernel
2
-
3
- def Boolean(string)
4
- return true if string == true || string =~ /^true$/i
5
- return false if string == false || string.nil? || string =~ /^false$/i
6
- raise ArgumentError.new("invalid value for Boolean: \"#{string}\"")
7
- end
8
-
9
- end
10
-
11
-
12
-
13
- class Configurable
14
- attr_reader :options
15
-
16
- @@options= {}
17
-
18
- def get_options(settings=nil, parent=nil)
19
- keys= @@options.keys
20
- values= @@options.map { |k,v| v[:value] }
21
-
22
- s= Struct.new(*keys).new(*values)
23
- return s if !settings
24
-
25
- setting_keys= settings.keys.map { |key| key.to_s }
26
-
27
- @@options.each { |key, value|
28
-
29
- intersect= value[:aliases] & setting_keys
30
- next if !parent && intersect.empty?
31
-
32
- if (intersect.empty?)
33
- s[key]= parent[key]
34
- next
35
- end
36
-
37
- if (intersect.length>1)
38
- raise ArgumentError, "Multiple variants for #{key.to_s} defined: #{intersect.join(", ")}"
39
- end
40
-
41
- setting_key= intersect[0]
42
- setting_value= settings[setting_key]
43
- settings.delete(setting_key)
44
-
45
- # decide if any type conversions are needed...
46
- type= value[:type]
47
- setting_value= case
48
- when FalseClass==type || TrueClass==type
49
- Boolean(setting_value)
50
- when Array==type
51
- setting_value.is_a?(String) ? setting_value.split(/\s*,\s*/) : setting_value
52
- when Fixnum==type
53
- setting_value.to_i
54
- when NilClass==type
55
- setting_value
56
- when String==type
57
- setting_value.to_s
58
- else
59
- type.new(setting_value)
60
- end
61
-
62
- s[key]= setting_value
63
-
64
- }
65
-
66
- s
67
- end
68
-
69
- def self.class_attr(name)
70
- if (@class_attributes.nil?)
71
- @class_attributes=[name]
72
- else
73
- @class_attributes<<name
74
- end
75
-
76
- class_eval %(
77
- def self.#{name}(*rest)
78
- if (rest.length>0)
79
- @#{name}= rest[0]
80
- else
81
- @#{name}
82
- end
83
- end
84
- def self.#{name}=(value)
85
- @#{name}= value
86
- end
87
- def #{name}
88
- @#{name} || self.class.#{name}
89
- end
90
- def #{name}=(value)
91
- @#{name}=value
92
- end
93
- )
94
-
95
- end
96
-
97
- def self.inherited(subclass)
98
- super(subclass)
99
- (@class_attributes||[]).each { |a|
100
- instance_var = "@#{a}"
101
- subclass.instance_variable_set(instance_var, instance_variable_get(instance_var))
102
- }
103
- end
104
-
105
- # option name, [type], [default], [options]
106
- def self.option(name, *rest)
107
-
108
- name_string= name.to_s
109
-
110
- info= {
111
- :aliases=>[name_string, name_string.gsub('_', '-'), name_string.gsub('_', ' ')].uniq
112
- }
113
-
114
- arg= rest.shift
115
-
116
- if (arg.is_a?(Class))
117
- info[:type]= arg
118
- info[:value]= nil #arg.new
119
- arg= rest.shift
120
- end
121
-
122
- if (!arg.is_a?(Hash))
123
- info[:value]= arg
124
- info[:type]= arg.class if !info.key?(:type)
125
- arg= rest.shift
126
- end
127
-
128
- # handle named arguments
129
- if (arg.is_a?(Hash))
130
- info.merge!(arg)
131
- end
132
-
133
- @@options[name]= info
134
-
135
- Configurable.send :define_method, name do
136
- @options[name]
137
- end
138
-
139
- end
140
-
141
- def self.option_alias(name, name_alias)
142
- if (!@@options.key?(name))
143
- raise ArgumentError, "No such option: #{name}"
144
- end
145
-
146
- name_alias= name_alias.to_s
147
-
148
- @@options[name][:aliases].concat([name_alias,
149
- name_alias.to_s.gsub('_', '-'),
150
- name_alias.to_s.gsub('_', ' ')].uniq)
151
- end
152
-
153
- def initialize(options={}, parent=nil)
154
- if (parent.is_a?(Configurable))
155
- parent_options= parent.options
156
- end
157
- @options= get_options(options, parent_options)
158
- @extras= options
159
- end
160
-
161
- end
data/lib/file-set.rb DELETED
@@ -1,49 +0,0 @@
1
- require "#{$script_dir}/source-file"
2
-
3
- class FileSet
4
- include Enumerable
5
- attr_reader :files
6
-
7
- def initialize(set)
8
- @files= []
9
- case
10
- when (set.is_a?(String))
11
- include_file(set)
12
- when (set.is_a?(Array))
13
- set.each { |f| include_file(f) }
14
- end
15
- end
16
-
17
- def include_file(file)
18
- full_path= File.expand_path(file)
19
-
20
- if File.directory?(full_path)
21
- Dir.foreach(full_path) { |f|
22
- next if ('.'==f[/^\./])
23
- include_file(File.join(full_path, f))
24
- }
25
- return
26
- end
27
-
28
- files= Dir.glob(full_path)
29
- if (files.length>0)
30
- files.each { |f|
31
- source_file= SourceFile.from_path(f)
32
- next if (@files.include?(source_file))
33
- @files << source_file
34
- }
35
- return
36
- end
37
-
38
- # file not found by globbing (would also find explicit reference)
39
- source_file= Project.current.find_file(file)
40
- return if (!source_file)
41
- return if (@files.include?(source_file))
42
- @files << source_file
43
- end
44
-
45
- def each
46
- @files.each { |f| yield f }
47
- end
48
-
49
- end
@@ -1,12 +0,0 @@
1
- class CssFile < SourceFile
2
-
3
- def self.extension
4
- ".css"
5
- end
6
-
7
- def debug_content(options)
8
- destination= File.expand_path(options.remove_prefix||"")
9
- "@import url(\"#{self.relative_to_folder(destination)}\");\n"
10
- end
11
-
12
- end
@@ -1,11 +0,0 @@
1
- class HtmlFile < SourceFile
2
-
3
- def self.extension
4
- ".html"
5
- end
6
-
7
- def minify_content(source)
8
- source.gsub(/>\s+</, "><")
9
- end
10
-
11
- end