archetype 0.0.1.pre.13 → 1.0.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (253) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +97 -24
  3. data/README.md +11 -5
  4. data/VERSION +1 -0
  5. data/lib/archetype.rb +30 -18
  6. data/lib/archetype/actions/migrate.rb +152 -0
  7. data/lib/archetype/actions/theme.rb +6 -7
  8. data/lib/archetype/executor.rb +21 -7
  9. data/lib/archetype/extensions.rb +57 -0
  10. data/lib/archetype/functions.rb +2 -3
  11. data/lib/archetype/functions/css.rb +70 -0
  12. data/lib/archetype/functions/css/constants.rb +247 -0
  13. data/lib/archetype/functions/css/helpers.rb +265 -0
  14. data/lib/archetype/functions/css/routers.rb +28 -0
  15. data/lib/archetype/functions/css/routers/animation.rb +55 -0
  16. data/lib/archetype/functions/css/routers/background.rb +38 -0
  17. data/lib/archetype/functions/css/routers/border.rb +151 -0
  18. data/lib/archetype/functions/css/routers/list.rb +63 -0
  19. data/lib/archetype/functions/css/routers/margin_padding.rb +40 -0
  20. data/lib/archetype/functions/css/routers/outline.rb +56 -0
  21. data/lib/archetype/functions/css/routers/overflow.rb +11 -0
  22. data/lib/archetype/functions/css/routers/target.rb +38 -0
  23. data/lib/archetype/functions/css/routers/transition.rb +48 -0
  24. data/lib/archetype/functions/css/shorthands.rb +43 -0
  25. data/lib/archetype/functions/css/shorthands/animation.rb +18 -0
  26. data/lib/archetype/functions/css/shorthands/background.rb +68 -0
  27. data/lib/archetype/functions/css/shorthands/border.rb +102 -0
  28. data/lib/archetype/functions/hash.rb +3 -149
  29. data/lib/archetype/functions/hash/extend.rb +74 -0
  30. data/lib/archetype/functions/hash/shim.rb +48 -0
  31. data/lib/archetype/functions/helpers.rb +231 -22
  32. data/lib/archetype/functions/styleguide_memoizer.rb +18 -1
  33. data/lib/archetype/sass_extensions.rb +1 -3
  34. data/lib/archetype/sass_extensions/functions.rb +15 -1
  35. data/lib/archetype/sass_extensions/functions/environment.rb +152 -1
  36. data/lib/archetype/sass_extensions/functions/lists.rb +95 -45
  37. data/lib/archetype/sass_extensions/functions/locale.rb +107 -28
  38. data/lib/archetype/sass_extensions/functions/numbers.rb +118 -4
  39. data/lib/archetype/sass_extensions/functions/strings.rb +53 -0
  40. data/lib/archetype/sass_extensions/functions/styleguide.rb +43 -375
  41. data/lib/archetype/sass_extensions/functions/styleguide/components.rb +25 -0
  42. data/lib/archetype/sass_extensions/functions/styleguide/constants.rb +27 -0
  43. data/lib/archetype/sass_extensions/functions/styleguide/grammar.rb +80 -0
  44. data/lib/archetype/sass_extensions/functions/styleguide/helpers.rb +36 -0
  45. data/lib/archetype/sass_extensions/functions/styleguide/resolve.rb +159 -0
  46. data/lib/archetype/sass_extensions/functions/styleguide/styles.rb +146 -0
  47. data/lib/archetype/sass_extensions/functions/styleguide/themes.rb +40 -0
  48. data/lib/archetype/sass_extensions/functions/ui.rb +7 -57
  49. data/lib/archetype/sass_extensions/functions/ui/glyphs.rb +118 -0
  50. data/lib/archetype/sass_extensions/functions/ui/scopes.rb +96 -0
  51. data/lib/archetype/sass_extensions/functions/util.rb +14 -0
  52. data/lib/archetype/sass_extensions/functions/util/debug.rb +22 -0
  53. data/lib/archetype/sass_extensions/functions/util/hacks.rb +44 -0
  54. data/lib/archetype/sass_extensions/functions/util/images.rb +132 -0
  55. data/lib/archetype/sass_extensions/functions/util/misc.rb +220 -0
  56. data/lib/archetype/sass_extensions/functions/util/spacing.rb +83 -0
  57. data/lib/archetype/sass_extensions/functions/version.rb +12 -17
  58. data/lib/archetype/version.rb +1 -1
  59. data/stylesheets/archetype/_config.scss +1 -389
  60. data/stylesheets/archetype/_core.scss +15 -0
  61. data/stylesheets/archetype/_hacks.scss +4 -120
  62. data/stylesheets/archetype/_init.scss +4 -22
  63. data/stylesheets/archetype/_required.scss +3 -0
  64. data/stylesheets/archetype/_reset.scss +3 -0
  65. data/stylesheets/archetype/_styleguide.scss +2 -6
  66. data/stylesheets/archetype/_ui.scss +2 -358
  67. data/stylesheets/archetype/_util.scss +3 -10
  68. data/stylesheets/archetype/config/_core.scss +14 -0
  69. data/stylesheets/archetype/config/_environment.scss +19 -0
  70. data/stylesheets/archetype/config/_formatting.scss +63 -0
  71. data/stylesheets/archetype/config/_glyphs.scss +252 -0
  72. data/stylesheets/archetype/config/_resets.scss +7 -0
  73. data/stylesheets/archetype/config/_resolution.scss +3 -0
  74. data/stylesheets/archetype/config/_spacing.scss +5 -0
  75. data/stylesheets/archetype/config/_targeting.scss +18 -0
  76. data/stylesheets/archetype/config/_theme.scss +3 -0
  77. data/stylesheets/archetype/config/_typography.scss +56 -0
  78. data/stylesheets/archetype/config/_units.scss +2 -0
  79. data/stylesheets/archetype/config/_vars.scss +10 -0
  80. data/stylesheets/archetype/hacks/_core.scss +4 -0
  81. data/stylesheets/archetype/hacks/_hacks.scss +160 -0
  82. data/stylesheets/archetype/hacks/_init.scss +2 -0
  83. data/stylesheets/archetype/styleguide/_core.scss +4 -0
  84. data/stylesheets/archetype/styleguide/_init.scss +1 -0
  85. data/stylesheets/archetype/styleguide/_styleguide.scss +41 -18
  86. data/stylesheets/archetype/ui/_accessibility.scss +41 -0
  87. data/stylesheets/archetype/ui/_breakpoints.scss +19 -0
  88. data/stylesheets/archetype/ui/_core.scss +10 -0
  89. data/stylesheets/archetype/ui/_elements.scss +98 -0
  90. data/stylesheets/archetype/ui/_glyphs.scss +244 -0
  91. data/stylesheets/archetype/ui/_init.scss +5 -0
  92. data/stylesheets/archetype/ui/_layout.scss +37 -0
  93. data/stylesheets/archetype/ui/_locale.scss +12 -0
  94. data/stylesheets/archetype/ui/_scopes.scss +42 -0
  95. data/stylesheets/archetype/util/_core.scss +8 -0
  96. data/stylesheets/archetype/util/_debug.scss +9 -21
  97. data/stylesheets/archetype/util/_init.scss +1 -0
  98. data/stylesheets/archetype/util/_misc.scss +21 -86
  99. data/stylesheets/archetype/util/_spacing.scss +9 -40
  100. data/stylesheets/archetype/util/_styles.scss +189 -178
  101. data/stylesheets/archetype/util/_targeting.scss +51 -68
  102. data/templates/example/manifest.rb +2 -2
  103. data/templates/example/screen.scss +0 -1
  104. data/templates/project/manifest.rb +3 -8
  105. metadata +93 -263
  106. data/bin/archetype +0 -3
  107. data/lib/archetype/sass_extensions/monkey_patches.rb +0 -3
  108. data/lib/archetype/sass_extensions/monkey_patches/handle_include_loop.rb +0 -13
  109. data/stylesheets/archetype/_base.scss +0 -54
  110. data/stylesheets/archetype/_grid.scss +0 -3
  111. data/stylesheets/archetype/base/_h5bp.scss +0 -307
  112. data/stylesheets/archetype/base/_hybrid.scss +0 -25
  113. data/stylesheets/archetype/base/_normalize.scss +0 -634
  114. data/stylesheets/archetype/base/_reset.scss +0 -72
  115. data/stylesheets/archetype/grid/_config.scss +0 -14
  116. data/stylesheets/archetype/grid/_grid.scss +0 -391
  117. data/stylesheets/archetype/styleguide/_components.scss +0 -25
  118. data/stylesheets/archetype/styleguide/_helpers.scss +0 -215
  119. data/stylesheets/archetype/styleguide/_primitives.scss +0 -10
  120. data/stylesheets/archetype/styleguide/components/_alerts.scss +0 -59
  121. data/stylesheets/archetype/styleguide/components/_annotations.scss +0 -27
  122. data/stylesheets/archetype/styleguide/components/_bristol.scss +0 -15
  123. data/stylesheets/archetype/styleguide/components/_button_groups.scss +0 -47
  124. data/stylesheets/archetype/styleguide/components/_button_toolbars.scss +0 -17
  125. data/stylesheets/archetype/styleguide/components/_buttons.scss +0 -339
  126. data/stylesheets/archetype/styleguide/components/_canvas.scss +0 -15
  127. data/stylesheets/archetype/styleguide/components/_carets.scss +0 -336
  128. data/stylesheets/archetype/styleguide/components/_closes.scss +0 -63
  129. data/stylesheets/archetype/styleguide/components/_container.scss +0 -27
  130. data/stylesheets/archetype/styleguide/components/_copy.scss +0 -85
  131. data/stylesheets/archetype/styleguide/components/_flyouts.scss +0 -52
  132. data/stylesheets/archetype/styleguide/components/_headings.scss +0 -33
  133. data/stylesheets/archetype/styleguide/components/_headlines.scss +0 -64
  134. data/stylesheets/archetype/styleguide/components/_hovercards.scss +0 -27
  135. data/stylesheets/archetype/styleguide/components/_icons.scss +0 -17
  136. data/stylesheets/archetype/styleguide/components/_identities.scss +0 -34
  137. data/stylesheets/archetype/styleguide/components/_links.scss +0 -68
  138. data/stylesheets/archetype/styleguide/components/_loaders.scss +0 -154
  139. data/stylesheets/archetype/styleguide/components/_menu_items.scss +0 -31
  140. data/stylesheets/archetype/styleguide/components/_module.scss +0 -15
  141. data/stylesheets/archetype/styleguide/components/_pullquotes.scss +0 -29
  142. data/stylesheets/archetype/styleguide/components/_punchcut.scss +0 -18
  143. data/stylesheets/archetype/styleguide/components/_tooltips.scss +0 -28
  144. data/stylesheets/archetype/styleguide/primitives/_animations.scss +0 -17
  145. data/stylesheets/archetype/styleguide/primitives/_dimensions.scss +0 -50
  146. data/stylesheets/archetype/styleguide/primitives/_glyphs.scss +0 -11
  147. data/stylesheets/archetype/styleguide/primitives/_misc.scss +0 -8
  148. data/stylesheets/archetype/styleguide/primitives/_palettes.scss +0 -94
  149. data/stylesheets/archetype/styleguide/primitives/_shadows.scss +0 -23
  150. data/stylesheets/archetype/styleguide/primitives/_sprites.scss +0 -46
  151. data/stylesheets/archetype/styleguide/primitives/_textures.scss +0 -10
  152. data/stylesheets/archetype/styleguide/primitives/_typography.scss +0 -56
  153. data/stylesheets/archetype/util/_lists.scss +0 -57
  154. data/stylesheets/archetype/util/_rtl.scss +0 -279
  155. data/stylesheets/archetype/util/_units.scss +0 -18
  156. data/templates/project/screen.scss +0 -1
  157. data/templates/project/vendor/archetype/animations/loaders/large/large.png +0 -0
  158. data/templates/project/vendor/archetype/animations/loaders/large/large_dark.png +0 -0
  159. data/templates/project/vendor/archetype/animations/loaders/large/large_dark_static.png +0 -0
  160. data/templates/project/vendor/archetype/animations/loaders/large/large_static.png +0 -0
  161. data/templates/project/vendor/archetype/animations/loaders/medium/medium.png +0 -0
  162. data/templates/project/vendor/archetype/animations/loaders/medium/medium_dark.png +0 -0
  163. data/templates/project/vendor/archetype/animations/loaders/medium/medium_dark_static.png +0 -0
  164. data/templates/project/vendor/archetype/animations/loaders/medium/medium_static.png +0 -0
  165. data/templates/project/vendor/archetype/animations/loaders/small/small.png +0 -0
  166. data/templates/project/vendor/archetype/animations/loaders/small/small_dark.png +0 -0
  167. data/templates/project/vendor/archetype/animations/loaders/small/small_dark_static.png +0 -0
  168. data/templates/project/vendor/archetype/animations/loaders/small/small_static.png +0 -0
  169. data/templates/project/vendor/archetype/fontawesome-webfont.eot +0 -0
  170. data/templates/project/vendor/archetype/fontawesome-webfont.svg +0 -255
  171. data/templates/project/vendor/archetype/fontawesome-webfont.ttf +0 -0
  172. data/templates/project/vendor/archetype/fontawesome-webfont.woff +0 -0
  173. data/test/fixtures/stylesheets/archetype/assets/fonts/fontawesome-webfont.eot +0 -0
  174. data/test/fixtures/stylesheets/archetype/assets/fonts/fontawesome-webfont.svg +0 -255
  175. data/test/fixtures/stylesheets/archetype/assets/fonts/fontawesome-webfont.ttf +0 -0
  176. data/test/fixtures/stylesheets/archetype/assets/fonts/fontawesome-webfont.woff +0 -0
  177. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders-s7889ccc8c1.png +0 -0
  178. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/large/large.png +0 -0
  179. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/large/large_dark.png +0 -0
  180. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/large/large_dark_static.png +0 -0
  181. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/large/large_static.png +0 -0
  182. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/medium/medium.png +0 -0
  183. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/medium/medium_dark.png +0 -0
  184. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/medium/medium_dark_static.png +0 -0
  185. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/medium/medium_static.png +0 -0
  186. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/small/small.png +0 -0
  187. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/small/small_dark.png +0 -0
  188. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/small/small_dark_static.png +0 -0
  189. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/small/small_static.png +0 -0
  190. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/sprites/hovercard_tip.png +0 -0
  191. data/test/fixtures/stylesheets/archetype/config.rb +0 -21
  192. data/test/fixtures/stylesheets/archetype/source/b.scss +0 -9
  193. data/test/fixtures/stylesheets/archetype/source/base.scss +0 -3
  194. data/test/fixtures/stylesheets/archetype/source/hacks/ie_pseudo.scss +0 -13
  195. data/test/fixtures/stylesheets/archetype/source/hacks/transparent_focusable.scss +0 -5
  196. data/test/fixtures/stylesheets/archetype/source/locale.scss +0 -43
  197. data/test/fixtures/stylesheets/archetype/source/styleguide/alerts.scss +0 -21
  198. data/test/fixtures/stylesheets/archetype/source/styleguide/buttons.scss +0 -18
  199. data/test/fixtures/stylesheets/archetype/source/styleguide/drop.scss +0 -101
  200. data/test/fixtures/stylesheets/archetype/source/styleguide/extend.scss +0 -24
  201. data/test/fixtures/stylesheets/archetype/source/styleguide/fallback_styles.scss +0 -23
  202. data/test/fixtures/stylesheets/archetype/source/styleguide/invalid_structures.scss +0 -85
  203. data/test/fixtures/stylesheets/archetype/source/styleguide/multi_value.scss +0 -18
  204. data/test/fixtures/stylesheets/archetype/source/styleguide/nested_styleguides.scss +0 -40
  205. data/test/fixtures/stylesheets/archetype/source/styleguide/selective_state.scss +0 -22
  206. data/test/fixtures/stylesheets/archetype/source/ui/glyph_icon.scss +0 -35
  207. data/test/fixtures/stylesheets/archetype/source/ui/hide_element.scss +0 -5
  208. data/test/fixtures/stylesheets/archetype/source/ui/stroke.scss +0 -13
  209. data/test/fixtures/stylesheets/archetype/source/ui/triangle.scss +0 -13
  210. data/test/fixtures/stylesheets/archetype/source/utilities/associative.scss +0 -24
  211. data/test/fixtures/stylesheets/archetype/source/utilities/custom_output_styler.scss +0 -22
  212. data/test/fixtures/stylesheets/archetype/source/utilities/if-set.scss +0 -16
  213. data/test/fixtures/stylesheets/archetype/source/utilities/spacing/horizontal-spacing.scss +0 -27
  214. data/test/fixtures/stylesheets/archetype/source/utilities/spacing/vertical-spacing.scss +0 -27
  215. data/test/fixtures/stylesheets/archetype/source/utilities/styles/filter.scss +0 -9
  216. data/test/fixtures/stylesheets/archetype/source/utilities/styles/font-family.scss +0 -9
  217. data/test/fixtures/stylesheets/archetype/source/utilities/styles/z-index.scss +0 -18
  218. data/test/fixtures/stylesheets/archetype/source/utilities/targeting/target-browser.scss +0 -77
  219. data/test/fixtures/stylesheets/archetype/source/utilities/targeting/target-os.scss +0 -42
  220. data/test/fixtures/stylesheets/archetype/tmp/b.css +0 -14
  221. data/test/fixtures/stylesheets/archetype/tmp/base.css +0 -349
  222. data/test/fixtures/stylesheets/archetype/tmp/hacks/ie_pseudo.css +0 -11
  223. data/test/fixtures/stylesheets/archetype/tmp/hacks/transparent_focusable.css +0 -4
  224. data/test/fixtures/stylesheets/archetype/tmp/locale.css +0 -23
  225. data/test/fixtures/stylesheets/archetype/tmp/styleguide/alerts.css +0 -711
  226. data/test/fixtures/stylesheets/archetype/tmp/styleguide/buttons.css +0 -2119
  227. data/test/fixtures/stylesheets/archetype/tmp/styleguide/drop.css +0 -63
  228. data/test/fixtures/stylesheets/archetype/tmp/styleguide/extend.css +0 -11
  229. data/test/fixtures/stylesheets/archetype/tmp/styleguide/fallback_styles.css +0 -10
  230. data/test/fixtures/stylesheets/archetype/tmp/styleguide/invalid_structures.css +0 -21
  231. data/test/fixtures/stylesheets/archetype/tmp/styleguide/multi_value.css +0 -13
  232. data/test/fixtures/stylesheets/archetype/tmp/styleguide/nested_styleguides.css +0 -28
  233. data/test/fixtures/stylesheets/archetype/tmp/styleguide/selective_state.css +0 -177
  234. data/test/fixtures/stylesheets/archetype/tmp/ui/glyph_icon.css +0 -127
  235. data/test/fixtures/stylesheets/archetype/tmp/ui/hide_element.css +0 -8
  236. data/test/fixtures/stylesheets/archetype/tmp/ui/stroke.css +0 -17
  237. data/test/fixtures/stylesheets/archetype/tmp/ui/triangle.css +0 -35
  238. data/test/fixtures/stylesheets/archetype/tmp/utilities/associative.css +0 -9
  239. data/test/fixtures/stylesheets/archetype/tmp/utilities/custom_output_styler.css +0 -8
  240. data/test/fixtures/stylesheets/archetype/tmp/utilities/if-set.css +0 -9
  241. data/test/fixtures/stylesheets/archetype/tmp/utilities/spacing/horizontal-spacing.css +0 -29
  242. data/test/fixtures/stylesheets/archetype/tmp/utilities/spacing/vertical-spacing.css +0 -29
  243. data/test/fixtures/stylesheets/archetype/tmp/utilities/styles/filter.css +0 -11
  244. data/test/fixtures/stylesheets/archetype/tmp/utilities/styles/font-family.css +0 -16
  245. data/test/fixtures/stylesheets/archetype/tmp/utilities/styles/z-index.css +0 -15
  246. data/test/fixtures/stylesheets/archetype/tmp/utilities/targeting/target-browser.css +0 -105
  247. data/test/fixtures/stylesheets/archetype/tmp/utilities/targeting/target-os.css +0 -55
  248. data/test/helpers/diff.rb +0 -49
  249. data/test/helpers/io.rb +0 -36
  250. data/test/helpers/test_case.rb +0 -62
  251. data/test/integrations/archetype_test.rb +0 -126
  252. data/test/test_helper.rb +0 -26
  253. data/test/units/sass_extensions_test.rb +0 -200
@@ -1,17 +1,16 @@
1
- require 'fileutils'
2
1
  description = "Generate a new Archetype theme"
3
2
 
4
3
  if @description.nil?
5
4
  options = {
6
- :extends => 'archetype'
5
+ :extends => Archetype.name
7
6
  }
8
7
  OptionParser.new do |opts|
9
8
  opts.banner = description
10
- opts.define_head "Usage: archetype theme [path] [options]"
9
+ opts.define_head "Usage: #{Archetype.name} theme [path] [options]"
11
10
  opts.separator ""
12
11
  opts.separator "Example usage:"
13
- opts.separator " archetype theme /path/to/scss/ --name=myCustomTheme"
14
- opts.separator " archetype theme --name=themes/myExtendedTheme --extends=themes/myBaseTheme"
12
+ opts.separator " #{Archetype.name} theme /path/to/scss/ --name=myCustomTheme"
13
+ opts.separator " #{Archetype.name} theme --name=themes/myExtendedTheme --extends=themes/myBaseTheme"
15
14
 
16
15
  opts.on('-n', '--name THEME', 'theme name') do |v|
17
16
  options[:theme] = v
@@ -38,7 +37,7 @@ if @description.nil?
38
37
  theme_template = File.join(File.dirname(__FILE__), '../../../templates/_theme/')
39
38
  theme_path = File.join(base, options[:theme])
40
39
  extends = "#{options[:extends]}"
41
- if options[:extends] != 'archetype'
40
+ if options[:extends] != Archetype.name
42
41
  extends = "#{extends}/core"
43
42
  end
44
43
  theme_name = File.basename(options[:theme])
@@ -47,7 +46,7 @@ if @description.nil?
47
46
  FileUtils.cp_r(Dir["#{theme_template}/**"], tmp)
48
47
 
49
48
  puts "Creating theme '#{theme_name}' in #{File.expand_path(theme_path)}..."
50
- puts "extending from #{options[:extends]}" if options[:extends] != 'archetype'
49
+ puts "extending from #{options[:extends]}" if options[:extends] != Archetype.name
51
50
 
52
51
  # update all placeholders in template files
53
52
  Dir.glob("#{tmp}/**/*.scss") do |filename|
@@ -1,21 +1,27 @@
1
+ require 'archetype'
1
2
  require 'optparse'
2
3
 
3
4
  @actions_path = File.join(File.dirname(__FILE__), 'actions')
5
+ @needs_help = true
4
6
 
5
7
  if not ARGV[0].nil? and not ARGV[0].empty?
6
8
  action_name = ARGV[0]
7
- action = File.join(@actions_path, action_name)
8
- begin
9
- require action
10
- rescue
11
- puts "unknown action: #{action_name}"
9
+ if /^[a-z]/ =~ action_name
10
+ action = File.join(@actions_path, action_name)
11
+ begin
12
+ require action
13
+ rescue LoadError
14
+ puts "unknown action: #{action_name}"
15
+ end
16
+ elsif /^-(h|-help)$/ =~ action_name
17
+ @needs_help = false
12
18
  end
13
19
  end
14
20
 
15
21
  # if we got here, there was either no action, or the action was invalid
16
22
  OptionParser.new do |opts|
17
23
  opts.banner = "Archetype command line actions\n\n"
18
- opts.define_head "Usage: archetype <action> [options]"
24
+ opts.define_head "Usage: #{Archetype.name} <action> [options]"
19
25
  opts.separator ""
20
26
  opts.separator "Available Actions:"
21
27
  Dir.glob("#{@actions_path}/*.rb") do |action|
@@ -23,5 +29,13 @@ OptionParser.new do |opts|
23
29
  load action
24
30
  opts.separator " * #{File.basename(action, '.rb')}\t- #{@description}"
25
31
  end
26
- puts opts
32
+ opts.separator ""
33
+ opts.separator "Available Options:"
34
+ opts.on("-v", "--version", "reports the current version") do
35
+ puts Archetype::VERSION
36
+ exit
37
+ end
38
+ @options = opts
27
39
  end.parse!
40
+
41
+ puts @options if @needs_help
@@ -0,0 +1,57 @@
1
+ module Archetype
2
+ module Extensions
3
+ def self.register(name, *arguments)
4
+ # make sure the name is properly formatted
5
+ name = "#{NAME}-#{name.gsub(/^#{NAME}-/, '')}"
6
+ Compass::Frameworks.register(name, *arguments)
7
+ end
8
+
9
+ class GemspecHelper
10
+
11
+ ROOT_PATH = File.expand_path("../../../", __FILE__)
12
+
13
+ def initialize(name)
14
+
15
+ e = @extension = {}
16
+ # we only care about the name, so strip off anything if we were given a file/path
17
+ e[:name] = File.basename(name, '.gemspec').strip
18
+ # the path to the extension
19
+ e[:path] = File.join(ROOT_PATH, 'extensions', e[:name])
20
+ # the lib directory within the extension
21
+ e[:lib] = File.join(e[:path], 'lib')
22
+
23
+ resolve_version
24
+ end
25
+
26
+ def info(prop)
27
+ return @extension[prop] || core.send(prop)
28
+ end
29
+
30
+ private
31
+
32
+ def resolve_version
33
+ # if a version.rb file exists within the extension, we'll get the version from that
34
+ version_rb = File.join(@extension[:lib], @extension[:name], 'version.rb')
35
+ require version_rb if File.exist?(version_rb)
36
+ # if the ::VERSION constant was set on the extension module, use it...
37
+ @extension[:version] = version_const if defined?(version_const)
38
+ # if the version isn't set, use Archetype's core version
39
+ @extension[:version] = core.version if @extension[:version].nil? or @extension[:version].empty?
40
+ end
41
+
42
+ def version_const
43
+ # converts the hyphenated name to a module
44
+ name = @extension[:name].gsub(/(?:_|\-|^)(\w)/){$1.upcase}
45
+ begin
46
+ return Module.const_get("#{name}::VERSION")
47
+ rescue NameError
48
+ return nil
49
+ end
50
+ end
51
+
52
+ def core
53
+ @core ||= Gem::Specification.load(File.join(ROOT_PATH, 'archetype.gemspec'))
54
+ end
55
+ end
56
+ end
57
+ end
@@ -1,9 +1,8 @@
1
1
  # :stopdoc:
2
2
  # Load necessary functions.
3
3
  #
4
- module Archetype::Functions
5
- end
4
+ module Archetype::Functions; end
6
5
 
7
- %w(hash helpers styleguide_memoizer).each do |dep|
6
+ %w(hash helpers styleguide_memoizer css).each do |dep|
8
7
  require "archetype/functions/#{dep}"
9
8
  end
@@ -0,0 +1,70 @@
1
+ # :stopdoc:
2
+
3
+ %w(constants helpers routers shorthands).each do |dep|
4
+ require "archetype/functions/css/#{dep}"
5
+ end
6
+
7
+ module Archetype::Functions::CSS
8
+ #include Sass::Script::Value::Helpers
9
+
10
+ #
11
+ # returns a best guess for the default CSS value of a given property
12
+ #
13
+ # *Parameters*:
14
+ # - <tt>key</tt> {String} the property to lookup
15
+ # *Returns*:
16
+ # - {*} the default value
17
+ #
18
+ def self.default(key)
19
+ value = ALL_CSS_PROPERTIES[key] || :invalid
20
+ if value.is_a?(Array)
21
+ value = Sass::Script::Value::List.new(value.map {|item| CSS_PRIMITIVES[item]}, :space)
22
+ else
23
+ value = CSS_PRIMITIVES[value]
24
+ end
25
+ helpers.warn("[#{Archetype.name}:css:default] cannot find a default value for `#{key}`") if value.nil?
26
+ return value
27
+ end
28
+
29
+ #
30
+ # calculates derived styles from a given map
31
+ #
32
+ # *Parameters*:
33
+ # - <tt>map</tt> {Sass::Script::Value::Map} the map of styles
34
+ # - <tt>properties</tt> {String|List|Array} the properties to extract the derived styles for
35
+ # - <tt>format</tt> {String} the format to return the results in [auto|map|list]
36
+ # - <tt>strict</tt> {Boolean} if true, will only return an exact match, and not try to extrapolate the value (TODO)
37
+ # *Returns*:
38
+ # - {*} the derived styles as either a list/map of the values or the individual value itself (based on the format)
39
+ #
40
+ def self.get_derived_styles(map, properties = [], format = :auto, strict = false)
41
+ # TODO how to handle multiple values?
42
+ computed = ::Archetype::Hash.new
43
+ (properties || []).to_a.each do |property|
44
+ value = Sass::Script::Value::Null.new
45
+ if not property.value.nil?
46
+ property = helpers.to_str(property, ' ', :quotes)
47
+ # simple case, exact match only
48
+ value = map[property] if map.key? property
49
+
50
+ # if we're not doing strict matching...
51
+ if not strict
52
+ # if the property is a short- or long-hand, we need to figure out what the value actually is
53
+ value = get_derived_styles_via_router(map, property) || value
54
+ end
55
+ end
56
+ computed[property] = value
57
+ end
58
+
59
+ format = :map if computed.length > 1 and format == :auto
60
+
61
+ case format
62
+ when :map
63
+ return helpers.hash_to_map(computed)
64
+ when :list
65
+ return Sass::Script::Value::List.new(computed.values, :comma)
66
+ else
67
+ return computed.values.first
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,247 @@
1
+ module Archetype::Functions::CSS
2
+ CSS_PRIMITIVES = {
3
+ # common
4
+ :inherit => Sass::Script::Value::String.new('inherit'),
5
+ :none => Sass::Script::Value::String.new('none'),
6
+ :auto => Sass::Script::Value::String.new('auto'),
7
+ :left => Sass::Script::Value::String.new('left'),
8
+ :top => Sass::Script::Value::String.new('top'),
9
+ :normal => Sass::Script::Value::String.new('normal'),
10
+ :repeat => Sass::Script::Value::String.new('repeat'),
11
+ :visible => Sass::Script::Value::String.new('visible'),
12
+ :scroll => Sass::Script::Value::String.new('scroll'),
13
+ :border_box => Sass::Script::Value::String.new('border-box'),
14
+ :padding_box => Sass::Script::Value::String.new('padding-box'),
15
+ :solid => Sass::Script::Value::String.new('solid'),
16
+ :static => Sass::Script::Value::String.new('static'),
17
+ :ease => Sass::Script::Value::String.new('ease'),
18
+ :running => Sass::Script::Value::String.new('running'),
19
+ :separate => Sass::Script::Value::String.new('separate'),
20
+ :stretch => Sass::Script::Value::String.new('stretch'),
21
+ :single => Sass::Script::Value::String.new('single'),
22
+ :inline_axis => Sass::Script::Value::String.new('inline-axis'),
23
+ :start => Sass::Script::Value::String.new('start'),
24
+ :content_box => Sass::Script::Value::String.new('content-box'),
25
+ :balance => Sass::Script::Value::String.new('balance'),
26
+ :medium => Sass::Script::Value::String.new('medium'),
27
+ :ltr => Sass::Script::Value::String.new('ltr'),
28
+ :inline => Sass::Script::Value::String.new('inline'),
29
+ :show => Sass::Script::Value::String.new('show'),
30
+ :outside => Sass::Script::Value::String.new('outside'),
31
+ :disc => Sass::Script::Value::String.new('disc'),
32
+ :invert => Sass::Script::Value::String.new('invert'),
33
+ :current => Sass::Script::Value::String.new('current'),
34
+ :window => Sass::Script::Value::String.new('window'),
35
+ :above => Sass::Script::Value::String.new('above'),
36
+ :flat => Sass::Script::Value::String.new('flat'),
37
+ :all => Sass::Script::Value::String.new('all'),
38
+ :baseline => Sass::Script::Value::String.new('baseline'),
39
+
40
+ # numbers
41
+ :zero => Sass::Script::Value::Number.new(0),
42
+ :one => Sass::Script::Value::Number.new(1),
43
+ :p100 => Sass::Script::Value::Number.new(100, ['%']),
44
+ :p100 => Sass::Script::Value::Number.new(50, ['%']),
45
+ # colors
46
+ :transparent => Sass::Script::Value::Color.new([0, 0, 0, 0]),
47
+ :black => Sass::Script::Value::Color.new([0, 0, 0]),
48
+ }
49
+
50
+ # a list of all CSS properties
51
+ ALL_CSS_PROPERTIES = {
52
+ 'animation' => [:none, :zero, :ease, :zero, :one, :normal],
53
+ 'animation-delay' => :zero,
54
+ 'animation-direction' => :normal,
55
+ 'animation-duration' => :zero,
56
+ 'animation-fill-mode' => :none,
57
+ 'animation-iteration-count' => :one,
58
+ 'animation-name' => :none,
59
+ 'animation-play-state' => :running,
60
+ 'animation-timing-function' => :ease,
61
+ 'appearance' => :normal,
62
+ 'backface-visibility' => :visible,
63
+ 'background' => :none,
64
+ 'background-attachment' => :scroll,
65
+ 'background-clip' => :border_box,
66
+ 'background-color' => :transparent,
67
+ 'background-image' => :none,
68
+ 'background-origin' => :padding_box,
69
+ 'background-position' => [:left, :top],
70
+ 'background-repeat' => :repeat,
71
+ 'background-size' => :auto,
72
+ 'border' => :none,
73
+ 'border-bottom' => :none,
74
+ 'border-bottom-color' => :transparent,
75
+ 'border-bottom-left-radius' => :zero,
76
+ 'border-bottom-right-radius' => :zero,
77
+ 'border-bottom-style' => :solid,
78
+ 'border-bottom-width' => :zero,
79
+ 'border-collapse' => :separate,
80
+ 'border-color' => :transparent,
81
+ 'border-image' => [:none, :p100, :one1, :zero, :stretch],
82
+ 'border-image-outset' => :zero,
83
+ 'border-image-repeat' => :stretch,
84
+ 'border-image-slice' => :p100,
85
+ 'border-image-source' => :none,
86
+ 'border-image-width' => :zero,
87
+ 'border-left' => :none,
88
+ 'border-left-color' => :transparent,
89
+ 'border-left-style' => :solid,
90
+ 'border-left-width' => :zero,
91
+ 'border-radius' => :zero,
92
+ 'border-right' => :none,
93
+ 'border-right-color' => :transparent,
94
+ 'border-right-style' => :solid,
95
+ 'border-right-width' => :zero,
96
+ 'border-spacing' => :inherit,
97
+ 'border-style' => :solid,
98
+ 'border-top' => :none,
99
+ 'border-top-color' => :transparent,
100
+ 'border-top-left-radius' => :zero,
101
+ 'border-top-right-radius' => :zero,
102
+ 'border-top-style' => :solid,
103
+ 'border-top-width' => :zero,
104
+ 'border-width' => :zero,
105
+ 'bottom' => :auto,
106
+ 'box-align' => :stretch,
107
+ 'box-direction' => :normal,
108
+ 'box-flex' => :zero,
109
+ 'box-flex-group' => :one,
110
+ 'box-lines' => :single,
111
+ 'box-ordinal-group' => :one,
112
+ 'box-orient' => :inline_axis,
113
+ 'box-pack' => :start,
114
+ 'box-shadow' => :none,
115
+ 'box-sizing' => :content_box,
116
+ 'caption-side' => :top,
117
+ 'clear' => :none,
118
+ 'clip' => :auto,
119
+ 'color' => :inherit,
120
+ 'column-count' => :auto,
121
+ 'column-fill' => :balance,
122
+ 'column-gap' => :normal,
123
+ 'column-rule' => [:medium, :none, :black],
124
+ 'column-rule-color' => :black,
125
+ 'column-rule-style' => :none,
126
+ 'column-rule-width' => :width,
127
+ 'column-span' => :one,
128
+ 'column-width' => :auto,
129
+ 'columns' => [:auto, :auto],
130
+ 'content' => :normal,
131
+ 'counter-increment' => :none,
132
+ 'counter-reset' => :none,
133
+ 'cursor' => :auto,
134
+ 'direction' => :ltr,
135
+ 'display' => :inline,
136
+ 'empty-cells' => :show,
137
+ 'float' => :none,
138
+ 'font' => :inherit,
139
+ 'font-family' => :inherit,
140
+ 'font-size' => :inherit,
141
+ 'font-size-adjust' => :inherit,
142
+ 'font-stretch' => :inherit,
143
+ 'font-style' => :inherit,
144
+ 'font-variant' => :inherit,
145
+ 'font-weight' => :inherit,
146
+ 'grid-columns' => :none,
147
+ 'grid-rows' => :none,
148
+ 'hanging-punctuation' => :none,
149
+ 'height' => :auto,
150
+ 'icon' => :auto,
151
+ 'left' => :auto,
152
+ 'letter-spacing' => :normal,
153
+ 'line-height' => :normal,
154
+ 'list-style' => [:disc, :outside, :none],
155
+ 'list-style-image' => :none,
156
+ 'list-style-position' => :outside,
157
+ 'list-style-type' => :disc,
158
+ 'margin' => :zero,
159
+ 'margin-bottom' => :zero,
160
+ 'margin-left' => :zero,
161
+ 'margin-right' => :zero,
162
+ 'margin-top' => :zero,
163
+ 'max-height' => :none,
164
+ 'max-width' => :none,
165
+ 'min-height' => :none,
166
+ 'min-width' => :none,
167
+ 'nav-down' => :auto,
168
+ 'nav-index' => :auto,
169
+ 'nav-left' => :auto,
170
+ 'nav-right' => :auto,
171
+ 'nav-up' => :auto,
172
+ 'opacity' => :one,
173
+ 'outline' => [:invert, :none, :medium],
174
+ 'outline-color' => :invert,
175
+ 'outline-offset' => :zero,
176
+ 'outline-style' => :none,
177
+ 'outline-width' => :medium,
178
+ 'overflow' => :visible,
179
+ 'overflow-x' => :visible,
180
+ 'overflow-y' => :visible,
181
+ 'padding' => :zero,
182
+ 'padding-bottom' => :zero,
183
+ 'padding-left' => :zero,
184
+ 'padding-right' => :zero,
185
+ 'padding-top' => :zero,
186
+ 'page-break-after' => :auto,
187
+ 'page-break-before' => :auto,
188
+ 'page-break-inside' => :auto,
189
+ 'perspective' => :none,
190
+ 'perspective-origin' => [:p50, :p50],
191
+ 'position' => :static,
192
+ 'punctuation-trim' => :none,
193
+ 'quotes' => :inherit,
194
+ 'resize' => :none,
195
+ 'right' => :auto,
196
+ 'rotation' => :zero,
197
+ 'rotation-point' => [:p50, :p50],
198
+ 'table-layout' => :auto,
199
+ 'target' => [:current, :window, :above],
200
+ 'target-name' => :current,
201
+ 'target-new' => :window,
202
+ 'target-position' => :above,
203
+ 'text-align' => :left,
204
+ 'text-decoration' => :none,
205
+ 'text-indent' => :zero,
206
+ 'text-justify' => :auto,
207
+ 'text-outline' => :none,
208
+ 'text-overflow' => :clip,
209
+ 'text-shadow' => :none,
210
+ 'text-transform' => :none,
211
+ 'text-wrap' => :normal,
212
+ 'top' => :auto,
213
+ 'transform' => :none,
214
+ 'transform-origin' => [:p50, :p50, :zero],
215
+ 'transform-style' => :flat,
216
+ 'transition' => [:all, :zero, :ease, :zero],
217
+ 'transition-delay' => :zero,
218
+ 'transition-duration' => :zero,
219
+ 'transition-property' => :all,
220
+ 'transition-timing-function' => :ease,
221
+ 'unicode-bidi' => :normal,
222
+ 'vertical-align' => :baseline,
223
+ 'visibility' => :visible,
224
+ 'white-space' => :normal,
225
+ 'width' => :auto,
226
+ 'word-break' => :normal,
227
+ 'word-spacing' => :normal,
228
+ 'word-wrap' => :normal,
229
+ 'z-index' => :zero,
230
+ # archetype custom properties...
231
+ 'ie-filter' => :none,
232
+ 'border-top-radius' => :zero,
233
+ 'border-right-radius' => :zero,
234
+ 'border-bottom-radius' => :zero,
235
+ 'border-left-radius' => :zero
236
+ }
237
+
238
+ private
239
+
240
+ R_TIMING_FUNCTION = /^(?:linear|ease|ease-in|ease-out|ease-in-out|step-start|step-stop|steps\(.*\)|cubic-bezier\(.*\)|)$/
241
+ RS_BORDER_POSITION = '(-(?:top|right|bottom|left))'
242
+ RS_BORDER_TYPE = '(-(?:color|width|style))'
243
+ R_BORDER_STD = /^border#{RS_BORDER_POSITION}?#{RS_BORDER_TYPE}?$/
244
+ R_BORDER_SHORTHANDS = /^border#{RS_BORDER_POSITION}?$/
245
+ R_BORDER_IMG_OR_RADIUS = /(image|radius)/
246
+
247
+ end