palette 0.0.4 → 0.0.5

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/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- palette (0.0.3)
4
+ palette (0.0.4)
5
5
  sass (= 3.1.0.alpha.23)
6
6
 
7
7
  GEM
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
+ """
@@ -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
- rgb = Palette::Color.hex_to_decimal(Palette::Color.parse(hex))
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
- rgb = Palette::Color.hex_to_decimal(Palette::Color.parse(hex))
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
- def sass_context
53
- @context ||= Sass::Script::Functions::EvaluationContext.new({})
54
- end
55
-
56
- def String(*args)
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
@@ -1,3 +1,3 @@
1
1
  module Palette
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
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: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
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-04 00:00:00 -04:00
18
+ date: 2010-11-17 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency