palette 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/features/cli.feature +15 -0
- data/lib/palette/color_scheme.rb +21 -12
- data/lib/palette/version.rb +1 -1
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/features/cli.feature
CHANGED
@@ -80,3 +80,18 @@ Feature: Run palette from the command line
|
|
80
80
|
When I run "palette invalid_scheme"
|
81
81
|
Then the exit status should be 1
|
82
82
|
And the output should contain "Please check the syntax of your palette file"
|
83
|
+
|
84
|
+
Scenario: Process a file with Ruby constants
|
85
|
+
Given a file named "valid_theme" with:
|
86
|
+
"""
|
87
|
+
vim_colors "ruby constants" do
|
88
|
+
String "000", "FFF"
|
89
|
+
Float "FFF", "000"
|
90
|
+
end
|
91
|
+
"""
|
92
|
+
When I run "palette valid_theme"
|
93
|
+
Then the output should contain:
|
94
|
+
"""
|
95
|
+
hi String guifg=#000000 ctermfg=16 guibg=#FFFFFF ctermbg=231
|
96
|
+
hi Float guifg=#FFFFFF ctermfg=231 guibg=#000000 ctermbg=16
|
97
|
+
"""
|
data/lib/palette/color_scheme.rb
CHANGED
@@ -33,9 +33,7 @@ module Palette
|
|
33
33
|
%w(darken lighten saturate desaturate).each do |sass_method|
|
34
34
|
class_eval <<-EOM
|
35
35
|
def #{sass_method}(hex, number)
|
36
|
-
|
37
|
-
sass_context.#{sass_method}(Sass::Script::Color.new(rgb),
|
38
|
-
Sass::Script::Number.new(number)).tap{|c| c.options = {}}.inspect.gsub(/#/, "")
|
36
|
+
sass_evaluator(:#{sass_method}, hex_to_sass_color(hex), Sass::Script::Number.new(number))
|
39
37
|
end
|
40
38
|
EOM
|
41
39
|
end
|
@@ -43,19 +41,16 @@ module Palette
|
|
43
41
|
%w(grayscale complement invert).each do |sass_method|
|
44
42
|
class_eval <<-EOM
|
45
43
|
def #{sass_method}(hex)
|
46
|
-
|
47
|
-
sass_context.#{sass_method}(Sass::Script::Color.new(rgb)).tap{|c| c.options = {}}.inspect.gsub(/#/, "")
|
44
|
+
sass_evaluator(:#{sass_method}, hex_to_sass_color(hex))
|
48
45
|
end
|
49
46
|
EOM
|
50
47
|
end
|
51
48
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
@rules ||= []
|
58
|
-
@rules << Palette::Rule.new("String", *args)
|
49
|
+
%w(String Float).each do |constant|
|
50
|
+
define_method(constant) do |*args|
|
51
|
+
@rules ||= []
|
52
|
+
@rules << Palette::Rule.new(constant, *args)
|
53
|
+
end
|
59
54
|
end
|
60
55
|
|
61
56
|
def to_s
|
@@ -124,5 +119,19 @@ endif
|
|
124
119
|
instance.instance_eval(&block)
|
125
120
|
instance.to_s
|
126
121
|
end
|
122
|
+
|
123
|
+
private
|
124
|
+
|
125
|
+
def sass_evaluator(method, *arguments)
|
126
|
+
sass_context.send(method, *arguments).tap {|c| c.options = {}}.inspect.gsub(/#/, "")
|
127
|
+
end
|
128
|
+
|
129
|
+
def hex_to_sass_color(hex)
|
130
|
+
Sass::Script::Color.new(Palette::Color.hex_to_decimal(Palette::Color.parse(hex)))
|
131
|
+
end
|
132
|
+
|
133
|
+
def sass_context
|
134
|
+
@context ||= Sass::Script::Functions::EvaluationContext.new({})
|
135
|
+
end
|
127
136
|
end
|
128
137
|
end
|
data/lib/palette/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: palette
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Josh Clayton
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-17 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|