vimcolorscheme 0.1

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.
@@ -0,0 +1,15 @@
1
+ module VimColorScheme
2
+ class RawNode
3
+ # The raw node gets initialized with a string. This string will later just
4
+ # be printed as-is into the vim file.
5
+ def initialize raw
6
+ @raw = raw
7
+ end
8
+
9
+ # Just returns the value that was passed into the constructor of this
10
+ # object.
11
+ def to_s
12
+ @raw + "\n"
13
+ end
14
+ end
15
+ end
data/spec/base_spec.rb ADDED
@@ -0,0 +1,92 @@
1
+ require 'spec_helper'
2
+ require 'fileutils'
3
+
4
+ describe VimColorScheme::Base do
5
+ let :test_scheme do
6
+ VimColorScheme.new :test_scheme, :dark do
7
+ comment "This is a comment!"
8
+ comment do
9
+ "This is a block comment!"
10
+ end
11
+
12
+ highlight :Normal do
13
+ ctermfg '231'
14
+ ctermbg '31'
15
+ cterm :bold, :underline
16
+ end
17
+
18
+ raw "Some raw input."
19
+
20
+ raw do
21
+ "Some raw block input."
22
+ end
23
+ end.to_s
24
+ end
25
+
26
+ let :test_scheme_path do
27
+ VimColorScheme::ROOTDIR + '/spec/data/test_scheme.vim'
28
+ end
29
+
30
+ let :test_scheme_object do
31
+ VimColorScheme.new :test_scheme, :dark do
32
+ highlight :Normal do
33
+ ctermfg '231'
34
+ ctermbg '31'
35
+ cterm :bold, :underline
36
+ end
37
+ end
38
+ end
39
+
40
+ # Ensure that the test scheme file does not exists for each test.
41
+ after :each do
42
+ FileUtils.rm test_scheme_path if File.exists?(test_scheme_path)
43
+ end
44
+
45
+ it "should print out the color scheme name" do
46
+ test_scheme.should include("let g:colors_name = 'test_scheme'")
47
+ end
48
+
49
+ it "should set the background" do
50
+ test_scheme.should include("set background=dark")
51
+ end
52
+
53
+ it "should clear highlighting at the start" do
54
+ test_scheme.should include("highlight clear")
55
+ end
56
+
57
+ it "should check if syntax highlighting is on" do
58
+ test_scheme.should include("if exists('syntax_on')")
59
+ end
60
+
61
+ it "should set bold and underline style values" do
62
+ test_scheme.should include("cterm=bold,underline")
63
+ end
64
+
65
+ it 'should write to file with the save method' do
66
+ test_scheme_object.save!(test_scheme_path)
67
+
68
+ File.open(test_scheme_path) do |file|
69
+ file.read.should == test_scheme_object.to_s
70
+ end
71
+ end
72
+
73
+ it 'should render comments' do
74
+ test_scheme.should include('" This is a comment!' + "\n")
75
+ end
76
+
77
+ it 'should render block comments' do
78
+ test_scheme.should include('" This is a block comment!' + "\n")
79
+ end
80
+
81
+ it 'should render comments at the top... at the top' do
82
+ test_scheme.start_with?('" This is a comment!' + "\n").should be_true
83
+ end
84
+
85
+ it 'should render raw' do
86
+ test_scheme.should include("Some raw input.\n")
87
+ end
88
+
89
+ it 'should render raw blocks' do
90
+ test_scheme.should include("Some raw block input.\n")
91
+ end
92
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe VimColorScheme::CommentNode do
4
+ let :single_line_comment do
5
+ comment = VimColorScheme::CommentNode.new "This is a comment!"
6
+ comment.to_s
7
+ end
8
+
9
+ let :multi_line_comment do
10
+ comment = VimColorScheme::CommentNode.new "This is.\nA multiline.\nComment."
11
+ comment.to_s
12
+ end
13
+
14
+ it 'should put the comment character on the front of a comment' do
15
+ single_line_comment.should == '" This is a comment!' + "\n"
16
+ end
17
+
18
+ it 'should render multiline comments properly' do
19
+ multi_line_comment.should == '" This is.' + "\n" + '" A multiline.' +
20
+ "\n" + '" Comment.' + "\n"
21
+ end
22
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe VimColorScheme::Hex2Term do
4
+ # Just a method to reduce clutter in this test. Delegates to the Hex2Term
5
+ # class in the ColorSchemeRb module.
6
+ def convert value
7
+ VimColorScheme::Hex2Term.convert value
8
+ end
9
+
10
+ it "correctly convert hex colors to term colors" do
11
+ convert('123456').should == '23'
12
+ convert('00af00').should == '34'
13
+ convert('odadd6').should == '38'
14
+
15
+ convert('231').should == '#ffffff'
16
+ convert(231).should == '#ffffff'
17
+ convert(23).should == '#005f5f'
18
+ end
19
+
20
+ it "correctly handle hex number with leading hashes" do
21
+ convert('#123456').should == '23'
22
+ convert('#00af00').should == '34'
23
+ convert('#odadd6').should == '38'
24
+ end
25
+ end
@@ -0,0 +1,77 @@
1
+ require 'spec_helper'
2
+
3
+ describe VimColorScheme::HighlightNode do
4
+ let :guinode do
5
+ temp = VimColorScheme::HighlightNode.new :Normal
6
+ temp.guifg '#00af00'
7
+ temp.guibg '#00afd7'
8
+ temp.gui :bold
9
+ temp.to_s
10
+ end
11
+
12
+ let :ctermnode do
13
+ temp = VimColorScheme::HighlightNode.new :Normal
14
+ temp.ctermfg '34'
15
+ temp.ctermbg '35'
16
+ temp.cterm :italic
17
+ temp.gui :none
18
+ temp.to_s
19
+ end
20
+
21
+ let :bothnode do
22
+ temp = VimColorScheme::HighlightNode.new :Normal
23
+ temp.ctermfg '34'
24
+ temp.ctermbg '35'
25
+ temp.guifg '#00af00'
26
+ temp.guibg '#00afd7'
27
+ temp.to_s
28
+ end
29
+
30
+ let :reversenode do
31
+ temp = VimColorScheme::HighlightNode.new :Normal
32
+ temp.gui :reverse
33
+ temp.to_s
34
+ end
35
+
36
+ it 'should start with the word highlight' do
37
+ guinode.start_with?('highlight').should be_true
38
+ bothnode.start_with?('highlight').should be_true
39
+ ctermnode.start_with?('highlight').should be_true
40
+ reversenode.start_with?('highlight').should be_true
41
+ end
42
+
43
+ it "should convert between gui and cterm colors correctly" do
44
+ guinode.should include('ctermfg=34')
45
+ guinode.should include('ctermbg=38')
46
+ end
47
+
48
+ it "should convert between cterm and gui colors correctly" do
49
+ ctermnode.should include('guifg=#00af00')
50
+ ctermnode.should include('guibg=#00af5f')
51
+ end
52
+
53
+ it 'should not convert colors if both are present' do
54
+ bothnode.should include('ctermfg=34')
55
+ bothnode.should include('ctermbg=35')
56
+ bothnode.should include('guifg=#00af00')
57
+ bothnode.should include('guibg=#00afd7')
58
+ end
59
+
60
+ it 'should correctly default nodes to none if no value is given' do
61
+ bothnode.should include('gui=NONE')
62
+ end
63
+
64
+ it 'should correctly convert :reverse values to REVERSE' do
65
+ reversenode.should include('gui=REVERSE')
66
+ end
67
+
68
+ it 'should set gui to bold and correctly mirror that in cterm' do
69
+ guinode.should include('gui=bold')
70
+ guinode.should include('cterm=bold')
71
+ end
72
+
73
+ it 'should set not mirror gui and cterm if coth are set' do
74
+ ctermnode.should include('cterm=italic')
75
+ ctermnode.should include('gui=NONE')
76
+ end
77
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe VimColorScheme::RawNode do
4
+ let :raw_node do
5
+ raw = VimColorScheme::RawNode.new "Raw content."
6
+ raw.to_s
7
+ end
8
+
9
+ it 'should render content verbatim' do
10
+ raw_node.should == "Raw content.\n"
11
+ end
12
+ end
@@ -0,0 +1 @@
1
+ require File.dirname(__FILE__) + '/../lib/vimcolorscheme.rb'
@@ -0,0 +1,16 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = %q{vimcolorscheme}
3
+ s.version = "0.1"
4
+ s.date = %q{2012-05-01}
5
+ s.authors = ["Sam Rose"]
6
+ s.email = %q{samwho@lbak.co.uk}
7
+ s.summary = %q{A Ruby DSL for creating Vim color schemes}
8
+ s.homepage = %q{http://github.com/samwho/vimcolorscheme}
9
+ s.description = %q{Allows for creating of Vim color schemes using a nifty Ruby DSL}
10
+ s.required_ruby_version = '>= 1.8.7'
11
+ s.license = 'MIT'
12
+
13
+ # Add all files to the files parameter.
14
+ s.files = []
15
+ Dir["**/*.*"].each { |path| s.files.push path }
16
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vimcolorscheme
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Sam Rose
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-01 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Allows for creating of Vim color schemes using a nifty Ruby DSL
15
+ email: samwho@lbak.co.uk
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - vimcolorscheme-0.1.gem
21
+ - lib/vimcolorscheme.rb
22
+ - lib/vimcolorscheme/highlight_node.rb
23
+ - lib/vimcolorscheme/base.rb
24
+ - lib/vimcolorscheme/document.rb
25
+ - lib/vimcolorscheme/comment_node.rb
26
+ - lib/vimcolorscheme/hex2term.rb
27
+ - lib/vimcolorscheme/raw_node.rb
28
+ - README.md
29
+ - Gemfile.lock
30
+ - spec/comment_node_spec.rb
31
+ - spec/raw_node_spec.rb
32
+ - spec/spec_helper.rb
33
+ - spec/highlight_node_spec.rb
34
+ - spec/hex2term_spec.rb
35
+ - spec/base_spec.rb
36
+ - vimcolorscheme.gemspec
37
+ - examples/vimscheme1.rb
38
+ - examples/simple_theme.rb
39
+ homepage: http://github.com/samwho/vimcolorscheme
40
+ licenses:
41
+ - MIT
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: 1.8.7
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 1.8.23
61
+ signing_key:
62
+ specification_version: 3
63
+ summary: A Ruby DSL for creating Vim color schemes
64
+ test_files: []