compass-core-sass37 1.1.0

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 (147) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +22 -0
  3. data/VERSION +1 -0
  4. data/data/caniuse.json +1 -0
  5. data/data/caniuse_extras/css-placeholder.json +171 -0
  6. data/lib/compass/browser_support.rb +64 -0
  7. data/lib/compass/configuration/adapters.rb +109 -0
  8. data/lib/compass/configuration/data.rb +199 -0
  9. data/lib/compass/configuration/defaults.rb +207 -0
  10. data/lib/compass/configuration/inheritance.rb +307 -0
  11. data/lib/compass/configuration/paths.rb +19 -0
  12. data/lib/compass/configuration/watch.rb +38 -0
  13. data/lib/compass/configuration.rb +175 -0
  14. data/lib/compass/core/caniuse.rb +314 -0
  15. data/lib/compass/core/generated_version.rb +6 -0
  16. data/lib/compass/core/sass_extensions/functions/colors.rb +67 -0
  17. data/lib/compass/core/sass_extensions/functions/configuration.rb +173 -0
  18. data/lib/compass/core/sass_extensions/functions/constants.rb +56 -0
  19. data/lib/compass/core/sass_extensions/functions/cross_browser_support.rb +270 -0
  20. data/lib/compass/core/sass_extensions/functions/display.rb +32 -0
  21. data/lib/compass/core/sass_extensions/functions/enumerate.rb +7 -0
  22. data/lib/compass/core/sass_extensions/functions/env.rb +72 -0
  23. data/lib/compass/core/sass_extensions/functions/files.rb +33 -0
  24. data/lib/compass/core/sass_extensions/functions/font_files.rb +65 -0
  25. data/lib/compass/core/sass_extensions/functions/gradient_support.rb +859 -0
  26. data/lib/compass/core/sass_extensions/functions/image_size.rb +117 -0
  27. data/lib/compass/core/sass_extensions/functions/inline_image.rb +63 -0
  28. data/lib/compass/core/sass_extensions/functions/lists.rb +102 -0
  29. data/lib/compass/core/sass_extensions/functions/math.rb +105 -0
  30. data/lib/compass/core/sass_extensions/functions/selectors.rb +79 -0
  31. data/lib/compass/core/sass_extensions/functions/urls.rb +315 -0
  32. data/lib/compass/core/sass_extensions/functions.rb +41 -0
  33. data/lib/compass/core/sass_extensions/monkey_patches/browser_support.rb +119 -0
  34. data/lib/compass/core/sass_extensions/monkey_patches/traversal.rb +23 -0
  35. data/lib/compass/core/sass_extensions/monkey_patches.rb +3 -0
  36. data/lib/compass/core/sass_extensions.rb +10 -0
  37. data/lib/compass/core/version.rb +13 -0
  38. data/lib/compass/core.rb +78 -0
  39. data/lib/compass/error.rb +5 -0
  40. data/lib/compass/frameworks.rb +181 -0
  41. data/lib/compass/util.rb +19 -0
  42. data/lib/compass-core.rb +1 -0
  43. data/stylesheets/_compass.scss +3 -0
  44. data/stylesheets/_lemonade.scss +38 -0
  45. data/stylesheets/compass/_configuration.scss +54 -0
  46. data/stylesheets/compass/_css3.scss +21 -0
  47. data/stylesheets/compass/_layout.scss +3 -0
  48. data/stylesheets/compass/_reset-legacy.scss +3 -0
  49. data/stylesheets/compass/_reset.scss +3 -0
  50. data/stylesheets/compass/_support.scss +447 -0
  51. data/stylesheets/compass/_typography.scss +4 -0
  52. data/stylesheets/compass/_utilities.scss +9 -0
  53. data/stylesheets/compass/css3/_animation.scss +122 -0
  54. data/stylesheets/compass/css3/_appearance.scss +17 -0
  55. data/stylesheets/compass/css3/_background-clip.scss +35 -0
  56. data/stylesheets/compass/css3/_background-origin.scss +37 -0
  57. data/stylesheets/compass/css3/_background-size.scss +19 -0
  58. data/stylesheets/compass/css3/_border-radius.scss +107 -0
  59. data/stylesheets/compass/css3/_box-shadow.scss +88 -0
  60. data/stylesheets/compass/css3/_box-sizing.scss +21 -0
  61. data/stylesheets/compass/css3/_box.scss +85 -0
  62. data/stylesheets/compass/css3/_columns.scss +212 -0
  63. data/stylesheets/compass/css3/_deprecated-support.scss +272 -0
  64. data/stylesheets/compass/css3/_filter.scss +50 -0
  65. data/stylesheets/compass/css3/_flexbox.scss +156 -0
  66. data/stylesheets/compass/css3/_font-face.scss +48 -0
  67. data/stylesheets/compass/css3/_hyphenation.scss +71 -0
  68. data/stylesheets/compass/css3/_images.scss +152 -0
  69. data/stylesheets/compass/css3/_inline-block.scss +31 -0
  70. data/stylesheets/compass/css3/_opacity.scss +27 -0
  71. data/stylesheets/compass/css3/_pie.scss +1 -0
  72. data/stylesheets/compass/css3/_regions.scss +27 -0
  73. data/stylesheets/compass/css3/_selection.scss +59 -0
  74. data/stylesheets/compass/css3/_shared.scss +5 -0
  75. data/stylesheets/compass/css3/_text-shadow.scss +82 -0
  76. data/stylesheets/compass/css3/_transform.scss +590 -0
  77. data/stylesheets/compass/css3/_transition.scss +190 -0
  78. data/stylesheets/compass/css3/_user-interface.scss +71 -0
  79. data/stylesheets/compass/layout/_grid-background.scss +178 -0
  80. data/stylesheets/compass/layout/_sticky-footer.scss +23 -0
  81. data/stylesheets/compass/layout/_stretching.scss +24 -0
  82. data/stylesheets/compass/reset/_utilities-legacy.scss +135 -0
  83. data/stylesheets/compass/reset/_utilities.scss +142 -0
  84. data/stylesheets/compass/typography/_links.scss +3 -0
  85. data/stylesheets/compass/typography/_lists.scss +4 -0
  86. data/stylesheets/compass/typography/_text.scss +4 -0
  87. data/stylesheets/compass/typography/_units.scss +183 -0
  88. data/stylesheets/compass/typography/_vertical_rhythm.scss +300 -0
  89. data/stylesheets/compass/typography/links/_hover-link.scss +5 -0
  90. data/stylesheets/compass/typography/links/_link-colors.scss +28 -0
  91. data/stylesheets/compass/typography/links/_unstyled-link.scss +7 -0
  92. data/stylesheets/compass/typography/lists/_bullets.scss +34 -0
  93. data/stylesheets/compass/typography/lists/_horizontal-list.scss +63 -0
  94. data/stylesheets/compass/typography/lists/_inline-block-list.scss +50 -0
  95. data/stylesheets/compass/typography/lists/_inline-list.scss +47 -0
  96. data/stylesheets/compass/typography/text/_ellipsis.scss +25 -0
  97. data/stylesheets/compass/typography/text/_force-wrap.scss +12 -0
  98. data/stylesheets/compass/typography/text/_nowrap.scss +2 -0
  99. data/stylesheets/compass/typography/text/_replacement.scss +74 -0
  100. data/stylesheets/compass/utilities/_color.scss +1 -0
  101. data/stylesheets/compass/utilities/_general.scss +6 -0
  102. data/stylesheets/compass/utilities/_links.scss +5 -0
  103. data/stylesheets/compass/utilities/_lists.scss +6 -0
  104. data/stylesheets/compass/utilities/_print.scss +17 -0
  105. data/stylesheets/compass/utilities/_sass.scss +2 -0
  106. data/stylesheets/compass/utilities/_sprites.scss +2 -0
  107. data/stylesheets/compass/utilities/_tables.scss +3 -0
  108. data/stylesheets/compass/utilities/_text.scss +5 -0
  109. data/stylesheets/compass/utilities/color/_brightness.scss +20 -0
  110. data/stylesheets/compass/utilities/color/_contrast.scss +52 -0
  111. data/stylesheets/compass/utilities/general/_clearfix.scss +44 -0
  112. data/stylesheets/compass/utilities/general/_float.scss +38 -0
  113. data/stylesheets/compass/utilities/general/_hacks.scss +65 -0
  114. data/stylesheets/compass/utilities/general/_min.scss +16 -0
  115. data/stylesheets/compass/utilities/general/_reset.scss +2 -0
  116. data/stylesheets/compass/utilities/general/_tabs.scss +1 -0
  117. data/stylesheets/compass/utilities/general/_tag-cloud.scss +18 -0
  118. data/stylesheets/compass/utilities/links/_hover-link.scss +3 -0
  119. data/stylesheets/compass/utilities/links/_link-colors.scss +3 -0
  120. data/stylesheets/compass/utilities/links/_unstyled-link.scss +3 -0
  121. data/stylesheets/compass/utilities/lists/_bullets.scss +3 -0
  122. data/stylesheets/compass/utilities/lists/_horizontal-list.scss +3 -0
  123. data/stylesheets/compass/utilities/lists/_inline-block-list.scss +3 -0
  124. data/stylesheets/compass/utilities/lists/_inline-list.scss +3 -0
  125. data/stylesheets/compass/utilities/sass/_lists.scss +16 -0
  126. data/stylesheets/compass/utilities/sass/_maps.scss +19 -0
  127. data/stylesheets/compass/utilities/sprites/_base.scss +92 -0
  128. data/stylesheets/compass/utilities/sprites/_sprite-img.scss +81 -0
  129. data/stylesheets/compass/utilities/tables/_alternating-rows-and-columns.scss +22 -0
  130. data/stylesheets/compass/utilities/tables/_borders.scss +38 -0
  131. data/stylesheets/compass/utilities/tables/_scaffolding.scss +9 -0
  132. data/stylesheets/compass/utilities/text/_ellipsis.scss +3 -0
  133. data/stylesheets/compass/utilities/text/_nowrap.scss +3 -0
  134. data/stylesheets/compass/utilities/text/_replacement.scss +3 -0
  135. data/templates/ellipsis/ellipsis.sass +9 -0
  136. data/templates/ellipsis/manifest.rb +27 -0
  137. data/templates/ellipsis/xml/ellipsis.xml +14 -0
  138. data/templates/extension/manifest.rb +26 -0
  139. data/templates/extension/stylesheets/main.sass +1 -0
  140. data/templates/extension/templates/project/manifest.rb +2 -0
  141. data/templates/extension/templates/project/screen.sass +2 -0
  142. data/templates/project/USAGE.markdown +32 -0
  143. data/templates/project/ie.sass +6 -0
  144. data/templates/project/manifest.rb +4 -0
  145. data/templates/project/print.sass +6 -0
  146. data/templates/project/screen.sass +7 -0
  147. metadata +257 -0
@@ -0,0 +1,173 @@
1
+ require 'pathname'
2
+ module Compass::Core::SassExtensions::Functions::Configuration
3
+ extend Compass::Core::SassExtensions::Functions::SassDeclarationHelper
4
+
5
+ # Users who need to support windows and unix paths in their configuration
6
+ # should construct them with this helper function.
7
+ def join_file_segments(*segments)
8
+ quoted_string(File.join(*segments.map{|s| assert_type s, :String; s.value}))
9
+ end
10
+ declare :absolute_path, [], :var_args => true
11
+
12
+ # Returns an absolute path for the path relative to the sass file it was called from.
13
+ def absolute_path(relative_path)
14
+ quoted_string(File.expand_path(File.join(File.dirname(options[:filename]), relative_path.value)))
15
+ end
16
+ declare :absolute_path, [:relative_path]
17
+
18
+ # split a file into directory, basename, and extension
19
+ def split_filename(path)
20
+ pathname = Pathname.new(path.value)
21
+ list(quoted_string(pathname.dirname.to_s),
22
+ quoted_string(pathname.basename(pathname.extname).to_s),
23
+ quoted_string(pathname.extname.to_s),
24
+ :space)
25
+ end
26
+ declare :split_filename, [:path]
27
+
28
+ # Returns true if the compass compiler is compiling this stylesheet.
29
+ def using_compass_compiler
30
+ bool(options[:compass] && options[:compass][:compiler_in_use])
31
+ end
32
+ declare :using_compass_compiler, []
33
+
34
+ def reset_configuration()
35
+ Compass.reset_configuration!
36
+ null()
37
+ end
38
+ declare :reset_configuration, []
39
+
40
+ def add_sass_configuration(project_path)
41
+ css_location = template_location = nil
42
+ if options[:template_location] && options[:template_location].is_a?(Array)
43
+ css_location = File.expand_path(options[:template_location].first.last)
44
+ template_location = File.expand_path(options[:template_location].first.first)
45
+ else
46
+ css_location = File.expand_path(options[:css_location]) if options[:css_location]
47
+ template_location = File.expand_path(options[:template_location]) if options[:template_location]
48
+ end
49
+ original_filename = File.expand_path(options[:original_filename]) if options[:original_filename]
50
+ project_path = if project_path.value.nil?
51
+ if css_location && template_location
52
+ common_parent_directory(css_location, template_location)
53
+ end
54
+ else
55
+ project_path.value
56
+ end
57
+ config = {
58
+ :project_path => project_path,
59
+ :cache => options[:cache],
60
+ :additional_import_paths => options[:load_paths],
61
+ :line_comments => options[:line_comments]
62
+ }
63
+ unless options[:quiet].nil?
64
+ config.update(:disable_warnings => options[:quiet])
65
+ end
66
+ if project_path && css_location && (css_dir = relative_path_from(css_location, project_path))
67
+ config.update(:css_dir => css_dir)
68
+ elsif css_location
69
+ config.update(:css_path => css_location)
70
+ end
71
+ if project_path && template_location && (sass_dir = relative_path_from(template_location, project_path))
72
+ config.update(:sass_dir => sass_dir)
73
+ elsif template_location
74
+ config.update(:css_path => template_location)
75
+ end
76
+ config_name = "Sass Defaults: #{project_path ? relative_path_from(original_filename, project_path) : original_filename}"
77
+ Compass.add_configuration(Compass::Configuration::Data.new(config_name, config))
78
+ update_sass_options!
79
+ null
80
+ rescue => e
81
+ puts e.backtrace.join("\n")
82
+ raise
83
+ end
84
+ declare :add_sass_configuration, [:project_path]
85
+
86
+ OPTION_TRANSFORMER = Hash.new() {|h, k| proc {|v, ctx| v.value } }
87
+ OPTION_TRANSFORMER[:asset_cache_buster] = proc do |v, ctx|
88
+ proc do |url, file|
89
+ if ctx.environment.function(v.value) || Sass::Script::Functions.callable?(v.value.tr('-', '_'))
90
+ # Sass 3.5+: Use get_function() instead of passing string to call()
91
+ fn = ctx.get_function(v)
92
+ result = ctx.call(fn, ctx.quoted_string(url),
93
+ file.nil? ? ctx.null() : ctx.quoted_string(file.path))
94
+ case result
95
+ when Sass::Script::Value::String, Sass::Script::Value::Null
96
+ result.value
97
+ else
98
+ ctx.assert_type(result, :Map)
99
+ result.value.keys.inject({}) do |r, k|
100
+ ctx.assert_type k, :String
101
+ ctx.assert_type(result.value[k], :String) unless result.value[k].value.nil?
102
+ if k.value == "path" || k.value == "query"
103
+ r[k.value.to_sym] = result.value[k].value
104
+ end
105
+ r
106
+ end
107
+ end
108
+ else
109
+ raise ArgumentError, "#{v.value} is not a function."
110
+ end
111
+ end
112
+ end
113
+ OPTION_TRANSFORMER[:asset_host] = proc do |v, ctx|
114
+ proc do |file|
115
+ if ctx.environment.function(v.value) || Sass::Script::Functions.callable?(v.value.tr('-', '_'))
116
+ # Sass 3.5+: Use get_function() instead of passing string to call()
117
+ fn = ctx.get_function(v)
118
+ result = ctx.call(fn, ctx.quoted_string(file))
119
+ case result
120
+ when Sass::Script::Value::String, Sass::Script::Value::Null
121
+ result.value
122
+ else
123
+ ctx.assert_type(result, :String)
124
+ end
125
+ else
126
+ raise ArgumentError, "#{v.value} is not a function."
127
+ end
128
+ end
129
+ end
130
+
131
+ def add_configuration(options)
132
+ attributes = {}
133
+ options.value.keys.each do |key|
134
+ underscored = key.value.to_s.tr("-", "_")
135
+ unless runtime_writable_attributes.find{|a| a.to_s == underscored}
136
+ raise ArgumentError, "#{key} is not a valid configuration option."
137
+ end
138
+ underscored = underscored.to_sym
139
+ attributes[underscored] = OPTION_TRANSFORMER[underscored].call(options.value[key], self)
140
+ end
141
+ name = "#{options.source_range.file}:#{options.source_range.start_pos.line}"
142
+ Compass.add_configuration(Compass::Configuration::Data.new(name, attributes))
143
+ update_sass_options!
144
+ null
145
+ end
146
+ declare :add_configuration, [:options]
147
+
148
+ private
149
+
150
+ def runtime_writable_attributes
151
+ Compass::Configuration::ATTRIBUTES - Compass::Configuration::RUNTIME_READONLY_ATTRIBUTES
152
+ end
153
+
154
+ def common_parent_directory(directory1, directory2)
155
+ relative = Pathname.new(directory1).relative_path_from(Pathname.new(directory2))
156
+ File.expand_path(directory2, relative.to_s.scan("..#{File::SEPARATOR}").join)
157
+ end
158
+
159
+ def relative_path_from(directory1, directory2)
160
+ Pathname.new(directory1).relative_path_from(Pathname.new(directory2)).to_s
161
+ end
162
+
163
+ def update_sass_options!
164
+ Compass.configuration.additional_import_paths.each do |lp|
165
+ options[:load_paths] << lp unless options[:load_paths].include?(lp)
166
+ end
167
+ if Compass.configuration.disable_warnings
168
+ Sass.logger.log_level = :error
169
+ else
170
+ Sass.logger.log_level = :warn
171
+ end
172
+ end
173
+ end
@@ -0,0 +1,56 @@
1
+ module Compass::Core::SassExtensions::Functions::Constants
2
+ POSITIONS = /top|bottom|left|right|center/
3
+ def is_position(position)
4
+ bool(position.is_a?(Sass::Script::Value::String) && !!(position.value =~ POSITIONS))
5
+ end
6
+ def is_position_list(position_list)
7
+ bool(position_list.is_a?(Sass::Script::Value::List) && position_list.value.all?{|p| is_position(p).to_bool})
8
+ end
9
+ # returns the opposite position of a side or corner.
10
+ def opposite_position(position)
11
+ position = unless position.is_a?(Sass::Script::Value::List)
12
+ list(position, :space)
13
+ else
14
+ list(position.value.dup, position.separator)
15
+ end
16
+ position = list(position.value.map do |pos|
17
+ if pos.is_a? Sass::Script::Value::String
18
+ opposite = case pos.value
19
+ when "top" then "bottom"
20
+ when "bottom" then "top"
21
+ when "left" then "right"
22
+ when "right" then "left"
23
+ when "center" then "center"
24
+ else
25
+ Compass::Util.compass_warn("Cannot determine the opposite position of: #{pos}")
26
+ pos.value
27
+ end
28
+ identifier(opposite)
29
+ elsif pos.is_a? Sass::Script::Value::Number
30
+ if pos.numerator_units == ["%"] && pos.denominator_units == []
31
+ number(100-pos.value, "%")
32
+ else
33
+ Compass::Util.compass_warn("Cannot determine the opposite position of: #{pos}")
34
+ pos
35
+ end
36
+ else
37
+ Compass::Util.compass_warn("Cannot determine the opposite position of: #{pos}")
38
+ pos
39
+ end
40
+ end, position.separator)
41
+ if position.value.size == 1
42
+ position.value.first
43
+ else
44
+ position
45
+ end
46
+ end
47
+
48
+ def is_url(string)
49
+ if string.is_a?(Sass::Script::Value::String)
50
+ is_url = !!(string.value =~ /^url\(.*\)$/)
51
+ bool(is_url)
52
+ else
53
+ bool(false)
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,270 @@
1
+ module Compass::Core::SassExtensions::Functions::CrossBrowserSupport
2
+ extend Compass::Core::SassExtensions::Functions::SassDeclarationHelper
3
+
4
+ class CSS2FallbackValue < Sass::Script::Value::Base
5
+ attr_accessor :value, :css2_value
6
+ def children
7
+ [value, css2_value]
8
+ end
9
+ def initialize(value, css2_value)
10
+ self.value = value
11
+ self.css2_value = css2_value
12
+ end
13
+ def inspect
14
+ to_s
15
+ end
16
+ def to_s(options = self.options)
17
+ value.to_s(options)
18
+ end
19
+ def supports?(aspect)
20
+ aspect == "css2"
21
+ end
22
+ def has_aspect?
23
+ true
24
+ end
25
+ def to_css2(options = self.options)
26
+ css2_value
27
+ end
28
+ end
29
+
30
+ # Check if any of the arguments passed require a vendor prefix.
31
+ def prefixed(prefix, *args)
32
+ assert_type prefix, :String
33
+ aspect = prefix.value.sub(/^-/,"")
34
+ needed = args.any?{|a| a.respond_to?(:supports?) && a.supports?(aspect)}
35
+ bool(needed)
36
+ end
37
+
38
+ %w(webkit moz o ms svg css2 owg).each do |prefix|
39
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
40
+ # Syntactic sugar to apply the given prefix
41
+ # -moz($arg) is the same as calling prefix(-moz, $arg)
42
+ def _#{prefix}(*args)
43
+ prefix("#{prefix}", *args)
44
+ end
45
+ RUBY
46
+ end
47
+
48
+ def prefix(prefix, *objects)
49
+ assert_type prefix, :String if prefix.is_a?(Sass::Script::Value::Base)
50
+ prefix = prefix.value if prefix.is_a?(Sass::Script::Value::String)
51
+ prefix = prefix[1..-1] if prefix[0] == ?-
52
+ if objects.size > 1
53
+ self.prefix(prefix, list(objects, :comma))
54
+ else
55
+ object = objects.first
56
+ if object.is_a?(Sass::Script::Value::List)
57
+ list(object.value.map{|e|
58
+ self.prefix(prefix, e)
59
+ }, object.separator)
60
+ elsif object.respond_to?(:supports?) && object.supports?(prefix) && object.respond_to?(:"to_#{prefix}")
61
+ object.options = options
62
+ object.send(:"to_#{prefix}")
63
+ else
64
+ object
65
+ end
66
+ end
67
+ end
68
+
69
+ def css2_fallback(value, css2_value)
70
+ CSS2FallbackValue.new(value, css2_value)
71
+ end
72
+
73
+ # The known browsers.
74
+ #
75
+ # If prefix is given, limits the returned browsers to those using the specified prefix.
76
+ def browsers(prefix = nil)
77
+ browsers = if prefix
78
+ assert_type prefix, :String
79
+ Compass::Core::CanIUse.instance.browsers_with_prefix(prefix.value)
80
+ else
81
+ Compass::Core::CanIUse.instance.browsers
82
+ end
83
+ list(browsers.map{|b| identifier(b)}, :comma)
84
+ end
85
+ declare(:browsers, [])
86
+ declare(:browsers, [:prefix])
87
+
88
+ # The known capabilities of browsers.
89
+ def browser_capabilities
90
+ list(Compass::Core::CanIUse.instance.capabilities.map{|c| identifier(c)}, :comma)
91
+ end
92
+ declare(:browser_capabilities, [])
93
+
94
+ # The versions for the given browser.
95
+ def browser_versions(browser)
96
+ assert_type browser, :String
97
+ list(Compass::Core::CanIUse.instance.versions(browser.value).map{|v| quoted_string(v)}, :comma)
98
+ rescue ArgumentError => e
99
+ raise Sass::SyntaxError.new(e.message)
100
+ end
101
+ declare(:browser_versions, [:browser])
102
+
103
+ # whether the browser uses a prefix for the given capability at the version
104
+ # specified or a later version. Returns the prefix it requires, or null.
105
+ def browser_requires_prefix(browser, version, capability, capability_options)
106
+ assert_type browser, :String
107
+ assert_type version, :String
108
+ assert_type capability, :String
109
+ p = Compass::Core::CanIUse.instance.requires_prefix(browser.value,
110
+ version.value,
111
+ capability.value,
112
+ unbox_capability_options_list(capability_options))
113
+ p ? identifier(p) : null()
114
+ rescue ArgumentError => e
115
+ raise Sass::SyntaxError.new(e.message)
116
+ end
117
+ declare(:browser_requires_prefix, [:browser, :version, :capability])
118
+
119
+ # the prefix for the given browser.
120
+ def browser_prefix(browser, version = nil)
121
+ assert_type browser, :String
122
+ identifier(Compass::Core::CanIUse.instance.prefix(browser.value))
123
+ rescue ArgumentError => e
124
+ raise Sass::SyntaxError.new(e.message)
125
+ end
126
+ declare(:browser_prefix, [:browser])
127
+ declare(:browser_prefix, [:browser, :version])
128
+
129
+ # The prefixes used by the given browsers.
130
+ def browser_prefixes(browsers)
131
+ browsers = list(browsers, :comma) if browsers.is_a?(Sass::Script::Value::String)
132
+ assert_type browsers, :List
133
+ browser_strings = browsers.value.map {|b| assert_type(b, :String); b.value }
134
+ prefix_strings = Compass::Core::CanIUse.instance.prefixes(browser_strings)
135
+ list(prefix_strings.map {|p| identifier(p)}, :comma)
136
+ rescue ArgumentError => e
137
+ raise Sass::SyntaxError.new(e.message)
138
+ end
139
+ declare(:browser_prefixes, [:browsers])
140
+
141
+ # The percent of users that are omitted by setting the min_version of browser
142
+ # as specified.
143
+ def omitted_usage(browser, min_version, max_version = nil)
144
+ assert_type browser, :String
145
+ assert_type min_version, :String, :min_version
146
+ assert_type(max_version, :String, :max_version) if max_version
147
+ versions = [min_version.value]
148
+ versions << max_version.value if max_version
149
+ number(Compass::Core::CanIUse.instance.omitted_usage(browser.value, *versions))
150
+ end
151
+ declare(:omitted_usage, [:browser, :min_version])
152
+ declare(:omitted_usage, [:browser, :min_version, :max_version])
153
+
154
+ # The version before the version for the browser specified
155
+ def previous_version(browser, version)
156
+ assert_type browser, :String
157
+ assert_type version, :String
158
+ previous = Compass::Core::CanIUse.instance.previous_version(browser.value, version.value)
159
+ previous.nil? ? null() : quoted_string(previous)
160
+ end
161
+ declare(:previous_version, [:browser, :version])
162
+
163
+ # The version before the version for the browser specified
164
+ def next_version(browser, version)
165
+ assert_type browser, :String
166
+ assert_type version, :String
167
+ next_version = Compass::Core::CanIUse.instance.next_version(browser.value, version.value)
168
+ next_version.nil? ? null() : quoted_string(next_version)
169
+ end
170
+ declare(:next_version, [:browser, :version])
171
+
172
+ # The percent of users relying on a particular prefix
173
+ def prefix_usage(prefix, capability, capability_options)
174
+ assert_type prefix, :String
175
+ assert_type capability, :String
176
+ number(Compass::Core::CanIUse.instance.prefixed_usage(prefix.value,
177
+ capability.value,
178
+ unbox_capability_options_list(capability_options)))
179
+ rescue ArgumentError => e
180
+ raise Sass::SyntaxError.new(e.message)
181
+ end
182
+ declare(:prefix_usage, [:prefix, :capability])
183
+
184
+ # Compares two browser versions. Returning:
185
+ #
186
+ # * 0 if they are the same
187
+ # * <0 if the first version is less than the second
188
+ # * >0 if the first version is more than the second
189
+ def compare_browser_versions(browser, version1, version2)
190
+ assert_type browser, :String, :browser
191
+ assert_type version1, :String, :version1
192
+ assert_type version2, :String, :version2
193
+ index1 = index2 = nil
194
+ Compass::Core::CanIUse.instance.versions(browser.value).each_with_index do |v, i|
195
+ index1 = i if v == version1.value
196
+ index2 = i if v == version2.value
197
+ break if index1 && index2
198
+ end
199
+ unless index1
200
+ raise Sass::SyntaxError.new("#{version1} is not a version for #{browser}")
201
+ end
202
+ unless index2
203
+ raise Sass::SyntaxError.new("#{version2} is not a version for #{browser}")
204
+ end
205
+ number(index1 <=> index2)
206
+ end
207
+ declare(:compare_browser_versions, [:browser, :version1, :version2])
208
+
209
+ # Returns a map of browsers to the first version the capability became available
210
+ # without a prefix.
211
+ #
212
+ # If a prefix is provided, only those browsers using that prefix will be returned
213
+ # and the minimum version will be when it first became available as a prefix or
214
+ # without a prefix.
215
+ #
216
+ # If a browser does not have the capability, it will not included in the map.
217
+ def browser_ranges(capability, prefix = null(), include_unprefixed_versions = bool(true))
218
+ assert_type capability, :String
219
+ assert_type(prefix, :String) unless prefix == null()
220
+ mins = Compass::Core::CanIUse.instance.browser_ranges(capability.value,
221
+ prefix.value,
222
+ include_unprefixed_versions.to_bool)
223
+ Sass::Script::Value::Map.new(mins.inject({}) do |m, (h, range)|
224
+ m[identifier(h)] = list(range.map{|version| quoted_string(version)}, :space)
225
+ m
226
+ end)
227
+ end
228
+ declare(:browser_minimums, [:capability])
229
+ declare(:browser_minimums, [:capability, :prefix])
230
+
231
+ private
232
+
233
+ def unbox_capability_options_list(capability_options_list)
234
+ if capability_options_list.is_a?(Sass::Script::Value::Map)
235
+ [unbox_capability_options(capability_options_list)]
236
+ elsif capability_options_list.is_a?(Sass::Script::Value::List)
237
+ capability_options_list.to_a.map{|opts| unbox_capability_options(opts) }
238
+ else
239
+ assert_type capability_options_list, :List
240
+ end
241
+ end
242
+
243
+ CAPABILITY_OPTION_KEYS = {
244
+ "full-support" => :full_support,
245
+ "partial-support" => :partial_support,
246
+ "prefixed" => :prefixed,
247
+ "spec-versions" => :spec_versions,
248
+ }
249
+
250
+ CAPABILITY_OPTION_UNBOXER = {
251
+ :full_support => lambda {|v| v.to_bool },
252
+ :partial_support => lambda {|v| v.to_bool },
253
+ :prefixed => lambda {|v| v.to_bool },
254
+ :spec_versions => lambda {|versions| versions.to_a.map {|v| v.value } }
255
+ }
256
+
257
+ def unbox_capability_options(capability_options)
258
+ assert_type capability_options, :Map
259
+ result = {}
260
+ capability_options.value.each do |k, v|
261
+ assert_type k, :String
262
+ key = CAPABILITY_OPTION_KEYS[k.value]
263
+ unless key
264
+ raise Sass::SyntaxError, "#{k} is not valid capability option"
265
+ end
266
+ result[key] = CAPABILITY_OPTION_UNBOXER[key].call(v)
267
+ end
268
+ result
269
+ end
270
+ end
@@ -0,0 +1,32 @@
1
+ module Compass::Core::SassExtensions::Functions::Display
2
+ DEFAULT_DISPLAY = {
3
+ "block" => %w{address article aside blockquote center dir div dd details dl dt fieldset
4
+ figcaption figure form footer frameset h1 h2 h3 h4 h5 h6 hr header hgroup
5
+ isindex main menu nav noframes noscript ol p pre section summary ul},
6
+ "inline" => %w{a abbr acronym audio b basefont bdo big br canvas cite code command
7
+ datalist dfn em embed font i img input keygen kbd label mark meter output
8
+ progress q rp rt ruby s samp select small span strike strong sub
9
+ sup textarea time tt u var video wbr},
10
+ "inline-block" => %w{img},
11
+ "table" => %w{table},
12
+ "list-item" => %w{li},
13
+ "table-row-group" => %w{tbody},
14
+ "table-header-group" => %w{thead},
15
+ "table-footer-group" => %w{tfoot},
16
+ "table-row" => %w{tr},
17
+ "table-cell" => %w{th td},
18
+ "html5-block" => %w{article aside details figcaption figure footer header hgroup main menu nav
19
+ section summary},
20
+ "html5-inline" => %w{audio canvas command datalist embed keygen mark meter output progress rp
21
+ rt ruby time video wbr},
22
+ "text-input" => %w{input textarea}
23
+ }
24
+
25
+ DEFAULT_DISPLAY["html5"] = (DEFAULT_DISPLAY["html5-block"] + DEFAULT_DISPLAY["html5-inline"]).sort.uniq
26
+
27
+ # returns a comma delimited string for all the
28
+ # elements according to their default css3 display value.
29
+ def elements_of_type(display)
30
+ identifier(DEFAULT_DISPLAY.fetch(display.value.to_s).join(", "))
31
+ end
32
+ end
@@ -0,0 +1,7 @@
1
+ module Compass::Core::SassExtensions::Functions::Enumerate
2
+ def enumerate(prefix, from, through, separator = nil)
3
+ separator ||= identifier("-")
4
+ selectors = (from.value..through.value).map{|i| "#{prefix.value}#{separator.value}#{i}"}.join(", ")
5
+ identifier(selectors)
6
+ end
7
+ end
@@ -0,0 +1,72 @@
1
+ module Compass::Core::SassExtensions::Functions::Env
2
+ extend Compass::Core::SassExtensions::Functions::SassDeclarationHelper
3
+ extend Sass::Script::Value::Helpers
4
+
5
+ def compass_env
6
+ compass_opts = options[:compass] || {}
7
+ identifier((compass_opts[:environment] || "development").to_s)
8
+ end
9
+ declare :compass_env, []
10
+
11
+ DEFAULT_TIME = identifier("%T%:z")
12
+ def current_time(format = DEFAULT_TIME)
13
+ assert_type format, :String
14
+ identifier(Time.now.strftime(format.value))
15
+ end
16
+ declare :current_time, []
17
+ declare :current_time, [:format]
18
+
19
+ DEFAULT_DATE = identifier("%F")
20
+ def current_date(format = DEFAULT_DATE)
21
+ current_time(format)
22
+ end
23
+ declare :current_date, []
24
+ declare :current_date, [:format]
25
+
26
+ NOT_ABSOLUTE = bool(false)
27
+ def current_source_file(absolute = NOT_ABSOLUTE)
28
+ if absolute.to_bool
29
+ identifier(options[:original_filename].to_s)
30
+ else
31
+ filename = Pathname.new(options[:original_filename].to_s)
32
+ sass_path = Pathname.new(Compass.configuration.sass_path)
33
+ relative_filename = filename.relative_path_from(sass_path).to_s rescue filename
34
+ identifier(relative_filename.to_s)
35
+ end
36
+ end
37
+ declare :current_source_file, []
38
+ declare :current_source_file, [:absolute]
39
+
40
+ def current_output_file(absolute = NOT_ABSOLUTE)
41
+ if absolute.to_bool
42
+ identifier(options[:css_filename].to_s)
43
+ else
44
+ filename = Pathname.new(options[:css_filename].to_s)
45
+ css_path = Pathname.new(Compass.configuration.css_path)
46
+ relative_filename = filename.relative_path_from(css_path).to_s rescue filename
47
+ identifier(relative_filename.to_s)
48
+ end
49
+ end
50
+ declare :current_output_file, []
51
+ declare :current_output_file, [:absolute]
52
+
53
+ def compass_extensions
54
+ # Sass::Util.ordered_hash was removed in Sass 3.7
55
+ # Ruby 1.9+ hashes maintain insertion order, so we can use a regular Hash
56
+ exts = {identifier("compass") => quoted_string(Compass::Core::VERSION)}
57
+ if defined?(Compass::Frameworks::ALL)
58
+ Compass::Frameworks::ALL.each do |framework|
59
+ next if framework.name == "compass"
60
+ exts[identifier(framework.name)] =
61
+ framework.version ? quoted_string(framework.version) : bool(true);
62
+ end
63
+ end
64
+ map(exts)
65
+ end
66
+ declare :compass_extensions, []
67
+
68
+ def at_stylesheet_root
69
+ bool(environment.selector.nil?)
70
+ end
71
+ declare :at_stylesheet_root, []
72
+ end
@@ -0,0 +1,33 @@
1
+ require 'digest/md5'
2
+
3
+ module Compass::Core::SassExtensions::Functions::Files
4
+ extend Compass::Core::SassExtensions::Functions::SassDeclarationHelper
5
+ extend Sass::Script::Value::Helpers
6
+
7
+ def md5sum(file, format = nil)
8
+ assert_type file, :String
9
+ filename = nil
10
+ if options[:css_filename] && File.exist?(options[:css_filename])
11
+ filename = File.expand_path(file.value, File.dirname(options[:css_filename]))
12
+ elsif Pathname.new(file.value).absolute?
13
+ filename = file.value
14
+ end
15
+ if filename && File.exist?(filename)
16
+ assert_type file, :String if format
17
+ digest = Digest::MD5.new()
18
+ digest << File.read(filename)
19
+ if !format || format.value == "hex"
20
+ unquoted_string(digest.hexdigest)
21
+ elsif format && format.value == "integer"
22
+ number(digest.hexdigest.hex)
23
+ elsif format
24
+ raise Sass::SyntaxError, "Unknown format '#{format}' for md5sum"
25
+ end
26
+ else
27
+ raise Sass::SyntaxError, "File not found: #{file}"
28
+ end
29
+ end
30
+ declare :md5sum, [:file]
31
+ declare :md5sum, [:file, :format]
32
+ end
33
+