smurfville 0.0.6 → 0.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.
- data/README.md +22 -6
- data/Rakefile +1 -7
- data/app/assets/stylesheets/smurfville/application.css.sass +2 -2
- data/app/controllers/smurfville/styleguide_controller.rb +2 -2
- data/app/helpers/smurfville/styleguide_helper.rb +9 -1
- data/app/views/layouts/smurfville/application.html.erb +1 -2
- data/app/views/smurfville/styleguide/_color_var.html.haml +3 -3
- data/app/views/smurfville/styleguide/_typography_classes.erb +4 -0
- data/app/views/smurfville/styleguide/colors.html.haml +6 -8
- data/app/views/smurfville/styleguide/typography.html.haml +9 -5
- data/lib/smurfville.rb +1 -1
- data/lib/smurfville/color_variable_parser.rb +28 -33
- data/lib/smurfville/typography_parser.rb +6 -6
- data/lib/smurfville/version.rb +1 -1
- data/test/dummy/app/assets/stylesheets/_scss_partial.css.scss +1 -0
- data/test/dummy/app/assets/stylesheets/_typography.sass +49 -32
- data/test/dummy/app/assets/stylesheets/application.css.sass +5 -2
- data/test/dummy/config/initializers/smurfville.rb +1 -1
- data/test/dummy/log/development.log +3469 -63
- data/test/dummy/log/test.log +99 -498
- data/test/dummy/tmp/cache/assets/C55/E50/sprockets%2Fc7707635524d769f850d0052fd2626b4 +0 -0
- data/test/dummy/tmp/cache/assets/D05/E40/sprockets%2F6cd474670f7dd5f06041b6b25711eb0d +0 -0
- data/test/dummy/tmp/cache/assets/D41/DA0/sprockets%2F4fa8e1d6a63a13923b9196e76fec3a15 +0 -0
- data/test/dummy/tmp/cache/assets/D73/630/sprockets%2F78ad329b32ade44bbea292b9e05f9728 +0 -0
- data/test/dummy/tmp/cache/assets/E44/290/sprockets%2F3eb5e7d41dbddceae0faa1b02185fa15 +0 -0
- data/test/dummy/tmp/cache/assets/E93/8D0/sprockets%2F585cb1ceee30feaa7acf7b993f1fd6be +0 -0
- data/test/unit/color_variable_parser_test.rb +12 -42
- data/test/unit/helpers/smurf/styleguide_helper_test.rb +2 -2
- metadata +15 -10
- data/app/assets/stylesheets/smurfville/typography.css.sass.erb +0 -0
- data/lib/smurfville/sass_visitor.rb +0 -45
- data/test/dummy/tmp/pids/server.pid +0 -1
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -9,10 +9,10 @@ class ColorVariablesTest < ActiveSupport::TestCase
|
|
9
9
|
parser.parse_variable_usage "#{File.dirname(__FILE__)}/sass/colors_01.sass"
|
10
10
|
|
11
11
|
variable_counts = [
|
12
|
-
["
|
13
|
-
["
|
14
|
-
["
|
15
|
-
["
|
12
|
+
["green", 2],
|
13
|
+
["white", 2],
|
14
|
+
["special", 4],
|
15
|
+
["foo", nil]
|
16
16
|
]
|
17
17
|
|
18
18
|
variable_counts.each do |count_pair|
|
@@ -25,17 +25,16 @@ class ColorVariablesTest < ActiveSupport::TestCase
|
|
25
25
|
parser.parse_sass_file "#{File.dirname(__FILE__)}/sass/colors_01.sass"
|
26
26
|
|
27
27
|
assert_equal({
|
28
|
-
"
|
29
|
-
"
|
30
|
-
"
|
31
|
-
"shade($special, 10%)" => ["$function-generated"]
|
28
|
+
"green" => { :variables => ["green"], :alternate_values=>["#008000"] },
|
29
|
+
"white" => { :variables => ["white", "another-white"], :alternate_values => ["#ffffff"] },
|
30
|
+
"black" => { :variables => ["black"], :alternate_values=>["#000000"] },
|
32
31
|
}, parser.colors)
|
33
32
|
|
34
33
|
assert_equal({
|
35
|
-
"
|
36
|
-
"
|
37
|
-
"
|
38
|
-
"
|
34
|
+
"white" => ["light-color"],
|
35
|
+
"black" => ["dark-color"],
|
36
|
+
"green" => ["special"],
|
37
|
+
"special" => ["more_special"]
|
39
38
|
}, parser.variable_mappings)
|
40
39
|
end
|
41
40
|
|
@@ -47,33 +46,4 @@ class ColorVariablesTest < ActiveSupport::TestCase
|
|
47
46
|
assert_equal 1, parser.print_variable_usage_count_for("$special")
|
48
47
|
assert_equal 0, parser.print_variable_usage_count_for("$foo")
|
49
48
|
end
|
50
|
-
|
51
|
-
# ---- parse_color ----
|
52
|
-
|
53
|
-
test "parse_color with valid colors" do
|
54
|
-
equal_colors = [
|
55
|
-
["#000000", "#000"],
|
56
|
-
["#ff0000", "red"],
|
57
|
-
["#000000", "black"],
|
58
|
-
["#ffffff", "white"]
|
59
|
-
]
|
60
|
-
equal_colors.each do |color_pair|
|
61
|
-
assert_equal color_pair[0], Smurfville::ColorVariableParser.parse_color(color_pair[1]).html
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
test "parse_color with invalid colors" do
|
66
|
-
invalid_colors = [nil, "", true, "#0001", "gruen", "####", "#12", "#ffffff7", "(1, 2, 3)"] # didn't work: "#0xy000"
|
67
|
-
invalid_colors.each do |color|
|
68
|
-
assert_equal false, Smurfville::ColorVariableParser.parse_color(color)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
test 'is_sass_color_function?' do
|
73
|
-
# real sass color functions
|
74
|
-
assert Smurfville::ColorVariableParser.is_sass_color_function?("tint(#ccc, 27%)")
|
75
|
-
assert Smurfville::ColorVariableParser.is_sass_color_function?("shade($other-color, 0%)")
|
76
|
-
# other expressions
|
77
|
-
assert !Smurfville::ColorVariableParser.is_sass_color_function?("13px + 37px")
|
78
|
-
end
|
79
|
-
end
|
49
|
+
end
|
@@ -6,17 +6,17 @@ module Smurfville
|
|
6
6
|
class StyleguideHelperTest < ActionView::TestCase
|
7
7
|
test 'foreground_color' do
|
8
8
|
# dark colors
|
9
|
-
assert_equal "white", foreground_color("red")
|
10
9
|
assert_equal "white", foreground_color("#012123")
|
11
10
|
assert_equal "white", foreground_color("#000")
|
12
11
|
|
13
12
|
# bright colors
|
14
13
|
assert_equal "black", foreground_color("#efefef")
|
15
14
|
assert_equal "black", foreground_color("white")
|
15
|
+
assert_equal "black", foreground_color("red")
|
16
16
|
|
17
17
|
# non-colors
|
18
18
|
# => black = default
|
19
|
-
assert_equal "black", foreground_color("
|
19
|
+
assert_equal "black", foreground_color("schmuddelgelb")
|
20
20
|
assert_equal "black", foreground_color(nil)
|
21
21
|
end
|
22
22
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smurfville
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2013-02-17 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: color
|
@@ -36,7 +36,7 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - ~>
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '3.
|
39
|
+
version: '3.2'
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
47
|
+
version: '3.2'
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: rails
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,6 +88,7 @@ extra_rdoc_files: []
|
|
88
88
|
files:
|
89
89
|
- app/views/smurfville/styleguide/typography.html.haml
|
90
90
|
- app/views/smurfville/styleguide/colors.html.haml
|
91
|
+
- app/views/smurfville/styleguide/_typography_classes.erb
|
91
92
|
- app/views/smurfville/styleguide/_color_var.html.haml
|
92
93
|
- app/views/layouts/smurfville/application.html.erb
|
93
94
|
- app/controllers/smurfville/application_controller.rb
|
@@ -97,12 +98,10 @@ files:
|
|
97
98
|
- app/assets/images/smurfville/smurf.png
|
98
99
|
- app/assets/javascripts/smurfville/application.js
|
99
100
|
- app/assets/stylesheets/smurfville/application.css.sass
|
100
|
-
- app/assets/stylesheets/smurfville/typography.css.sass.erb
|
101
101
|
- config/routes.rb
|
102
102
|
- lib/smurfville.rb
|
103
103
|
- lib/smurfville/version.rb
|
104
104
|
- lib/smurfville/color_variable_parser.rb
|
105
|
-
- lib/smurfville/sass_visitor.rb
|
106
105
|
- lib/smurfville/typography_parser.rb
|
107
106
|
- lib/smurfville/engine.rb
|
108
107
|
- lib/tasks/smurfville_tasks.rake
|
@@ -120,12 +119,15 @@ files:
|
|
120
119
|
- test/dummy/app/controllers/application_controller.rb
|
121
120
|
- test/dummy/app/helpers/application_helper.rb
|
122
121
|
- test/dummy/app/assets/javascripts/application.js
|
122
|
+
- test/dummy/app/assets/stylesheets/_scss_partial.css.scss
|
123
123
|
- test/dummy/app/assets/stylesheets/_typography.sass
|
124
124
|
- test/dummy/app/assets/stylesheets/application.css.sass
|
125
|
-
- test/dummy/tmp/pids/server.pid
|
126
125
|
- test/dummy/tmp/cache/assets/C55/E50/sprockets%2Fc7707635524d769f850d0052fd2626b4
|
126
|
+
- test/dummy/tmp/cache/assets/D41/DA0/sprockets%2F4fa8e1d6a63a13923b9196e76fec3a15
|
127
127
|
- test/dummy/tmp/cache/assets/D76/310/sprockets%2Fe637960fec03ed305c18c27e0ffbf676
|
128
128
|
- test/dummy/tmp/cache/assets/D09/FD0/sprockets%2F18fa0451fff833061f0b9902baa4759c
|
129
|
+
- test/dummy/tmp/cache/assets/E93/8D0/sprockets%2F585cb1ceee30feaa7acf7b993f1fd6be
|
130
|
+
- test/dummy/tmp/cache/assets/E44/290/sprockets%2F3eb5e7d41dbddceae0faa1b02185fa15
|
129
131
|
- test/dummy/tmp/cache/assets/D21/AE0/sprockets%2Fa4b75eade53b1f02d320bc720513a645
|
130
132
|
- test/dummy/tmp/cache/assets/D73/630/sprockets%2F78ad329b32ade44bbea292b9e05f9728
|
131
133
|
- test/dummy/tmp/cache/assets/DC2/3F0/sprockets%2Fe83ce5c8393ea833ad2a2eab114bd82c
|
@@ -172,7 +174,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
172
174
|
version: '0'
|
173
175
|
segments:
|
174
176
|
- 0
|
175
|
-
hash:
|
177
|
+
hash: 1558584876731474371
|
176
178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
179
|
none: false
|
178
180
|
requirements:
|
@@ -181,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
183
|
version: '0'
|
182
184
|
segments:
|
183
185
|
- 0
|
184
|
-
hash:
|
186
|
+
hash: 1558584876731474371
|
185
187
|
requirements: []
|
186
188
|
rubyforge_project:
|
187
189
|
rubygems_version: 1.8.24
|
@@ -201,12 +203,15 @@ test_files:
|
|
201
203
|
- test/dummy/app/controllers/application_controller.rb
|
202
204
|
- test/dummy/app/helpers/application_helper.rb
|
203
205
|
- test/dummy/app/assets/javascripts/application.js
|
206
|
+
- test/dummy/app/assets/stylesheets/_scss_partial.css.scss
|
204
207
|
- test/dummy/app/assets/stylesheets/_typography.sass
|
205
208
|
- test/dummy/app/assets/stylesheets/application.css.sass
|
206
|
-
- test/dummy/tmp/pids/server.pid
|
207
209
|
- test/dummy/tmp/cache/assets/C55/E50/sprockets%2Fc7707635524d769f850d0052fd2626b4
|
210
|
+
- test/dummy/tmp/cache/assets/D41/DA0/sprockets%2F4fa8e1d6a63a13923b9196e76fec3a15
|
208
211
|
- test/dummy/tmp/cache/assets/D76/310/sprockets%2Fe637960fec03ed305c18c27e0ffbf676
|
209
212
|
- test/dummy/tmp/cache/assets/D09/FD0/sprockets%2F18fa0451fff833061f0b9902baa4759c
|
213
|
+
- test/dummy/tmp/cache/assets/E93/8D0/sprockets%2F585cb1ceee30feaa7acf7b993f1fd6be
|
214
|
+
- test/dummy/tmp/cache/assets/E44/290/sprockets%2F3eb5e7d41dbddceae0faa1b02185fa15
|
210
215
|
- test/dummy/tmp/cache/assets/D21/AE0/sprockets%2Fa4b75eade53b1f02d320bc720513a645
|
211
216
|
- test/dummy/tmp/cache/assets/D73/630/sprockets%2F78ad329b32ade44bbea292b9e05f9728
|
212
217
|
- test/dummy/tmp/cache/assets/DC2/3F0/sprockets%2Fe83ce5c8393ea833ad2a2eab114bd82c
|
File without changes
|
@@ -1,45 +0,0 @@
|
|
1
|
-
module Smurfville
|
2
|
-
class SassVisitor < Sass::Tree::Visitors::Base
|
3
|
-
|
4
|
-
def visit_import(node)
|
5
|
-
if path = node.css_import?
|
6
|
-
return Sass::Tree::CssImportNode.resolved("url(#{path})")
|
7
|
-
end
|
8
|
-
file = node.imported_file
|
9
|
-
handle_import_loop!(node) if @stack.any? {|e| e[:filename] == file.options[:filename]}
|
10
|
-
|
11
|
-
@stack.push(:filename => node.filename, :line => node.line)
|
12
|
-
root = file.to_tree
|
13
|
-
Sass::Tree::Visitors::CheckNesting.visit(root)
|
14
|
-
node.children = root.children.map {|c| visit(c)}.flatten
|
15
|
-
node
|
16
|
-
rescue Sass::SyntaxError => e
|
17
|
-
e.modify_backtrace(:filename => node.imported_file.options[:filename])
|
18
|
-
e.add_backtrace(:filename => node.filename, :line => node.line)
|
19
|
-
raise e
|
20
|
-
ensure
|
21
|
-
@stack.pop unless path
|
22
|
-
end
|
23
|
-
|
24
|
-
protected
|
25
|
-
|
26
|
-
def initialize
|
27
|
-
# Stack trace information, including mixin includes and imports.
|
28
|
-
@stack = []
|
29
|
-
end
|
30
|
-
|
31
|
-
def handle_import_loop!(node)
|
32
|
-
msg = "An @import loop has been found:"
|
33
|
-
files = @stack.map {|s| s[:filename]}.compact
|
34
|
-
if node.filename == node.imported_file.options[:filename]
|
35
|
-
raise Sass::SyntaxError.new("#{msg} #{node.filename} imports itself")
|
36
|
-
end
|
37
|
-
|
38
|
-
files << node.filename << node.imported_file.options[:filename]
|
39
|
-
msg << "\n" << Sass::Util.enum_cons(files, 2).map do |m1, m2|
|
40
|
-
" #{m1} imports #{m2}"
|
41
|
-
end.join("\n")
|
42
|
-
raise Sass::SyntaxError.new(msg)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
7109
|