flint-gs 2.1.4 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62fdbbd2f7bcd9e44852bb8a9e980792ee50d529
4
- data.tar.gz: e0866a6bdf45667960b289a7df5dc6199091c9cb
3
+ metadata.gz: f9f756a8f74ec0109b5b0e6bab31bc7721a65f99
4
+ data.tar.gz: 2e9e4b2af16cf3e4344c875802c16b2ddab45362
5
5
  SHA512:
6
- metadata.gz: 8ef4fff7fe04af89319a0a4f22b41caecbd37fb37c836a2550e104720bdae96728fed3dbbac7850d09f8fa31f79e3b4d6b48e60a848b794b5944f4ef6caec232
7
- data.tar.gz: cea6e7bf22b451b3dd7d7ec81a23c09461d7551d7a6c7c0cca5557939899b2e7294a4b9ad1bc4d9813ef03133638573b37413b431e25a267904b19b4738a9fe0
6
+ metadata.gz: 6986295e0c48b1b0b7ea33d7ec4adbedf32209d0a573175daa7d0a42fe3825ebe30478991c250329682c491a28ea84c6799a2c56d44fe834640fae6f1b5408df
7
+ data.tar.gz: 8e2023f8c225d5f80214f1b89dfd474c01747cd696a5b79c0e94c23fd53010f824dad684fa7da0f79292e337f38ffb1ac3d36c6de87a50e3fe8b7a5d6fd233d8
data/README.md CHANGED
@@ -63,32 +63,9 @@ function parses the selector string (for example, `.block__element__element`) li
63
63
  ///
64
64
  /// @group Internal Functions
65
65
  ///
66
- @function flint-support-syntax-bem($selectors) {
67
- // Clean up selector, remove double underscores for spaces
68
- // add pseudo character to differentiate selectors
69
- $selectors: flint-replace-substring(inspect(unquote($selectors)), "__", "/");
70
- // Parse string back to list without pseudo character
71
- $selectors: flint-string-to-list($selectors, "/");
72
- // Define top-most parent of selector
73
- $parent: nth($selectors, 1);
74
- // Create new list of parsed selectors
75
- $selector-list: ("#{$parent}",);
76
-
77
- // Loop over each selector and build list of selectors
78
- @each $selector in $selectors {
79
- // Make sure current selector is not the parent
80
- @if $selector != $parent {
81
- // Save to selector list
82
- $selector-list: append($selector-list, "#{$parent}__#{$selector}", "comma");
83
- // Define new parent
84
- $parent: "#{$parent}__#{$selector}";
85
- }
86
- }
87
-
88
- // Return the list of parsed selectors
89
- @return $selector-list;
90
- }
66
+ @function flint-support-syntax-bem($selectors) { ... }
91
67
  ```
68
+ [View Source](https://github.com/ezekg/flint/blob/master/stylesheets/flint/functions/lib/_support-syntax-bem.scss)
92
69
 
93
70
  This will be parsed into a list of selectors: `.block, .block__element, .block__element__element`. The list of selectors can then be used by the
94
71
  instance system to look up a selectors parent, etc. To support your own preferred syntax: create a `flint-support-syntax-<syntax-name>` function
@@ -1,92 +1,127 @@
1
1
  module Flint
2
2
 
3
- def self.declare(*args)
4
- Sass::Script::Functions.declare(*args)
5
- end
3
+ def self.declare(*args)
4
+ Sass::Script::Functions.declare(*args)
5
+ end
6
6
 
7
- ###
8
- # Use ruby functions
9
- #
10
- # @return {Bool}
11
- ###
12
- def flint_use_ruby()
13
- Sass::Script::Bool.new(true)
14
- end
7
+ #
8
+ # Use ruby functions
9
+ #
10
+ # @return {Bool}
11
+ #
12
+ def flint_use_ruby()
13
+ Sass::Script::Bool.new(true)
14
+ end
15
15
 
16
- ###
17
- # Fetch value from map
18
- #
19
- # @param {Map} map - map to fetch value from
20
- # @param {ArgList} keys - list of keys to traverse
21
- #
22
- # @return {*}
23
- ###
24
- def flint_ruby_map_fetch(map, *keys)
25
- assert_type map, :Map, :map
26
- result = map
27
- keys.each { |key| result.nil? ? break : result = result.to_h.fetch(key, nil) }
28
- unless result.nil?
29
- result
30
- else
31
- Sass::Script::Bool.new(false)
32
- end
16
+ #
17
+ # Fetch value from map
18
+ #
19
+ # @param {Map} map - map to fetch value from
20
+ # @param {ArgList} keys - list of keys to traverse
21
+ #
22
+ # @return {*}
23
+ #
24
+ def flint_ruby_map_fetch(map, *keys)
25
+ assert_type map, :Map, :map
26
+
27
+ result = map
28
+ keys.each { |key| result.nil? ? break : result = result.to_h.fetch(key, nil) }
29
+
30
+ unless result.nil?
31
+ result
32
+ else
33
+ Sass::Script::Bool.new(false)
33
34
  end
34
- declare :flint_ruby_map_fetch, :args => [:map, :keys], :var_args => true
35
-
36
- ###
37
- # Joins all elements of list with passed glue
38
- #
39
- # @param {List} list
40
- # @param {String} glue
41
- #
42
- # @return {String}
43
- ###
44
- def flint_ruby_list_to_string(list, glue)
45
- assert_type list, :List, :list
46
- assert_type glue, :String, :glue
47
- arr = list.to_a.flatten.map { |item| item.value }
48
- Sass::Script::String.new(arr.join(glue.value))
35
+ end
36
+ declare :flint_ruby_map_fetch, :args => [:map, :keys], :var_args => true
37
+
38
+ #
39
+ # Joins all elements of list with passed glue
40
+ #
41
+ # @param {List} list
42
+ # @param {String} glue
43
+ #
44
+ # @return {String}
45
+ #
46
+ def flint_ruby_list_to_string(list, glue)
47
+ assert_type list, :List, :list
48
+ assert_type glue, :String, :glue
49
+
50
+ arr = list.to_a.flatten.map { |item| item.value }
51
+
52
+ Sass::Script::String.new(arr.join(glue.value))
53
+ end
54
+ declare :flint_ruby_list_to_string, :args => [:list, :glue]
55
+
56
+ #
57
+ # Turn string into a flat list
58
+ #
59
+ # @param {String} string - string to operate on
60
+ # @param {String} separator - item to find which separates substrings
61
+ # @param {String} ignore - removes remaining string beyond item
62
+ #
63
+ # @return {List}
64
+ #
65
+ def flint_ruby_string_to_list(string, separator, ignore)
66
+ assert_type string, :String, :string
67
+ assert_type separator, :String, :separator
68
+ assert_type ignore, :String, :ignore
69
+
70
+ # Remove everything after ignore, split with separator
71
+ items = string.value[/[^#{ignore}]+/].split(separator.value)
72
+
73
+ if items.count == 1
74
+ Sass::Script::String.new(items[0], :comma)
75
+ else
76
+ Sass::Script::List.new(items.map { |i| Sass::Script::String.new(i) }, :comma)
49
77
  end
50
- declare :flint_ruby_list_to_string, :args => [:list, :glue]
51
-
52
- ###
53
- # Turn string into a flat list
54
- #
55
- # @param {String} string - string to operate on
56
- # @param {String} separator - item to find which separates substrings
57
- # @param {String} ignore - removes remaining string beyond item
58
- #
59
- # @return {List}
60
- ###
61
- def flint_ruby_string_to_list(string, separator, ignore)
62
- assert_type string, :String, :string
63
- assert_type separator, :String, :separator
64
- assert_type ignore, :String, :ignore
65
- # Remove everything after ignore, split with separator
66
- items = string.value[/[^#{ignore}]+/].split(separator.value)
67
- if items.count == 1
68
- Sass::Script::String.new(items[0], :comma)
69
- else
70
- Sass::Script::List.new(items.map { |i| Sass::Script::String.new(i) }, :comma)
78
+ end
79
+ declare :flint_ruby_string_to_list, :args => [:string, :separator, :ignore]
80
+
81
+ #
82
+ # Replace substring with string
83
+ #
84
+ # @param {String} string - string that contains substring
85
+ # @param {String} find - substring to replace
86
+ # @param {String} replace - new string to replace sub with
87
+ #
88
+ # @return {String}
89
+ #
90
+ def flint_ruby_replace_substring(string, find, replace)
91
+ assert_type string, :String, :string
92
+ assert_type find, :String, :find
93
+ assert_type replace, :String, :replace
94
+
95
+ Sass::Script::String.new(string.value.gsub(find.value, replace.value))
96
+ end
97
+ declare :flint_ruby_replace_substring, :args => [:string, :find, :replace]
98
+
99
+ #
100
+ # Check if key exists in map
101
+ #
102
+ # @param {Map} map - map to search
103
+ # @param {String} key - key to search for
104
+ #
105
+ # @return {Bool}
106
+ #
107
+ def flint_ruby_exists(map, key)
108
+ assert_type map, :Map, :map
109
+ assert_type key, :String, :key
110
+
111
+ hash = map.to_h
112
+
113
+ if hash.fetch(key, false)
114
+ return Sass::Script::Bool.new(true)
115
+ else
116
+ hash.each do |_, value|
117
+ if value.is_a?(Sass::Script::Value::Map)
118
+ return Sass::Script::Bool.new(true) if flint_ruby_exists(value, key).value
71
119
  end
120
+ end
72
121
  end
73
- declare :flint_ruby_string_to_list, :args => [:string, :separator, :ignore]
74
-
75
- ###
76
- # Replace substring with string
77
- #
78
- # @param {String} string - string that contains substring
79
- # @param {String} find - substring to replace
80
- # @param {String} replace - new string to replace sub with
81
- #
82
- # @return {String}
83
- ###
84
- def flint_ruby_replace_substring(string, find, replace)
85
- assert_type string, :String, :string
86
- assert_type find, :String, :find
87
- assert_type replace, :String, :replace
88
- Sass::Script::String.new(string.value.gsub(find.value, replace.value))
89
- end
90
- declare :flint_ruby_replace_substring, :args => [:string, :find, :replace]
122
+
123
+ Sass::Script::Bool.new(false)
124
+ end
125
+ declare :flint_ruby_exists, :args => [:map, :key]
91
126
 
92
127
  end
data/lib/flint/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Flint
2
- VERSION = "2.1.4"
2
+ VERSION = "2.2.0"
3
3
  end
@@ -198,7 +198,7 @@
198
198
  ///
199
199
  /// @return {Number} em value of target relative to context
200
200
  ///
201
- @function flint-to-em($target, $context: $flint__base-font-size) {
201
+ @function flint-to-em($target, $context: $flint-base-font-size) {
202
202
  @return ($target / $context) * 1em;
203
203
  }
204
204
 
@@ -212,7 +212,7 @@
212
212
  ///
213
213
  /// @return {Number} rem value of target relative to context
214
214
  ///
215
- @function flint-to-rem($target, $context: $flint__base-font-size) {
215
+ @function flint-to-rem($target, $context: $flint-base-font-size) {
216
216
  @return ($target / $context) * 1rem;
217
217
  }
218
218
 
@@ -16,8 +16,8 @@
16
16
  $result: ();
17
17
 
18
18
  // Check to see if value has been cached
19
- @if map-has-key($flint__cached-values, "#{$key, $span, $context, $deduct}::width") and $context != "auto" {
20
- @return map-get($flint__cached-values, "#{$key, $span, $context, $deduct}::width");
19
+ @if map-has-key($flint-cached-values, "#{$key, $span, $context, $deduct}::width") and $context != "auto" {
20
+ @return map-get($flint-cached-values, "#{$key, $span, $context, $deduct}::width");
21
21
  }
22
22
 
23
23
  @if $span == "container" {
@@ -30,7 +30,7 @@
30
30
  // Check if instance maps are enabled
31
31
  //
32
32
  @if not flint-get-value("settings", "instance-maps") {
33
- @if not $flint__development-mode {
33
+ @if not $flint-development-mode {
34
34
  @error "Instance maps are disabled. Automatic context is not available. Enable `instance-maps` in the config to continue.";
35
35
  } @else {
36
36
  @warn "Instance maps are disabled. Automatic context is not available. Enable `instance-maps` in the config to continue.";
@@ -41,7 +41,7 @@
41
41
  $result: map-merge($result, ("target": ((flint-get-instance-value($key, "internal", "width") / flint-get-instance-value($key, "span") * $span) - if($deduct, $deduct, 0))));
42
42
  $result: map-merge($result, ("context": flint-get-instance-value($key, "internal", "width")));
43
43
  } @else {
44
- @if not $flint__development-mode {
44
+ @if not $flint-development-mode {
45
45
  @error "You set context to `#{$context}`, but a parent instance could not be found for `#{nth(&, 1) + '::' + $key}`";
46
46
  } @else {
47
47
  @return false;
@@ -62,7 +62,7 @@
62
62
 
63
63
  // Save result to cache
64
64
  @if $context != "auto" {
65
- $flint__cached-values: map-merge($flint__cached-values, ("#{$key, $span, $context, $deduct}::width": $result));
65
+ $flint-cached-values: map-merge($flint-cached-values, ("#{$key, $span, $context, $deduct}::width": $result));
66
66
  }
67
67
 
68
68
  // Return result
@@ -3,26 +3,34 @@
3
3
  ///
4
4
  /// @access private
5
5
  ///
6
- /// @param {Map} $map - map to search
7
- /// @param {String} $value - key to search for
6
+ /// @param {Map} $map - map to search
7
+ /// @param {String} $key - key to search for
8
8
  ///
9
9
  /// @return {Bool}
10
10
  ///
11
11
  /// @group Internal Functions
12
12
  ///
13
- @function flint-exists($map, $value){
14
- $is-map: flint-is-map($map);
15
- $top-has-key: $is-map and map-has-key($map, $value) or false;
13
+ @function flint-exists($map, $key) {
16
14
 
17
- @if $top-has-key {
18
- @return true;
19
- } @else if $is-map {
20
- @each $m, $k in $map {
21
- @if flint-exists($k, $value) {
22
- @return true;
15
+ @if not flint-is-string($key) {
16
+ @return false;
17
+ }
18
+
19
+ // Use Ruby function if available
20
+ @if $flint-use-ruby-functions {
21
+ @return flint_ruby_exists($map, $key);
22
+ } @else {
23
+ $is-map: flint-is-map($map);
24
+ $top-has-key: $is-map and map-has-key($map, $key) or false;
25
+
26
+ @if $top-has-key {
27
+ @return true;
28
+ } @else if $is-map {
29
+ @each $m, $k in $map {
30
+ @return flint-exists($k, $key)
23
31
  }
24
32
  }
25
- }
26
33
 
27
- @return false;
34
+ @return false;
35
+ }
28
36
  }
@@ -11,5 +11,5 @@
11
11
  /// @group Internal Functions
12
12
  ///
13
13
  @function flint-get-instance-value($key, $values...) {
14
- @return flint-map-fetch($flint__instances, flint-has-family-instance($key), $values...);
14
+ @return flint-map-fetch($flint-instances, flint-has-family-instance($key), $values...);
15
15
  }
@@ -10,13 +10,13 @@
10
10
  ///
11
11
  /// @group Internal Functions
12
12
  ///
13
- @function flint-has-family-instance($key: flint-get-value("settings", "default"), $syntax: $flint__support-syntax) {
13
+ @function flint-has-family-instance($key: flint-get-value("settings", "default"), $syntax: $flint-support-syntax) {
14
14
  $selector: nth(&, 1);
15
15
 
16
16
  // Check if instance result had been cached
17
- @if map-has-key($flint__cached-instances, "#{$selector}") {
17
+ @if map-has-key($flint-cached-instances, "#{$selector}") {
18
18
  // Get cached instance
19
- $cached-instance: map-get($flint__cached-instances, "#{$selector}");
19
+ $cached-instance: map-get($flint-cached-instances, "#{$selector}");
20
20
  // Return with current key
21
21
  @return "#{$cached-instance}::#{$key}";
22
22
  }
@@ -30,18 +30,18 @@
30
30
  // Loop through transformed selectors
31
31
  @for $i from 1 through $length {
32
32
 
33
- // Check flint-last selector in list
34
- @if flint-exists($flint__instances, "#{flint-last($parsed-selector)}::#{$key}") {
33
+ // Check last selector in list
34
+ @if flint-exists($flint-instances, "#{flint-last($parsed-selector)}::#{$key}") {
35
35
 
36
36
  // Cache result
37
- $flint__cached-instances: map-merge($flint__cached-instances, ("#{$selector}": "#{flint-last($parsed-selector)}"));
37
+ $flint-cached-instances: map-merge($flint-cached-instances, ("#{$selector}": "#{flint-last($parsed-selector)}"));
38
38
 
39
39
  // Return the matching instance key
40
40
  @return "#{flint-last($parsed-selector)}::#{$key}";
41
41
 
42
42
  } @else {
43
43
 
44
- // Else, flint-remove the flint-last selector and loop again
44
+ // Else, remove the last selector and loop again
45
45
  $parsed-selector: flint-remove($parsed-selector, flint-last($parsed-selector));
46
46
 
47
47
  }
@@ -56,15 +56,16 @@
56
56
 
57
57
  // Loop through length of list of selectors
58
58
  @for $i from 1 through $length {
59
+ $selector-string: flint-list-to-string($selector-list, " ");
59
60
 
60
61
  // Make sure that we're not counting the current selector set
61
- @if flint-exists($flint__instances, "#{flint-list-to-string($selector-list, ' ')}::#{$key}") and $selector != $selector-list {
62
+ @if flint-exists($flint-instances, "#{$selector-string}::#{$key}") and $selector != $selector-list {
62
63
 
63
64
  // Cache result
64
- $flint__cached-instances: map-merge($flint__cached-instances, ("#{$selector}": "#{flint-list-to-string($selector-list, ' ')}"));
65
+ $flint-cached-instances: map-merge($flint-cached-instances, ("#{$selector}": "#{$selector-string}"));
65
66
 
66
67
  // Return the matching instance key
67
- @return "#{flint-list-to-string($selector-list, ' ')}::#{$key}";
68
+ @return "#{$selector-string}::#{$key}";
68
69
 
69
70
  } @else {
70
71
 
@@ -18,14 +18,14 @@
18
18
  @function flint-instance($key, $span, $context, $gutter, $output-width, $output-margin-right, $output-margin-left) {
19
19
 
20
20
  // Increase the instance count
21
- $flint__instance-count: $flint__instance-count + 1 !global;
21
+ $flint-instance-count: $flint-instance-count + 1 !global;
22
22
 
23
23
  // Lets clean up the selector a bit...
24
24
  $selector: nth(&, 1);
25
25
 
26
- $flint__instance: (
26
+ $flint-instance: (
27
27
  "#{$selector}::#{$key}": (
28
- "instance-count": $flint__instance-count,
28
+ "instance-count": $flint-instance-count,
29
29
  "parent-selector": if(flint-has-family-instance($key) != false, flint-has-family-instance($key), none),
30
30
  "key": $key,
31
31
  "breakpoint": flint-get-value("breakpoints", $key, "breakpoint"),
@@ -41,5 +41,5 @@
41
41
  )
42
42
  );
43
43
 
44
- @return map-merge($flint__instance, $flint__instances);
44
+ @return map-merge($flint-instance, $flint-instances);
45
45
  }
@@ -16,7 +16,7 @@
16
16
  @function flint-list-to-string($list, $glue: "", $is-nested: false) {
17
17
 
18
18
  // Use Ruby function if available
19
- @if $flint__use-ruby-functions {
19
+ @if $flint-use-ruby-functions {
20
20
  @return flint_ruby_list_to_string($list, $glue);
21
21
  } @else {
22
22
  $result: null;
@@ -13,7 +13,7 @@
13
13
  @function flint-map-fetch($map, $keys...) {
14
14
 
15
15
  // Use Ruby function if available
16
- @if $flint__use-ruby-functions {
16
+ @if $flint-use-ruby-functions {
17
17
  @return flint_ruby_map_fetch($map, $keys...);
18
18
  } @else {
19
19
  $result: $map;
@@ -14,7 +14,7 @@
14
14
  @function flint-replace-substring($string, $substring, $new-substring: " ") {
15
15
 
16
16
  // Use Ruby function if available
17
- @if $flint__use-ruby-functions {
17
+ @if $flint-use-ruby-functions {
18
18
  @return flint_ruby_replace_substring($string, $substring, $new-substring);
19
19
  } @else {
20
20
  // Loop through length of string
@@ -13,7 +13,7 @@
13
13
  $length: length(map-keys(flint-get-value("breakpoints")));
14
14
 
15
15
  @if not flint-is-number($index) {
16
- @if not $flint__development-mode {
16
+ @if not $flint-development-mode {
17
17
  @error "Passed $index (#{$index}) is not a number. Function takes index number of breakpoint key.";
18
18
  } @else {
19
19
  @return false;
@@ -21,7 +21,7 @@
21
21
  }
22
22
 
23
23
  @if $index > $length {
24
- @if not $flint__development-mode {
24
+ @if not $flint-development-mode {
25
25
  @error "Passed $index (#{$index}) is greater than the length of the config map.";
26
26
  } @else {
27
27
  @return false;
@@ -15,7 +15,7 @@
15
15
  @if flint-is-string($string) {
16
16
 
17
17
  // Use Ruby function if available
18
- @if $flint__use-ruby-functions {
18
+ @if $flint-use-ruby-functions {
19
19
  @return flint_ruby_string_to_list($string, $find, $ignore);
20
20
  } @else {
21
21
  $string-list: ();
@@ -22,7 +22,7 @@
22
22
  @return call("flint-support-syntax-#{$syntax}", $selectors);
23
23
 
24
24
  } @else {
25
- @if not $flint__development-mode {
25
+ @if not $flint-development-mode {
26
26
  // Throw error if the syntax does not exist and a function to call cannot be found
27
27
  @error "You did not pass a valid syntax to `flint-support-syntax`: #{$syntax}. Either specify a custom `flint-support-syntax-<syntax>` function to call, or use one of the offically supported syntaxes. For more info, please visit the docs.";
28
28
  } @else {
@@ -10,11 +10,11 @@
10
10
  /// @group Internal Functions
11
11
  ///
12
12
  @function flint-use-syntax($selectors) {
13
- @if $flint__support-syntax {
14
- @return flint-support-syntax($flint__support-syntax, $selectors);
13
+ @if $flint-support-syntax {
14
+ @return flint-support-syntax($flint-support-syntax, $selectors);
15
15
  } @else {
16
- @if not $flint__development-mode {
17
- @error "Support syntax is set to #{$flint__support-syntax}. Aborting mission.";
16
+ @if not $flint-development-mode {
17
+ @error "Support syntax is set to #{$flint-support-syntax}. Aborting mission.";
18
18
  } @else {
19
19
  @return false;
20
20
  }
@@ -9,7 +9,7 @@
9
9
  ///
10
10
  /// @type Bool
11
11
  ///
12
- $flint__development-mode: false !global;
12
+ $flint-development-mode: false !global;
13
13
 
14
14
  ///
15
15
  /// Set global variable to check if foundation has been set
@@ -18,7 +18,7 @@ $flint__development-mode: false !global;
18
18
  ///
19
19
  /// @type String
20
20
  ///
21
- $flint__foundation: "non-existent" !global;
21
+ $flint-foundation: "non-existent" !global;
22
22
 
23
23
  ///
24
24
  /// Keep count of all instances
@@ -27,7 +27,7 @@ $flint__foundation: "non-existent" !global;
27
27
  ///
28
28
  /// @type Number
29
29
  ///
30
- $flint__instance-count: 0 !global;
30
+ $flint-instance-count: 0 !global;
31
31
 
32
32
  ///
33
33
  /// Keep map of all instances
@@ -36,7 +36,7 @@ $flint__instance-count: 0 !global;
36
36
  ///
37
37
  /// @type Map
38
38
  ///
39
- $flint__instances: () !global;
39
+ $flint-instances: () !global;
40
40
 
41
41
  ///
42
42
  /// Font size for em calculation
@@ -45,7 +45,7 @@ $flint__instances: () !global;
45
45
  ///
46
46
  /// @type Number
47
47
  ///
48
- $flint__base-font-size: 16px !global;
48
+ $flint-base-font-size: 16px !global;
49
49
 
50
50
  ///
51
51
  /// Detect if Ruby functions are available
@@ -54,7 +54,7 @@ $flint__base-font-size: 16px !global;
54
54
  ///
55
55
  /// @type Bool
56
56
  ///
57
- $flint__use-ruby-functions: if(flint-use-ruby-functions() == true, true, false) !global;
57
+ $flint-use-ruby-functions: if(flint-use-ruby-functions() == true, true, false) !global;
58
58
 
59
59
  ///
60
60
  /// Global syntax support
@@ -63,7 +63,7 @@ $flint__use-ruby-functions: if(flint-use-ruby-functions() == true, true, false)
63
63
  ///
64
64
  /// @type String
65
65
  ///
66
- $flint__support-syntax: flint-get-value("settings", "support-syntax") !global;
66
+ $flint-support-syntax: flint-get-value("settings", "support-syntax") !global;
67
67
 
68
68
  ///
69
69
  /// Gather all keys, breakpoints and column counts
@@ -72,9 +72,9 @@ $flint__support-syntax: flint-get-value("settings", "support-syntax") !global;
72
72
  ///
73
73
  /// @type List
74
74
  ///
75
- $flint__all-keys: flint-get-all-keys() !global;
76
- $flint__all-breakpoints: flint-get-all-breakpoints() !global;
77
- $flint__all-columns: flint-get-all-columns() !global;
75
+ $flint-all-keys: flint-get-all-keys() !global;
76
+ $flint-all-breakpoints: flint-get-all-breakpoints() !global;
77
+ $flint-all-columns: flint-get-all-columns() !global;
78
78
 
79
79
  ///
80
80
  /// Cache selector instance lists
@@ -83,7 +83,7 @@ $flint__all-columns: flint-get-all-columns() !global;
83
83
  ///
84
84
  /// @type Map
85
85
  ///
86
- $flint__cached-instances: () !global;
86
+ $flint-cached-instances: () !global;
87
87
 
88
88
  ///
89
89
  /// Cache calculated values
@@ -92,7 +92,7 @@ $flint__cached-instances: () !global;
92
92
  ///
93
93
  /// @type Map
94
94
  ///
95
- $flint__cached-values: () !global;
95
+ $flint-cached-values: () !global;
96
96
 
97
97
  ///
98
98
  /// Cache calculation results
@@ -101,4 +101,4 @@ $flint__cached-values: () !global;
101
101
  ///
102
102
  /// @type Map
103
103
  ///
104
- $flint__cached-results: () !global;
104
+ $flint-cached-results: () !global;
@@ -14,7 +14,7 @@
14
14
  @mixin flint-output($width, $margin-right, $margin-left) {
15
15
 
16
16
  @if not flint-is-map($width) {
17
- @if not $flint__development-mode {
17
+ @if not $flint-development-mode {
18
18
  @error "Passed $width (#{$width}) was not a map; a map containing a target / context combination is required."
19
19
  }
20
20
  }
@@ -65,9 +65,9 @@
65
65
  //
66
66
  // Check lengths, if invalid throw error
67
67
  //
68
- @if flint-types-in-list($calc-gutter, "string") and length($calc-gutter) != length($flint__all-keys) {
69
- @if not $flint__development-mode {
70
- @error "Invalid argument length of #{length($calc-gutter)} for gutter. If you're using a shorthand, please provide an argument for each breakpoint in your config (#{length($flint__all-keys)}). Your argument was: #{$calc-gutter}";
68
+ @if flint-types-in-list($calc-gutter, "string") and length($calc-gutter) != length($flint-all-keys) {
69
+ @if not $flint-development-mode {
70
+ @error "Invalid argument length of #{length($calc-gutter)} for gutter. If you're using a shorthand, please provide an argument for each breakpoint in your config (#{length($flint-all-keys)}). Your argument was: #{$calc-gutter}";
71
71
  }
72
72
  }
73
73
 
@@ -95,8 +95,8 @@
95
95
  // Check for cached results
96
96
  //
97
97
  @if $calc-context != "auto" and $calc-span != 0 {
98
- @if map-has-key($flint__cached-results, "#{$calc-key, $calc-span, $calc-context, $calc-gutter, $i}") {
99
- $result: map-get($flint__cached-results, "#{$calc-key, $calc-span, $calc-context, $calc-gutter, $i}");
98
+ @if map-has-key($flint-cached-results, "#{$calc-key, $calc-span, $calc-context, $calc-gutter, $i}") {
99
+ $result: map-get($flint-cached-results, "#{$calc-key, $calc-span, $calc-context, $calc-gutter, $i}");
100
100
 
101
101
  // Get results
102
102
  $output-width-map: nth($result, 1);
@@ -206,7 +206,7 @@
206
206
  $output-margin-left: 0;
207
207
 
208
208
  } @else {
209
- @if not $flint__development-mode {
209
+ @if not $flint-development-mode {
210
210
  @error "Invalid gutter argument: #{$calc-gutter}. Please provide a valid argument.";
211
211
  } @else {
212
212
  $errors: true;
@@ -218,7 +218,7 @@
218
218
 
219
219
  // Cache result
220
220
  @if $calc-context != "auto" and $calc-span != 0 and not $cached {
221
- $flint__cached-results: map-merge($flint__cached-results, (
221
+ $flint-cached-results: map-merge($flint-cached-results, (
222
222
  "#{$calc-key, $calc-span, $calc-context, $calc-gutter, $i}": ($output-width-map, $output-margin-right, $output-margin-left)
223
223
  )) !global;
224
224
  }
@@ -499,11 +499,11 @@
499
499
 
500
500
  // Apply global border-box-sizing if set to true
501
501
  @if flint-get-value("settings", "border-box-sizing") {
502
- $flint__foundation: "existent" !global;
502
+ $flint-foundation: "existent" !global;
503
503
  }
504
504
 
505
505
  // Foundation is now globally existant
506
- @if $flint__foundation == "existent" {
506
+ @if $flint-foundation == "existent" {
507
507
  @at-root *, *:before, *:after {
508
508
  @include flint-box-sizing;
509
509
  @content;
@@ -516,14 +516,14 @@
516
516
  } @else if $key == "container" or $span == "container" or $context == "container" {
517
517
 
518
518
  // Apply individually if foundation is not set globally, but is set to true in config
519
- @if flint-get-value("settings", "border-box-sizing") and $flint__foundation == "non-existent" {
519
+ @if flint-get-value("settings", "border-box-sizing") and $flint-foundation == "non-existent" {
520
520
  @include _("foundation");
521
521
  }
522
522
 
523
523
  // Output container for each breakpoint if fixed grid
524
524
  @if $key == "container" and flint-get-value("settings", "grid") == "fixed" {
525
525
 
526
- @for $i from 1 through length($flint__all-keys) {
526
+ @for $i from 1 through length($flint-all-keys) {
527
527
 
528
528
  // Set up variables
529
529
  $calc-key: flint-steal-key($i);
@@ -609,7 +609,7 @@
609
609
  } @else {
610
610
 
611
611
  // Apply individually if foundation is not set globally, but is set to true in config
612
- @if flint-get-value("settings", "border-box-sizing") and $flint__foundation == "non-existent" {
612
+ @if flint-get-value("settings", "border-box-sizing") and $flint-foundation == "non-existent" {
613
613
  @include _("foundation");
614
614
  }
615
615
 
@@ -648,17 +648,17 @@
648
648
  or flint-types-in-list($key, "number") and $span == "auto" {
649
649
 
650
650
  // Emit erroring for invalid argument lengths
651
- @if flint-types-in-list($key, "number") and length($key) != length($flint__all-keys) {
652
- @if not $flint__development-mode {
653
- @error "Invalid argument length of #{length($key)} for span. Please provide an argument for each breakpoint in your config (#{length($flint__all-keys)}). Your argument was: #{$key}";
651
+ @if flint-types-in-list($key, "number") and length($key) != length($flint-all-keys) {
652
+ @if not $flint-development-mode {
653
+ @error "Invalid argument length of #{length($key)} for span. Please provide an argument for each breakpoint in your config (#{length($flint-all-keys)}). Your argument was: #{$key}";
654
654
  }
655
- } @else if flint-types-in-list($span, "number") and length($span) != length($flint__all-keys) {
656
- @if not $flint__development-mode {
657
- @error "Invalid argument length of #{length($span)} for context. Please provide an argument for each breakpoint in your config (#{length($flint__all-keys)}). Your argument was: #{$span}";
655
+ } @else if flint-types-in-list($span, "number") and length($span) != length($flint-all-keys) {
656
+ @if not $flint-development-mode {
657
+ @error "Invalid argument length of #{length($span)} for context. Please provide an argument for each breakpoint in your config (#{length($flint-all-keys)}). Your argument was: #{$span}";
658
658
  }
659
659
  } @else {
660
660
 
661
- @for $i from 1 through length($flint__all-keys) {
661
+ @for $i from 1 through length($flint-all-keys) {
662
662
 
663
663
  $calc-key: flint-steal-key($i);
664
664
  $calc-span: $key;
@@ -714,7 +714,7 @@
714
714
  }
715
715
 
716
716
  } @else {
717
- @if not $flint__development-mode {
717
+ @if not $flint-development-mode {
718
718
  @error "Invalid gutter settings in config map: #{flint-get-value('settings', 'grid')}. Valid arguments: fluid, fixed";
719
719
  }
720
720
  }
@@ -735,7 +735,7 @@
735
735
 
736
736
  // Throw error for invalid argument lengths
737
737
  @if not flint-exists($flint, $key) {
738
- @if not $flint__development-mode {
738
+ @if not $flint-development-mode {
739
739
  @error "Invalid argument: #{$key}. Breakpoint does not exist. Please provide a valid argument.";
740
740
  }
741
741
  } @else {
@@ -794,7 +794,7 @@
794
794
  }
795
795
 
796
796
  } @else {
797
- @if not $flint__development-mode {
797
+ @if not $flint-development-mode {
798
798
  @error "Invalid gutter settings in config map: #{flint-get-value('settings', 'grid')}. Valid arguments: fluid, fixed";
799
799
  }
800
800
  }
@@ -833,7 +833,7 @@
833
833
  }
834
834
  }
835
835
  } @else {
836
- @if not $flint__development-mode {
836
+ @if not $flint-development-mode {
837
837
  @error "Invalid gutter settings in config map: #{flint-get-value('settings', 'grid')}. Valid arguments: fluid, fixed";
838
838
  }
839
839
  }
@@ -852,7 +852,7 @@
852
852
  @content;
853
853
  }
854
854
  } @else {
855
- @if not $flint__development-mode {
855
+ @if not $flint-development-mode {
856
856
  @error "Invalid gutter settings in config map: #{flint-get-value('settings', 'grid')}. Valid arguments: fluid, fixed";
857
857
  }
858
858
  }
@@ -871,7 +871,7 @@
871
871
  @content;
872
872
  }
873
873
  } @else {
874
- @if not $flint__development-mode {
874
+ @if not $flint-development-mode {
875
875
  @error "Invalid gutter settings in config map: #{flint-get-value('settings', 'grid')}. Valid arguments: fluid, fixed";
876
876
  }
877
877
  }
@@ -887,7 +887,7 @@
887
887
  }
888
888
  // Throw error
889
889
  } @else {
890
- @if not $flint__development-mode {
890
+ @if not $flint-development-mode {
891
891
  @error "Passed units [#{unit(nth($key, 2))}, #{unit(nth($key, 4))}] do not match the unit used in your config map: #{flint-get-config-unit()}";
892
892
  }
893
893
  }
@@ -906,7 +906,7 @@
906
906
  @content;
907
907
  }
908
908
  } @else {
909
- @if not $flint__development-mode {
909
+ @if not $flint-development-mode {
910
910
  @error "Invalid gutter settings in config map: #{flint-get-value('settings', 'grid')}. Valid arguments: fluid, fixed";
911
911
  }
912
912
  }
@@ -921,7 +921,7 @@
921
921
  @content;
922
922
  }
923
923
  } @else {
924
- @if not $flint__development-mode {
924
+ @if not $flint-development-mode {
925
925
  @error "Passed units [#{unit(nth($key, 3))}] do not match the unit used in your config map: #{flint-get-config-unit()}";
926
926
  }
927
927
  }
@@ -936,7 +936,7 @@
936
936
  @content;
937
937
  }
938
938
  } @else {
939
- @if not $flint__development-mode {
939
+ @if not $flint-development-mode {
940
940
  @error "Passed units [#{unit(nth($key, 1))}] do not match the unit used in your config map: #{flint-get-config-unit()}";
941
941
  }
942
942
  }
@@ -955,7 +955,7 @@
955
955
  @content;
956
956
  }
957
957
  } @else {
958
- @if not $flint__development-mode {
958
+ @if not $flint-development-mode {
959
959
  @error "Invalid gutter settings in config map: #{flint-get-value('settings', 'grid')}. Valid arguments: fluid, fixed";
960
960
  }
961
961
  }
@@ -970,7 +970,7 @@
970
970
  @content;
971
971
  }
972
972
  } @else {
973
- @if not $flint__development-mode {
973
+ @if not $flint-development-mode {
974
974
  @error "Passed units [#{unit(nth($key, 3))}] do not match the unit used in your config map: #{flint-get-config-unit()}";
975
975
  }
976
976
  }
@@ -985,7 +985,7 @@
985
985
  @content;
986
986
  }
987
987
  } @else {
988
- @if not $flint__development-mode {
988
+ @if not $flint-development-mode {
989
989
  @error "Passed units [#{unit(nth($key, 1))}] do not match the unit used in your config map: #{flint-get-config-unit()}";
990
990
  }
991
991
  }
@@ -1017,13 +1017,13 @@
1017
1017
  $query: append($query, unquote('( min-width: #{flint-calc-breakpoint("alias", $calc-key, flint-get-index($calc-key))} ) and ( max-width: #{(flint-calc-breakpoint("prev", $calc-key, flint-get-index($calc-key)) - $unit)} )'), "comma");
1018
1018
  }
1019
1019
  } @else {
1020
- @if not $flint__development-mode {
1020
+ @if not $flint-development-mode {
1021
1021
  @error "Invalid gutter settings in config map: #{flint-get-value('settings', 'grid')}. Valid arguments: fluid, fixed";
1022
1022
  }
1023
1023
  }
1024
1024
  } @else {
1025
1025
  @if not $calc-key == "for" {
1026
- @if not $flint__development-mode {
1026
+ @if not $flint-development-mode {
1027
1027
  @error "Invalid argument: #{$calc-key}. Breakpoint does not exist. Please provide a valid argument.";
1028
1028
  }
1029
1029
  }
@@ -1040,7 +1040,7 @@
1040
1040
  //
1041
1041
  } @else {
1042
1042
  @if $key != "clear" {
1043
- @if not $flint__development-mode {
1043
+ @if not $flint-development-mode {
1044
1044
  @error "Invalid argument(s). Please double check and provide a valid argument. If you're calling by alias, please provide a single span argument for your breakpoint. See documentation for additional details.";
1045
1045
  }
1046
1046
  }
@@ -14,7 +14,7 @@
14
14
  /// @group Internal Mixins
15
15
  ///
16
16
  @mixin flint-new-instance($calc-key, $calc-span, $calc-context, $calc-gutter, $output-width, $output-margin-right, $output-margin-left) {
17
- $flint__instances:
17
+ $flint-instances:
18
18
  flint-instance(
19
19
  $calc-key,
20
20
  $calc-span,
@@ -15,7 +15,7 @@
15
15
  $selector: nth(&, 1);
16
16
  // Append key to selector
17
17
  $print-selector: "#{$selector}" + "::" + "#{$calc-key}";
18
- @include flint-print-instance(map-get($flint__instances, unquote($print-selector)));
18
+ @include flint-print-instance(map-get($flint-instances, unquote($print-selector)));
19
19
  }
20
20
  }
21
21
 
data/tests/config.rb CHANGED
@@ -1,6 +1,6 @@
1
- require '../lib/flint.rb'
2
- require 'rubygems'
3
- require 'bundler'
1
+ require "../lib/flint.rb"
2
+ require "rubygems"
3
+ require "bundler"
4
4
 
5
5
  # Require dependencies through bundler
6
6
  Bundler.require(:default, :test) if defined?(Bundler)
@@ -24,29 +24,100 @@ sass_options = {
24
24
  :unix_newlines => true
25
25
  }
26
26
 
27
- module Sass::Script::Functions
28
- @@timeStart = Time.now
29
- @@timeLast = Time.now
27
+ module Flint
28
+ class Profiler
30
29
 
31
- def profileRender(timeLast)
32
- diff = Time.now - timeLast
33
- return Sass::Script::String.new(diff * 1)
30
+ @@t_then = Time.now
31
+ @@t_now = Time.now
32
+
33
+ def initialize(function, action, args = nil, env = nil)
34
+ @function = function
35
+ @action = action
36
+ @args = args
37
+ @env = env
38
+ profile
39
+ end
40
+
41
+ def get_time
42
+ @@t_now = Time.now
43
+ t = (@@t_now.to_f - @@t_then.to_f) * 1000.0
44
+ @@t_then = @@t_now
45
+ @@t_total = t
46
+ "\e[0;31m#{t.to_s}\e[0m".ljust(40)
47
+ end
48
+
49
+ def get_name
50
+ case
51
+ when @function.respond_to?(:name)
52
+ @function.name
53
+ else
54
+ nil
55
+ end
56
+ end
57
+
58
+ def get_args
59
+ if @args.nil?
60
+ nil
61
+ else
62
+ @args.to_s[1...@args.length-2]
63
+ end
64
+ end
65
+
66
+ def get_env
67
+ if @env
68
+ original_filename = @env.options.fetch(:original_filename, "unknown file")
69
+ filename = @env.options.fetch(:filename, "unknown file")
70
+ "\e[0;33m#{File.basename(original_filename)}:#{File.basename(filename)}\e[0m".ljust(80)
71
+ else
72
+ "\e[0;33munknown file\e[0m".ljust(80)
73
+ end
34
74
  end
35
75
 
36
- def timing_total()
37
- return self.profileRender(@@timeStart)
76
+ def get_action
77
+ "\e[0;32m#{@action.to_s}\e[0m".ljust(40)
38
78
  end
39
79
 
40
- def timing_interval()
41
- str = profileRender(@@timeLast)
42
- @@timeLast = Time.now
43
- return str
80
+ def get_caller
81
+ "\e[0;34m#{get_name}\e[0m(\e[0;30m#{get_args}\e[0m)"
44
82
  end
83
+
84
+ # Black: \e[0;30m
85
+ # Red: \e[0;31m
86
+ # Green: \e[0;32m
87
+ # Yellow: \e[0;33m
88
+ # Blue: \e[0;34m
89
+ # Purple: \e[0;35m
90
+ # Cyan: \e[0;36m
91
+ # White: \e[0;37m
92
+ def profile
93
+ puts "#{get_env} | #{get_time} | #{get_action} | #{get_caller}"
94
+ # exit if @@t_total > 100 && @action == :execute
95
+ end
96
+ end
97
+ end
98
+
99
+ class Sass::Tree::Visitors::Perform
100
+ alias_method :visit_function_old, :visit_function
101
+
102
+ def visit_function(node)
103
+ Flint::Profiler.new node.dup, :create
104
+ visit_function_old node
105
+ end
106
+ end
107
+
108
+ class Sass::Script::Tree::Funcall
109
+ alias_method :perform_sass_fn_old, :perform_sass_fn
110
+
111
+ def perform_sass_fn(function, args, splat, environment)
112
+ Flint::Profiler.new function.dup, :execute, args.dup, environment.dup
113
+ perform_sass_fn_old function, args, splat, environment
114
+ end
45
115
  end
46
116
 
47
117
  class Sass::Tree::Visitors::Perform < Sass::Tree::Visitors::Base
48
- # Removes all comments completely
49
- def visit_comment(node)
50
- return []
51
- end
118
+
119
+ # Removes all comments completely
120
+ def visit_comment(node)
121
+ return []
122
+ end
52
123
  end
@@ -3,7 +3,7 @@
3
3
  //
4
4
  @include describe("[function] get-instance-value") {
5
5
 
6
- // $flint__instances: (
6
+ // $flint-instances: (
7
7
  // ".instance::desktop": (
8
8
  // "instance-count": 1,
9
9
  // "parent-selector": none,
@@ -67,6 +67,6 @@
67
67
  }
68
68
  }
69
69
 
70
- $flint__instances: () !global;
71
- $flint__instance-count: 0 !global;
70
+ $flint-instances: () !global;
71
+ $flint-instance-count: 0 !global;
72
72
  }
@@ -30,6 +30,6 @@
30
30
  }
31
31
  }
32
32
 
33
- $flint__instances: () !global;
34
- $flint__instance-count: 0 !global;
33
+ $flint-instances: () !global;
34
+ $flint-instance-count: 0 !global;
35
35
  }
@@ -26,24 +26,24 @@
26
26
 
27
27
  @at-root {
28
28
  @include it("should expect instance map to match pseudo instance") {
29
- @include should(expect(inspect($flint__instances)), to(be(inspect($pseudo-instance))));
29
+ @include should(expect(inspect($flint-instances)), to(be(inspect($pseudo-instance))));
30
30
  }
31
31
  }
32
32
 
33
- $flint__instances: () !global;
34
- $flint__instance-count: 0 !global;
33
+ $flint-instances: () !global;
34
+ $flint-instance-count: 0 !global;
35
35
 
36
- $flint__instances: flint-instance("desktop", 4, null, null, 18.75em, 0.625em, 0.625em) !global;
36
+ $flint-instances: flint-instance("desktop", 4, null, null, 18.75em, 0.625em, 0.625em) !global;
37
37
 
38
38
  @at-root {
39
39
  @include it("should expect instance map to match pseudo instance") {
40
- @include should(expect(inspect($flint__instances)), to(be(inspect($pseudo-instance))));
40
+ @include should(expect(inspect($flint-instances)), to(be(inspect($pseudo-instance))));
41
41
  }
42
42
  }
43
43
  }
44
44
 
45
- $flint__instances: () !global;
46
- $flint__instance-count: 0 !global;
45
+ $flint-instances: () !global;
46
+ $flint-instance-count: 0 !global;
47
47
 
48
48
  $pseudo-instance: (
49
49
  ".parent-instance .child-instance::mobile": (
@@ -176,12 +176,12 @@
176
176
 
177
177
  @at-root {
178
178
  @include it("should expect instance map to match pseudo instance map") {
179
- @include should(expect(inspect($flint__instances)), to(be(inspect($pseudo-instance))));
179
+ @include should(expect(inspect($flint-instances)), to(be(inspect($pseudo-instance))));
180
180
  }
181
181
  }
182
182
  }
183
183
  }
184
184
 
185
- $flint__instances: () !global;
186
- $flint__instance-count: 0 !global;
185
+ $flint-instances: () !global;
186
+ $flint-instance-count: 0 !global;
187
187
  }
@@ -42,10 +42,10 @@ $flint: (
42
42
  ) !global;
43
43
 
44
44
  // Enable development mode
45
- $flint__development-mode: true !global;
45
+ $flint-development-mode: true !global;
46
46
 
47
47
  // Test speed improvements
48
- // $flint__use-ruby-functions: false !global;
48
+ // $flint-use-ruby-functions: false !global;
49
49
 
50
50
  ///
51
51
  /// BEGIN TESTS
@@ -58,7 +58,7 @@ $flint__development-mode: true !global;
58
58
  ///
59
59
 
60
60
  @include it("should expect foundation to not be set") {
61
- @include should(expect($flint__foundation),
61
+ @include should(expect($flint-foundation),
62
62
  to(be("non-existent"))
63
63
  );
64
64
  }
@@ -66,7 +66,7 @@ $flint__development-mode: true !global;
66
66
  @include _("foundation");
67
67
 
68
68
  @include it("should expect foundation to be set") {
69
- @include should(expect($flint__foundation),
69
+ @include should(expect($flint-foundation),
70
70
  to(be("existent"))
71
71
  );
72
72
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flint-gs
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.4
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ezekiel Gabrielse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-16 00:00:00.000000000 Z
11
+ date: 2015-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler