Skip to content
Browse files

Support Float in addition to String. Closes #1

  • Loading branch information...
1 parent 646fed3 commit c98294e10e535cb436ab251426791452048ca783 @joshuaclayton committed Nov 17, 2010
Showing with 20 additions and 3 deletions.
  1. +15 −0 features/cli.feature
  2. +5 −3 lib/palette/color_scheme.rb
View
15 features/cli.feature
@@ -80,3 +80,18 @@ Feature: Run palette from the command line
When I run "palette invalid_scheme"
Then the exit status should be 1
And the output should contain "Please check the syntax of your palette file"
+
+ Scenario: Process a file with Ruby constants
+ Given a file named "valid_theme" with:
+ """
+ vim_colors "ruby constants" do
+ String "000", "FFF"
+ Float "FFF", "000"
+ end
+ """
+ When I run "palette valid_theme"
+ Then the output should contain:
+ """
+ hi String guifg=#000000 ctermfg=16 guibg=#FFFFFF ctermbg=231
+ hi Float guifg=#FFFFFF ctermfg=231 guibg=#000000 ctermbg=16
+ """
View
8 lib/palette/color_scheme.rb
@@ -46,9 +46,11 @@ def #{sass_method}(hex)
EOM
end
- def String(*args)
- @rules ||= []
- @rules << Palette::Rule.new("String", *args)
+ %w(String Float).each do |constant|
+ define_method(constant) do |*args|
+ @rules ||= []
+ @rules << Palette::Rule.new(constant, *args)
+ end
end
def to_s

0 comments on commit c98294e

Please sign in to comment.
Something went wrong with that request. Please try again.