pry-theme 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +1 -0
- data/.travis.yml +8 -1
- data/CHANGELOG.md +40 -0
- data/Gemfile +1 -1
- data/README.md +26 -48
- data/Rakefile +10 -1
- data/VERSION +1 -0
- data/lib/pry-theme/basic_editor.rb +116 -0
- data/lib/pry-theme/color.rb +431 -0
- data/lib/pry-theme/color_table.rb +39 -0
- data/lib/pry-theme/colors/color16.rb +35 -0
- data/lib/pry-theme/colors/color256.rb +30 -0
- data/lib/pry-theme/colors/color8.rb +31 -0
- data/lib/pry-theme/commands.rb +237 -275
- data/lib/pry-theme/declaration.rb +120 -0
- data/lib/pry-theme/definition.rb +111 -0
- data/lib/pry-theme/formattable.rb +26 -0
- data/lib/pry-theme/hex.rb +76 -0
- data/lib/pry-theme/preview.rb +74 -0
- data/lib/pry-theme/rgb.rb +238 -13
- data/lib/pry-theme/term.rb +66 -0
- data/lib/pry-theme/theme.rb +116 -26
- data/lib/pry-theme/theme_list.rb +52 -0
- data/lib/pry-theme/when_started_hook.rb +25 -27
- data/lib/pry-theme.rb +84 -158
- data/pry-theme.gemspec +14 -18
- data/spec/color_table.rb +53 -0
- data/spec/colors/color16_spec.rb +255 -0
- data/spec/colors/color256_spec.rb +323 -0
- data/spec/colors/color8_spec.rb +254 -0
- data/spec/commands_spec.rb +203 -0
- data/spec/helper.rb +16 -0
- data/spec/hex_spec.rb +52 -0
- data/spec/rgb_spec.rb +81 -0
- data/spec/term_spec.rb +23 -0
- data/spec/theme_spec.rb +486 -0
- data/themes/github.prytheme.rb +49 -0
- data/themes/monokai.prytheme.rb +48 -0
- data/themes/pry-classic-16.prytheme.rb +48 -0
- data/themes/pry-classic-256.prytheme.rb +48 -0
- data/themes/pry-classic-8.prytheme.rb +48 -0
- data/themes/pry-cold.prytheme.rb +49 -0
- data/themes/pry-love-16.prytheme.rb +48 -0
- data/themes/pry-love-8.prytheme.rb +48 -0
- data/themes/pry-modern-16.prytheme.rb +48 -0
- data/themes/pry-modern-256.prytheme.rb +48 -0
- data/themes/pry-modern-8.prytheme.rb +48 -0
- data/themes/pry-monochrome.prytheme.rb +32 -0
- data/themes/pry-siberia-16.prytheme.rb +48 -0
- data/themes/pry-siberia-8.prytheme.rb +48 -0
- data/themes/pry-tepid-16.prytheme.rb +48 -0
- data/themes/pry-tepid-8.prytheme.rb +48 -0
- data/themes/pry-zealand-16.prytheme.rb +48 -0
- data/themes/pry-zealand-8.prytheme.rb +49 -0
- data/themes/railscasts.prytheme.rb +50 -0
- data/themes/solarized.prytheme.rb +48 -0
- data/themes/tomorrow.prytheme.rb +48 -0
- data/themes/twilight.prytheme.rb +48 -0
- data/themes/vim-default.prytheme.rb +50 -0
- data/themes/vim-detailed.prytheme.rb +50 -0
- data/themes/zenburn.prytheme.rb +48 -0
- metadata +56 -41
- data/lib/pry-theme/color_converter.rb +0 -55
- data/lib/pry-theme/helper.rb +0 -87
- data/lib/pry-theme/palette.rb +0 -85
- data/lib/pry-theme/term_notation.rb +0 -17
- data/lib/pry-theme/version.rb +0 -3
- data/test/fixtures/pry-classic.prytheme +0 -38
- data/test/helper.rb +0 -56
- data/test/test_color_converter.rb +0 -38
- data/test/test_commands.rb +0 -55
- data/test/test_helper.rb +0 -45
- data/test/test_palette.rb +0 -11
- data/themes/github.prytheme +0 -43
- data/themes/monokai.prytheme +0 -42
- data/themes/pry-classic.prytheme +0 -43
- data/themes/pry-cold.prytheme +0 -43
- data/themes/pry-modern.prytheme +0 -42
- data/themes/railscasts.prytheme +0 -44
- data/themes/saturday.prytheme +0 -42
- data/themes/solarized.prytheme +0 -43
- data/themes/tomorrow.prytheme +0 -43
- data/themes/twilight.prytheme +0 -42
- data/themes/vim-default.prytheme +0 -42
- data/themes/vim-detailed.prytheme +0 -42
- data/themes/zenburn.prytheme +0 -43
data/spec/theme_spec.rb
ADDED
@@ -0,0 +1,486 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe PryTheme::Theme do
|
4
|
+
describe "name option" do
|
5
|
+
it "defaults to some value if it's not specified" do
|
6
|
+
theme = PryTheme.create{}
|
7
|
+
theme.name.should =~ /prytheme-\d+/
|
8
|
+
end
|
9
|
+
|
10
|
+
it "adds a theme name" do
|
11
|
+
theme = PryTheme.create(:name => 'w00t'){}
|
12
|
+
theme.name.should == 'w00t'
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "validation" do
|
16
|
+
it "ensures that the first character is a letter" do
|
17
|
+
lambda { PryTheme.create(:name => '0ol'){} }.
|
18
|
+
should.raise(PryTheme::ThemeError).
|
19
|
+
message.should.match /must start with a letter/
|
20
|
+
end
|
21
|
+
|
22
|
+
it "ensures that the the length is no longer than 18 characters" do
|
23
|
+
long_n = 'x' * 19
|
24
|
+
lambda { PryTheme.create(:name => long_n){} }.
|
25
|
+
should.raise(PryTheme::ThemeError).
|
26
|
+
message.should.match /no longer than 18 characters/
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "color model option" do
|
32
|
+
it "defaults to some value if it's not specified" do
|
33
|
+
theme = PryTheme.create{}
|
34
|
+
theme.color_model.should == 256
|
35
|
+
end
|
36
|
+
|
37
|
+
it "adds color model" do
|
38
|
+
theme = PryTheme.create(:color_model => 8){}
|
39
|
+
theme.color_model.should == 8
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "validation" do
|
43
|
+
it "ensures that it's a correct number" do
|
44
|
+
lambda { PryTheme.create(:name => 'w00t', :color_model => 255){} }.
|
45
|
+
should.raise(PryTheme::ThemeError).
|
46
|
+
message.should.match /incorrect color model/
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "#author" do
|
52
|
+
it "defaults to some value if it's not specified" do
|
53
|
+
theme = PryTheme.create{}
|
54
|
+
theme.author.first[:name].should == 'Unknown Author'
|
55
|
+
end
|
56
|
+
|
57
|
+
it "adds an author" do
|
58
|
+
theme = PryTheme.create{ author(:name => 'Kvitka', :email => 'kvi@t.ka') }
|
59
|
+
theme.author.first[:name].should == 'Kvitka'
|
60
|
+
theme.author.first[:email].should == 'kvi@t.ka'
|
61
|
+
end
|
62
|
+
|
63
|
+
it "adds multiple authors" do
|
64
|
+
theme = PryTheme.create{
|
65
|
+
author(:name => 'Kvitka', :email => 'kvi@t.ka')
|
66
|
+
author(:name => 'Cisyk', :email => 'ci@s.yk') }
|
67
|
+
theme.author.first[:name].should == 'Kvitka'
|
68
|
+
theme.author.first[:email].should == 'kvi@t.ka'
|
69
|
+
theme.author.last[:name].should == 'Cisyk'
|
70
|
+
theme.author.last[:email].should == 'ci@s.yk'
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "validation" do
|
74
|
+
it "ensures that the the length is no longer than 32 characters" do
|
75
|
+
long_n = 'x' * 33
|
76
|
+
lambda { PryTheme.create{ author(:name => long_n)} }.
|
77
|
+
should.raise(PryTheme::ThemeError).
|
78
|
+
message.should.match /no longer than 32 characters/
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "#description" do
|
84
|
+
it "defaults to some value if it's not specified" do
|
85
|
+
theme = PryTheme.create{}
|
86
|
+
theme.description.should == ''
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
it "adds description" do
|
91
|
+
theme = PryTheme.create{ description('wub wub') }
|
92
|
+
theme.description.should == 'wub wub'
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "validation" do
|
96
|
+
it "ensures that the the length is no longer than 280 characters" do
|
97
|
+
long_d = 'x' * 281
|
98
|
+
lambda { PryTheme.create{ description(long_d)} }.
|
99
|
+
should.raise(PryTheme::ThemeError).
|
100
|
+
message.should.match /no longer than 280 characters/
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "definition" do
|
106
|
+
describe "correct theme" do
|
107
|
+
describe "with 8 colours" do
|
108
|
+
it "sets foreground" do
|
109
|
+
theme = PryTheme.create(:color_model => 8) {
|
110
|
+
define_theme{ constant('blue') } }
|
111
|
+
theme.definition.constant.foreground.should == 34
|
112
|
+
theme.definition.constant.background.should == false
|
113
|
+
end
|
114
|
+
|
115
|
+
it "sets backround" do
|
116
|
+
theme = PryTheme.create(:color_model => 8) {
|
117
|
+
define_theme{ constant(:bg => 'blue') } }
|
118
|
+
theme.definition.constant.foreground.should == false
|
119
|
+
theme.definition.constant.background.should == 44
|
120
|
+
end
|
121
|
+
|
122
|
+
it "sets foreground and background" do
|
123
|
+
theme = PryTheme.create(:color_model => 8) {
|
124
|
+
define_theme{ symbol('blue', 'red') } }
|
125
|
+
theme.definition.symbol.foreground.should == 34
|
126
|
+
theme.definition.symbol.background.should == 41
|
127
|
+
end
|
128
|
+
|
129
|
+
it "defaults to proper colours" do
|
130
|
+
theme = PryTheme.create(:color_model => 8){ define_theme{} }
|
131
|
+
theme.definition.integer.to_ansi.should == '39;49'
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe "with 16 colours" do
|
136
|
+
it "sets foreground" do
|
137
|
+
theme = PryTheme.create(:color_model => 16) {
|
138
|
+
define_theme{ constant('bright_blue') } }
|
139
|
+
theme.definition.constant.foreground.should == '34;1'
|
140
|
+
theme.definition.constant.background.should == false
|
141
|
+
end
|
142
|
+
|
143
|
+
it "sets backround" do
|
144
|
+
theme = PryTheme.create(:color_model => 16) {
|
145
|
+
define_theme{ constant(:bg => 'bright_yellow') } }
|
146
|
+
theme.definition.constant.foreground.should == false
|
147
|
+
theme.definition.constant.background.should == 43
|
148
|
+
end
|
149
|
+
|
150
|
+
it "sets foreground and background" do
|
151
|
+
theme = PryTheme.create(:color_model => 16) {
|
152
|
+
define_theme{ symbol('blue', 'red') } }
|
153
|
+
theme.definition.symbol.foreground.should == 34
|
154
|
+
theme.definition.symbol.background.should == 41
|
155
|
+
end
|
156
|
+
|
157
|
+
it "defaults to proper colours" do
|
158
|
+
theme = PryTheme.create(:color_model => 16){ define_theme{} }
|
159
|
+
theme.definition.integer.to_ansi.should == '39;49'
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe "with 256" do
|
164
|
+
it "sets foreground" do
|
165
|
+
theme = PryTheme.create(:color_model => 256) {
|
166
|
+
define_theme{ constant('celadon') } }
|
167
|
+
theme.definition.constant.foreground.should == 115
|
168
|
+
theme.definition.constant.background.should == false
|
169
|
+
end
|
170
|
+
|
171
|
+
it "sets backround" do
|
172
|
+
theme = PryTheme.create(:color_model => 256) {
|
173
|
+
define_theme{ constant(:bg => 'viridian') } }
|
174
|
+
theme.definition.constant.foreground.should == false
|
175
|
+
theme.definition.constant.background.should == 118
|
176
|
+
end
|
177
|
+
|
178
|
+
it "sets foreground and background" do
|
179
|
+
theme = PryTheme.create(:color_model => 256) {
|
180
|
+
define_theme{ symbol('celadon', 'viridian') } }
|
181
|
+
theme.definition.symbol.foreground.should == 115
|
182
|
+
theme.definition.symbol.background.should == 118
|
183
|
+
end
|
184
|
+
|
185
|
+
it "defaults to proper colours" do
|
186
|
+
theme = PryTheme.create(:color_model => 256){ define_theme{} }
|
187
|
+
theme.definition.integer.to_ansi.should == '0'
|
188
|
+
end
|
189
|
+
|
190
|
+
describe "effects" do
|
191
|
+
it "sets effects without layers" do
|
192
|
+
theme = PryTheme.create(:color_model => 256) {
|
193
|
+
define_theme{ symbol([:bold, :underline, :italic]) } }
|
194
|
+
theme.definition.symbol.foreground.should == false
|
195
|
+
theme.definition.symbol.background.should == false
|
196
|
+
theme.definition.symbol.bold?.should == true
|
197
|
+
theme.definition.symbol.underline?.should == true
|
198
|
+
theme.definition.symbol.italic?.should == true
|
199
|
+
end
|
200
|
+
|
201
|
+
it "sets effects and foreground" do
|
202
|
+
theme = PryTheme.create(:color_model => 256) {
|
203
|
+
define_theme{ symbol('sky02', [:bold, :underline, :italic]) } }
|
204
|
+
theme.definition.symbol.foreground.should == 117
|
205
|
+
theme.definition.symbol.background.should == false
|
206
|
+
theme.definition.symbol.bold?.should == true
|
207
|
+
theme.definition.symbol.underline?.should == true
|
208
|
+
theme.definition.symbol.italic?.should == true
|
209
|
+
end
|
210
|
+
|
211
|
+
it "sets effects and background" do
|
212
|
+
theme = PryTheme.create(:color_model => 256) {
|
213
|
+
define_theme{
|
214
|
+
symbol({:bg => 'olive01'}, [:bold, :underline, :italic]) } }
|
215
|
+
theme.definition.symbol.foreground.should == false
|
216
|
+
theme.definition.symbol.background.should == 100
|
217
|
+
theme.definition.symbol.bold?.should == true
|
218
|
+
theme.definition.symbol.underline?.should == true
|
219
|
+
theme.definition.symbol.italic?.should == true
|
220
|
+
end
|
221
|
+
|
222
|
+
it "sets effects, foreground and background" do
|
223
|
+
theme = PryTheme.create(:color_model => 256) {
|
224
|
+
define_theme{
|
225
|
+
symbol('sky02', 'olive01', [:bold, :underline, :italic]) } }
|
226
|
+
theme.definition.symbol.foreground.should == 117
|
227
|
+
theme.definition.symbol.background.should == 100
|
228
|
+
theme.definition.symbol.bold?.should == true
|
229
|
+
theme.definition.symbol.underline?.should == true
|
230
|
+
theme.definition.symbol.italic?.should == true
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
describe "broken theme" do
|
237
|
+
it "raises error when colour definition is malformed" do
|
238
|
+
should.raise(PryTheme::ThemeError) {
|
239
|
+
PryTheme.create{ define_theme { class_ 'wowzers' } }
|
240
|
+
}.message.should =~ /malformed color declaration \(wowzers\)/
|
241
|
+
end
|
242
|
+
|
243
|
+
describe "with 8 colours" do
|
244
|
+
it "doesn't allow effects" do
|
245
|
+
lambda { PryTheme.create(:color_model => 8) {
|
246
|
+
define_theme{ constant('blue', [:bold]) } } }.
|
247
|
+
should.raise(PryTheme::ThemeError).
|
248
|
+
message.should.match /effects are available only for 256-color themes/
|
249
|
+
|
250
|
+
lambda { PryTheme.create(:color_model => 8) {
|
251
|
+
define_theme{ constant({:fg => 'blue'}, [:bold]) } } }.
|
252
|
+
should.raise(PryTheme::ThemeError).
|
253
|
+
message.should.match /effects are available only for 256-color themes/
|
254
|
+
|
255
|
+
|
256
|
+
lambda { PryTheme.create(:color_model => 8) {
|
257
|
+
define_theme{ constant([:bold]) } } }.
|
258
|
+
should.raise(PryTheme::ThemeError).
|
259
|
+
message.should.match /effects are available only for 256-color themes/
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
describe "with 16 colours" do
|
264
|
+
it "doesn't allow effects" do
|
265
|
+
lambda { PryTheme.create(:color_model => 16) {
|
266
|
+
define_theme{ constant('blue', [:bold]) } } }.
|
267
|
+
should.raise(PryTheme::ThemeError).
|
268
|
+
message.should.match /effects are available only for 256-color themes/
|
269
|
+
|
270
|
+
lambda { PryTheme.create(:color_model => 16) {
|
271
|
+
define_theme{ constant({:fg => 'blue'}, [:bold]) } } }.
|
272
|
+
should.raise(PryTheme::ThemeError).
|
273
|
+
message.should.match /effects are available only for 256-color themes/
|
274
|
+
|
275
|
+
lambda { PryTheme.create(:color_model => 16) {
|
276
|
+
define_theme{ constant([:bold]) } } }.
|
277
|
+
should.raise(PryTheme::ThemeError).
|
278
|
+
message.should.match /effects are available only for 256-color themes/
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
describe "non-existent options" do
|
283
|
+
it "raises error" do
|
284
|
+
lambda { PryTheme.create { define_theme { klass 'red' } } }.
|
285
|
+
should.raise(PryTheme::ThemeError).
|
286
|
+
message.should.match /unknown option "klass"/
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
describe "nested definition" do
|
293
|
+
it "doesn't conflict with other nested definitions" do
|
294
|
+
theme = PryTheme.create(:color_model => 8) {
|
295
|
+
define_theme{
|
296
|
+
regexp{ self_ 'blue' }
|
297
|
+
string{ self_ 'green'; delimiter 'black' } } }
|
298
|
+
theme.definition.regexp.self_.foreground(true).should == 'blue'
|
299
|
+
theme.definition.string.self_.foreground(true).should == 'green'
|
300
|
+
theme.definition.regexp.modifier.to_ansi.should == '39;49'
|
301
|
+
theme.definition.string.delimiter.foreground(true).should == 'black'
|
302
|
+
theme.definition.regexp.delimiter.to_ansi.should == '39;49'
|
303
|
+
theme.definition.shell.delimiter.to_ansi.should == '39;49'
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
describe "a wholesome theme" do
|
308
|
+
it "works with all options :-)" do
|
309
|
+
lambda {
|
310
|
+
PryTheme.create(:name => 'wholesome', :color_model => 8) {
|
311
|
+
author :name => 'Kyrylo Silin', :email => 'kyrylosilin@gmail.com'
|
312
|
+
description 'a kool theme!'
|
313
|
+
define_theme {
|
314
|
+
class_ 'magenta'
|
315
|
+
class_variable 'cyan'
|
316
|
+
comment 'blue'
|
317
|
+
constant 'blue'
|
318
|
+
error 'yellow', 'red'
|
319
|
+
float 'magenta'
|
320
|
+
global_variable :bg => 'green'
|
321
|
+
inline_delimiter 'blue'
|
322
|
+
instance_variable 'red'
|
323
|
+
integer 'blue'
|
324
|
+
keyword 'red'
|
325
|
+
method 'blue'
|
326
|
+
predefined_constant 'cyan'
|
327
|
+
symbol 'green'
|
328
|
+
regexp {
|
329
|
+
self_ 'red'
|
330
|
+
char 'magenta'
|
331
|
+
content 'red'
|
332
|
+
delimiter 'red'
|
333
|
+
modifier 'magenta'
|
334
|
+
escape 'magenta' }
|
335
|
+
shell {
|
336
|
+
self_ :bg => 'green'
|
337
|
+
char 'magenta'
|
338
|
+
content 'yellow'
|
339
|
+
delimiter 'white'
|
340
|
+
escape 'black' }
|
341
|
+
string {
|
342
|
+
self_ 'green'
|
343
|
+
char 'white'
|
344
|
+
content 'green'
|
345
|
+
delimiter 'green'
|
346
|
+
escape 'white' } } }
|
347
|
+
}.should.not.raise
|
348
|
+
end
|
349
|
+
end
|
350
|
+
|
351
|
+
describe "declaration type guessing" do
|
352
|
+
it "guesses random colour types" do
|
353
|
+
theme = PryTheme.create(:color_model => 8) {
|
354
|
+
define_theme {
|
355
|
+
class_ 'magenta'
|
356
|
+
class_variable '#1188AA'
|
357
|
+
comment 3
|
358
|
+
constant 'blue'
|
359
|
+
error [111, 111, 101], [31, 125, 255]
|
360
|
+
float '0, 0, 125'
|
361
|
+
global_variable :bg => 5
|
362
|
+
inline_delimiter :bg => '#cabe99'
|
363
|
+
string {
|
364
|
+
content '#122122', '#FA4499' } } }
|
365
|
+
d = theme.definition
|
366
|
+
d.class_.foreground.should == 35
|
367
|
+
d.class_variable.foreground.should == 30
|
368
|
+
d.comment.foreground.should == 33
|
369
|
+
d.constant.foreground.should == 34
|
370
|
+
d.error.foreground.should == 31
|
371
|
+
d.error.background.should == 41
|
372
|
+
d.global_variable.foreground.should == false
|
373
|
+
d.global_variable.background.should == 45
|
374
|
+
d.inline_delimiter.foreground.should == false
|
375
|
+
d.inline_delimiter.background.should == 45
|
376
|
+
d.string.content.foreground.should == 30
|
377
|
+
d.string.content.background.should == 46
|
378
|
+
end
|
379
|
+
|
380
|
+
#it "raises error if background and foreground aren't of the same type" do
|
381
|
+
#lambda { PryTheme.create(:color_model => 8) {
|
382
|
+
#define_theme { class_ 'magenta', '#123456' } } }.
|
383
|
+
#should.raise(PryTheme::ThemeError).
|
384
|
+
#message.should.match /foreground and background are not of the same type/
|
385
|
+
|
386
|
+
#lambda { PryTheme.create(:color_model => 8) {
|
387
|
+
#define_theme { class_ '#123456', 'magenta' } } }.
|
388
|
+
#should.raise(PryTheme::ThemeError).
|
389
|
+
#message.should.match /foreground and background are not of the same type/
|
390
|
+
|
391
|
+
#lambda { PryTheme.create(:color_model => 8) {
|
392
|
+
#define_theme { class_ '#123456', '31, 31, 31' } } }.
|
393
|
+
#should.raise(PryTheme::ThemeError).
|
394
|
+
#message.should.match /foreground and background are not of the same type/
|
395
|
+
|
396
|
+
#lambda { PryTheme.create(:color_model => 8) {
|
397
|
+
#define_theme { class_ '31, 31, 31', '#123456' } } }.
|
398
|
+
#should.raise(PryTheme::ThemeError).
|
399
|
+
#message.should.match /foreground and background are not of the same type/
|
400
|
+
|
401
|
+
#lambda { PryTheme.create(:color_model => 8) {
|
402
|
+
#define_theme { class_ '31, 31, 31', 'magenta' } } }.
|
403
|
+
#should.raise(PryTheme::ThemeError).
|
404
|
+
#message.should.match /foreground and background are not of the same type/
|
405
|
+
|
406
|
+
#lambda { PryTheme.create(:color_model => 8) {
|
407
|
+
#define_theme { class_ 'magenta', '31, 31, 31' } } }.
|
408
|
+
#should.raise(PryTheme::ThemeError).
|
409
|
+
#message.should.match /foreground and background are not of the same type/
|
410
|
+
#end
|
411
|
+
end
|
412
|
+
|
413
|
+
describe "state" do
|
414
|
+
it "can be active" do
|
415
|
+
theme = PryTheme.create{}
|
416
|
+
theme.activate
|
417
|
+
theme.active?.should == true
|
418
|
+
end
|
419
|
+
|
420
|
+
it "can be disabled" do
|
421
|
+
theme = PryTheme.create{}
|
422
|
+
theme.activate
|
423
|
+
theme.disable
|
424
|
+
theme.active?.should == false
|
425
|
+
end
|
426
|
+
|
427
|
+
it "is inactive by default" do
|
428
|
+
theme = PryTheme.create{}
|
429
|
+
theme.active?.should == false
|
430
|
+
end
|
431
|
+
end
|
432
|
+
|
433
|
+
describe "#to_coderay" do
|
434
|
+
before do
|
435
|
+
@coderay_hash = {
|
436
|
+
:class => '48;5;118',
|
437
|
+
:class_variable => '0',
|
438
|
+
:comment => '0',
|
439
|
+
:constant => '0',
|
440
|
+
:error => '0',
|
441
|
+
:float => '0',
|
442
|
+
:global_variable => '38;5;81;4',
|
443
|
+
:integer => '38;5;64;48;5;208',
|
444
|
+
:inline_delimiter => '0',
|
445
|
+
:instance_variable => '0',
|
446
|
+
:keyword => '0',
|
447
|
+
:method => '0',
|
448
|
+
:predefined_constant => '0',
|
449
|
+
:symbol => '0',
|
450
|
+
:regexp => {
|
451
|
+
:self => '0',
|
452
|
+
:char => '0',
|
453
|
+
:content => '0',
|
454
|
+
:delimiter => '0',
|
455
|
+
:modifier => '38;5;148',
|
456
|
+
:escape => '0',
|
457
|
+
},
|
458
|
+
:shell => {
|
459
|
+
:self => '0',
|
460
|
+
:char => '0',
|
461
|
+
:content => '0',
|
462
|
+
:delimiter => '0',
|
463
|
+
:escape => '0',
|
464
|
+
},
|
465
|
+
:string => {
|
466
|
+
:self => '38;5;186',
|
467
|
+
:char => '0',
|
468
|
+
:content => '0',
|
469
|
+
:delimiter => '0',
|
470
|
+
:escape => '0',
|
471
|
+
}
|
472
|
+
}
|
473
|
+
end
|
474
|
+
|
475
|
+
it "represents theme definition as a hash" do
|
476
|
+
theme = PryTheme.create{
|
477
|
+
define_theme{
|
478
|
+
class_(:bg => 'viridian')
|
479
|
+
integer('olive_drab', 'tangerine')
|
480
|
+
global_variable('sky01', [:underline])
|
481
|
+
string{ self_('flax') }
|
482
|
+
regexp{ modifier('lime01') } } }
|
483
|
+
theme.to_coderay.should == @coderay_hash
|
484
|
+
end
|
485
|
+
end
|
486
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
t = PryTheme.create :name => 'github' do
|
2
|
+
author :name => 'John Mair'
|
3
|
+
author :name => 'Kyrylo Silin', :email => 'kyrylosilin@gmail.com'
|
4
|
+
description 'Based on GitHub theme'
|
5
|
+
|
6
|
+
define_theme do
|
7
|
+
class_ 'seroburomalinovyj01', [:bold]
|
8
|
+
class_variable 'teal01'
|
9
|
+
comment 'gray01'
|
10
|
+
constant 'teal'
|
11
|
+
error 'bismarck_furious', 'periwinkle'
|
12
|
+
float 'teal01'
|
13
|
+
global_variable 'teal01'
|
14
|
+
inline_delimiter 'cerise01'
|
15
|
+
instance_variable 'teal01'
|
16
|
+
integer 'teal01'
|
17
|
+
keyword 'black', [:bold]
|
18
|
+
method 'maroon', [:bold]
|
19
|
+
predefined_constant 'teal01'
|
20
|
+
symbol 'violet_eggplant01'
|
21
|
+
|
22
|
+
regexp do
|
23
|
+
self_ 'toad_in_love01'
|
24
|
+
char 'toad_in_love01'
|
25
|
+
content 'toad_in_love01'
|
26
|
+
delimiter 'toad_in_love01'
|
27
|
+
modifier 'toad_in_love01'
|
28
|
+
escape 'toad_in_love01'
|
29
|
+
end
|
30
|
+
|
31
|
+
shell do
|
32
|
+
self_ 'cerise01'
|
33
|
+
char 'cerise01'
|
34
|
+
content 'cerise01'
|
35
|
+
delimiter 'cerise01'
|
36
|
+
escape 'cerise01'
|
37
|
+
end
|
38
|
+
|
39
|
+
string do
|
40
|
+
self_ 'cerise01'
|
41
|
+
char 'cerise01'
|
42
|
+
content 'cerise01'
|
43
|
+
delimiter 'cerise01'
|
44
|
+
escape 'cerise01'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
PryTheme::ThemeList.add_theme(t)
|
@@ -0,0 +1,48 @@
|
|
1
|
+
t = PryTheme.create :name => 'monokai' do
|
2
|
+
author :name => 'Kyrylo Silin', :email => 'kyrylosilin@gmail.com'
|
3
|
+
description "Based on Wimer Hazenberg's theme"
|
4
|
+
|
5
|
+
define_theme do
|
6
|
+
class_ 'sky01'
|
7
|
+
class_variable 'white'
|
8
|
+
comment 'pale_mauve01'
|
9
|
+
constant 'sky01'
|
10
|
+
error 'crimson', [:italic]
|
11
|
+
float 'amethyst01'
|
12
|
+
global_variable 'white'
|
13
|
+
inline_delimiter 'white'
|
14
|
+
instance_variable 'white'
|
15
|
+
integer 'amethyst01'
|
16
|
+
keyword 'crimson'
|
17
|
+
method 'lime01'
|
18
|
+
predefined_constant 'sky01'
|
19
|
+
symbol 'amethyst01'
|
20
|
+
|
21
|
+
regexp do
|
22
|
+
self_ 'flax'
|
23
|
+
char 'white'
|
24
|
+
content 'flax'
|
25
|
+
delimiter 'flax'
|
26
|
+
modifier 'flax'
|
27
|
+
escape 'white'
|
28
|
+
end
|
29
|
+
|
30
|
+
shell do
|
31
|
+
self_ 'flax'
|
32
|
+
char 'white'
|
33
|
+
content 'flax'
|
34
|
+
delimiter 'flax'
|
35
|
+
escape 'white'
|
36
|
+
end
|
37
|
+
|
38
|
+
string do
|
39
|
+
self_ 'flax'
|
40
|
+
char 'white'
|
41
|
+
content 'flax'
|
42
|
+
delimiter 'flax'
|
43
|
+
escape 'white'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
PryTheme::ThemeList.add_theme(t)
|
@@ -0,0 +1,48 @@
|
|
1
|
+
t = PryTheme.create :name => 'pry-classic-16', :color_model => 16 do
|
2
|
+
author :name => 'Kyrylo Silin', :email => 'kyrylosilin@gmail.com'
|
3
|
+
description 'The default Pry Theme for terminals with average color support'
|
4
|
+
|
5
|
+
define_theme do
|
6
|
+
class_ 'bright_magenta'
|
7
|
+
class_variable 'bright_blue'
|
8
|
+
comment 'blue'
|
9
|
+
constant 'bright_blue'
|
10
|
+
error 'bright_yellow', 'red'
|
11
|
+
float 'bright_magenta'
|
12
|
+
global_variable 'green'
|
13
|
+
inline_delimiter 'red'
|
14
|
+
instance_variable 'bright_blue'
|
15
|
+
integer 'bright_blue'
|
16
|
+
keyword 'bright_red'
|
17
|
+
method 'bright_blue'
|
18
|
+
predefined_constant 'bright_cyan'
|
19
|
+
symbol 'bright_green'
|
20
|
+
|
21
|
+
regexp do
|
22
|
+
self_ 'red'
|
23
|
+
char 'red'
|
24
|
+
content 'red'
|
25
|
+
delimiter 'bright_red'
|
26
|
+
modifier 'bright_magenta'
|
27
|
+
escape 'red'
|
28
|
+
end
|
29
|
+
|
30
|
+
shell do
|
31
|
+
self_ 'green'
|
32
|
+
char 'green'
|
33
|
+
content 'bright_green'
|
34
|
+
delimiter 'bright_green'
|
35
|
+
escape 'green'
|
36
|
+
end
|
37
|
+
|
38
|
+
string do
|
39
|
+
self_ 'green'
|
40
|
+
char 'green'
|
41
|
+
content 'bright_green'
|
42
|
+
delimiter 'bright_green'
|
43
|
+
escape 'green'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
PryTheme::ThemeList.add_theme(t)
|
@@ -0,0 +1,48 @@
|
|
1
|
+
t = PryTheme.create :name => 'pry-classic-256' do
|
2
|
+
author :name => 'Kyrylo Silin', :email => 'kyrylosilin@gmail.com'
|
3
|
+
description 'The default Pry Theme'
|
4
|
+
|
5
|
+
define_theme do
|
6
|
+
class_ 'pale_red_violet03', [:bold]
|
7
|
+
class_variable 'cerulean_grey02'
|
8
|
+
comment 'wisteria02'
|
9
|
+
constant 'blue'
|
10
|
+
error 'yellow', 'red'
|
11
|
+
float 'magenta'
|
12
|
+
global_variable 'lime02'
|
13
|
+
inline_delimiter 'red'
|
14
|
+
instance_variable 'cerulean_grey02'
|
15
|
+
integer 'blue'
|
16
|
+
keyword 'red'
|
17
|
+
method 'blue', [:bold]
|
18
|
+
predefined_constant 'robin_egg_blue04'
|
19
|
+
symbol 'green'
|
20
|
+
|
21
|
+
regexp do
|
22
|
+
self_ 'red'
|
23
|
+
char 'pale_red_violet03'
|
24
|
+
content 'eggplant02'
|
25
|
+
delimiter 'red', [:bold]
|
26
|
+
modifier 'magenta', [:underline]
|
27
|
+
escape 'red'
|
28
|
+
end
|
29
|
+
|
30
|
+
shell do
|
31
|
+
self_ 'green'
|
32
|
+
char 'dark_spring_green'
|
33
|
+
content 'green'
|
34
|
+
delimiter 'green', [:bold]
|
35
|
+
escape 'dark_spring_green'
|
36
|
+
end
|
37
|
+
|
38
|
+
string do
|
39
|
+
self_ 'green'
|
40
|
+
char 'dark_spring_green'
|
41
|
+
content 'green'
|
42
|
+
delimiter 'green', [:bold]
|
43
|
+
escape 'dark_spring_green'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
PryTheme::ThemeList.add_theme(t)
|